Core Contracts

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

Incorrect Debt Calculation in totalSupply function of DebtToken Contract

Summary

The totalSupply() function uses rayDiv instead of rayMul when applying the normalized debt index, causing systematic underreporting of total debt.

Vulnerability Details

scaledSupplytracks total Debt tokens. this should be multiplied by the index to get total Debt.

In the return statement below ,scaledSupply.rayDiv() inverts the debt accrual logic, making total debt appear to shrink as interest accrues which is wrong. Debt should actually increase over time.

function totalSupply() public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledSupply = super.totalSupply();
//@audit should be rayMul, not div.
return scaledSupply.rayDiv(ILendingPool(_reservePool).getNormalizedDebt());
}

Impact

  • totalSupply() function is used in mint,burn functions and also in other contracts to track the total debt .

  • This math error causes underreporting of total Debt in multiple places of the codebase.

Tools Used

Manual review

Recommendations

Instead of rayDiv(), we need to call rayMul() on scaledSupply

return scaledSupply.rayMul(ILendingPool(_reservePool).getNormalizedDebt());
Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

DebtToken::totalSupply incorrectly uses rayDiv instead of rayMul, severely under-reporting total debt and causing lending protocol accounting errors

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

DebtToken::totalSupply incorrectly uses rayDiv instead of rayMul, severely under-reporting total debt and causing lending protocol accounting errors

Support

FAQs

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