Submitted by Koolex
When a Collateralized Debt Position (CDP) reaches that liquidation threshold, it becomes eligible for liquidation and anyone can repay a position in exchange for a portion of the collateral.
Market._isSolvent is used to check if the user is solvent. if not, then it can be liquidated. Here is the method body:
Code link
The issue is that the collateralizationRate is multiplied by collateralShare (with precision constants) then converted to amount. This is incorrect, the collateralizationRate sholud be used with amounts and not shares. Otherwise, we get wrong results.
Please note that when using shares it is not in favour of the protocol, so amounts should be used instead. The only case where this is ok, is when the share/amount ratio is 1:1 which can not be, because totalAmount always get +1 and totalShares +1e8 to prevent 1:1 ratio type of attack.
Code link
Moreover, in the method _computeMaxAndMinLTVInAsset which is supposed to returns the min and max LTV for user in asset price. Amount is used and not share. Here is the code:
Code Link
Ive set this to high severity because solvency check is a crucial part of the protocol. In short, we have :
Note: this is also applicable for ohter methods. For example, Market._computeMaxBorrowableAmount.
As you can see, numbers are not equal, and when using shares it is not in favour of the protocol, so amount should be used instead.
Use amount for calculation instead of shares. Check the PoC as it demonstrates such an example.
0xRektora (sponsor) confirmed
