Core Contracts

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

Mathematical Error in RToken's Dust Calculation

Summary

A critical mathematical error was discovered in the calculateDustAmount() function of the RToken contract. The function incorrectly handles normalized income calculations by both dividing the actual balance and double-multiplying the total supply by the normalized income factor. This results in significant underestimation of dust amounts and potential permanent locking of funds in the contract.

Vulnerability Details

The calculateDustAmount() function contains two critical mathematical errors:

1. Incorrect Balance Normalization

uint256 contractBalance = IERC20(_assetAddress).balanceOf(address(this)).rayDiv(ILendingPool(_reservePool).getNormalizedIncome());

The actual token balance is incorrectly divided by normalized income, artificially reducing the reported contract balance. The actual balance represents real tokens and should not be normalized.

2. Double Interest Application:

// First multiplication in totalSupply():
function totalSupply() public view override(ERC20, IERC20) returns (uint256) {
return super.totalSupply().rayMul(ILendingPool(_reservePool).getNormalizedIncome());
}
// Second multiplication in calculateDustAmount():
uint256 totalRealBalance = currentTotalSupply.rayMul(ILendingPool(_reservePool).getNormalizedIncome());

The normalized income is applied twice to the total supply calculation, exponentially inflating the reported total balance.

Impact

The vulnerability has severe implications for the protocol, due to underestimated contract balances and overestimated total supplies

  1. Dust amounts will be reported as zero even when excess funds exist, permanently locking funds in the contract.

  2. Preventing legitimate dust transfers and disrupting the protocol's interest distribution mechanism.

  3. Over time, as normalized income increases with accrued interest, the magnitude of the calculation error grows exponentially, potentially affecting protocol solvency and user fund accessibility.

Tools Used

  • Manual code review

Recommendations

  • Remove the incorrect normalization of contract balance:

uint256 contractBalance = IERC20(_assetAddress).balanceOf(address(this));

  • Remove the redundant normalized income multiplication:

uint256 totalRealBalance = totalSupply(); // Already includes normalized income

Updates

Lead Judging Commences

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

RToken::calculateDustAmount incorrectly applies liquidity index, severely under-reporting dust amounts and permanently trapping crvUSD in contract

Support

FAQs

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