hyperd.dex.quote
Compare swap quotes from Paraswap and 0x aggregators to find the route with the highest output. Returns per-source quotes and best route, with a fixed cost of $0.02 in USDC.
Instructions
Get the best DEX swap route across multiple aggregators (Paraswap + 0x). Returns the highest output amount and per-source quotes. Costs $0.02 in USDC.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from | Yes | Source token symbol or contract address | |
| to | Yes | Destination token symbol or contract address | |
| amount | Yes | Decimal amount of source token | |
| chain | No | Chain. Default 'base'. | |
| slippage | No | Max slippage in basis points. Default 50. | |
| taker | No | Optional payer address for 0x quote (improves accuracy) |
Implementation Reference
- src/server.ts:294-306 (registration)Registration of the 'hyperd.dex.quote' tool using the MCP server.tool() method. Defines schema (from, to, amount, chain, slippage, taker) and handler (calls paidGet('/api/dex/quote', args)).
server.tool( "hyperd.dex.quote", "Get the best DEX swap route across multiple aggregators (Paraswap + 0x). Returns the highest output amount and per-source quotes. Costs $0.02 in USDC.", { from: z.string().describe("Source token symbol or contract address"), to: z.string().describe("Destination token symbol or contract address"), amount: z.string().describe("Decimal amount of source token"), chain: z.enum(["base", "ethereum", "polygon", "arbitrum", "optimism", "avalanche", "bnb"]).optional().describe("Chain. Default 'base'."), slippage: z.number().int().optional().describe("Max slippage in basis points. Default 50."), taker: z.string().optional().describe("Optional payer address for 0x quote (improves accuracy)"), }, async (args) => asText(await paidGet("/api/dex/quote", args)), ); - src/server.ts:305-306 (handler)Handler implementation: async (args) => asText(await paidGet('/api/dex/quote', args)). Delegates to paidGet() which performs an x402 payment flow to the API endpoint.
async (args) => asText(await paidGet("/api/dex/quote", args)), ); - src/server.ts:297-304 (schema)Input schema using Zod. Parameters: from (string - source token), to (string - destination token), amount (string - decimal amount), chain (enum, optional - default base), slippage (number, optional - basis points, default 50), taker (string, optional - payer address for 0x quote).
{ from: z.string().describe("Source token symbol or contract address"), to: z.string().describe("Destination token symbol or contract address"), amount: z.string().describe("Decimal amount of source token"), chain: z.enum(["base", "ethereum", "polygon", "arbitrum", "optimism", "avalanche", "bnb"]).optional().describe("Chain. Default 'base'."), slippage: z.number().int().optional().describe("Max slippage in basis points. Default 50."), taker: z.string().optional().describe("Optional payer address for 0x quote (improves accuracy)"), }, - src/server.ts:79-92 (helper)paidGet helper: constructs URL with query params from args, calls paidRequest('GET', url, undefined) which handles the x402 payment dance (HTTP 402 -> payment -> retry).
async function paidGet( path: string, query: Record<string, string | number | boolean | undefined>, ): Promise<unknown> { if (!httpClient) { throw new Error(WALLET_NOT_CONFIGURED_MSG); } const url = new URL(`${API_BASE}${path}`); for (const [k, v] of Object.entries(query)) { if (v !== undefined && v !== "" && v !== null) url.searchParams.set(k, String(v)); } return paidRequest("GET", url, undefined); } - src/server.ts:155-157 (helper)asText helper: wraps data in MCP content response format { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }.
function asText(data: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; }