Due to a logic error, users will still have scaledDebtBalance despite burning all of their debt tokens.
Assume Alice borrows 100 rTokens at usageIndex = 2
Alice is minted 100 debtTokens, scaledDebtBalance = 100 / 2 = 50
Some time passes, usageIndex = 3 and Alice wants to repay her loan
Alice invokes repay with amount = type(uint256).max
amount is checked against user's total debt balance and capped against it in DebtToken.sol
Afterwards the amount is burnt and the method returns some values
One of the return values is amountScaled = 100 / 3 = 33,(3) which is the root of the issue.
amountScaled is returned in LendingPool as amountBurned and then deducted from user.scaledDebtBalance
However scaledDebtBalance = 50 while amountBurned = 33 - user successfully burnt all of their debt tokens however there is still debt left. User can't repay the rest since there aren't any debt tokens to burn. This debt continues accruing interest which degrades user's health factor which affects future borrows and will lead to liquidation and seize of their collateral even when they have 0 debt tokens.
Loss of funds, unfair liquidations, broken core functionality
Complete rehaul of the method is needed
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.