The borrow function in the LendingPool contract incorrectly checks if 80% of the debt is covered by collateral, allowing borrowing even when the collateral is under-collateralized. The actual requirement is that the 80% of the collateral value should cover the total debt, and if it fails to cover, then borrowing should not be allowed.
The current check in the borrow function is:
This condition allows borrowing if 80% of the debt is covered by collateral, which can lead to under-collateralized loans.
Copy and paste the below test in the lendingPool.test.js
run the test the oputput should be like
This issue can lead to under-collateralized loans, increasing the risk of defaults and potential losses for the protocol.
Manual code review.
Update the condition to correctly check if the collateral value is sufficient to cover the debt after reducing it to 80% of its actual value. The corrected check should be:
This ensures that borrowing is only allowed if the collateral value, after being reduced to 80%, is still sufficient to cover the user's total debt.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.