diff --git a/core/src/exchanges/hyperliquid/fetcher.ts b/core/src/exchanges/hyperliquid/fetcher.ts index a53aab7a..036952b2 100644 --- a/core/src/exchanges/hyperliquid/fetcher.ts +++ b/core/src/exchanges/hyperliquid/fetcher.ts @@ -226,6 +226,22 @@ export class HyperliquidFetcher implements IExchangeFetcher r.outcome.outcome === targetOutcomeId); + } catch { + results = []; + } + } + + // Filter by parent eventId (HL question number) + if ((params as any)?.eventId !== undefined && (params as any).eventId !== null) { + const targetEventId = String((params as any).eventId); + results = results.filter(r => r.question && String(r.question.question) === targetEventId); + } + // Limit const limit = params?.limit || 250000; const offset = params?.offset || 0; @@ -239,6 +255,12 @@ export class HyperliquidFetcher implements IExchangeFetcher String(q.question) === targetEventId); + } + // Filter by query if (params?.query) { const lowerQuery = params.query.toLowerCase(); @@ -278,18 +300,22 @@ export class HyperliquidFetcher implements IExchangeFetcher({ + const raw = await this.postInfo({ type: 'candleSnapshot', req: { coin, interval: params.resolution || '1h', startTime, endTime }, }); + // ponytail: HL returns the full window; honor caller's limit by trimming to the most recent N + return params.limit && raw.length > params.limit ? raw.slice(-params.limit) : raw; } // -- Trades ---------------------------------------------------------------- - async fetchRawTrades(marketId: string, _params: TradesParams): Promise { + async fetchRawTrades(marketId: string, params: TradesParams): Promise { const outcomeId = fromMarketId(marketId); const coin = toCoinNotation(outcomeId, 'yes'); - return this.postInfo({ type: 'recentTrades', coin }); + const raw = await this.postInfo({ type: 'recentTrades', coin }); + // ponytail: HL recentTrades returns a fixed page; honor caller's limit (most recent N) + return params?.limit && raw.length > params.limit ? raw.slice(0, params.limit) : raw; } // -- User data -------------------------------------------------------------