Skip to main content
Glama

tapp_swap_amm

Use this tool to execute token swaps on Automated Market Maker (AMM) pools on the Aptos blockchain. Specify pool address, swap direction, and token amounts to trade assets efficiently.

Instructions

Execute a swap on an AMM pool

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
a2bYesDirection of the swap; true for token A to B, false for B to A
amount0YesAmount of token A
amount1YesAmount of token B
fixedAmountInNoWhether the input amount is fixed (defaults to true)
poolIdYesThe address of the pool in which the swap is performed

Implementation Reference

  • The MCP tool handler function for 'tapp_swap_amm' that validates input, calls TappAgent.swapAMM, and returns the transaction result.
    handler: async (agent: TappAgent, input: Record<string, any>) => { const result = await agent.swapAMM({ poolId: input.poolId, a2b: input.a2b, fixedAmountIn: input.fixedAmountIn ?? true, amount0: input.amount0, amount1: input.amount1 }); return { status: "success", transaction: result }; },
  • Zod schema defining the input parameters for the tapp_swap_amm tool.
    schema: { poolId: z.string().describe("The address of the pool in which the swap is performed"), a2b: z.boolean().describe("Direction of the swap; true for token A to B, false for B to A"), fixedAmountIn: z.boolean().optional().describe("Whether the input amount is fixed (defaults to true)"), amount0: z.number().describe("Amount of token A"), amount1: z.number().describe("Amount of token B") },
  • src/mcp/index.ts:33-33 (registration)
    Registration of the SwapAMMTool (tapp_swap_amm) in the central MCP tools export.
    "SwapAMMTool": SwapAMMTool,
  • TappAgent.swapAMM helper method that generates the swap transaction payload using the Tapp SDK and submits it via Aptos client.
    async swapAMM(params: SwapAMMParams): Promise<TransactionResponse> { try { const data = this.sdk.Swap.swapAMMTransactionPayload(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