tapp_swap_stable
Facilitate token swaps within Stable pools on Tapp Exchange by specifying pool address, input/output token indices, amount, and minimum output. Optimizes trading operations on Aptos blockchain.
Instructions
Execute a swap on a Stable pool
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amountIn | Yes | The input token amount for the swap | |
| minAmountOut | Yes | The minimum amount of output tokens | |
| poolId | Yes | The address of the Stable pool | |
| tokenIn | Yes | The index of the token to swap from | |
| tokenOut | Yes | The index of the token to swap to |
Implementation Reference
- src/mcp/tapp/swap-tools.ts:108-120 (handler)The handler function that executes the tapp_swap_stable tool logic by calling TappAgent.swapStable with input parameters and returning the transaction result.handler: async (agent: TappAgent, input: Record<string, any>) => { const result = await agent.swapStable({ poolId: input.poolId, tokenIn: input.tokenIn, tokenOut: input.tokenOut, amountIn: input.amountIn, minAmountOut: input.minAmountOut }); return { status: "success", transaction: result }; },
- src/mcp/tapp/swap-tools.ts:101-107 (schema)Input schema using Zod for validating parameters: poolId, tokenIn, tokenOut, amountIn, minAmountOut.schema: { poolId: z.string().describe("The address of the Stable pool"), tokenIn: z.number().describe("The index of the token to swap from"), tokenOut: z.number().describe("The index of the token to swap to"), amountIn: z.number().describe("The input token amount for the swap"), minAmountOut: z.number().describe("The minimum amount of output tokens") },
- src/mcp/index.ts:30-36 (registration)Registration of SwapStableTool (tapp_swap_stable) in the TappExchangeMcpTools object used for MCP tool server.// Swap Tools "GetSwapEstimateTool": GetSwapEstimateTool, "GetSwapRouteTool": GetSwapRouteTool, "SwapAMMTool": SwapAMMTool, "SwapCLMMTool": SwapCLMMTool, "SwapStableTool": SwapStableTool,
- src/agent/index.ts:294-313 (helper)Supporting method in TappAgent that generates the stable swap transaction payload using the Tapp SDK and submits it via Aptos SDK.async swapStable(params: SwapStableParams): Promise<TransactionResponse> { try { const data = this.sdk.Swap.swapStableTransactionPayload(params); const response = await this.aptos.transaction.submit.simple({ sender: this.account.accountAddress, data: data } as any); return { hash: response.hash, success: true }; } catch (error) { return { hash: '', success: false, error: error instanceof Error ? error.message : 'Unknown error' }; } }