Skip to content

Spec drift: hyperliquid — toMidKey() uses @N key format but live API uses #(10*N) for HIP-4 outcomes; all mid-price lookups silently return undefined #887

@realfishsam

Description

@realfishsam

Exchange

hyperliquid

Drift Type

changed_response

Severity

CRITICAL — all HIP-4 prediction market mid-price lookups silently return undefined

Their Docs

The allMids endpoint (POST /info { type: "allMids" }) returns a map keyed by asset identifier. For HIP-4 prediction market outcomes the key format is #N where N = 10 * outcomeId + sideIndex (e.g., #80 for outcome 8 Yes side, #81 for No side). The # prefix identifies outcome markets; @ prefix identifies spot pairs.

Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api (allMids section + QuickNode Hyperliquid API guide)

Our Cached Spec

core/src/exchanges/hyperliquid/utils.tstoMidKey() function returns `@${outcomeId}` (e.g., @8). This is the spot pair format. The function is called in the normalizer to look up mid prices from the allMids response.

File: core/src/exchanges/hyperliquid/utils.ts (toMidKey helper)

callApi() References at Risk

None (Hyperliquid uses direct POST calls, not callApi)

Hardcoded URL Bypasses

All info calls go to POST ${baseUrl}/info at fetcher.ts:163

Impact

fetchMarkets() and fetchEvents() look up mid prices by calling allMids[toMidKey(outcomeId)]. Because toMidKey returns @8 but the response contains keys like #80, every lookup returns undefined. All markets show undefined / NaN mid-prices instead of real values.

Fix: toMidKey should return `#${outcomeId * 10}` for the Yes side mid.


Found by automated spec drift audit

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions