Query DEX Volume
query_dex_volumeRetrieve DEX trading pair volume statistics including 24h and 7d volume, trade count, and trends across multiple blockchains.
Instructions
Get volume statistics for DEX trading pairs. Shows 24h volume, 7d volume, trade count, and volume trends by pair and chain. Cost: $0.005 per query. Source: On-chain DEX analytics.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pair | No | Trading pair (e.g. WETH-USDC) | |
| chain | No | Filter by blockchain network | |
| period | No | Volume aggregation period (default: 24h) | |
| limit | No | Maximum results (default 25) |
Implementation Reference
- src/tools/dex.ts:29-97 (registration)The registerDexTools function is called from src/index.ts line 52, registering all DEX tools including query_dex_volume on the MCP server.
export function registerDexTools(server: McpServer): void { // ── Query DEX trades ────────────────────────────────────────────────── server.registerTool( "query_dex_trades", { title: "Query DEX Trades", description: "Get recent swap transactions on decentralized exchanges. Filter by trading pair, " + "chain, minimum size, and DEX protocol. Returns trade details including price, " + "size, slippage, and maker/taker addresses. " + "Cost: $0.003 per query. Source: On-chain DEX analytics.", inputSchema: { pair: z .string() .optional() .describe("Trading pair (e.g. WETH-USDC)"), chain: z .enum(["ethereum", "arbitrum", "polygon", "base", "bsc"]) .optional() .describe("Filter by blockchain network"), dex: z .string() .optional() .describe("Filter by DEX protocol (e.g. uniswap_v3, sushiswap)"), min_usd: z .number() .optional() .describe("Minimum trade size in USD"), limit: z .number() .int() .min(1) .max(100) .optional() .describe("Maximum results (default 25)"), }, }, async ({ pair, chain, dex, min_usd, limit }) => { const res = await apiGet<DexQueryResponse>("/api/v1/dex/trades", { pair, chain, dex, min_usd, 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 trade(s).`; const json = JSON.stringify(data, null, 2); return { content: [{ type: "text" as const, text: `${summary}\n\n${json}` }], }; }, ); - src/tools/dex.ts:162-223 (handler)The handler for query_dex_volume tool: calls apiGet to /api/v1/dex/volume with optional pair, chain, period, and limit parameters, returns volume statistics.
// ── Query DEX volume ────────────────────────────────────────────────── server.registerTool( "query_dex_volume", { title: "Query DEX Volume", description: "Get volume statistics for DEX trading pairs. Shows 24h volume, 7d volume, " + "trade count, and volume trends by pair and chain. " + "Cost: $0.005 per query. Source: On-chain DEX analytics.", inputSchema: { pair: z .string() .optional() .describe("Trading pair (e.g. WETH-USDC)"), chain: z .enum(["ethereum", "arbitrum", "polygon", "base", "bsc"]) .optional() .describe("Filter by blockchain network"), period: z .enum(["24h", "7d", "30d"]) .optional() .describe("Volume aggregation period (default: 24h)"), limit: z .number() .int() .min(1) .max(100) .optional() .describe("Maximum results (default 25)"), }, }, async ({ pair, chain, period, limit }) => { const res = await apiGet<DexQueryResponse>("/api/v1/dex/volume", { pair, chain, period: period ?? "24h", 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 volume record(s).`; const json = JSON.stringify(data, null, 2); return { content: [{ type: "text" as const, text: `${summary}\n\n${json}` }], }; }, ); - src/tools/dex.ts:172-192 (schema)Input schema for query_dex_volume: optional pair (string), chain (enum: ethereum, arbitrum, polygon, base, bsc), period (enum: 24h, 7d, 30d), and limit (int 1-100).
inputSchema: { pair: z .string() .optional() .describe("Trading pair (e.g. WETH-USDC)"), chain: z .enum(["ethereum", "arbitrum", "polygon", "base", "bsc"]) .optional() .describe("Filter by blockchain network"), period: z .enum(["24h", "7d", "30d"]) .optional() .describe("Volume aggregation period (default: 24h)"), limit: z .number() .int() .min(1) .max(100) .optional() .describe("Maximum results (default 25)"), }, - src/index.ts:52-58 (registration)Top-level registration: registerDexTools(server) is called in the MCP server setup in src/index.ts line 52.
registerDexTools(server); registerContractTools(server); registerPmTools(server); registerPmArbTools(server); registerPmResolutionTools(server); registerEconTools(server); registerPmMicroTools(server); - src/client.ts:44-76 (helper)The apiGet helper function used by the handler to make HTTP GET requests to the Verilex API backend (calls /api/v1/dex/volume).
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, }; }