Omniscia Alliance Block Audit
RewardsPoolBase Static Analysis Findings
RewardsPoolBase Static Analysis Findings
RPB-01S: State Mutability Optimization
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | RewardsPoolBase.sol:L81, L90, L97 |
Description:
The linked functions can have their state mutability restricted to view
.
Example:
contracts/RewardsPoolBase.sol
81function onlyInsideBlockBounds() internal {82 uint256 currentBlock = _getBlock();83 require(84 currentBlock > startBlock,85 "S::Staking has not yet started"86 );87 require(currentBlock <= endBlock, "Stake::Staking has finished");88}89
90function onlyFactory(address sender) public {91 require(92 msg.sender == rewardsPoolFactory,93 "Caller is not Factory contract"94 );95}96
97function onlyUnderStakeLimit(address staker, uint256 newStake) internal {98 UserInfo storage user = userInfo[staker];99 require(user.amountStaked.add(newStake) <= stakeLimit, "oUSL::Stake limit reached");100 require(totalStaked.add(newStake) <= contractStakeLimit, "oUSL::Contract Stake limit reached");101}
Recommendation:
We advise it to be done so to optimize the gas cost involved in their execution.
Alleviation:
The state mutability of the function was properly set to view
.