diff --git a/core/src/exchanges/hyperliquid/fetcher.ts b/core/src/exchanges/hyperliquid/fetcher.ts index dc0bb47f..1cc11621 100644 --- a/core/src/exchanges/hyperliquid/fetcher.ts +++ b/core/src/exchanges/hyperliquid/fetcher.ts @@ -1,7 +1,7 @@ import { MarketFilterParams, EventFetchParams, OHLCVParams, TradesParams } from '../../BaseExchange'; import { IExchangeFetcher, FetcherContext } from '../interfaces'; import { hyperliquidErrorMapper } from './errors'; -import { toCoinNotation, fromMarketId } from './utils'; +import { toCoinNotation, toMidKey, fromMarketId } from './utils'; // ---------------------------------------------------------------------------- // Raw venue-native types (Hyperliquid HIP-4 Outcome Markets) @@ -305,7 +305,7 @@ export class HyperliquidFetcher implements IExchangeFetcher o.outcome === outcomeId); if (!outcome) continue; - const yesCoin = toCoinNotation(outcomeId, 'yes'); - const midPrice = mids[yesCoin]; + const midKey = toMidKey(outcomeId); + const midPrice = mids[midKey]; const market = this.normalizeMarket({ outcome, diff --git a/core/src/exchanges/hyperliquid/utils.ts b/core/src/exchanges/hyperliquid/utils.ts index 1a1fb957..4675e4d0 100644 --- a/core/src/exchanges/hyperliquid/utils.ts +++ b/core/src/exchanges/hyperliquid/utils.ts @@ -51,6 +51,17 @@ export function fromCoinEncoding(encoding: number): { outcomeId: number; side: ' }; } +/** + * Convert an outcome ID to the allMids lookup key. + * + * The allMids endpoint keys prediction-market outcomes as "@{outcomeId}" + * (e.g. "@8"), which is distinct from the "#encoding" coin notation used + * for orders and positions. + */ +export function toMidKey(outcomeId: number): string { + return `@${outcomeId}`; +} + /** * Build a unique market ID string from an outcome. * We use "hl-outcome-{outcomeId}" as the market ID.