/** * Fee Calculator — Railgun Unshield Fee + B402 Protocol Fees * * All math uses BigInt exclusively — zero floating point. * * b402 Railgun fork has 0% unshield fee (upstream Railgun charges 0.25%). * B402 charges a tiered protocol fee: base ($0.05) + volume tier (5-10 bps). */ import type { FeeBreakdown, FeeTier } from '../types'; /** * Calculate the gross unshield amount needed so that after Railgun's fee, * the net amount equals `desiredNetAmount`. * * Formula: gross = ceil(desired * 10000 / (10000 - feeBps)) * * @param desiredNetAmount - Amount you want AFTER the fee (in token's smallest unit) * @param feeBps - Fee in basis points (default: 0 on b402 fork) * @returns Gross amount to unshield */ export declare function calculateUnshieldAmount(desiredNetAmount: bigint, feeBps?: bigint): bigint; /** * Calculate the net amount after Railgun's unshield fee is deducted. * * Formula: net = gross * (10000 - feeBps) / 10000 * * @param grossAmount - Amount being unshielded (before fee) * @param feeBps - Fee in basis points (default: 0 on b402 fork) * @returns Net amount after fee deduction */ export declare function calculateNetAfterUnshieldFee(grossAmount: bigint, feeBps?: bigint): bigint; /** * Determine the fee tier based on the USD value of the amount. * * Tiers (from base-volume-loop-gasless-v2.ts): * - small: < $1,000 → 5 bps (0.05%) * - medium: $1k-$10k → 8 bps (0.08%) * - large: > $10,000 → 10 bps (0.10%) * * @param amount - Amount in token's smallest unit * @param decimals - Token decimals (6 for USDC, 18 for WETH) * @returns Fee tier */ export declare function getFeeTier(amount: bigint, decimals: number): FeeTier; /** * Calculate the B402 protocol fee for a given amount. * * Fee = baseFee + volumeFee * - baseFee: flat $0.05 (in token's smallest unit) * - volumeFee: amount * tierBps / 10000 * * @param amount - Amount in token's smallest unit * @param decimals - Token decimals (6 for USDC, 18 for WETH) * @returns Fee breakdown with total, base, volume, and tier rate */ export declare function calculateB402Fee(amount: bigint, decimals: number): FeeBreakdown;