import { type PerpsSDKClient, type ProviderGetQuoteParams, type QuoteListener, type SubscriptionListener, WsProviderBase, type WsProviderFactory, type WsStatusListener } from '@lifi/perps-sdk'; import type { Subscription } from '@lifi/perps-types'; /** * `WsProviderFactory` constructor for Hyperliquid — pass to * `new PerpsWsClient(client, { wsProviders: { hyperliquid: hyperliquidWsProvider() } })`. * * Higher-order shape mirrors `lighterWsProvider(options)` so the two factories * register identically. * * @public */ export declare const hyperliquidWsProvider: () => WsProviderFactory; /** * Hyperliquid WebSocket {@link WsProvider}: multiplexes markets context, * positions, orders, fills and spot balances over a single * {@link ReconnectingWebSocket}. * Construct via {@link hyperliquidWsProvider}. * * `orderUpdates` supports a single address per provider instance: HL delivers * those frames without a user field, so frames from two concurrent address * subscriptions on one socket cannot be attributed. Subscribing a second * address rejects while the first still has listeners; once the first is * released, an address switch reclaims the channel immediately. * * @public */ export declare class HyperliquidWsProvider extends WsProviderBase { private orderUpdatesKey; private orderUpdatesEpoch; private readonly orderApiUrl; private readonly clearinghouseRefs; private readonly client; private readonly registry; private readonly abstractionByUser; private readonly spotRefs; private readonly unifiedSummaryByUser; private readonly latestPositionsByUser; private readonly heldSummaryByUser; private perpCtxBySubDex; private spotCtxByMarketId; private marketsContextByMarketId; private orderbookKeysByMarketId; private latestOrderbookByMarketId; private fastCtxByMarketId; private readonly reportDecodeFailure; private readonly fastDecodeChain; private readonly pacDecodeChain; private readonly sacDecodeChain; private readonly orderbookDecodeChain; private readonly orderUpdateChain; constructor(wsUrl: string, providerKey: string, client?: PerpsSDKClient); subscribe(sub: Subscription, listener: SubscriptionListener, onStatus?: WsStatusListener): Promise<() => void>; subscribeQuote(params: ProviderGetQuoteParams, onQuote: QuoteListener): Promise<() => void>; protected openChannel(sub: Subscription): Promise<() => void>; /** * Enforce the single-address `orderUpdates` invariant (HL frames carry no * user field, so concurrent address subscriptions are unattributable). A * listener-free lingering channel for another address is torn down eagerly * so a wallet switch needn't wait out the teardown linger; a live one throws. */ private claimOrderUpdatesKey; private claimOrderbookKey; /** * Sub-key + payload pairs for the markets-context aggregation: compressed * all-perp (`pac`) and all-spot (`sac`) asset contexts plus the documented * `fastAssetCtxs` feed (high-frequency mid + mark across every dex). */ private getMarketsContextSubEntries; private registerOrderbook; private releaseOrderbook; protected onClose(): void; protected sendSubscribe(payload: object): void; protected toKey(sub: Subscription): string; private orderbookAggregation; private orderbookAggregationKey; private toHlPayload; protected handleMessage(raw: string): void; private handleAllDexsAssetCtxs; private handlePac; /** Merge perp asset contexts in place; returns the marketIds this frame touched. */ private mergePerpAssetCtxEntries; private handleSac; private spotMarketIdBySacKey; /** * Decode a `fastAssetCtxs` frame (base64 + raw-DEFLATE) and merge its changed * coins into the per-market fast-context store. Frames are incremental, so a * field absent from this frame keeps its prior value. Decodes are chained to * preserve arrival order across the async boundary; a backlog coalesces to * its newest frame (see the chain's mode). */ private handleFastAssetCtxs; /** * Emit the all-markets context map, re-mapping only the markets the incoming * frame touched. Each emission is a fresh snapshot object that carries * untouched entries over by reference, so a listener holding an earlier * snapshot never observes later-frame mutation. */ private emitMarketsContext; /** * Context for one market from the cached feeds: spot asset context when it * maps, else perp asset context with mid + mark overlaid from * `fastAssetCtxs`, else the fast feed alone — each price standing in for the * other where it carries only one of mid/mark. An attached registry gates the * market id: an id it does not list, or lists as delisted, yields no context. */ private computeMarketContext; private handleActiveAssetCtx; private handleActiveSpotAssetCtx; /** Latest mid per `Market.id` across asset-context and fast feeds. */ private mergedMids; private orderbookReferencePrice; private handleL2Book; private handleL2; private handleCompactL2Delta; private emitOrderbook; private handleCandle; private handleTrades; private handleOrderUpdates; private handleUserFills; private handleAllDexsClearinghouseState; /** Whether the mode's collateral lives per-dex, making the perps-only * summary frame honest. Unified/portfolio hold collateral in spot. */ private static summaryComputableFor; private acquireSpotWire; /** Start or stop the spot-fed unified pipeline to match the resolved mode. */ private syncUnifiedPipeline; private emitUnifiedSummary; /** Re-read the abstraction mode this long after the previous read, so an * in-session account-mode switch flips the gate within one refresh. */ private static readonly ABSTRACTION_TTL_MS; /** Subscribe-triggered re-reads younger than this are skipped: a config * change resubscribes every consumer hook in one React commit, and one * read serves them all. */ private static readonly REFRESH_COALESCE_MS; private emitSummaryIfModeAllows; private fetchAbstractionMode; private handleSpotState; } //# sourceMappingURL=HyperliquidWsProvider.d.ts.map