# Accumulated profit/losses by the cumulative value is not dealt with in `borrowingLiquidation::liquidationType1()`, leading to losses

LiquidationType1 reduces totalCdsDepositedAmount and totalVolumeOfBorrowersAmountinWei without updating cumulative value, causing CDS withdrawal underflow and locked funds.

- Payout: Audit contest
- Severity: medium
- Program: Autonomint
- Found by: 0x73696d616f
- Disclosed: 2024-11-26
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/755
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AM-19
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:liquidation

**Target:** borrowLiquidation.sol liquidationType1 / CDSLib withdrawal
**Root cause:** liquidationType1 mutates totalCdsDepositedAmount and totalVolumeOfBorrowersAmountinWei without reconciling the cumulative value (priceDiff * volume / cds), so the stored cumulative loss diverges from actual state.
**Steps:**
1. Set price 1000 USD/ETH; CDS deposit 1000 USDa; borrow 1 ETH for 800 USDa.
2. Price drops to 800 USD/ETH.
3. Borrower deposits 1 wei to trigger cumulative value update, registering loss ~0.2.
4. Liquidate first borrower: totalCdsDepositAmount drops to 360 (800 treasury + 20 abond, 180 cds profit).
5. CDS depositor withdraws 1000 USDa: returnAmount = 1000 - 1000*0.2 = 800; then returnAmountWithGains = 800 + 180 - 1000 underflows.
**How found:** Code reading of liquidationType1's state mutations and tracing how cumulative value is derived from the two totals; constructed a numeric scenario showing the withdrawal underflow.
**Exploitation:** Any user triggers cumulative value updates before liquidation to lock the divergence; CDS depositor cannot withdraw until cumulative value recovers, funds effectively frozen.
**Insight:** When a protocol stores a derived cumulative/accumulator value, audit every mutation of its input totals (especially liquidation paths) for reconciliation; construct small numeric scenarios to expose underflow in downstream withdrawal math.

