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
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | Number of days of data to return (default: 7) | |
| poolId | Yes | Pool address |
Input Schema (JSON Schema)
{
"properties": {
"days": {
"description": "Number of days of data to return (default: 7)",
"type": "number"
},
"poolId": {
"description": "Pool address",
"type": "string"
}
},
"required": [
"poolId"
],
"type": "object"
}
Implementation Reference
- src/index.ts:851-867 (handler)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), }, ], }; }
- src/index.ts:281-297 (schema)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'], },
- src/subgraph.ts:341-353 (helper)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; } }
- src/subgraph.ts:146-184 (helper)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 } } `;