get_hip4_tpsl
Retrieve take-profit and stop-loss order history for a HIP-4 outcome market coin, including trigger prices and triggered status.
Instructions
Get HIP-4 TP/SL order history (Pro+ tier) for a coin (e.g. '0'). Bare numeric coins are canonical; legacy '#0' / '%230' forms are also accepted.Returns take-profit and stop-loss orders with trigger prices and triggered status.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coin | Yes | HIP-4 outcome-market coin symbol. Canonical form is the bare numeric '<10*outcome_id + side>' (e.g. '0' for outcome 0 Yes, '1' for outcome 0 No, '10' for outcome 1 Yes). The legacy '#0' and '%230' forms are also accepted. Use get_hip4_instruments to list all. | |
| 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:1828-1850 (registration)Registration of the 'get_hip4_tpsl' tool via registerTool (which calls server.registerTool under the hood). Defines input schema (coin, history params, user, triggered) and the inline async handler.
// HIP-4 TP/SL registerTool( "get_hip4_tpsl", "Get HIP-4 TP/SL order history (Pro+ tier) for a coin (e.g. '0'). Bare numeric coins are canonical; legacy '#0' / '%230' forms are also accepted.Returns take-profit and stop-loss orders with trigger prices and triggered status.", { coin: Hip4CoinParam, ...HistoryParams, user: UserParam, triggered: TriggeredParam, }, ListOutputSchema, async (params) => { const q = buildHistoryQuery(params.start, params.end, params.limit, params.cursor, { user: params.user, triggered: params.triggered, }); const result = await hip4Request( `/orders/${normalizeHip4Coin(params.coin)}/tpsl`, q ); return formatCursorResponse(result); } ); - src/index.ts:1839-1849 (handler)The inline handler function for get_hip4_tpsl. Builds a query object from params, calls hip4Request to GET /v1/hyperliquid/hip4/orders/<coin>/tpsl, and formats the cursor-paginated response.
async (params) => { const q = buildHistoryQuery(params.start, params.end, params.limit, params.cursor, { user: params.user, triggered: params.triggered, }); const result = await hip4Request( `/orders/${normalizeHip4Coin(params.coin)}/tpsl`, q ); return formatCursorResponse(result); } - src/index.ts:1539-1559 (helper)Helper function used by get_hip4_tpsl to build a query object with start/end timestamps, limit, cursor, and any extra params (user, triggered).
function buildHistoryQuery( start?: number | string, end?: number | string, limit?: number, cursor?: string, extra?: Record<string, unknown> ): Record<string, unknown> { const range = resolveTimeRange(start, end); const q: Record<string, unknown> = { start: range.start, end: range.end, limit: resolveLimit(limit), }; if (cursor) q.cursor = cursor; if (extra) { for (const [k, v] of Object.entries(extra)) { if (v !== undefined) q[k] = v; } } return q; } - src/index.ts:1487-1537 (helper)Generic REST helper used by get_hip4_tpsl (and all HIP-4 tools) to make authenticated GET requests to the 0xArchive API with query parameters, error handling, and cursor extraction.
async function hip4Request( path: string, query?: Record<string, unknown> ): Promise<{ data: unknown; nextCursor?: string }> { const url = new URL(`${HIP4_BASE_PATH}${path}`, HIP4_BASE_URL); if (query) { for (const [k, v] of Object.entries(query)) { if (v === undefined || v === null) continue; url.searchParams.set(k, String(v)); } } const headers: Record<string, string> = { "Content-Type": "application/json", "User-Agent": "0xarchive-mcp/1.9.0", }; if (apiKey) headers["X-API-Key"] = apiKey; const controller = new AbortController(); const timeout = setTimeout(() => controller.abort(), 60000); try { const response = await fetch(url.toString(), { method: "GET", headers, signal: controller.signal, }); const text = await response.text(); let body: any; try { body = text ? JSON.parse(text) : null; } catch { body = text; } if (!response.ok) { const requestId = response.headers.get("x-request-id") || body?.meta?.requestId; const message = (body && (body.error?.message || body.error || body.message)) || `HTTP ${response.status}`; throw new OxArchiveError(message, response.status, requestId ?? undefined); } if (body && typeof body === "object" && "data" in body) { return { data: body.data, nextCursor: body.meta?.nextCursor, }; } return { data: body }; } finally { clearTimeout(timeout); } } - src/index.ts:63-67 (schema)Input schema for the 'coin' parameter used by get_hip4_tpsl — validates HIP-4 coin symbols.
const Hip4CoinParam = z .string() .describe( "HIP-4 outcome-market coin symbol. Canonical form is the bare numeric '<10*outcome_id + side>' (e.g. '0' for outcome 0 Yes, '1' for outcome 0 No, '10' for outcome 1 Yes). The legacy '#0' and '%230' forms are also accepted. Use get_hip4_instruments to list all." ); - src/index.ts:129-136 (schema)Output schema used by get_hip4_tpsl — defines the list response shape with records, count, and optional nextCursor.
const ListOutputSchema: ZodRawShape = { records: z.array(z.record(z.unknown())).describe("Array of result records"), count: z.number().describe("Total number of records in the full result set"), nextCursor: z .string() .optional() .describe("Cursor for next page, if more results available"), };