the user.scaledDebtBalance
value that stores the debt is handled differently in borrow and repay in the lendingpool
in the borrow()
function, after minting debt tokens and receiving the borrowed funds, the user.scaledDebtBalance
is increased by the scaledamount value. however, in the _repay()
function, the user.scaledDebtBalance
is decreased by the amountburned value rather than the scaledamount value. for accurate accounting, the same value should be used for both increasing and decreasing the debt.
when a borrower takes out their first loan, the debttoken is minted without scaling (while the lendingpool's debt is updated using a scaled value). later, when the borrower repays their debt, the burn()
function burns debt tokens using the unscaled amount rather than the scaled value. as a result, when the lendingpool decreases the scaledDebtBalance
, it reduces by a smaller amount than what was added during borrowing, leaving a residual debt even after full repayment
this occurs for every loan, not only the first one. for non-initial loans, mint() mint tokens using the scaled value, while burn() uses the amount value
improper debt management in lendingpool due to incorrect variable usage
code review
the scaledDebtBalance
value should be decreased using the scaled value in the _replay() function, consistent with the approach in the borrow()
function
Interest IS applied through the balanceOf() mechanism. The separate balanceIncrease calculation is redundant/wrong. Users pay full debt including interest via userBalance capping.
Interest IS applied through the balanceOf() mechanism. The separate balanceIncrease calculation is redundant/wrong. Users pay full debt including interest via userBalance capping.
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.