The DebtToken's burn mechanism prevents users from fully repaying their debt when interest has accrued. When attempting to repay the full visible debt amount, the transaction reverts due to insufficient DebtTokens, as the contract doesn't mint additional tokens for accrued interest.
The issue occurs in the burn() function during debt repayment:
Initial State:
User borrows 50 @index 1.0
Borrows another 50 @index 1.1
Results in:
DebtToken Balance = 105.5
user.scaledDebtBalance = 95.45
Attempt to Repay Full Debt @index 1.2:
Try to repay 114.54 (full debt with interest):
userBalance = 95.45 1.2 = 114.54
Tries to burn 114.54 DebtTokens
Reverts: user only has 105.5 DebtTokens
Try to repay available DebtTokens (105.5):
Succeeds in burning 105.5 DebtTokens
amountScaled = 105.5/1.2 = 87.916
Remaining scaledDebtBalance = 95.45 - 87.916 = 7.534
Cannot repay remaining debt
When a borrower's position becomes liquidatable and they attempt to rescue their position by repaying their full debt, they are unable to do so because the protocol fails to account for accrued interest in DebtTokens. This creates a situation where even if a borrower has sufficient funds to repay their entire debt, they cannot close the liquidation position since the interest portion remains unpayable due to missing DebtTokens. Consequently, borrowers are forced to watch their collateral be liquidated despite having the means to save their position, leading to unnecessary loss of valuable collateral to liquidators.
This is particularly severe because it removes the safety net that liquidation grace periods are designed to provide, where borrowers should have the opportunity to save their position by repaying their debt. The bug effectively makes grace periods meaningless since repayment becomes technically impossible, guaranteeing loss of collateral even for borrowers actively trying to save their positions.
Manual Review
Mint additional DebtTokens to accounts as interest accrues
Modify repayment logic to handle interest separately from principal
Add special full repayment function that calculates total debt including interest
Implement proper scaling mechanism for debt repayments
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.