Core Contracts

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

`rayMul` should be used in DebtToken totalSupply

Summary

In the DebtToken contract, both totalSupply and balanceOf functions should account for the current index of the debt. While balanceOf is correctly implemented, totalSupply is not. Instead of using rayMul, the totalSupply function incorrectly uses rayDiv, leading to inaccurate calculations.


Vulnerability Details

The totalSupply function in the DebtToken contract is designed to return the total supply of debt tokens adjusted by the normalized debt index. However, the current implementation uses rayDiv instead of rayMul to adjust the scaled supply. This results in an incorrect computation of the total supply, as the division operation inverts the intended scaling.


Impact

The incorrect computation of totalSupply in the DebtToken contract will lead to inconsistencies in the accounting of debt. Users and external systems relying on this value will receive inaccurate data, potentially affecting operations such as debt calculations, interest accruals, and financial reporting.


Tools Used

The issue was identified through manual code review.


Recommendations

To fix the issue, replace rayDiv with rayMul in the totalSupply function of the DebtToken contract. This ensures that the total supply is correctly adjusted by the normalized debt index.

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());
}

This change will align the totalSupply function with the intended logic and ensure accurate debt calculations.

Updates

Lead Judging Commences

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