Skip to main content
Glama

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
NameRequiredDescriptionDefault
a2bYesDirection of the swap; true for token A to B, false for B to A
amountInYesThe input token amount for the swap
fixedAmountInNoIndicates whether amountIn is fixed (defaults to true)
minAmountOutYesThe minimum acceptable output amount
poolIdYesThe address of the CLMM pool
targetSqrtPriceYesThe target square root price

Implementation Reference

  • 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 }; }, };
  • 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,
  • 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' }; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tamago-labs/tapp-exchange-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server