get_gasless_price
Calculate indicative prices for token swaps without gas fees by specifying chain, tokens, and amounts to enable cost-efficient DeFi trading.
Instructions
Get indicative price for a gasless token swap (no gas fees required)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chainId | Yes | Blockchain ID (e.g., 8453 for Base) | |
| buyToken | Yes | Contract address of token to buy | |
| sellToken | Yes | Contract address of token to sell | |
| sellAmount | Yes | Amount of sellToken in base units | |
| taker | No | Address executing the trade (optional) | |
| slippageBps | No | Maximum acceptable slippage in basis points (optional, min: 30) |
Implementation Reference
- src/toolService.js:415-431 (handler)Primary MCP tool handler for get_gasless_price. Validates parameters and delegates to AgService.getGaslessPrice, returning formatted response.async getGaslessPrice(params) { const { chainId, buyToken, sellToken, sellAmount } = params; if (!chainId || !buyToken || !sellToken || !sellAmount) { throw new Error( "Missing required parameters: chainId, buyToken, sellToken, sellAmount" ); } const result = await this.agg.getGaslessPrice(params); return { message: "Gasless swap price retrieved successfully", data: result, note: "This is a gasless swap - no ETH needed for gas fees", }; }
- src/index.js:634-668 (schema)Input schema definition for the get_gasless_price tool, registered in ListToolsRequestHandler.name: TOOL_NAMES.GET_GASLESS_PRICE, description: "Get indicative price for a gasless token swap (no gas fees required)", inputSchema: { type: "object", properties: { chainId: { type: "integer", description: "Blockchain ID (e.g., 8453 for Base)", }, buyToken: { type: "string", description: "Contract address of token to buy", }, sellToken: { type: "string", description: "Contract address of token to sell", }, sellAmount: { type: "string", description: "Amount of sellToken in base units", }, taker: { type: "string", description: "Address executing the trade (optional)", }, slippageBps: { type: "integer", description: "Maximum acceptable slippage in basis points (optional, min: 30)", }, }, required: ["chainId", "buyToken", "sellToken", "sellAmount"], }, },
- src/index.js:1138-1140 (registration)Tool dispatch/registration in the main CallToolRequestHandler switch statement.case TOOL_NAMES.GET_GASLESS_PRICE: result = await toolService.getGaslessPrice(args); break;
- src/services/agService.js:118-137 (helper)Supporting helper method in AgService that makes the actual API call to the aggregator's gasless price endpoint.async getGaslessPrice(params) { try { const queryParams = new URLSearchParams(params); const response = await fetch(`${this.baseUrl}/api/swap/gasless/price?${queryParams}`); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const data = await response.json(); if (!data.success) { throw new Error(data.error || 'Gasless price request failed'); } return data.data; } catch (error) { throw new Error(`Failed to get gasless price: ${error.message}`); } }
- src/constants.js:11-11 (registration)Constant defining the tool name string used throughout the codebase.GET_GASLESS_PRICE: "get_gasless_price",