The burn
function in the DebtToken
contract fails to account for accrued interest balanceIncrease
when repaying debt. Specifically:
It retrieves userBalance = balanceOf(from)
which does not include newly accrued interest.
It caps the repayment amount based on an outdated balance leading to incorrect debt repayment and accounting.
It updates the user's index to the latest value effectively discarding the balanceIncrease
in subsequent calculations.
DebtTokens accrue interest over time using a borrow index (usageIndex in borrow, borrowIndex in repay).
When users borrow, interest is added by minting new DebtTokens corresponding to accrued interest balanceIncrease.
However, when users repay, the _repay
function calls debtToken.burn
.The function calculates balanceIncrease
based on the borrow index but does not mint equivalent DebtTokens
before checking the user's debt balance userBalance
This outdated balance is then used to cap the repayment amount ignoring the balanceIncrease
The mint function correctly accounts for balanceIncrease
by minting additional DebtTokens, but the burn function does not follow the same logic.
Users repay less than they actually owe (principal + interest) as the repayment amount is capped based on outdated balance.
Manual code review
Modify the burn()
function to mint additional debt tokens for accrued interest before processing the repayment
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.