get_order_history
Retrieve Hyperliquid order history with user addresses. Filter by coin, status, type, time range, and wallet to track order lifecycle events.
Instructions
Get Hyperliquid order history with user attribution (Build+ tier). Returns order lifecycle events including placements, fills, cancellations, and modifications with user addresses.
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 | |
| user | No | User wallet address filter (e.g., '0x1234...') | |
| status | No | Filter orders by status | |
| order_type | No | Filter orders by type |
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:1011-1024 (registration)Registration of the 'get_order_history' tool using registerHistoryTool. It delegates to api().hyperliquid.orders.history() with CoinParam (normalized via normalizeHLCoin), plus optional user, status, and order_type filters.
// Hyperliquid Order History registerHistoryTool( "get_order_history", "Get Hyperliquid order history with user attribution (Build+ tier). Returns order lifecycle events including placements, fills, cancellations, and modifications with user addresses.", (coin, params) => api().hyperliquid.orders.history(coin, params as any), CoinParam, normalizeHLCoin, { user: UserParam, status: OrderStatusParam, order_type: OrderTypeParam, } ); - src/index.ts:991-1009 (schema)Input parameter schemas used by get_order_history: UserParam (optional wallet address), OrderStatusParam (open/filled/cancelled/expired), OrderTypeParam (limit/market/trigger/tpsl), and the TriggeredParam boolean filter.
const UserParam = z .string() .optional() .describe("User wallet address filter (e.g., '0x1234...')"); const OrderStatusParam = z .enum(["open", "filled", "cancelled", "expired"]) .optional() .describe("Filter orders by status"); const OrderTypeParam = z .enum(["limit", "market", "trigger", "tpsl"]) .optional() .describe("Filter orders by type"); const TriggeredParam = z .boolean() .optional() .describe("Filter TP/SL orders by triggered status"); - src/index.ts:407-438 (helper)registerHistoryTool — the registration helper that builds the handler for history-based tools. It resolves time range, limit, cursor, passes extra params (like user/status/order_type) and calls the SDK, then formats via formatCursorResponse.
// 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); }); } - src/index.ts:83-93 (helper)The HistoryParams shared schema object (start, end, limit, cursor) that gets spread into get_order_history's input schema.
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 - src/index.ts:282-290 (helper)formatCursorResponse helper used to format paginated results with nextCursor support.
function formatCursorResponse(result: { data: unknown; nextCursor?: string; }): McpContent { return formatResponse(result.data, { nextCursor: result.nextCursor, paginated: true, }); }