Query DEX Trades
query_dex_tradesGet recent swap trades on decentralized exchanges, filtered by trading pair, chain, minimum size, and DEX protocol. Returns price, size, slippage, and maker/taker addresses.
Instructions
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.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pair | No | Trading pair (e.g. WETH-USDC) | |
| chain | No | Filter by blockchain network | |
| dex | No | Filter by DEX protocol (e.g. uniswap_v3, sushiswap) | |
| min_usd | No | Minimum trade size in USD | |
| limit | No | Maximum results (default 25) |
Implementation Reference
- src/tools/dex.ts:67-97 (handler)The async handler function that executes the query_dex_trades tool. Calls apiGet to fetch DEX trades from /api/v1/dex/trades with optional filters (pair, chain, dex, min_usd, limit), formats the response as text, and handles errors.
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:41-65 (schema)Input schema for query_dex_trades defined via Zod. Defines optional parameters: pair (string), chain (enum of ethereum/arbitrum/polygon/base/bsc), dex (string), min_usd (number), and limit (integer 1-100, default 25).
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)"), }, - src/tools/dex.ts:32-97 (registration)Registration of the tool named 'query_dex_trades' via server.registerTool() inside the registerDexTools() function, with title 'Query DEX Trades', description, inputSchema, and the handler callback.
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/index.ts:52-52 (registration)Top-level registration call: registerDexTools(server) is invoked from the main MCP server setup in src/index.ts.
registerDexTools(server); - src/client.ts:44-76 (helper)The apiGet helper function used by the handler to make HTTP GET requests to the Verilex API server.
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, }; }