# MIN_LEFTOVER_BASE Prevents Valid Max-Close-Factor Liquidations

K2's hardcoded $1,000 MIN_LEFTOVER_BASE rejects valid max 50% close-factor liquidations, leaving bad debt in stressed markets.

- Payout: Contest reward
- Severity: high
- Program: K2
- Credited: Egobouros
- Disclosed: 2026-08-20
- Write-up quality: 6/10
- Original: https://code4rena.com/reports/2026-04-k2#h-18
- Library page: https://bugbountylibrary.com/r/c4%3A2026-04-k2%3AH-18
- Tags: domain:web3 impact:dos impact:funds-loss kind:contest platform:code4rena sev:high tech:rust technique:source-review vuln:business-logic vuln:liquidation

**Target:** Kinetic Router liquidation logic (Soroban/Rust contracts)
**Root cause:** A hardcoded $1,000 leftover floor on remaining debt/collateral conflicts with the 50% close-factor cap, so repayments that leave non-zero value under $1,000 revert even when within the permitted close-factor range.
**Steps:**
1. Set position: debt $4,000, collateral $3,000, liq threshold 80%, bonus 5%, HF=0.60
2. Confirm default 50% close factor applies (debt and collateral >= $2,000, HF >= 0.5)
3. Compute max_liquidatable_debt = 4000*50% = $2,000
4. Call liquidation with debt_to_cover = $2,000; collateral_seized = 2000*1.05 = $2,100
5. Observe remaining_collateral = 3000-2100 = $900 < MIN_LEFTOVER_BASE (1000 WAD)
6. Transaction reverts with LeavesTooLittleDebt despite passing close-factor check
**How found:** Code reading of constants.rs and liquidation.rs: noticed the leftover check imposes a second implicit limit inconsistent with the close-factor math, then constructed a position where the max permitted repayment leaves collateral in the rejected interval.
**Insight:** When auditing liquidation logic, model the post-liquidation state algebraically (C - D*(1+bonus)) and check whether dust/leftover floors overlap the close-factor-permitted repayment interval; hardcoded absolute thresholds are a common source of unreachable valid states.
