get_gasless_price
Retrieve indicative prices for gasless token swaps, enabling cost-efficient trades across multiple blockchains without gas fees. Essential for DeFi trading agents.
Instructions
Get indicative price for a gasless token swap (no gas fees required)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| buyToken | Yes | Contract address of token to buy | |
| chainId | Yes | Blockchain ID (e.g., 8453 for Base) | |
| sellAmount | Yes | Amount of sellToken in base units | |
| sellToken | Yes | Contract address of token to sell | |
| slippageBps | No | Maximum acceptable slippage in basis points (optional, min: 30) | |
| taker | No | Address executing the trade (optional) |
Input Schema (JSON Schema)
{
"properties": {
"buyToken": {
"description": "Contract address of token to buy",
"type": "string"
},
"chainId": {
"description": "Blockchain ID (e.g., 8453 for Base)",
"type": "integer"
},
"sellAmount": {
"description": "Amount of sellToken in base units",
"type": "string"
},
"sellToken": {
"description": "Contract address of token to sell",
"type": "string"
},
"slippageBps": {
"description": "Maximum acceptable slippage in basis points (optional, min: 30)",
"type": "integer"
},
"taker": {
"description": "Address executing the trade (optional)",
"type": "string"
}
},
"required": [
"chainId",
"buyToken",
"sellToken",
"sellAmount"
],
"type": "object"
}
Implementation Reference
- src/toolService.js:415-431 (handler)Primary handler for the 'get_gasless_price' tool. Validates input parameters (chainId, buyToken, sellToken, sellAmount) and delegates to AgService to fetch the gasless price from the aggregator API, 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-667 (schema)Input schema definition for the 'get_gasless_price' tool, specifying parameters, types, descriptions, and required fields. Part of the tool registration 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:633-668 (registration)Tool registration in the MCP server's ListToolsRequestHandler, including name, description, and input schema for 'get_gasless_price'.{ 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)Dispatch handler in CallToolRequestHandler switch statement that routes 'get_gasless_price' calls to toolService.getGaslessPrice.case TOOL_NAMES.GET_GASLESS_PRICE: result = await toolService.getGaslessPrice(args); break;
- src/services/agService.js:118-137 (helper)Supporting utility in AgService that performs the actual HTTP request to the aggregator API endpoint /api/swap/gasless/price to retrieve the gasless price data.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}`); } }