Skip to main content
Glama

Query DEX Trades

query_dex_trades

Get 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

TableJSON Schema
NameRequiredDescriptionDefault
pairNoTrading pair (e.g. WETH-USDC)
chainNoFilter by blockchain network
dexNoFilter by DEX protocol (e.g. uniswap_v3, sushiswap)
min_usdNoMinimum trade size in USD
limitNoMaximum results (default 25)

Implementation Reference

  • 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}` }],
        };
      },
    );
  • 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);
  • 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,
      };
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description covers cost ($0.003) and source (on-chain analytics), but lacks details on data freshness, pagination, or rate limits. It is adequate but not comprehensive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, front-loaded with purpose, then filters, then cost/source. No unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers purpose, filters, output fields, cost, and source. Missing explicit time range for 'recent', but limit default is in schema. Fairly complete for a query tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description lists filters already in schema and adds output field names but no additional parameter semantics beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves 'recent swap transactions' with specific filters (pair, chain, min size, DEX). It distinguishes from sibling tools like query_dex_pairs and query_dex_volume by focusing on individual trades.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for recent trade queries but does not explicitly mention when to use alternatives or provide exclusion criteria. No reference to sibling tools or when-not-to-use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/carrierone/verilexdata-mcp'

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