/** * Pre-PegIn fee math primitives used by both UTXO selection and * transaction funding so they make bit-identical decisions about base * fee, change-output fee, and whether to emit change at all. * * Dust handling matches the wallet-side check in * `babylon-vault crates/btc-wallet-remote/src/client.rs` (dust-change * rejection): a change output is emitted only when the post-fee residual * exceeds DUST_THRESHOLD (546 sats). Broader fee-estimation behaviors * (output sizing, safety margins) are NOT cross-stack guarantees — see * JS-vs-Rust parity fixtures in `__tests__/peginFeeMath.test.ts` for the * invariants we pin. */ export interface ComputeBaseFeeParams { numInputs: number; /** * Number of outputs in the unfunded transaction (HTLC vault outputs + * CPFP anchor + optional auth-anchor OP_RETURN). Excludes the change * output — `applyChangeOutputPolicy` adds the change-output fee * separately. */ numOutputs: number; feeRate: number; } /** * Compute the base fee (sats) for a Pre-PegIn transaction with no change * output, including the low-fee-rate buffer. * * Used as the starting point by `applyChangeOutputPolicy`, which then * decides whether to add the incremental change-output fee. */ export declare function computePeginBaseFeeSats(params: ComputeBaseFeeParams): bigint; /** * Incremental fee (sats) for adding one P2TR-sized change output at the * given fee rate. Does NOT include the low-fee-rate buffer — that is part * of the base fee, paid once per transaction. */ export declare function computeChangeOutputFeeSats(feeRate: number): bigint; export interface ApplyChangeOutputPolicyParams { totalInputValue: bigint; peginAmount: bigint; baseFee: bigint; changeOutputFee: bigint; } export interface ChangeOutputPolicyResult { /** Final transaction fee (sats). */ fee: bigint; /** * Final change amount (sats). 0n when no change output is emitted. * When `emitChangeOutput` is false, the would-be change is paid to * miners as part of `fee` — i.e. it is dust by policy. */ changeAmount: bigint; /** Whether the funded transaction must include a change output. */ emitChangeOutput: boolean; } /** * Apply the change-output dust policy: emit a change output iff the * post-change-output-fee residual strictly exceeds DUST_THRESHOLD. * * Returns `{ fee, changeAmount, emitChangeOutput }` so the selector and * funder both end up with the same fee and same change decision for the * same inputs. * * Inputs: * - `totalInputValue`: sum of selected UTXO values * - `peginAmount`: amount being pegged in * - `baseFee`: fee assuming no change output (from `computePeginBaseFeeSats`) * - `changeOutputFee`: incremental fee for adding one change output * (from `computeChangeOutputFeeSats`) * * @throws If `totalInputValue < peginAmount + baseFee` (insufficient funds * even before considering change). Callers that need to surface * "insufficient funds" with their own error wording should check the * precondition themselves before invoking this. */ export declare function applyChangeOutputPolicy(params: ApplyChangeOutputPolicyParams): ChangeOutputPolicyResult; export interface ComputeMaxDepositParams { numInputs: number; /** * Number of outputs in the unfunded transaction. Use the worst-case * count for the use case being budgeted (e.g. max-batch with * auth-anchor) — `computeMaxDeposit` is intentionally an UPPER BOUND * and assumes no change output. */ numOutputs: number; totalBalance: bigint; feeRate: number; } /** * Compute the maximum depositable amount (sats) given a fixed-cost * sweep: every UTXO is spent, no change output is emitted, fee is the * base fee for the requested input/output count. * * Returns null when `totalBalance <= 0n`. Returns 0n if the base fee * alone exceeds the balance. */ export declare function computeMaxDeposit(params: ComputeMaxDepositParams): bigint | null; //# sourceMappingURL=peginFeeMath.d.ts.map