get_tpsl
Retrieve take-profit and stop-loss order history from Hyperliquid with trigger prices, user addresses, and triggered status. Requires Pro+ tier access.
Instructions
Get Hyperliquid TP/SL order history (Pro+ tier). Returns take-profit and stop-loss orders with trigger prices, user addresses, and triggered status.
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...') | |
| triggered | No | Filter TP/SL orders by triggered status |
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:1055-1066 (registration)Registration of the 'get_tpsl' tool using registerHistoryTool pattern. It delegates to api().hyperliquid.orders.tpsl(coin, params) for the actual SDK call.
registerHistoryTool( "get_tpsl", "Get Hyperliquid TP/SL order history (Pro+ tier). Returns take-profit and stop-loss orders with trigger prices, user addresses, and triggered status.", (coin, params) => api().hyperliquid.orders.tpsl(coin, params as any), CoinParam, normalizeHLCoin, { user: UserParam, triggered: TriggeredParam, } ); - src/index.ts:1056-1057 (handler)The actual handler logic: calls api().hyperliquid.orders.tpsl(coin, params as any) which is the SDK method that retrieves TP/SL order history.
"get_tpsl", "Get Hyperliquid TP/SL order history (Pro+ tier). Returns take-profit and stop-loss orders with trigger prices, user addresses, and triggered status.", - src/index.ts:1058-1065 (schema)Input schema for 'get_tpsl': uses CoinParam (string), HistoryParams (start/end/limit/cursor), plus optional 'user' (UserParam) and 'triggered' (TriggeredParam) filters.
(coin, params) => api().hyperliquid.orders.tpsl(coin, params as any), CoinParam, normalizeHLCoin, { user: UserParam, triggered: TriggeredParam, } - src/index.ts:1004-1009 (helper)Definition of OrderTypeParam which lists 'tpsl' as a valid order type, and TriggeredParam used by the get_tpsl tool for filtering by triggered status.
.describe("Filter orders by type"); const TriggeredParam = z .boolean() .optional() .describe("Filter TP/SL orders by triggered status"); - src/index.ts:408-438 (helper)The registerHistoryTool helper function that defines the registration pattern used by 'get_tpsl'. It wraps the SDK call with cursor pagination, time range resolution, and output formatting.
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); }); }