Skip to main content
Glama
edkdev

DeFi Trading Agent MCP Server

by edkdev

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

TableJSON Schema
NameRequiredDescriptionDefault
networkYesNetwork ID (e.g., 'eth', 'bsc', 'polygon_pos')
poolAddressYesPool contract address
trade_volume_in_usd_greater_thanNoFilter trades with volume greater than this USD amount (optional)

Implementation Reference

  • Main handler function for the get_pool_trades tool. Validates parameters and delegates to CoinGecko API service, then formats the response.
    async getPoolTrades(network, poolAddress, options = {}) {
      if (!network || !poolAddress) {
        throw new Error("Missing required parameters: network, poolAddress");
      }
    
      const result = await this.coinGeckoApi.getPoolTrades(
        network,
        poolAddress,
        options
      );
    
      return {
        message: `Pool trades for ${poolAddress} on ${network} retrieved successfully`,
        data: result,
        summary: `Found ${result.data?.length || 0} trades for pool`,
        minVolumeFilter: options.trade_volume_in_usd_greater_than || "none",
      };
    }
  • Input schema definition for the get_pool_trades tool, including parameters and validation rules.
    name: TOOL_NAMES.GET_POOL_TRADES,
    description: "Get recent trades for a specific pool",
    inputSchema: {
      type: "object",
      properties: {
        network: {
          type: "string",
          description: "Network ID (e.g., 'eth', 'bsc', 'polygon_pos')",
        },
        poolAddress: {
          type: "string",
          description: "Pool contract address",
        },
        trade_volume_in_usd_greater_than: {
          type: "number",
          description:
            "Filter trades with volume greater than this USD amount (optional)",
        },
      },
      required: ["network", "poolAddress"],
    },
  • src/index.js:1127-1136 (registration)
    Registration and dispatch logic in the main switch case that routes tool calls to the handler.
    case TOOL_NAMES.GET_POOL_TRADES:
      result = await toolService.getPoolTrades(
        args.network,
        args.poolAddress,
        {
          trade_volume_in_usd_greater_than:
            args.trade_volume_in_usd_greater_than,
        }
      );
      break;
  • 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}`);
      }
    }

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/edkdev/defi-trading-mcp'

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