get_pool_trades
Retrieve recent trades for a specific DeFi liquidity pool to analyze trading activity and volume patterns.
Instructions
Get recent trades for a specific pool
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | Yes | Network ID (e.g., 'eth', 'bsc', 'polygon_pos') | |
| poolAddress | Yes | Pool contract address | |
| trade_volume_in_usd_greater_than | No | Filter trades with volume greater than this USD amount (optional) |
Implementation Reference
- Core helper function that performs the actual API call to CoinGecko for retrieving pool trades.
async getPoolTrades(network, poolAddress, options = {}) { try { const queryParams = new URLSearchParams(); if (options.trade_volume_in_usd_greater_than) queryParams.append('trade_volume_in_usd_greater_than', options.trade_volume_in_usd_greater_than); const url = `${this.baseUrl}/networks/${network}/pools/${poolAddress}/trades${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 pool trades: ${error.message}`); } }