# LiquidationManager does not correctly maintain entireSystemColl and calculates TCR incor- rectly when performing liquidation

Bima's LiquidationManager omits collateral gas compensation when decrementing entireSystemColl, inflating TCR and blocking legitimate recovery-mode liquidations.

- Payout: Contest reward
- Severity: high
- Program: Bima
- Credited: pkqs90
- Disclosed: 2025-02-05
- Write-up quality: 7/10
- Original: https://cdn.cantina.xyz/reports/cantina_competition_bima_december2024.pdf#3.1.7
- Library page: https://bugbountylibrary.com/r/cantina%3Abima_december2024%3A3.1.7
- Tags: domain:web3 impact:funds-loss kind:contest platform:cantina sev:high tech:solidity technique:regression technique:source-review vuln:accounting-error vuln:liquidation

**Target:** LiquidationManager smart contract (liquidateTroves/batchLiquidateTroves)
**Root cause:** When maintaining entireSystemColl during liquidation, the code subtracts collToSendToSP and collSurplus but not collGasCompensation, so system collateral is overstated relative to reality.
**Steps:**
1. Enter recovery mode where TCR < CCR and liquidateTroves is invoked.
2. Liquidate a Trove with 10000 collateral / 9900 debt via Stability Pool: collGasCompensation = 10000*0.5% = 50, collToSendToSP = 9950.
3. Observe `entireSystemColl -= (collToSendToSP + collSurplus) * price` subtracts only 9950, not 10000.
4. Recompute TCR via `BimaMath._computeCR(entireSystemColl, entireSystemDebt)`; it is higher than true value.
5. Loop breaks on `TCR >= CCR || ICR >= TCR`, halting liquidations that should proceed.
**How found:** Compared Bima's liquidation accounting against Liquity V1 TroveManager (lines 583-586), noticing the gas compensation term was dropped from the entireSystemColl decrement.
**Exploitation:** Not weaponized; the flaw causes under-liquidation, leaving undercollateralized Troves unliquidated and bad debt accumulating in the protocol during recovery mode.
**Insight:** When porting Liquity-style code, diff every accounting subtraction against upstream: gas compensation is a silent third term alongside collToSendToSP and collSurplus that is easy to omit.
