import type { ClientConfig } from "../config.js"; import type { PriceStore } from "./priceStore.js"; import type { PriceFeedStatus } from "./types.js"; /** * A live price watch. `stop()` releases it (idempotent); the underlying * subscription is shared and torn down when the last handle stops. * * @category price feeds */ export interface PriceWatchHandle { /** * Release this handle's reference on the asset's watch (idempotent — extra calls * are no-ops). Handles on the same asset share one subscription; stopping the * LAST one tears the asset down after a short linger (which absorbs * unmount/remount without re-snapshotting): the socket closes, the asset's rows * are purged, and live price reads for it return null/empty again. */ stop(): void; } /** What a PriceFeed runs against — its own config + price store, per client. */ export interface PriceFeedDeps { getConfig: () => ClientConfig; store: PriceStore; } export declare class PriceFeed { private readonly deps; private readonly refs; private readonly tails; private readonly hydrations; private readonly lingers; constructor(deps: PriceFeedDeps); /** * Watch one asset's price: hydrate a snapshot and stream live updates. Resolves * once the snapshot has landed (reads are populated); the socket connecting (or * dropping later) is handled transparently. Rejects + releases the ref on a * failed snapshot or an unconfigured asset. */ watchPrice(asset: string): Promise; /** Per-asset watch state (see {@link PriceFeedStatus}). */ getStatus(asset: string): PriceFeedStatus; /** * Tear down every price watch, subscription, and timer. The store keeps its * last state (reads keep answering, stale). */ stopAll(): void; private hydrate; private subscribe; private onConnStatus; private acquire; private release; private releaseNow; private teardown; private handle; private linger; private cancelLinger; private ensureHydration; private keyOf; }