Skip to main content
Glama

tapp_get_swap_estimate

Calculate the estimated input or output amount for a token swap on Tapp Exchange, specifying pool, token pair, direction, and amount type.

Instructions

Estimate the amount received or needed for a swap on Tapp Exchange

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
a2bYesSwap direction - true for token at pair[0] to pair[1], false for pair[1] to pair[0]
amountYesThe amount for estimation (used as input or desired output depending on field)
fieldNoIndicates if amount is an 'input' or 'output' amount (defaults to 'input')
pairYesA tuple of token indexes to swap, e.g., [0, 1] means token at index 0 is being swapped for token at index 1
poolIdYesThe identifier of the pool

Implementation Reference

  • The MCP tool handler function that parses input and delegates to TappAgent.getEstimateSwapAmount, returning the estimate result.
    handler: async (agent: TappAgent, input: Record<string, any>) => { const estimate = await agent.getEstimateSwapAmount({ amount: input.amount, poolId: input.poolId, pair: input.pair as [number, number], a2b: input.a2b, field: input.field || 'input' }); return { status: "success", estimate }; },
  • Zod-based input schema defining parameters: amount, poolId, pair, a2b, and optional field.
    schema: { amount: z.number().describe("The amount for estimation (used as input or desired output depending on field)"), poolId: z.string().describe("The identifier of the pool"), pair: z.array(z.number()).describe("A tuple of token indexes to swap, e.g., [0, 1] means token at index 0 is being swapped for token at index 1"), a2b: z.boolean().describe("Swap direction - true for token at pair[0] to pair[1], false for pair[1] to pair[0]"), field: z.enum(['input', 'output']).optional().describe("Indicates if amount is an 'input' or 'output' amount (defaults to 'input')") },
  • src/mcp/index.ts:31-31 (registration)
    The tool is registered in the TappExchangeMcpTools object by mapping the export name to the tool object, which is later iterated to register with MCP server.
    "GetSwapEstimateTool": GetSwapEstimateTool,
  • TappAgent helper method that calls the underlying SDK to compute the swap estimate.
    async getEstimateSwapAmount(params: { amount: number; poolId: string; pair: [number, number]; a2b: boolean; field?: 'input' | 'output'; }): Promise<SwapEstimate> { const result = await this.sdk.Swap.getEstSwapAmount(params); return result; }
  • src/index.ts:20-52 (registration)
    The dynamic registration loop in the MCP server creation that registers the tool using its internal name, description, schema, and wrapped handler.
    for (const [_key, tool] of Object.entries(TappExchangeMcpTools)) { server.tool(tool.name, tool.description, tool.schema, async (params: any): Promise<any> => { try { // Execute the handler with the params directly const result = await tool.handler(agent, params); // Format the result as MCP tool response return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { console.error("error", error); // Handle errors in MCP format return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error occurred", }, ], }; } }) }

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