# executeIsolateLiquidate() totalBidAmout/availableLiquidity incorrect accounting

executeIsolateLiquidate double-counts totalExtraAmount in availableLiquidity and over-decrements totalBidAmout, corrupting borrow rates and blocking future liquidations.

- Payout: Contest reward
- Severity: high
- Program: BendDAO
- Credited: bin2chen
- Disclosed: 2025-01-22
- Write-up quality: 6/10
- Original: https://code4rena.com/reports/2024-12-benddao-invitational#h-01
- Library page: https://bugbountylibrary.com/r/c4%3A2024-12-benddao-invitational%3AH-01
- Tags: domain:web3 impact:dos impact:integrity kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:accounting-error vuln:liquidation

**Target:** IsolateLogic.sol executeIsolateLiquidate accounting
**Root cause:** totalBorrowAmount already includes totalExtraAmount, but the code adds totalExtraAmount again to availableLiquidity and subtracts the full totalBorrowAmount from totalBidAmout instead of totalBorrowAmount - totalExtraAmount.
**Steps:**
1. Call executeIsolateLiquidate with a bid where totalBorrowAmount > actual bid (totalExtraAmount > 0).
2. Observe erc20TransferInLiquidity adds totalExtraAmount to availableLiquidity, then erc20TransferOutBidAmountToLiqudity adds totalBorrowAmount again.
3. Observe totalBidAmout is decremented by totalBorrowAmount rather than totalBorrowAmount - totalExtraAmount.
4. Result: availableLiquidity inflated by totalExtraAmount; totalBidAmout underflows, reverting future liquidations.
**How found:** Code review of the liquidation accounting path, noticing totalBorrowAmount already contains totalExtraAmount yet both are added to availableLiquidity and the full totalBorrowAmount is subtracted from totalBidAmout.
**Exploitation:** Trigger isolate liquidation with a bid below the borrow amount so totalExtraAmount > 0; the inflated availableLiquidity skews borrowRate and the over-subtraction of totalBidAmout causes underflow that blocks subsequent liquidations.
**Insight:** In liquidation flows, check whether the 'extra' top-up amount is already folded into the total repay figure before it is added to liquidity or subtracted from bid balances; double-counting here silently corrupts rate math and can underflow bid accounting.
