get_lighter_trades
Retrieve trade history for a specific coin on Lighter.xyz. Get price, size, side, and timestamps with cursor-based pagination.
Instructions
Get Lighter.xyz trade history for a coin over a time range. Returns price, size, side, and timestamps. Supports cursor pagination.
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 |
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:817-825 (registration)Registration of the 'get_lighter_trades' tool using the registerHistoryTool helper. It passes the LighterCoinParam schema and normalizeLighterCoin normalizer to set up a history tool that calls api().lighter.trades.list(coin, params).
// 25. Lighter Trades registerHistoryTool( "get_lighter_trades", "Get Lighter.xyz trade history for a coin over a time range. Returns price, size, side, and timestamps. Supports cursor pagination.", (coin, params) => api().lighter.trades.list(coin, params as any), LighterCoinParam, normalizeLighterCoin ); - src/index.ts:73-75 (schema)LighterCoinParam — the Zod schema for the 'coin' input parameter, describing a Lighter.xyz coin symbol like 'BTC' or 'ETH'.
const LighterCoinParam = z .string() .describe("Lighter.xyz coin symbol, e.g. 'BTC', 'ETH'"); - src/index.ts:316-318 (helper)normalizeLighterCoin — a normalization helper that uppercases the coin symbol before passing it to the SDK.
function normalizeLighterCoin(coin: string): string { return coin.toUpperCase(); } - src/index.ts:407-438 (handler)registerHistoryTool — the generic handler factory used by get_lighter_trades. It resolves time range, limit, and cursor parameters, passes them to the SDK call, and formats the cursor-paginated response.
// 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); }); }