Skip to main content
Glama

get_pool_historical_data

Retrieve historical data for a liquidity pool on SailFish DEX by specifying the pool address and number of days, enabling detailed analysis of pool performance.

Instructions

Get historical data for a liquidity pool on SailFish DEX

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNoNumber of days of data to return (default: 7)
poolIdYesPool address

Implementation Reference

  • MCP tool handler for 'get_pool_historical_data': validates input parameters (poolId required, days optional default 7), fetches historical data via subgraph.getPoolDayData, and returns JSON stringified response.
    case 'get_pool_historical_data': {
      if (!args.poolId || typeof args.poolId !== 'string') {
        throw new McpError(ErrorCode.InvalidParams, 'Pool ID is required');
      }
      
      const days = typeof args.days === 'number' ? args.days : 7;
      const data = await subgraph.getPoolDayData(args.poolId, days);
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(data, null, 2),
          },
        ],
      };
    }
  • Tool schema definition including name, description, and input schema specifying poolId (required string) and days (optional number, default 7).
    {
      name: 'get_pool_historical_data',
      description: 'Get historical data for a liquidity pool on SailFish DEX',
      inputSchema: {
        type: 'object',
        properties: {
          poolId: {
            type: 'string',
            description: 'Pool address',
          },
          days: {
            type: 'number',
            description: 'Number of days of data to return (default: 7)',
          },
        },
        required: ['poolId'],
      },
  • src/index.ts:281-297 (registration)
    Registration of the tool in the ListToolsRequestSchema response, making it discoverable by MCP clients.
    {
      name: 'get_pool_historical_data',
      description: 'Get historical data for a liquidity pool on SailFish DEX',
      inputSchema: {
        type: 'object',
        properties: {
          poolId: {
            type: 'string',
            description: 'Pool address',
          },
          days: {
            type: 'number',
            description: 'Number of days of data to return (default: 7)',
          },
        },
        required: ['poolId'],
      },
  • Helper function that executes GraphQL query to fetch historical day data for a specific pool from the SailFish subgraph, returning array of PoolDayData.
    export async function getPoolDayData(poolId: string, count: number = 7): Promise<PoolDayData[]> {
      try {
        const data = await request<PoolDayDataQueryResult>(
          SUBGRAPH_URL,
          POOL_DAY_DATA_QUERY,
          { poolId: poolId.toLowerCase(), count }
        );
        return data.poolDayDatas;
      } catch (error) {
        console.error('Error fetching pool day data:', error);
        throw error;
      }
    }
  • GraphQL query definition for fetching historical pool day data, including pool details, liquidity, prices, volume, fees, and OHLC metrics.
    const POOL_DAY_DATA_QUERY = gql`
      query getPoolDayData($poolId: String!, $count: Int!) {
        poolDayDatas(
          first: $count
          orderBy: date
          orderDirection: desc
          where: { pool: $poolId }
        ) {
          id
          date
          pool {
            id
            token0 {
              id
              symbol
            }
            token1 {
              id
              symbol
            }
          }
          liquidity
          sqrtPrice
          token0Price
          token1Price
          tick
          tvlUSD
          volumeToken0
          volumeToken1
          volumeUSD
          feesUSD
          txCount
          open
          high
          low
          close
        }
      }
    `;

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/SailFish-Finance/educhain-ai-agent-kit'

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