get_pool_ohlcv
Retrieve OHLCV (Open, High, Low, Close, Volume) data for DeFi pools across multiple blockchains to analyze historical price trends and trading volumes for informed decision-making in crypto trading strategies.
Instructions
Get OHLCV (Open, High, Low, Close, Volume) data for a pool
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| aggregate | No | Aggregate interval (optional, default: '1') | |
| before_timestamp | No | Get data before this timestamp (optional) | |
| currency | No | Currency for price data: 'usd', 'token' (optional, default: 'usd') | |
| include_empty_intervals | No | Include empty intervals (optional, default: false) | |
| limit | No | Limit number of results (optional, max: 1000) | |
| network | Yes | Network ID (e.g., 'eth', 'bsc', 'polygon_pos') | |
| poolAddress | Yes | Pool contract address | |
| timeframe | Yes | Timeframe for OHLCV data: 'day', 'hour', 'minute' | |
| token | No | Token for price data: 'base', 'quote' (optional, default: 'base') |
Input Schema (JSON Schema)
{
"properties": {
"aggregate": {
"description": "Aggregate interval (optional, default: '1')",
"type": "string"
},
"before_timestamp": {
"description": "Get data before this timestamp (optional)",
"type": "integer"
},
"currency": {
"description": "Currency for price data: 'usd', 'token' (optional, default: 'usd')",
"enum": [
"usd",
"token"
],
"type": "string"
},
"include_empty_intervals": {
"description": "Include empty intervals (optional, default: false)",
"type": "boolean"
},
"limit": {
"description": "Limit number of results (optional, max: 1000)",
"type": "integer"
},
"network": {
"description": "Network ID (e.g., 'eth', 'bsc', 'polygon_pos')",
"type": "string"
},
"poolAddress": {
"description": "Pool contract address",
"type": "string"
},
"timeframe": {
"description": "Timeframe for OHLCV data: 'day', 'hour', 'minute'",
"enum": [
"day",
"hour",
"minute"
],
"type": "string"
},
"token": {
"description": "Token for price data: 'base', 'quote' (optional, default: 'base')",
"enum": [
"base",
"quote"
],
"type": "string"
}
},
"required": [
"network",
"poolAddress",
"timeframe"
],
"type": "object"
}
Implementation Reference
- Core implementation of getPoolOHLCV: constructs CoinGecko API URL for pool OHLCV data and fetches the response.async getPoolOHLCV(network, poolAddress, timeframe, options = {}) { try { const queryParams = new URLSearchParams(); if (options.aggregate) queryParams.append('aggregate', options.aggregate); if (options.before_timestamp) queryParams.append('before_timestamp', options.before_timestamp); if (options.limit) queryParams.append('limit', options.limit); if (options.currency) queryParams.append('currency', options.currency); if (options.token) queryParams.append('token', options.token); if (options.include_empty_intervals) queryParams.append('include_empty_intervals', options.include_empty_intervals); const url = `${this.baseUrl}/networks/${network}/pools/${poolAddress}/ohlcv/${timeframe}${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 OHLCV: ${error.message}`); } }
- src/toolService.js:370-393 (handler)ToolService wrapper for getPoolOHLCV: validates inputs, delegates to CoinGeckoApiService, formats response.async getPoolOHLCV(network, poolAddress, timeframe, options = {}) { if (!network || !poolAddress || !timeframe) { throw new Error( "Missing required parameters: network, poolAddress, timeframe" ); } const result = await this.coinGeckoApi.getPoolOHLCV( network, poolAddress, timeframe, options ); return { message: `OHLCV data for pool ${poolAddress} retrieved successfully`, data: result, summary: `Retrieved ${timeframe} OHLCV data for pool on ${network}`, timeframe: timeframe, aggregate: options.aggregate || "1", currency: options.currency || "usd", token: options.token || "base", }; }
- src/index.js:559-608 (schema)Input schema definition for the get_pool_ohlcv tool, including parameters, types, descriptions, and requirements.name: TOOL_NAMES.GET_POOL_OHLCV, description: "Get OHLCV (Open, High, Low, Close, Volume) data for a pool", inputSchema: { type: "object", properties: { network: { type: "string", description: "Network ID (e.g., 'eth', 'bsc', 'polygon_pos')", }, poolAddress: { type: "string", description: "Pool contract address", }, timeframe: { type: "string", description: "Timeframe for OHLCV data: 'day', 'hour', 'minute'", enum: ["day", "hour", "minute"], }, aggregate: { type: "string", description: "Aggregate interval (optional, default: '1')", }, before_timestamp: { type: "integer", description: "Get data before this timestamp (optional)", }, limit: { type: "integer", description: "Limit number of results (optional, max: 1000)", }, currency: { type: "string", description: "Currency for price data: 'usd', 'token' (optional, default: 'usd')", enum: ["usd", "token"], }, token: { type: "string", description: "Token for price data: 'base', 'quote' (optional, default: 'base')", enum: ["base", "quote"], }, include_empty_intervals: { type: "boolean", description: "Include empty intervals (optional, default: false)", }, }, required: ["network", "poolAddress", "timeframe"], },
- src/index.js:1111-1125 (registration)MCP server switch case registration/dispatch: calls ToolService.getPoolOHLCV with parsed tool arguments.case TOOL_NAMES.GET_POOL_OHLCV: result = await toolService.getPoolOHLCV( args.network, args.poolAddress, args.timeframe, { aggregate: args.aggregate, before_timestamp: args.before_timestamp, limit: args.limit, currency: args.currency, token: args.token, include_empty_intervals: args.include_empty_intervals, } ); break;
- src/constants.js:35-35 (helper)Constant definition for the tool name used across the codebase.GET_POOL_OHLCV: "get_pool_ohlcv",