Core Contracts

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

updating user index in the ``RToken::burn()`` two times consume more gas

Summary

RToken::burn(): https://github.com/Cyfrin/2025-02-raac/blob/main/contracts/core/tokens/RToken.sol#L154.

updating the value of index, two time

Vulnerability Details

the struct is updated each time the user deposit or withdraw, mainly in mint and burn functions

struct UserState {
uint128 index;
}
mapping(address => UserState) private _userState;

the function burn() updates the value of index, two time which cost more gas because it is in storage:

uint256 userBalance = balanceOf(from);
_userState[from].index = index.toUint128(); //here!!
if(amount > userBalance){
amount = userBalance;
}
uint256 amountScaled = amount.rayMul(index);
_userState[from].index = index.toUint128(); // and here!!
_burn(from, amount.toUint128());
if (receiverOfUnderlying != address(this)) {
IERC20(_assetAddress).safeTransfer(receiverOfUnderlying, amount);
}
emit Burn(from, receiverOfUnderlying, amount, index);

Impact

cost more gas for nothing

Tools Used

Manual Review

Recommendations

update the user index just one Time

Updates

Lead Judging Commences

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

Give us feedback!