The _repay function incorrectly converts DebtToken balance from scaled to underlying units using rayDiv instead of rayMul, leading to incorrect debt calculations and potential repayment issues.
In the repayment function:
The issue occurs because:
userDebt is already in scaled units (DebtToken units)
It needs to be converted to underlying asset units for comparison with amount
The code incorrectly uses rayDiv instead of rayMul
This makes the debt appear smaller than it actually is
Correct conversion should be:
Incorrect calculation of user's actual debt amount
Users might be allowed to repay less than their actual debt
Comparison between amount and userScaledDebt uses incompatible units
Protocol's debt accounting becomes inaccurate
Could lead to bad debt accumulation
Users might be unable to fully repay their loans
Manual Review
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.