/** * Listen to real-time obligation changes via WebSocket. * Decodes + hydrates via {@link KaminoObligation.fromAccountData}. */ import { type Address, type Commitment, type Slot } from '@solana/kit'; import type { LedgerInstant } from '../utils/ledger'; import { type AccountSubscriptionManager, type ProgramFilter } from './accountSubscriptionManager'; import type { KaminoMarket } from '../classes/market'; import { KaminoObligation } from '../classes/obligation'; import type { SubscriptionHandle } from './subscriptionHandle'; import type { UpdateScheduler } from './wsUpdateScheduler'; export interface ObligationChangeEvent { obligation: KaminoObligation; address: Address; slot: Slot; } export type ObligationChangeCallback = (event: ObligationChangeEvent) => void; export interface ObligationListenerParams { manager: AccountSubscriptionManager; /** Map (eager) or getter (lazy) for market lookup during hydration. * * **Perf contract:** the getter form is invoked ONCE PER WS NOTIFICATION. * Make it cheap — a constant-time read of an already-built map (e.g. * `() => this.markets`) or a memoized value. Do NOT rebuild market * state inside the getter; high-throughput obligation streams would * pay that cost on every event. */ markets: Map | (() => Map); /** * The ledger instant (slot + block time) the obligation's positions are hydrated at - value (fixed) or getter * (lazy, e.g. a periodically refreshed `getCurrentLedgerInstant`). The WebSocket notification only carries a slot, * and the positions of an obligation on `TrueApr` reserves accrue per second, so the block time must come from the * caller; the same perf contract as `markets` applies to the getter form (invoked once per notification). */ currentLedgerInstant: LedgerInstant | (() => LedgerInstant); owner: Address; onChange: ObligationChangeCallback; onError?: (error: unknown) => void; programId?: Address; commitment?: Commitment; /** Default: no throttle — obligations are low-frequency, user-action-driven. */ throttleMs?: number; /** Requires `throttleMs`. */ scheduler?: UpdateScheduler; } export declare function buildObligationFilters(owner: Address): ProgramFilter[]; export declare function listenToObligationChanges(params: ObligationListenerParams): SubscriptionHandle; //# sourceMappingURL=obligationListener.d.ts.map