Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: high
Invalid

Users Unable to Fully Repay Debt Due to Wrong Interest Accrual Mechanism

Summary

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.

Vulnerability Details

The issue occurs in the burn() function during debt repayment:

function burn(address from, uint256 amount, uint256 index) external {
uint256 userBalance = balanceOf(from); // Returns current debt with interest
if(amount > userBalance){
amount = userBalance;
}
uint256 amountScaled = amount.rayDiv(index);
_burn(from, amount.toUint128()); // @audit - Will revert if trying to repay full debt
}

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:

  1. 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

  2. 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

Impact

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.

Tools Used

  • Manual Review

Recommendations

  1. Mint additional DebtTokens to accounts as interest accrues

  2. Modify repayment logic to handle interest separately from principal

  3. Add special full repayment function that calculates total debt including interest

  4. Implement proper scaling mechanism for debt repayments

Updates

Lead Judging Commences

inallhonesty Lead Judge 2 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
inallhonesty Lead Judge 2 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.