import type { PolyNodeWS } from './ws.js'; import type { PolyNodeEvent, EventMap } from './types/events.js'; import type { ShortFormInterval, ShortFormCoin, ShortFormOptions, ShortFormMarket, RotationEvent } from './types/short-form.js'; type EventHandler = (event: T) => void; /** * Auto-rotating stream for Polymarket short-form crypto markets. * * Discovers current markets via Gamma API, subscribes via WebSocket, * and automatically rotates to the next window at expiry. * * Each market includes zero-cost enrichments (odds, liquidity, volume) * and the price-to-beat (Chainlink opening price, one HTTP call per rotation). * * @example * ```ts * const ws = new PolyNodeWS(key, 'wss://ws.polynode.dev/ws'); * const stream = ws.shortForm('15m', { coins: ['btc', 'eth'] }); * * stream.on('rotation', (r) => { * for (const m of r.markets) { * console.log(`${m.coin}: beat $${m.priceToBeat} | ${m.upOdds * 100}% up | ${r.timeRemaining}s left`); * } * }); * * stream.on('settlement', (e) => console.log(e)); * ``` */ export declare class ShortFormStream { readonly interval: ShortFormInterval; readonly coins: ShortFormCoin[]; private readonly _ws; private readonly _apiBase; private readonly _rotationBuffer; private readonly _handlers; private _sub; private _markets; private _rotationTimer; private _rotating; private _stopped; constructor(ws: PolyNodeWS, interval: ShortFormInterval, options?: ShortFormOptions); /** Register a handler for event types, 'rotation', or '*'. */ on(type: K, handler: EventHandler): this; on(type: 'rotation', handler: EventHandler): this; on(type: '*', handler: EventHandler): this; on(type: 'error', handler: EventHandler): this; /** Remove a handler. */ off(type: string, handler: EventHandler): this; /** Current discovered markets. */ get markets(): readonly ShortFormMarket[]; /** * Seconds remaining in the current window (computed client-side, zero cost). * Returns 0 if no markets are active. */ get timeRemaining(): number; /** Start discovery and subscription. Called automatically by ws.shortForm(). */ start(): Promise; /** Stop the stream. Unsubscribes and cancels rotation timer. */ stop(): void; private _rotate; private _scheduleRotation; private _computeWindowEnd; private _discoverMarkets; private _discoverCoin; private _buildDiscoveryUrl; /** Fetch the Chainlink opening price for this market's window. */ private _fetchPriceToBeat; private _parseGammaEvent; private _emit; } export {}; //# sourceMappingURL=short-form.d.ts.map