tapp_swap_clmm
Perform a token swap on a Concentrated Liquidity Market Maker (CLMM) pool using specified input amount, minimum output, direction, and target price. Execute trades efficiently within the Tapp Exchange ecosystem.
Instructions
Execute a swap on a CLMM (Concentrated Liquidity Market Maker) pool
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a2b | Yes | Direction of the swap; true for token A to B, false for B to A | |
| amountIn | Yes | The input token amount for the swap | |
| fixedAmountIn | No | Indicates whether amountIn is fixed (defaults to true) | |
| minAmountOut | Yes | The minimum acceptable output amount | |
| poolId | Yes | The address of the CLMM pool | |
| targetSqrtPrice | Yes | The target square root price |
Implementation Reference
- src/mcp/tapp/swap-tools.ts:82-96 (handler)The main handler function for the "tapp_swap_clmm" tool. It validates inputs via schema and delegates to TappAgent.swapCLMM to execute the CLMM swap transaction.handler: async (agent: TappAgent, input: Record<string, any>) => { const result = await agent.swapCLMM({ poolId: input.poolId, amountIn: input.amountIn, minAmountOut: input.minAmountOut, a2b: input.a2b, fixedAmountIn: input.fixedAmountIn ?? true, targetSqrtPrice: input.targetSqrtPrice }); return { status: "success", transaction: result }; }, };
- src/mcp/tapp/swap-tools.ts:74-81 (schema)Zod schema defining the input parameters and validation for the tapp_swap_clmm tool.schema: { poolId: z.string().describe("The address of the CLMM pool"), amountIn: z.number().describe("The input token amount for the swap"), minAmountOut: z.number().describe("The minimum acceptable output amount"), a2b: z.boolean().describe("Direction of the swap; true for token A to B, false for B to A"), fixedAmountIn: z.boolean().optional().describe("Indicates whether amountIn is fixed (defaults to true)"), targetSqrtPrice: z.number().describe("The target square root price") },
- src/mcp/index.ts:34-34 (registration)Registration of the SwapCLMMTool (named tapp_swap_clmm) in the central TappExchangeMcpTools export object used by the MCP server."SwapCLMMTool": SwapCLMMTool,
- src/agent/index.ts:273-292 (helper)Helper method in TappAgent class that implements the core swapCLMM logic by generating transaction payload from the Tapp SDK and submitting it via Aptos client.async swapCLMM(params: SwapCLMMParams): Promise<TransactionResponse> { try { const data = this.sdk.Swap.swapCLMMTransactionPayload(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' }; } }