get_lighter_price_history
Retrieve historical mark, oracle, and mid prices for a Lighter.xyz coin over a specified time range with customizable aggregation intervals.
Instructions
Get mark/oracle price history for a Lighter.xyz coin over a time range. Returns mark_price, oracle_price, and mid_price at each timestamp. Supports aggregation intervals.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coin | Yes | Lighter.xyz coin symbol, e.g. 'BTC', 'ETH' | |
| start | No | Start timestamp (Unix ms or ISO). Defaults to 24h ago. | |
| end | No | End timestamp (Unix ms or ISO). Defaults to now. | |
| limit | No | Max records to return (default 100, max 1000) | |
| cursor | No | Pagination cursor from previous response's nextCursor | |
| interval | No | Aggregation interval: '5m', '15m', '30m', '1h', '4h', '1d'. Default '1h' |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| records | Yes | Array of result records | |
| count | Yes | Total number of records in the full result set | |
| nextCursor | No | Cursor for next page, if more results available |
Implementation Reference
- src/index.ts:913-922 (registration)Registration of the get_lighter_price_history tool via registerHistoryTool helper. The tool is described as 'Get mark/oracle price history for a Lighter.xyz coin over a time range. Returns mark_price, oracle_price, and mid_price at each timestamp. Supports aggregation intervals.' It delegates to api().lighter.priceHistory(coin, params) with LighterCoinParam schema and normalizeLighterCoin normalization. Extra schema allows an optional aggregation interval parameter (5m, 15m, 30m, 1h, 4h, 1d).
// Lighter Price History registerHistoryTool( "get_lighter_price_history", "Get mark/oracle price history for a Lighter.xyz coin over a time range. Returns mark_price, oracle_price, and mid_price at each timestamp. Supports aggregation intervals.", (coin, params) => api().lighter.priceHistory(coin, params as any), LighterCoinParam, normalizeLighterCoin, { interval: z.enum(["5m", "15m", "30m", "1h", "4h", "1d"]).optional().describe("Aggregation interval: '5m', '15m', '30m', '1h', '4h', '1d'. Default '1h'") } ); - src/index.ts:73-75 (schema)The LighterCoinParam Zod schema defines the input validation for the coin parameter used by get_lighter_price_history. It's a string describing a Lighter.xyz coin symbol (e.g., 'BTC', 'ETH').
const LighterCoinParam = z .string() .describe("Lighter.xyz coin symbol, e.g. 'BTC', 'ETH'"); - src/index.ts:316-318 (helper)The normalizeLighterCoin helper normalizes the coin symbol to uppercase before passing it to the SDK call.
function normalizeLighterCoin(coin: string): string { return coin.toUpperCase(); } - src/index.ts:407-438 (helper)The registerHistoryTool helper function (Pattern 4) that handles tool registration for get_lighter_price_history. It constructs the input schema (coin + HistoryParams + extraSchema), resolves time ranges, handles cursor pagination, passes extra params through, and calls the provided SDK function.
// Pattern 4: History with cursor pagination (coin + time range) function registerHistoryTool( name: string, description: string, sdkCall: (coin: string, params: Record<string, unknown>) => Promise<{ data: unknown; nextCursor?: string }>, coinSchema: z.ZodString, normFn: (coin: string) => string, extraSchema?: ZodRawShape ): void { const schema: ZodRawShape = { coin: coinSchema, ...HistoryParams }; if (extraSchema) Object.assign(schema, extraSchema); registerTool(name, description, schema, ListOutputSchema, async (params) => { const { coin, start, end, limit, cursor, ...extra } = params; const timeRange = resolveTimeRange(start, end); const sdkParams: Record<string, unknown> = { ...timeRange, limit: resolveLimit(limit), }; if (cursor) sdkParams.cursor = cursor; // Pass through extra params (interval, side, etc.) for (const [k, v] of Object.entries(extra)) { if (v !== undefined) sdkParams[k] = v; } const result = await sdkCall(normFn(coin), sdkParams); return formatCursorResponse(result); }); }