get_token_historical_data
Retrieve historical price and trading data for a specific token on SailFish DEX by specifying the token address and desired time range in days.
Instructions
Get historical data for a token on SailFish DEX
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | Number of days of data to return (default: 7) | |
| tokenId | Yes | Token address |
Input Schema (JSON Schema)
{
"properties": {
"days": {
"description": "Number of days of data to return (default: 7)",
"type": "number"
},
"tokenId": {
"description": "Token address",
"type": "string"
}
},
"required": [
"tokenId"
],
"type": "object"
}
Implementation Reference
- src/subgraph.ts:326-338 (handler)Core handler function that executes the GraphQL query to fetch historical daily data for the specified token from the SailFish subgraph.export async function getTokenDayData(tokenId: string, count: number = 7): Promise<TokenDayData[]> { try { const data = await request<TokenDayDataQueryResult>( SUBGRAPH_URL, TOKEN_DAY_DATA_QUERY, { tokenId: tokenId.toLowerCase(), count } ); return data.tokenDayDatas; } catch (error) { console.error('Error fetching token day data:', error); throw error; } }
- src/index.ts:833-849 (registration)MCP CallToolRequestSchema handler registration for 'get_token_historical_data': validates parameters, delegates to subgraph.getTokenDayData, formats and returns response.case 'get_token_historical_data': { if (!args.tokenId || typeof args.tokenId !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Token ID is required'); } const days = typeof args.days === 'number' ? args.days : 7; const data = await subgraph.getTokenDayData(args.tokenId, days); return { content: [ { type: 'text', text: JSON.stringify(data, null, 2), }, ], }; }
- src/index.ts:264-279 (schema)Input schema definition for the tool, used in ListToolsRequestSchema response.name: 'get_token_historical_data', description: 'Get historical data for a token on SailFish DEX', inputSchema: { type: 'object', properties: { tokenId: { type: 'string', description: 'Token address', }, days: { type: 'number', description: 'Number of days of data to return (default: 7)', }, }, required: ['tokenId'], },
- src/subgraph.ts:115-142 (helper)GraphQL query definition used by getTokenDayData to retrieve token historical day data.const TOKEN_DAY_DATA_QUERY = gql` query getTokenDayData($tokenId: String!, $count: Int!) { tokenDayDatas( first: $count orderBy: date orderDirection: desc where: { token: $tokenId } ) { id date token { id symbol name } volume volumeUSD untrackedVolumeUSD totalValueLocked totalValueLockedUSD priceUSD feesUSD open high low close } }