import type { PubkeyStr } from "../../shared"; import type { DepositTokenBalance, DepositTokenBalancesSnapshot, WalletDepositBalancesEvent } from "./index"; /** * Canonical WSOL mint under Solana's legacy SPL Token Program (“Tokenkeg”). * ATA derivation stays pinned to Tokenkeg rather than Token-2022 so state and * transaction planning address the protocol's one canonical account. */ export declare const WRAPPED_SOL_MINT: PubkeyStr; /** Unsponsored native reserve floor, in lamports, when canonical ATA creation is required. */ export declare const SOL_RESERVE_WITH_ACCOUNT_CREATION_LAMPORTS = 3500000n; /** Unsponsored native reserve floor, in lamports, when canonical WSOL already exists. */ export declare const SOL_RESERVE_WITH_EXISTING_ACCOUNT_LAMPORTS = 1000000n; /** Exact native and canonical WSOL breakdown behind the displayed SOL asset. */ export interface SolBalanceBreakdown { /** Lamports held by the Trading Wallet system account. */ nativeLamports: bigint; /** Token amount in the Trading Wallet's persistent canonical WSOL ATA. */ canonicalWsolLamports: bigint; } /** * Stores live chain costs used to derive transaction funding requirements. * * {@link solBalanceAvailability} applies ordinary safety floors. * {@link unwrapAllSolBalanceAvailability} rejects account creation, upfront rent, * and sponsorship, then uses only `feeLamports` as the unwrap-all reserve. */ export interface SolActionCosts { /** Live `getFeeForMessage` result, in lamports. */ feeLamports: bigint; /** Rent funded up front, even when a temporary account refunds it later. */ upfrontRentLamports: bigint; /** Whether this transaction must create the persistent canonical WSOL ATA. */ createsCanonicalWsolAccount: boolean; /** Exact public sponsorship capability supplied by the caller. */ sponsored: boolean; } /** Action-specific displayed, reserved, and spendable SOL values. */ export interface SolBalanceAvailability { /** Separately authoritative native and canonical WSOL balances. */ breakdown: SolBalanceBreakdown; /** Sum of both balances in lamports, before reserve. */ displayedLamports: bigint; /** Native lamports withheld for live costs and any action-specific safety floor. */ reserveLamports: bigint; /** Displayed lamports available to this action after reserve. */ spendableLamports: bigint; } /** Derive fail-closed availability and type an insufficient native reserve as fee funding. */ export declare function solBalanceAvailability(breakdown: SolBalanceBreakdown, costs: SolActionCosts): SolBalanceAvailability; /** * Return unwrap-all availability with the live fee as its entire reserve. * * This function rejects costs that include sponsorship, account creation, or * upfront rent. It rejects malformed or out-of-range balances and costs. It * rejects a displayed-balance sum outside Solana's unsigned 64-bit range. Native * SOL must fund the fee without relying on lamports that a later `CloseAccount` * instruction may transfer. The ordinary persistent-account floor does not apply * because unwrap-all removes that account. An insufficient native fee balance * returns the typed transaction-fee error. */ export declare function unwrapAllSolBalanceAvailability(breakdown: SolBalanceBreakdown, costs: SolActionCosts): SolBalanceAvailability; /** Whether an event was accepted by, or rejected by, its lifecycle guard. */ export type WalletDepositBalancesApplyResult = { kind: "applied"; } | { kind: "ignored"; } | { kind: "rejected"; }; /** * Mutable application-owned wallet balance state. * * The default instance is uninitialized. A complete REST or WebSocket snapshot * establishes its wallet baseline; later balance events must match that wallet * and carry absolute values. Native SOL never enters the sparse SPL mint map, and * complete snapshots may replace `contextSlot` with a lower slot. * Map containers are copied, but mutable balance objects are retained by reference; * treat payload entries as immutable after applying them. */ export declare class WalletDepositBalancesState { /** Wallet owning the current baseline, or `undefined` before initialization. */ walletAddress: PubkeyStr | undefined; /** Slot of the last accepted event, not a globally monotonic stream version. */ contextSlot: number | undefined; /** Sparse mint-keyed SPL balances; explicit zero updates remove their mint. */ readonly balances: Map; /** Exact nine-decimal native SOL, separate from `balances`. */ nativeSolBalance: string | undefined; /** * Initialize or wholesale-replace state from a complete REST snapshot. * The caller supplies the wallet omitted by REST. When `minimumSnapshotSlot` * is present, a lower complete snapshot is ignored without mutation; otherwise * prior slots are not compared. * Unlike WebSocket parsing, this TypeScript REST boundary performs no runtime * shape validation. Malformed exact values fail when a derived method scales them. */ applyRestSnapshot(walletAddress: PubkeyStr, snapshot: DepositTokenBalancesSnapshot, minimumSnapshotSlot?: number): WalletDepositBalancesApplyResult; /** * Apply the wallet event state machine. * * Complete snapshots replace state unless they are below an optional minimum * snapshot slot. The floor never applies to incremental balance or status events. * Matching balance events replace one absolute value, zero SPL removes its * mint, and status, pre-initialization, or wrong-wallet events return `ignored`. */ applyEvent(event: WalletDepositBalancesEvent, minimumSnapshotSlot?: number): WalletDepositBalancesApplyResult; /** * Return exact native SOL plus canonical WSOL with nine fractional digits. * Uses arbitrary-width integer arithmetic and never merges the stored assets. */ combinedSolBalance(): string; /** Return the exact native and canonical WSOL breakdown for transaction planning. */ solBalanceBreakdown(): SolBalanceBreakdown; /** Scale cached native SOL exactly to lamports; requires initialized state. */ nativeSolLamports(): bigint; /** Scale the canonical WSOL idle balance exactly to lamports. */ canonicalWsolLamports(): bigint; private matchesInitializedWallet; private replace; } //# sourceMappingURL=state.d.ts.map