GalloDaSballo / Apollon-Review

Notes for the Apollon Solo Security Review
0 stars 0 forks source link

Liquidation Logic will not work on all troves when the system is underwater #65

Open GalloDaSballo opened 3 months ago

GalloDaSballo commented 3 months ago

Impact

batchLiquidateTroves allows for out of order liquidations

In the edge case of all troves being underwater, meaning all troves should be liquidated, the following check will allow liquidations only starting from the riskiest trove

https://github.com/blkswnStudio/ap/blob/8fab2b32b4f55efd92819bd1d0da9bed4b339e87/packages/contracts/contracts/LiquidationOperations.sol#L196-L197

    if (vars.ICR > outerVars.TCR) return false; /// @audit Looks wrong in edge cases

This is more of a gotcha than a real risk as having all Troves underwater is a failure scenario

Mitigation

The check could be refactored to ensure that if all Troves are underwater, the vast majority of the debt can still be liquidated

sambP commented 2 months ago

I would accept that because it should work if the troves gets liquidated, ordered by CR.