/** * Vault Split Utilities for Aave Liquidation Protection * * BTC vaults are indivisible UTXOs. During liquidation, the protocol seizes * whole vaults as a prefix of the borrower's ordered vault list until the * target seizure amount is covered. Splitting deposits into 2 optimally-sized * vaults (sacrificial + protected) minimizes over-seizure loss. * * The sacrificial vault (index 0) is sized to cover the expected target seizure * plus a safety margin. The protected vault (index 1) holds the remainder and * survives liquidation. * * Seizure formula (from Aave v4 Section 4.2): * ``` * liq_penalty = LB × CF * debt_to_repay = total_debt × (THF - current_HF) / (THF - liq_penalty) * target_seizure = debt_to_repay × LB * ``` */ /** * Parameters for computing the optimal vault split. */ export interface OptimalSplitParams { /** Total deposit amount in satoshis */ totalBtc: bigint; /** Collateral factor (e.g. 0.75 for 75%) */ CF: number; /** Liquidation bonus (e.g. 1.05 for 5% bonus) */ LB: number; /** Target health factor (e.g. 1.10) */ THF: number; /** Expected health factor at liquidation (e.g. 0.95) */ expectedHF: number; /** Safety margin multiplier for the sacrificial vault (e.g. 1.05 for 5% buffer) */ safetyMargin: number; } /** * Result of the optimal vault split computation. */ export interface OptimalSplitResult { /** Sacrificial vault amount in satoshis (index 0, seized first) */ sacrificialVault: bigint; /** Protected vault amount in satoshis (index 1, survives liquidation) */ protectedVault: bigint; /** Fraction of collateral that would be seized (0–1) */ seizedFraction: number; /** Raw target seizure amount in satoshis (before safety margin) */ targetSeizureBtc: bigint; } /** * Parameters for computing the minimum deposit required for a split. */ export interface MinDepositForSplitParams { /** Minimum peg-in amount in satoshis */ minPegin: bigint; /** Seized fraction (0–1), from computeOptimalSplit or computeSeizedFraction */ seizedFraction: number; /** Safety margin multiplier (e.g. 1.05) */ safetyMargin: number; } /** * Compute the fraction of collateral that would be seized during liquidation, * returning both the raw (unclamped) and clamped values. * * The raw value is useful for detecting unusual protocol parameter combinations * (values outside [0, 1] indicate something unexpected). * * Formula: * ``` * liq_penalty = LB × CF * seized_fraction = CF × (THF - expectedHF) / (THF - liq_penalty) × LB / expectedHF * ``` * * @param CF - Collateral factor (e.g. 0.75) * @param LB - Liquidation bonus (e.g. 1.05) * @param THF - Target health factor (e.g. 1.10) * @param expectedHF - Expected health factor at liquidation (e.g. 0.95) * @returns Both the raw seized fraction and the clamped [0, 1] value */ export declare function computeSeizedFractionDetailed(CF: number, LB: number, THF: number, expectedHF: number): { seizedFraction: number; seizedFractionRaw: number; }; /** * Compute the fraction of collateral that would be seized during liquidation. * * @param CF - Collateral factor (e.g. 0.75) * @param LB - Liquidation bonus (e.g. 1.05) * @param THF - Target health factor (e.g. 1.10) * @param expectedHF - Expected health factor at liquidation (e.g. 0.95) * @returns Seized fraction clamped to [0, 1] */ export declare function computeSeizedFraction(CF: number, LB: number, THF: number, expectedHF: number): number; /** * Compute the optimal split between a sacrificial vault and a protected vault. * * The sacrificial vault (index 0) is sized to cover the target seizure amount * plus a safety margin. The protected vault (index 1) holds the remainder. * * @param params - Split parameters including total BTC, risk params, and safety margin * @returns Split result with vault sizes, seized fraction, and target seizure * * @example * ```typescript * import { computeOptimalSplit } from "@babylonlabs-io/ts-sdk/tbv/integrations/aave"; * * const result = computeOptimalSplit({ * totalBtc: 1_000_000_000n, // 10 BTC in sats * CF: 0.75, * LB: 1.05, * THF: 1.10, * expectedHF: 0.95, * safetyMargin: 1.05, * }); * // result.sacrificialVault ≈ 418_000_000n (4.18 BTC) * // result.protectedVault ≈ 582_000_000n (5.82 BTC) * ``` */ export declare function computeOptimalSplit(params: OptimalSplitParams): OptimalSplitResult; /** * Compute the minimum total deposit required for a 2-vault split. * * Both vaults must be at least `minPegin` satoshis. This function returns * the minimum total deposit where both the sacrificial and protected vaults * would meet the minimum peg-in requirement. * * @param params - Parameters including minimum peg-in, seized fraction, and safety margin * @returns Minimum total deposit in satoshis. Returns 0n in two cases: * - `seizedFraction * safetyMargin >= 1`: split impossible (sacrificial vault would consume entire deposit) * - `seizedFraction <= 0`: split not useful (no seizure expected at this health factor) * * @example * ```typescript * import { computeMinDepositForSplit } from "@babylonlabs-io/ts-sdk/tbv/integrations/aave"; * * const minDeposit = computeMinDepositForSplit({ * minPegin: 50_000n, // 0.0005 BTC * seizedFraction: 0.398, * safetyMargin: 1.05, * }); * ``` */ export declare function computeMinDepositForSplit(params: MinDepositForSplitParams): bigint; //# sourceMappingURL=vaultSplit.d.ts.map