import { TokenBalance } from '@dynamic-labs/sdk-api-core'; /** * In-memory record of a shield operation that has been accepted by the * prover/relay but not yet observed on-chain by either the public * balance mapping (Provable's `/mapping/balances/...` endpoint) or * the RecordScanner index. Until reconciliation drops it, the entry * forces the widget to display the post-shield state — unshielded * rawBalance reduced by `amount`, shielded rawBalance increased by * the same — so the Shield Manually CTA disappears the moment the * shield is broadcast instead of flickering back into view during * the indexing tail and tempting the user into a second shield. */ export type OptimisticShieldEntry = { tokenAddress: string; isNative: boolean; amount: bigint; preShieldUnshieldedRaw: bigint; preShieldShieldedRaw: bigint; symbol: string; name: string; decimals: number; logoURI: string; price?: number; createdAtMs: number; }; export declare const OPTIMISTIC_SHIELD_STALE_MS = 180000; /** * Reduce each unshielded token's `rawBalance` by the sum of pending * optimistic shields for the same `(address, isNative)`, clamped to 0. * `balance` and `marketValue` scale by the same ratio so the fiat * column doesn't disagree with the optimistic raw balance. * * Rows that are zeroed by the deduction are dropped from the returned * array so they disappear immediately from the unshielded list instead * of lingering as a `<$0.01` ghost (the per-row fiat formatter renders * any non-positive-but-non-undefined `marketValue` as `<$0.01`, which * looks broken when the optimistic deduction has already taken the row * to exactly 0). Rows untouched by the optimistic shield pass through * by reference (no copy) so downstream memos / identity comparisons * don't churn on every render. */ export declare const applyOptimisticUnshieldedDeductions: (balances: TokenBalance[], optimisticShields: ReadonlyArray) => TokenBalance[]; /** * Apply optimistic shield additions to the shielded balance list. For * each optimistic shield with a matching `(address, isNative)` entry * already in `shielded`, bump that entry; otherwise prepend a fresh * synthesized row built from the entry's captured metadata. * * Returns a fresh array only when at least one optimistic shield * applies. When `optimisticShields` is empty we pass through the * input array by reference so consumers that compare by identity * don't churn. */ export declare const applyOptimisticShieldedAdditions: (shielded: TokenBalance[], optimisticShields: ReadonlyArray) => TokenBalance[]; /** * Filter the optimistic shield list down to entries that are still * relevant. An entry is dropped when any of: * * - the unshielded server feed reports a `rawBalance` strictly less * than `preShieldUnshieldedRaw` for that token (the burn was * observed on-chain), * - the shielded server feed reports a `rawBalance` strictly greater * than `preShieldShieldedRaw` for that token (the new record was * indexed), * - the unshielded server no longer lists the token at all (rare, * but means the public balance is effectively zero — our * optimistic deduct is moot), * - the entry is older than `staleMs` (safety net for shields whose * on-chain effect is masked by parallel inbound credits). * * Pure / module-scope so it's trivially unit-testable; the widget * just calls it on every server-side balance update. */ export declare const reconcileOptimisticShields: (optimisticShields: ReadonlyArray, unshieldedTokenBalances: TokenBalance[], shieldedTokenBalances: TokenBalance[], nowMs: number, staleMs?: number) => OptimisticShieldEntry[];