Open GalloDaSballo opened 3 months ago
batchLiquidateTroves allows for out of order liquidations
batchLiquidateTroves
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
The check could be refactored to ensure that if all Troves are underwater, the vast majority of the debt can still be liquidated
I would accept that because it should work if the troves gets liquidated, ordered by CR.
Impact
batchLiquidateTroves
allows for out of order liquidationsIn 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
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