> For the complete documentation index, see [llms.txt](https://docs.agentipy.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.agentipy.fun/tools/use-flash.md).

# Use Flash

The `Use Flash` tool, part of AgentiPy, provides functionalities for opening and closing trades on what appears to be a specific trading platform integrated via an Agentipy proxy service. The "Flash" name suggests these might be leveraged or quick trades.

## Functionality

This tool is implemented in the `FlashTradeManager` class. It interacts with an Agentipy proxy service (`agent.base_proxy_url`) to perform trading operations. The agent's private key is encrypted and sent to this proxy, and an OpenAI API key (`agent.openai_api_key`) also seems to be part of the payload sent to the proxy.

### Key Methods:

* `flash_open_trade(agent: SolanaAgentKit, token: str, side: str, collateral_usd: float, leverage: float) -> Optional[Dict[str, Any]]`:
  * Opens a trade on the Flash platform.
  * Parameters:
    * `agent`: The `SolanaAgentKit` instance.
    * `token`: The trading token (e.g., "SOL", "BTC" - specific format depends on the proxy/Flash platform).
    * `side`: The trade direction, likely "buy" (long) or "sell" (short).
    * `collateral_usd`: The collateral amount in USD.
    * `leverage`: The leverage multiplier for the trade.
  * Returns a dictionary with the transaction details from the proxy or an error.
* `flash_close_trade(agent: SolanaAgentKit, token: str, side: str) -> Optional[Dict[str, Any]]`:
  * Closes an existing trade on the Flash platform.
  * Parameters:
    * `agent`: The `SolanaAgentKit` instance.
    * `token`: The trading token of the position to close.
    * `side`: The side of the position to close (likely corresponding to the opening side).
  * Returns a dictionary with the transaction details from the proxy or an error.

##

**Important Considerations:**

* **Proxy Service:** This tool relies on an Agentipy proxy service. The availability, authentication (including the role of the OpenAI API key), and terms of use for this proxy are critical.
* **Financial Risk:** Leveraged trading, as suggested by the parameters, is extremely risky and can lead to rapid and significant financial losses. Users must understand these risks thoroughly.
* **On-Chain Actions:** Trades executed via this tool are likely on-chain transactions on Solana, incurring fees and requiring sufficient collateral in the user's wallet or trading account.
* **Platform Specifics:** The exact behavior, supported tokens, and trading rules are dictated by the underlying "Flash" platform integrated through the proxy.

## Source Code

You can find the source code for this tool on GitHub: <https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/use_flash.py>
