Skip to main content
Glama

DeFi Trading Agent MCP Server

by edkdev

get_gasless_quote

Obtain a gasless token swap quote with executable EIP-712 signature data for DeFi trades across multiple blockchains. Supports defined slippage and token pairs.

Instructions

Get executable quote for a gasless token swap with EIP-712 signature data

Input Schema

NameRequiredDescriptionDefault
buyTokenYesContract address of token to buy
chainIdYesBlockchain ID (e.g., 8453 for Base)
sellAmountYesAmount of sellToken in base units
sellTokenYesContract address of token to sell
slippageBpsNoMaximum acceptable slippage in basis points (optional, min: 30)
takerNoAddress executing the trade (required for gasless quotes, uses USER_ADDRESS from env if not provided)

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 (required for gasless quotes, uses USER_ADDRESS from env if not provided)", "type": "string" } }, "required": [ "chainId", "buyToken", "sellToken", "sellAmount" ], "type": "object" }

Implementation Reference

  • Primary MCP tool handler for 'get_gasless_quote'. Validates params, sets taker address from userAddress if missing, calls agService.getGaslessQuote, and returns formatted response with metadata.
    async getGaslessQuote(params) { const { chainId, buyToken, sellToken, sellAmount } = params; if (!chainId || !buyToken || !sellToken || !sellAmount) { throw new Error( "Missing required parameters: chainId, buyToken, sellToken, sellAmount" ); } // Add taker address if not provided (required for gasless quotes) const quoteParams = { ...params, taker: params.taker || this.userAddress, }; if (!quoteParams.taker) { throw new Error("Taker address is required for gasless quotes"); } const result = await this.agg.getGaslessQuote(quoteParams); return { message: "Gasless swap quote retrieved successfully", data: result, nextSteps: [ "1. Review the quote details including approval and trade objects", "2. Use submit_gasless_swap tool to execute this gasless swap", "3. Both approval and trade signatures will be handled automatically", ], gaslessInfo: { hasApproval: !!result.approval, hasTrade: !!result.trade, approvalType: result.approval?.type, tradeType: result.trade?.type, }, }; }
  • Input schema definition for the get_gasless_quote tool, including properties, descriptions, and required fields.
    { name: TOOL_NAMES.GET_GASLESS_QUOTE, description: "Get executable quote for a gasless token swap with EIP-712 signature data", 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 (required for gasless quotes, uses USER_ADDRESS from env if not provided)", }, slippageBps: { type: "integer", description: "Maximum acceptable slippage in basis points (optional, min: 30)", }, }, required: ["chainId", "buyToken", "sellToken", "sellAmount"], }, },
  • src/index.js:1142-1144 (registration)
    Registration in the MCP tool request handler switch statement, dispatching calls to toolService.getGaslessQuote.
    case TOOL_NAMES.GET_GASLESS_QUOTE: result = await toolService.getGaslessQuote(args); break;
  • Helper service method in agService that performs the actual HTTP fetch to the aggregator API endpoint for gasless quote.
    async getGaslessQuote(params) { try { const queryParams = new URLSearchParams(params); const response = await fetch(`${this.baseUrl}/api/swap/gasless/quote?${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 quote request failed'); } return data.data; } catch (error) { throw new Error(`Failed to get gasless quote: ${error.message}`); }
  • Constant definition mapping GET_GASLESS_QUOTE to the tool name string 'get_gasless_quote'.
    GET_GASLESS_QUOTE: "get_gasless_quote",

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/edkdev/defi-trading-mcp'

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