The borrower's debt to repay is increased incorrectly
When a user repays, we call DebtToken::burn()
:
The code above aims to accrue the interest he has to repay based on the current index and his cached index. The issue is that the balanceOf()
call already gets the amount with accrued interest:
This means that we are doing a weird calculation, let's imagine the cached index is 1 and the current one is 1.5 and the user has a scaled balance of 100. balanceOf()
would return 150 (150 * 1.5), then we would do 150 * 1.5 - 150 * 1 = 75
which means that the added interest is supposed to be 75, however that is incorrect as the index went up 50%, the user's debt must also increase by 50% to a total of 150, essentially the balanceOf()
value is correct.
NOTE: balanceIncrease
is not even used afterwards which makes the bug not actually occur but that is a completely separate bug, here the bug is about the fact that the way to compute the accrued interest is completely incorrect which will occur as soon as the bug that balanceIncrease
is unused is fixed. A lot of that will happen during the contest as the logic is infected with bugs and each bug makes another bug not actually happen.
Interest accrued incorrectly, loss of funds for the borrower
Manual Review
Either use the scaled balance for the calculations or simply use the balanceOf()
result
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.