Liquidation profit is never given to cds depositors who will take these losses
Summary
Liquidation profit is calculated in borrowingLiquidation::liquidationType1(), but is actually never handled and given to cds depositors. It is stored and added to totalCdsDepositedAmount, but it is missing the functionality to send the profits to cds depositors in CDSLib::withdrawUser().
Root Cause
In CDSLib::withdrawUser(), the cds profits stored in omniChainCDSLiqIndexToInfo are not given to the cds depositors.
Internal pre-conditions
None.
External pre-conditions
None.
Attack Path
- Borrower is liquidated, cds profits are calculated but when the cds depositors withdraw, they do not receive these profits.
Impact
Cds depositors take losses on liquidation instead of profiting.
PoC
See the links above.
Mitigation
Calculate the share of the profits and send to the cds depositors.