/**
 * Listen to real-time token and native SOL balance changes via WebSocket.
 *
 * Token balances go through {@link AccountSubscriptionManager}
 * (programNotifications); native SOL goes through {@link runReconnectLoop}
 * directly since the manager only supports programNotifications.
 */
import { type Address, type Commitment, type RpcSubscriptions, type Slot, type SolanaRpcSubscriptionsApi } from '@solana/kit';
import { type AccountSubscriptionManager, type ProgramFilter } from './accountSubscriptionManager';
import type { SubscriptionHandle } from './subscriptionHandle';
import type { WsCadenceOptions } from './wsCadenceOptions';
import type { WsListenerObservability } from './wsListenerObservability';
export interface TokenBalanceEvent {
    ataAddress: Address;
    /** Raw lamports, not decimal-adjusted. */
    amount: bigint;
    /** Raw 32-byte mint pubkey from the token account data. */
    mintBytes: Uint8Array;
    slot: Slot;
}
export interface NativeSolBalanceEvent {
    lamports: bigint;
    slot: Slot;
}
export type TokenBalanceCallback = (event: TokenBalanceEvent) => void;
export type NativeSolBalanceCallback = (event: NativeSolBalanceEvent) => void;
export interface BalanceListenerParams extends WsCadenceOptions {
    manager: AccountSubscriptionManager;
    owner: Address;
    /** MUST be the SPL Token program ID or the Token-2022 program ID. The
     *  decode path assumes that account-data layout (amount at offset 64,
     *  32-byte mint at offset 0). Passing any other program ID — even one
     *  whose accounts happen to satisfy the owner memcmp filter — will
     *  decode unrelated bytes as a token amount and surface garbage. */
    tokenProgramId: Address;
    onBalanceChange: TokenBalanceCallback;
    onError?: (error: unknown) => void;
    /** Refresh balances via HTTP after WS downtime — without it, balances
     *  stay frozen at the last WS value until the next change. */
    onReconnect?: () => void | Promise<void>;
}
export interface NativeSolListenerParams extends WsListenerObservability, WsCadenceOptions {
    wsRpc: RpcSubscriptions<SolanaRpcSubscriptionsApi>;
    owner: Address;
    onBalanceChange: NativeSolBalanceCallback;
    /** Defaults to 'confirmed'. */
    commitment?: Commitment;
}
/** u64 amount at SPL Token offset 64. */
export declare function decodeTokenAccountAmount(data: Uint8Array): bigint;
/** 32-byte mint at SPL Token offset 0. */
export declare function extractTokenAccountMintBytes(data: Uint8Array): Uint8Array;
/**
 * Owner memcmp only (no dataSize) so this matches both standard SPL Token
 * accounts (165 bytes) and Token-2022 accounts with extensions. Owner is at
 * offset 32 in both layouts.
 */
export declare function buildTokenBalanceFilters(owner: Address): ProgramFilter[];
/**
 * TODO: Monitor whether programSubscribe on the Token Program causes
 * connection instability under high server-side write volume — if so,
 * fall back to per-ATA accountSubscribe.
 */
export declare function listenToTokenBalanceChanges(params: BalanceListenerParams): SubscriptionHandle;
export declare function listenToNativeSolBalance(params: NativeSolListenerParams): SubscriptionHandle;
//# sourceMappingURL=balanceListener.d.ts.map