get_hip4_freshness
Check how fresh HIP-4 market data is for a coin by viewing last update timestamps and lag for orderbook, trades, open interest, and L4 data types.
Instructions
Get HIP-4 data freshness for a coin (e.g. '0') across all available data types (orderbook, trades, OI, L4). Bare numeric coins are canonical; legacy '#0' / '%230' forms are also accepted.Shows when each data type was last updated and current lag.
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. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | Result data object |
Implementation Reference
- src/index.ts:1731-1741 (registration)Registration of the 'get_hip4_freshness' tool via registerTool(). Defines the tool name, description, input schema (coin: Hip4CoinParam), output schema (ObjectOutputSchema), and the handler function that calls the API endpoint /freshness/{coin}.
// HIP-4 Freshness registerTool( "get_hip4_freshness", "Get HIP-4 data freshness for a coin (e.g. '0') across all available data types (orderbook, trades, OI, L4). Bare numeric coins are canonical; legacy '#0' / '%230' forms are also accepted.Shows when each data type was last updated and current lag.", { coin: Hip4CoinParam }, ObjectOutputSchema, async (params) => { const result = await hip4Request(`/freshness/${normalizeHip4Coin(params.coin)}`); return formatResponse(result.data); } ); - src/index.ts:1737-1739 (handler)The handler function for get_hip4_freshness. Normalizes the HIP-4 coin symbol, makes a GET request to /v1/hyperliquid/hip4/freshness/{coin}, and formats the response.
async (params) => { const result = await hip4Request(`/freshness/${normalizeHip4Coin(params.coin)}`); return formatResponse(result.data); - src/index.ts:63-67 (schema)Hip4CoinParam schema — defines the input parameter 'coin' for HIP-4 tools. Accepts bare numeric IDs (e.g. '0'), legacy '#0', or '%230' forms.
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:1487-1537 (helper)hip4Request helper — makes authenticated GET requests to the HIP-4 REST API under /v1/hyperliquid/hip4. Handles query params, error parsing, and cursor extraction from responses.
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:307-314 (helper)normalizeHip4Coin helper — normalizes HIP-4 coin symbols from legacy forms (#0, %230) to bare numeric form for API requests.
function normalizeHip4Coin(coin: string): string { const trimmed = String(coin).trim(); if (/^\d+$/.test(trimmed)) return trimmed; const stripped = trimmed.replace(/^(#|%23)/i, ""); if (/^\d+$/.test(stripped)) return stripped; // Unknown shape — fall back to URL-encoding the original. return encodeURIComponent(trimmed); }