> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sendai.fun/llms.txt
> Use this file to discover all available pages before exploring further.

# SolutioFi Token Management

> Learn how to manage tokens using SolutioFi protocol integration

Solana Agent Kit provides comprehensive integration with SolutioFi protocol for token management operations, including burning tokens, closing accounts, merging multiple tokens, and spreading tokens across different assets.

## Key Features

* Token burning
* Account closure
* Token merging
* Token spreading
* Priority fee management
* Transaction batching
* LangChain tool integration

## Basic Usage

### Burning Tokens

```typescript theme={"system"}
const signatures = await agent.methods.burnTokens([
  "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",  // USDC
  "So11111111111111111111111111111111111111112"    // SOL
]);
```

### Closing Accounts

```typescript theme={"system"}
const signatures = await agent.methods.closeAccounts([
  "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",  // USDC
  "So11111111111111111111111111111111111111112"    // SOL
]);
```

### Merging Tokens

```typescript theme={"system"}
const signatures = await agent.methods.mergeTokens(
  [
    {
      mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      inputAmount: "100",
      slippage: "1",
      onlyDirectRoutes: true
    }
  ],
  "So11111111111111111111111111111111111111112",
  "normal"
);
```

### Spreading Tokens

```typescript theme={"system"}
const signatures = await agent.methods.spreadToken(
  {
    mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    inputAmount: "1000",
    slippage: "1",
    onlyDirectRoutes: true
  },
  [
    {
      mint: "So11111111111111111111111111111111111111112",
      percentage: 50
    },
    {
      mint: "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So",
      percentage: 50
    }
  ],
  "normal"
);
```

## Input Types

### Input Asset Structure

```typescript theme={"system"}
interface InputAssetStruct {
  mint: string;           // Token mint address
  inputAmount: string;    // Amount to process
  slippage: string;       // Slippage tolerance
  onlyDirectRoutes: boolean; // Use only direct routes
}
```

### Target Token Structure

```typescript theme={"system"}
interface TargetTokenStruct {
  mint: string;           // Token mint address
  percentage: number;     // Allocation percentage
}
```

### Priority Fee Levels

```typescript theme={"system"}
type PriorityFee = "fast" | "normal" | "slow";
```

## LangChain Integration

Solana Agent Kit provides several LangChain tools for SolutioFi operations:

### Burn Tokens Tool

```typescript theme={"system"}
import { SolanaBurnTokensTool } from 'solana-agent-kit';

const burnTokensTool = new SolanaBurnTokensTool(agent);

// Tool input format (JSON string):
const input = JSON.stringify({
  mints: [
    "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "So11111111111111111111111111111111111111112"
  ]
});
```

### Close Accounts Tool

```typescript theme={"system"}
import { SolanaCloseAccountsTool } from 'solana-agent-kit';

const closeAccountsTool = new SolanaCloseAccountsTool(agent);

// Tool input format (JSON string):
const input = JSON.stringify({
  mints: [
    "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "So11111111111111111111111111111111111111112"
  ]
});
```

### Merge Tokens Tool

```typescript theme={"system"}
import { SolanaMergeTokensTool } from 'solana-agent-kit';

const mergeTokensTool = new SolanaMergeTokensTool(agent);

// Tool input format (JSON string):
const input = JSON.stringify({
  inputAssets: [{
    mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    inputAmount: "100",
    slippage: "1",
    onlyDirectRoutes: true
  }],
  outputMint: "So11111111111111111111111111111111111111112",
  priorityFee: "normal"
});
```

### Spread Token Tool

```typescript theme={"system"}
import { SolanaSpreadTokenTool } from 'solana-agent-kit';

const spreadTokenTool = new SolanaSpreadTokenTool(agent);

// Tool input format (JSON string):
const input = JSON.stringify({
  inputAsset: {
    mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    inputAmount: "1000",
    slippage: "1",
    onlyDirectRoutes: true
  },
  targetTokens: [
    {
      mint: "So11111111111111111111111111111111111111112",
      percentage: 50
    },
    {
      mint: "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So",
      percentage: 50
    }
  ],
  priorityFee: "normal"
});
```

## Example Prompts

For LangChain AI tools, here are example prompts:

### Token Management

```text theme={"system"}
"Burn these unused token accounts"
"Close all empty token accounts"
"Merge multiple USDC accounts into one"
"Split 1000 USDC equally between SOL and mSOL"
```

## Important Notes

1. **API Key Configuration**
   * Required for all operations
   * Set via SOLUTIOFI\_API\_KEY in config
   * Client authentication required before use

2. **Transaction Batching**
   * Operations may generate multiple transactions
   * All transactions are signed and sent sequentially
   * Failed transactions are skipped

3. **Priority Fees**
   * Three levels available: fast, normal, slow
   * Affects transaction processing speed
   * Higher fees for faster processing

## Best Practices

1. **Error Handling**
   ```typescript theme={"system"}
   try {
     const signatures = await agent.methods.burnTokens(mints);
     // Check each signature for success
   } catch (error) {
     if (error.message.includes("API key")) {
       // Handle authentication issues
     } else if (error.message.includes("insufficient")) {
       // Handle insufficient balance
     }
   }
   ```

2. **Transaction Management**
   ```typescript theme={"system"}
   // Process multiple transactions
   const signatures = [];
   for (const tx of transactions) {
     try {
       const signature = await sendAndConfirm(tx);
       signatures.push(signature);
     } catch (error) {
       continue; // Skip failed transactions
     }
   }
   ```

3. **Input Validation**
   ```typescript theme={"system"}
   // Validate percentage allocations
   const totalPercentage = targetTokens.reduce(
     (sum, token) => sum + token.percentage,
     0
   );
   if (totalPercentage !== 100) {
     throw new Error("Total percentage must equal 100");
   }
   ```

## Technical Details

### Client Initialization

```typescript theme={"system"}
const client = new SolutioFi({
  apiKey: process.env.SOLUTIOFI_API_KEY
});
await client.authenticate();
```

### Transaction Options

```typescript theme={"system"}
const TX_OPTIONS = {
  skipPreflight: false,
  preflightCommitment: "processed"
};
```

### Common Token Addresses

```typescript theme={"system"}
const TOKENS = {
  SOL: "So11111111111111111111111111111111111111112",
  USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  mSOL: "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"
};
```
