Core Contracts

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

A redundant state update in the burn function of the RToken.sol

Summary

A redundant state update was identified in the burn function of the RToken contract where the user's liquidity index is set twice with the same value, resulting in unnecessary gas costs and potential confusion in code maintenance.

Vulnerability Details

In the burn function, the following code appears twice:

// First occurrence
_userState[from].index = index.toUint128();
// ... other code ...
// Second occurrence
_userState[from].index = index.toUint128();

This duplicate state update:

  • Wastes gas by performing the same storage operation twice

  • Makes the code harder to maintain

  • Could lead to confusion about whether the second update is intended to be different

Impact

  • Gas Inefficiency: Each redundant SSTORE operation costs unnecessary gas

  • Code Quality: Reduces code maintainability and readability

  • Severity: Low (no security implications, but impacts gas efficiency)

Tools Used

  • Manual code review

  • Static analysis

Recommendations

Remove the redundant state update by keeping only one instance of the index update:

function burn(
address from,
address receiverOfUnderlying,
uint256 amount,
uint256 index
) external override onlyReservePool returns (uint256, uint256, uint256) {
if (amount == 0) {
return (0, totalSupply(), 0);
}
uint256 userBalance = balanceOf(from);
// Set user index once
_userState[from].index = index.toUint128();
if(amount > userBalance){
amount = userBalance;
}
uint256 amountScaled = amount.rayDiv(index);
_burn(from, amount.toUint128());
if (receiverOfUnderlying != address(this)) {
IERC20(_assetAddress).safeTransfer(receiverOfUnderlying, amount);
}
emit Burn(from, receiverOfUnderlying, amount, index);
return (amount, totalSupply(), amount);
}

This change will:

  • Reduce gas costs

  • Improve code clarity

  • Maintain the same functionality

  • Make the code easier to maintain

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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