Query DEX Pairs
query_dex_pairsRetrieve available trading pairs from decentralized exchanges. Filter by blockchain, base token, or quote token to get liquidity and volume data.
Instructions
List available trading pairs on decentralized exchanges. Filter by chain, base token, or quote token. Returns pair details with liquidity and volume. Cost: $0.001 per query. Source: On-chain DEX analytics.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain | No | Filter by blockchain network | |
| base_token | No | Filter by base token symbol (e.g. WETH) | |
| quote_token | No | Filter by quote token symbol (e.g. USDC) | |
| limit | No | Maximum results (default 25) |
Implementation Reference
- src/tools/dex.ts:131-160 (handler)The async handler function that executes the 'query_dex_pairs' tool logic. Calls apiGet('/api/v1/dex/pairs') with optional chain, base_token, quote_token, and limit parameters, then formats the response.
async ({ chain, base_token, quote_token, limit }) => { const res = await apiGet<DexQueryResponse>("/api/v1/dex/pairs", { chain, base_token, quote_token, limit: limit ?? 25, }); if (!res.ok) { return { content: [ { type: "text" as const, text: `API error (${res.status}): ${JSON.stringify(res.data)}`, }, ], isError: true, }; } const { count, data } = res.data; const warn = stalenessWarning(res); const summary = `${warn}Found ${count} DEX pair(s).`; const json = JSON.stringify(data, null, 2); return { content: [{ type: "text" as const, text: `${summary}\n\n${json}` }], }; }, ); - src/tools/dex.ts:103-130 (schema)Input schema for 'query_dex_pairs' using Zod. Defines optional parameters: chain (enum of chains), base_token, quote_token, and limit (1-100, default 25).
{ title: "Query DEX Pairs", description: "List available trading pairs on decentralized exchanges. Filter by chain, " + "base token, or quote token. Returns pair details with liquidity and volume. " + "Cost: $0.001 per query. Source: On-chain DEX analytics.", inputSchema: { chain: z .enum(["ethereum", "arbitrum", "polygon", "base", "bsc"]) .optional() .describe("Filter by blockchain network"), base_token: z .string() .optional() .describe("Filter by base token symbol (e.g. WETH)"), quote_token: z .string() .optional() .describe("Filter by quote token symbol (e.g. USDC)"), limit: z .number() .int() .min(1) .max(100) .optional() .describe("Maximum results (default 25)"), }, }, - src/tools/dex.ts:101-160 (registration)Registration of 'query_dex_pairs' tool via server.registerTool() with the tool name string 'query_dex_pairs', schema, and handler.
server.registerTool( "query_dex_pairs", { title: "Query DEX Pairs", description: "List available trading pairs on decentralized exchanges. Filter by chain, " + "base token, or quote token. Returns pair details with liquidity and volume. " + "Cost: $0.001 per query. Source: On-chain DEX analytics.", inputSchema: { chain: z .enum(["ethereum", "arbitrum", "polygon", "base", "bsc"]) .optional() .describe("Filter by blockchain network"), base_token: z .string() .optional() .describe("Filter by base token symbol (e.g. WETH)"), quote_token: z .string() .optional() .describe("Filter by quote token symbol (e.g. USDC)"), limit: z .number() .int() .min(1) .max(100) .optional() .describe("Maximum results (default 25)"), }, }, async ({ chain, base_token, quote_token, limit }) => { const res = await apiGet<DexQueryResponse>("/api/v1/dex/pairs", { chain, base_token, quote_token, limit: limit ?? 25, }); if (!res.ok) { return { content: [ { type: "text" as const, text: `API error (${res.status}): ${JSON.stringify(res.data)}`, }, ], isError: true, }; } const { count, data } = res.data; const warn = stalenessWarning(res); const summary = `${warn}Found ${count} DEX pair(s).`; const json = JSON.stringify(data, null, 2); return { content: [{ type: "text" as const, text: `${summary}\n\n${json}` }], }; }, ); - src/client.ts:35-41 (helper)stalenessWarning helper used by the handler to check for stale data headers.
export function stalenessWarning(res: ApiResponse): string { if (!res.stale) return ""; const parts = ["[STALE DATA]"]; if (res.lastUpdated) parts.push(`Last updated: ${res.lastUpdated}`); if (res.ageSeconds != null) parts.push(`Age: ${res.ageSeconds}s`); return parts.join(" ") + "\n\n"; } - src/client.ts:44-76 (helper)apiGet helper used by the handler to make HTTP GET requests to the Verilex API.
export async function apiGet<T = unknown>( path: string, params?: Record<string, string | number | undefined>, ): Promise<ApiResponse<T>> { const url = buildUrl(path, params); const headers: Record<string, string> = { Accept: "application/json", "User-Agent": "verilex-mcp-server/0.1.0", }; // Forward x402 payment token if present in env (for paid endpoints) const paymentToken = process.env.VERILEX_PAYMENT_TOKEN; if (paymentToken) { headers["X-Payment-Token"] = paymentToken; } const res = await fetch(url, { headers }); const data = (await res.json()) as T; const stale = res.headers.get("X-Data-Stale"); const lastUpdated = res.headers.get("X-Data-Last-Updated"); const ageSeconds = res.headers.get("X-Data-Age-Seconds"); return { ok: res.ok, status: res.status, data, stale: stale === "true", lastUpdated: lastUpdated ?? undefined, ageSeconds: ageSeconds ? Number(ageSeconds) : undefined, }; }