get_l4_diffs
Retrieve Hyperliquid L4 orderbook diffs showing raw order-level changes (new orders, modifications, cancellations, fills) for a market over a specified time range.
Instructions
Get Hyperliquid L4 orderbook diffs (Pro+ tier). Returns raw order-level changes (new orders, modifications, cancellations, fills) over a time range.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coin | Yes | Coin/market symbol, e.g. 'BTC', 'ETH', 'SOL' | |
| 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:1091-1098 (registration)Registration of 'get_l4_diffs' tool via registerHistoryTool helper. Delegates to the SDK's api().hyperliquid.l4Orderbook.diffs() function.
registerHistoryTool( "get_l4_diffs", "Get Hyperliquid L4 orderbook diffs (Pro+ tier). Returns raw order-level changes (new orders, modifications, cancellations, fills) over a time range.", (coin, params) => api().hyperliquid.l4Orderbook.diffs(coin, params as any), CoinParam, normalizeHLCoin ); - src/index.ts:53-56 (schema)Input schema for the 'coin' parameter, used by get_l4_diffs. Validates coin/market symbol (e.g. 'BTC', 'ETH').
const CoinParam = z .string() .describe("Coin/market symbol, e.g. 'BTC', 'ETH', 'SOL'"); - src/index.ts:83-97 (schema)TimestampParam: optional union of number or string for timestamps (Unix ms or ISO 8601).
const TimestampParam = z .union([z.number(), z.string()]) .optional() .describe("Timestamp as Unix milliseconds or ISO 8601 string"); const LimitParam = z .number() .optional() .describe("Max records to return (default 100, max 1000)"); const CursorParam = z .string() .optional() .describe("Pagination cursor from previous response's nextCursor"); - src/index.ts:88-92 (schema)LimitParam and CursorParam schemas used for pagination in get_l4_diffs history query.
const LimitParam = z .number() .optional() .describe("Max records to return (default 100, max 1000)"); - src/index.ts:408-438 (helper)registerHistoryTool helper that sets up the handler for get_l4_diffs. Handles coin normalization, time range resolution, limit/cursor pagination, and SDK call delegation.
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); }); }