# Type 1 borrower liquidation will incorrectly add cds profit directly to `totalCdsDepositedAmount`

Type 1 borrower liquidation adds CDS profit to totalCdsDepositedAmount, inflating the denominator used for cumulative value and option fee calculations.

- Payout: Audit contest
- Severity: high
- 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/746
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-15
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:accounting-error vuln:liquidation

**Target:** borrowLiquidation.sol liquidationType1 accounting
**Root cause:** totalCdsDepositedAmount is reduced by liquidationAmountNeeded - cdsProfits instead of the actual CDS amount removed, so the profit is implicitly added to the tracked total, diverging from the sum of individual CDS deposits.
**Steps:**
1. Borrower deposits 1 ETH at 1000 USD/ETH and borrows 800 USDa; one CDS depositor deposits 1000 USDa.
2. Price drops 20%, triggering borrowLiquidation::liquidationType1().
3. returnToAbond = (1000-800)*10/100 = 20; cdsProfits = 1000-800-20 = 180; liquidationAmountNeeded = 820; cdsAmountToGetFromThisChain = 640.
4. totalCdsDepositedAmount becomes 1000 - (820-180) = 360, though only 180 CDS remains.
5. Subsequent cumulative value and option fee rates divide by 360 instead of 180, understating per-depositor payouts.
**How found:** Code review of liquidationType1 accounting: noticed totalCdsDepositedAmount reduced by liquidationAmountNeeded - cdsProfits, which implicitly credits profit to the aggregate total rather than tracking it separately.
**Insight:** When a liquidation credits profit to a pool, check whether the aggregate accounting variable is adjusted by the net removed amount versus the gross; any divergence between aggregate total and sum of per-user balances corrupts every rate derived from it.

