Core Contracts

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

Gas Inefficiencies Due to Redundant Storage Reads in function notifyRewardAmount() in BaseGauge.sol

Summary

The function notifyRewardAmount redundantly checks amount > periodState.emission both in notifyRewardAmount() and again inside notifyReward(), leading to gas wastage.

Vulnerability Details

Redundant Validation of amount > periodState.emission

  • The condition if (amount > periodState.emission) revert RewardCapExceeded(); is checked twice—once in notifyRewardAmount() and again inside notifyReward().

  • This wastes gas by performing the same validation more than once.

function notifyRewardAmount(uint256 amount) external override onlyController updateReward(address(0)) { //
if (amount > periodState.emission) revert RewardCapExceeded();// unnecessary check done in next call
rewardRate = notifyReward(periodState, amount, periodState.emission, getPeriodDuration()); // same check done once again
periodState.distributed += amount;
uint256 balance = rewardToken.balanceOf(address(this));
if (rewardRate * getPeriodDuration() > balance) {
revert InsufficientRewardBalance();
}
lastUpdateTime = block.timestamp;
emit RewardNotified(amount);
}
function notifyReward(
PeriodState storage state,
uint256 amount,
uint256 maxEmission,
uint256 periodDuration
) internal view returns (uint256) {
if (amount > maxEmission) revert RewardCapExceeded(); // this is the same check as above
if (amount + state.distributed > state.emission) {
revert RewardCapExceeded();
}
uint256 rewardRate = amount / periodDuration;
if (rewardRate == 0) revert ZeroRewardRate();
return rewardRate;
}

Impact

Increased Gas Costs: The contract consumes more gas than necessary due to redundant calculations and storage reads.

Tools Used

Manual Review

Recommendations

Since notifyReward() already checks this condition, remove the extra validation in notifyRewardAmount()

-- if (amount > maxEmission) revert RewardCapExceeded();

Updates

Lead Judging Commences

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.