# Use SolutioFi

The `Use SolutioFi` tool, part of AgentiPy, provides a suite of utilities for managing SPL tokens on the Solana blockchain. These include functionalities like closing token accounts, burning tokens, merging multiple token balances into one, and spreading a single token balance into multiple other tokens. These operations are routed through an Agentipy proxy service and may require a SolutioFi API key.

## Functionality

This tool is implemented in the `SolutiofiManager` class. All its methods interact with an Agentipy proxy service (`agent.base_proxy_url`), sending encrypted private keys, an OpenAI API key, and a SolutioFi API key (`agent.solutiofi_api_key`) with each request.

### Key Methods:

* `close_accounts(agent: SolanaAgentKit, mints: List[str]) -> Optional[Dict[str, Any]]`:
  * Closes the token accounts associated with the provided list of `mints` for the agent's wallet.
  * Returns a dictionary with transaction details or an error.
* `burn_tokens(agent: SolanaAgentKit, mints: List[str]) -> Optional[Dict[str, Any]]`:
  * Burns all tokens in the token accounts associated with the provided list of `mints` for the agent's wallet.
  * Returns a dictionary with transaction details or an error.
* `merge_tokens(agent: SolanaAgentKit, input_assets: List[Dict[str, Any]], output_mint: str, priority_fee: str) -> Optional[Dict[str, Any]]`:
  * Merges multiple `input_assets` (list of dicts, each specifying mint and amount) into a single `output_mint`.
  * `priority_fee` can be 'fast', 'turbo', 'ultra'.
  * This likely involves swapping the input assets for the output asset.
  * Returns a dictionary with transaction details or an error.
* `spread_token(agent: SolanaAgentKit, input_asset: Dict[str, Any], target_tokens: List[Dict[str, Any]], priority_fee: str) -> Optional[Dict[str, Any]]`:
  * Spreads a single `input_asset` (dict with mint and amount) into multiple `target_tokens` (list of dicts, each specifying mint and percentage or amount).
  * `priority_fee` can be 'fast', 'turbo', 'ultra'.
  * This likely involves swapping the input asset for the target assets.
  * Returns a dictionary with transaction details or an error.

##

**Important Considerations:**

* **Proxy Service:** This tool relies on an Agentipy proxy service. The availability, authentication (including the role of OpenAI and SolutioFi API keys), and terms of use for this proxy are critical.
* **On-Chain Actions:** All methods (`close_accounts`, `burn_tokens`, `merge_tokens`, `spread_token`) result in on-chain transactions that modify token balances, close accounts, or execute swaps. These actions incur SOL fees and have financial implications.
* **API Keys:** A `solutiofi_api_key` is explicitly included in the payload to the proxy, indicating it's likely required by the SolutioFi backend accessed via the proxy. An `openai_api_key` is also passed.
* **Token Management:** These tools provide powerful ways to manage multiple tokens, but care must be taken, especially with operations like `merge_tokens` and `spread_token` which likely involve underlying swaps and associated slippage or price impact.

## Source Code

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