get_top_pools_by_dex
Retrieve the most active liquidity pools by transaction count or volume on a specific decentralized exchange (DEX) across supported networks.
Instructions
Get top pools on a specific DEX
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dex | Yes | DEX ID (e.g., 'uniswap_v3', 'sushiswap') | |
| include | No | Attributes to include: 'base_token', 'quote_token', 'dex' (comma-separated) | |
| network | Yes | Network ID (e.g., 'eth', 'bsc', 'polygon_pos') | |
| page | No | Page number for pagination (optional, default: 1) | |
| sort | No | Sort by: 'h24_tx_count_desc', 'h24_volume_usd_desc' (optional, default: 'h24_tx_count_desc') |
Input Schema (JSON Schema)
{
"properties": {
"dex": {
"description": "DEX ID (e.g., 'uniswap_v3', 'sushiswap')",
"type": "string"
},
"include": {
"description": "Attributes to include: 'base_token', 'quote_token', 'dex' (comma-separated)",
"type": "string"
},
"network": {
"description": "Network ID (e.g., 'eth', 'bsc', 'polygon_pos')",
"type": "string"
},
"page": {
"description": "Page number for pagination (optional, default: 1)",
"type": "integer"
},
"sort": {
"description": "Sort by: 'h24_tx_count_desc', 'h24_volume_usd_desc' (optional, default: 'h24_tx_count_desc')",
"enum": [
"h24_tx_count_desc",
"h24_volume_usd_desc"
],
"type": "string"
}
},
"required": [
"network",
"dex"
],
"type": "object"
}
Implementation Reference
- src/toolService.js:229-246 (handler)Main handler function in ToolService that validates inputs, delegates to CoinGecko API service, and formats the standardized response for the MCP tool.async getTopPoolsByDex(network, dex, options = {}) { if (!network || !dex) { throw new Error("Missing required parameters: network, dex"); } const result = await this.coinGeckoApi.getTopPoolsByDex( network, dex, options ); return { message: `Top pools for ${dex} on ${network} retrieved successfully`, data: result, summary: `Found ${result.data?.length || 0} pools on ${dex}`, sort: options.sort || "h24_tx_count_desc", }; }
- Core implementation that performs the HTTP fetch to CoinGecko API endpoint /networks/{network}/dexes/{dex}/pools with query params and handles response/error.async getTopPoolsByDex(network, dex, options = {}) { try { const queryParams = new URLSearchParams(); if (options.include) queryParams.append('include', options.include); if (options.page) queryParams.append('page', options.page); if (options.sort) queryParams.append('sort', options.sort); const url = `${this.baseUrl}/networks/${network}/dexes/${dex}/pools${queryParams.toString() ? '?' + queryParams.toString() : ''}`; const response = await fetch(url, { headers: { 'x-cg-demo-api-key': this.apiKey } }); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } return await response.json(); } catch (error) { throw new Error(`Failed to get top pools by DEX: ${error.message}`); } }
- src/index.js:353-384 (schema)Input schema definition for the tool, defining parameters, types, descriptions, and required fields for MCP tool validation.{ name: TOOL_NAMES.GET_TOP_POOLS_BY_DEX, description: "Get top pools on a specific DEX", inputSchema: { type: "object", properties: { network: { type: "string", description: "Network ID (e.g., 'eth', 'bsc', 'polygon_pos')", }, dex: { type: "string", description: "DEX ID (e.g., 'uniswap_v3', 'sushiswap')", }, include: { type: "string", description: "Attributes to include: 'base_token', 'quote_token', 'dex' (comma-separated)", }, page: { type: "integer", description: "Page number for pagination (optional, default: 1)", }, sort: { type: "string", description: "Sort by: 'h24_tx_count_desc', 'h24_volume_usd_desc' (optional, default: 'h24_tx_count_desc')", enum: ["h24_tx_count_desc", "h24_volume_usd_desc"], }, }, required: ["network", "dex"], },
- src/index.js:1049-1055 (registration)Dispatch/registration in the MCP request handler switch statement that routes calls to the toolService handler.case TOOL_NAMES.GET_TOP_POOLS_BY_DEX: result = await toolService.getTopPoolsByDex(args.network, args.dex, { include: args.include, page: args.page, sort: args.sort, }); break;
- src/constants.js:25-25 (helper)Constant definition for the tool name used across the codebase.GET_TOP_POOLS_BY_DEX: "get_top_pools_by_dex",