/**
 * Listen to real-time token and native SOL balance changes via WebSocket.
 *
 * Token balances: Uses AccountSubscriptionManager for programNotifications on the
 * Token Program with owner memcmp filter. Gets slot-ordering, buffer dedup, and
 * ref-counting for free.
 *
 * Native SOL: Uses its own WS loop with accountNotifications because the manager
 * only supports programNotifications. This is the only standalone loop in the
 * subscription infrastructure.
 */
import { type Address, type RpcSubscriptions, type SolanaRpcSubscriptionsApi } from '@solana/kit';
import { type AccountSubscriptionManager, type ProgramFilter } from './accountSubscriptionManager';
export interface TokenBalanceEvent {
    /** The ATA (Associated Token Account) address */
    ataAddress: Address;
    /** Raw token amount in lamports (not decimal-adjusted) */
    amount: bigint;
    /** The raw 32-byte mint pubkey from the token account data */
    mintBytes: Uint8Array;
}
export interface NativeSolBalanceEvent {
    lamports: bigint;
}
export type TokenBalanceCallback = (event: TokenBalanceEvent) => void;
export type NativeSolBalanceCallback = (event: NativeSolBalanceEvent) => void;
export interface BalanceListenerParams {
    manager: AccountSubscriptionManager;
    owner: Address;
    tokenProgramId: Address;
    onBalanceChange: TokenBalanceCallback;
    onError?: (error: unknown) => void;
}
export interface NativeSolListenerParams {
    wsRpc: RpcSubscriptions<SolanaRpcSubscriptionsApi>;
    owner: Address;
    onBalanceChange: NativeSolBalanceCallback;
    onError?: (error: unknown) => void;
    reconnectDelayMs?: number;
}
/** Decode u64 amount from SPL Token account data at byte offset 64 */
export declare function decodeTokenAccountAmount(data: Uint8Array): bigint;
/** Extract the 32-byte mint from SPL Token account data (offset 0-32) */
export declare function extractTokenAccountMintBytes(data: Uint8Array): Uint8Array;
/**
 * Build WS subscription filters for token accounts owned by a wallet.
 *
 * Uses only owner memcmp (no dataSize) so it matches both standard Token Program
 * accounts (165 bytes) and Token-2022 accounts with extensions (variable size).
 * The owner field is at offset 32 in both layouts.
 */
export declare function buildTokenBalanceFilters(owner: Address): ProgramFilter[];
/**
 * Subscribe to all token account balance changes for a given owner on
 * a specific token program. Routes through AccountSubscriptionManager
 * for slot-ordering, buffer dedup, and ref-counting.
 *
 * Returns an unsubscribe function.
 *
 * TODO: Monitor if programSubscribe on Token Program causes connection
 * instability due to high server-side write volume. If so, consumers
 * should fall back to per-ATA accountSubscribe.
 */
export declare function listenToTokenBalanceChanges(params: BalanceListenerParams): () => void;
/**
 * Subscribe to native SOL balance changes for a wallet.
 * Returns an unsubscribe function.
 *
 * Uses its own WS loop because AccountSubscriptionManager only supports
 * programNotifications, and native SOL requires accountNotifications.
 */
export declare function listenToNativeSolBalance(params: NativeSolListenerParams): () => void;
//# sourceMappingURL=balanceListener.d.ts.map