Core Contracts

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

Incorrect scaling in `DebtToken::totalSupply` leading to undervalued total debt

Summary

The DebtToken::totalSupply contains a critical mathematical error, it incorrectly scales down the total debt amount using rayDiv instead of scaling it up using rayMul. This token represents user debt that grows with interest over time through an interest index (normalized debt). When calculating the totalSupply, the contract should multiply the stored amount by the current interest index to get the true total debt including accrued interest. However, the current implementation divides by the index instead, which leads to reporting less debt than actually exists.

Vulnerability Details

function totalSupply() public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledSupply = super.totalSupply();
@> return scaledSupply.rayDiv(ILendingPool(_reservePool).getNormalizedDebt());
}

Impact

Underreporting of the protocol's total debt, which misleads users and protocol management about the true state of outstanding loans, leads to accounting issues. Additionally, there is an iconsistency with individual user balances (balanceOf) which are correctly scaled using rayMul.

Tools Used

Manual review

Recommendations

function totalSupply() public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledSupply = super.totalSupply();
- return scaledSupply.rayDiv(ILendingPool(_reservePool).getNormalizedDebt());
+ return scaledSupply.rayMul(ILendingPool(_reservePool).getNormalizedDebt());
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 7 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 7 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.

Give us feedback!