Whenever a user repays their debt, the corresponding debt tokens are burned. However, there is incorrect accounting during the burning process, leading to discrepancies in total supply calculations. This miscalculation could result in future protocol failures.
In the DebtToken::burn()
function, the contract first calculates the scaled balance:
The balance is determined as (balance * reserve.usageIndex) / 1e27
.
If amount > userBalance
, the function caps amount
to userBalance
before proceeding:
The scaled amount is then computed and used for burning:
The issue arises because balanceOf()
considers the balanceIncrease
amount, which represents accrued interest or changes in debt due to index adjustments. However, these additional balanceIncrease
tokens are never explicitly minted. The contract then attempts to burn tokens that were never created, leading to incorrect supply calculations.
The protocol's total supply tracking becomes inconsistent, as it burns tokens that do not exist on-chain.
Future functionalities relying on accurate debt token supply (e.g., interest rate calculations, liquidation mechanics) may break.
Users could face unexpected accounting issues, affecting borrowing and repayment mechanisms.
Manual code review
First Mint those balanceIncrease amount of tokens then burn total amount of tokens
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.