get_lighter_orderbook
Get the current Lighter.xyz orderbook snapshot for a coin. Returns bids, asks, mid price, and spread. Optionally specify depth.
Instructions
Get the current Lighter.xyz orderbook snapshot for a coin. Returns bids, asks, mid price, and spread. Optionally specify depth. Requires Pro tier for full depth.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coin | Yes | Lighter.xyz coin symbol, e.g. 'BTC', 'ETH' | |
| depth | No | Orderbook depth — number of price levels per side |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | Result data object |
Implementation Reference
- src/index.ts:791-798 (registration)Registration of the 'get_lighter_orderbook' tool via the registerOrderbookTool helper pattern. It passes LighterCoinParam as the input schema and delegates to api().lighter.orderbook.get().
// 24. Lighter Orderbook registerOrderbookTool( "get_lighter_orderbook", "Get the current Lighter.xyz orderbook snapshot for a coin. Returns bids, asks, mid price, and spread. Optionally specify depth. Requires Pro tier for full depth.", (coin, params) => api().lighter.orderbook.get(coin, params), LighterCoinParam, normalizeLighterCoin ); - src/index.ts:387-405 (handler)Generic orderbook tool handler. This is the actual function that executes when 'get_lighter_orderbook' is called: it normalizes the coin (via normalizeLighterCoin), optionally passes depth param, calls the SDK, and formats the response.
function registerOrderbookTool( name: string, description: string, sdkCall: (coin: string, params?: { depth?: number }) => Promise<unknown>, coinSchema: z.ZodString, normFn: (coin: string) => string ): void { registerTool( name, description, { coin: coinSchema, depth: DepthParam }, ObjectOutputSchema, async (params) => { const sdkParams = params.depth ? { depth: params.depth } : undefined; const data = await sdkCall(normFn(params.coin), sdkParams); return formatResponse(data); } ); } - src/index.ts:73-75 (schema)Input schema (Zod param) for the Lighter coin parameter used by get_lighter_orderbook.
const LighterCoinParam = z .string() .describe("Lighter.xyz coin symbol, e.g. 'BTC', 'ETH'"); - src/index.ts:316-322 (helper)Normalization helper that uppercases the Lighter coin symbol before passing it to the SDK.
function normalizeLighterCoin(coin: string): string { return coin.toUpperCase(); } function normalizeSpotCoin(coin: string): string { return coin.toUpperCase(); } - src/index.ts:387-405 (helper)Helper function that defines the pattern for registering orderbook tools. It sets up input schema (coin + depth), output schema (ObjectOutputSchema), and the handler logic.
function registerOrderbookTool( name: string, description: string, sdkCall: (coin: string, params?: { depth?: number }) => Promise<unknown>, coinSchema: z.ZodString, normFn: (coin: string) => string ): void { registerTool( name, description, { coin: coinSchema, depth: DepthParam }, ObjectOutputSchema, async (params) => { const sdkParams = params.depth ? { depth: params.depth } : undefined; const data = await sdkCall(normFn(params.coin), sdkParams); return formatResponse(data); } ); }