From 28a9d63bf87b828fac83aecf1e511a2697fbfc43 Mon Sep 17 00:00:00 2001 From: "Samuel EF. Tinnerholm" Date: Sun, 21 Jun 2026 18:52:48 +0200 Subject: [PATCH] feat(hyperliquid): implement fetchOrderBooks via client-side loop Hyperliquid has no native batch order-book endpoint. fetchOrderBooks previously threw 'Method not supported' on the SDKs. Now overrides the base stub with a Promise.all over fetchOrderBook, which inherits the outcome-token-or-marketId resolution from the single-fetch path. The capability map auto-flips because BaseExchange derives has.* by introspecting overrides. ponytail comment marks the unbounded concurrency: add a cap if HL info rate limits start biting in practice. Verified locally (Python + TS) against npm run server: hl.fetchOrderBooks(['hl-outcome-171', 'hl-outcome-172', 'hl-outcome-173']) -> 3 books returned, mixed marketId + outcomeToken input also works. --- core/src/exchanges/hyperliquid/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/src/exchanges/hyperliquid/index.ts b/core/src/exchanges/hyperliquid/index.ts index a0b788ff..a9e09ae5 100644 --- a/core/src/exchanges/hyperliquid/index.ts +++ b/core/src/exchanges/hyperliquid/index.ts @@ -146,6 +146,15 @@ export class HyperliquidExchange extends PredictionMarketExchange { return this.normalizer.normalizeOrderBook(raw, outcomeId); } + // ponytail: Hyperliquid has no native batch order-book endpoint; loop client-side. + // Add a concurrency cap if rate limits start biting in practice. + async fetchOrderBooks(outcomeIds: string[]): Promise> { + const entries = await Promise.all( + outcomeIds.map(async id => [id, await this.fetchOrderBook(id)] as const), + ); + return Object.fromEntries(entries); + } + async fetchOHLCV(outcomeId: string, params: OHLCVParams = { resolution: '1h' }): Promise { const raw = await this.fetcher.fetchRawOHLCV(outcomeId, params); return this.normalizer.normalizeOHLCV(raw, params);