getDexPools
Retrieve liquidity pool data from specific decentralized exchanges across blockchain networks to analyze trading volumes, prices, and transaction metrics for informed decision-making.
Instructions
Get pools from a specific DEX on a network. First use getNetworks, then getNetworkDexes to find valid DEX IDs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | Yes | Network ID from getNetworks (e.g., "ethereum", "solana") | |
| dex | Yes | DEX identifier from getNetworkDexes (e.g., "uniswap_v3") | |
| page | No | Page number for pagination | |
| limit | No | Number of items per page (max 100) | |
| sort | No | Sort order | desc |
| orderBy | No | Field to order by | volume_usd |
Implementation Reference
- src/index.js:115-130 (registration)Registration of the 'getDexPools' tool with server.tool(), including description, Zod input schema, and inline async handler function that fetches data from the DexPaprika API endpoint /networks/{network}/dexes/{dex}/pools with query params.server.tool( 'getDexPools', 'Get pools from a specific DEX on a network. First use getNetworks, then getNetworkDexes to find valid DEX IDs.', { network: z.string().describe('Network ID from getNetworks (e.g., "ethereum", "solana")'), dex: z.string().describe('DEX identifier from getNetworkDexes (e.g., "uniswap_v3")'), page: z.number().optional().default(0).describe('Page number for pagination'), limit: z.number().optional().default(10).describe('Number of items per page (max 100)'), sort: z.enum(['asc', 'desc']).optional().default('desc').describe('Sort order'), orderBy: z.enum(['volume_usd', 'price_usd', 'transactions', 'last_price_change_usd_24h', 'created_at']).optional().default('volume_usd').describe('Field to order by') }, async ({ network, dex, page, limit, sort, orderBy }) => { const data = await fetchFromAPI(`/networks/${network}/dexes/${dex}/pools?page=${page}&limit=${limit}&sort=${sort}&order_by=${orderBy}`); return formatMcpResponse(data); } );
- src/index.js:127-129 (handler)The core handler function executing the tool logic: constructs the API endpoint using input params and calls shared fetchFromAPI helper, then formats response with formatMcpResponse.const data = await fetchFromAPI(`/networks/${network}/dexes/${dex}/pools?page=${page}&limit=${limit}&sort=${sort}&order_by=${orderBy}`); return formatMcpResponse(data); }
- src/index.js:119-125 (schema)Zod schema object defining input parameters for validation: network (required string), dex (required string), and optional pagination/sorting params.network: z.string().describe('Network ID from getNetworks (e.g., "ethereum", "solana")'), dex: z.string().describe('DEX identifier from getNetworkDexes (e.g., "uniswap_v3")'), page: z.number().optional().default(0).describe('Page number for pagination'), limit: z.number().optional().default(10).describe('Number of items per page (max 100)'), sort: z.enum(['asc', 'desc']).optional().default('desc').describe('Sort order'), orderBy: z.enum(['volume_usd', 'price_usd', 'transactions', 'last_price_change_usd_24h', 'created_at']).optional().default('volume_usd').describe('Field to order by') },
- src/index.js:10-34 (helper)Shared helper function used by getDexPools handler to make HTTP requests to DexPaprika API with custom error handling for 410 (deprecated endpoints) and 429 (rate limits).async function fetchFromAPI(endpoint) { try { const response = await fetch(`${API_BASE_URL}${endpoint}`); if (!response.ok) { if (response.status === 410) { throw new Error( 'This endpoint has been permanently removed. Please use network-specific endpoints instead. ' + 'For example, use /networks/{network}/pools instead of /pools. ' + 'Get available networks first using the getNetworks function.' ); } if (response.status === 429) { throw new Error( 'Rate limit exceeded. You have reached the maximum number of requests allowed for the free tier. ' + 'To increase your rate limits and access additional features, please consider upgrading to a paid plan at https://docs.dexpaprika.com/' ); } throw new Error(`API request failed with status ${response.status}`); } return await response.json(); } catch (error) { console.error(`Error fetching from API: ${error.message}`); throw error; } }
- src/index.js:37-46 (helper)Shared helper function used by all tools including getDexPools to format API response data as MCP-compatible text content containing JSON string.function formatMcpResponse(data) { return { content: [ { type: "text", text: JSON.stringify(data) } ] }; }