sherlock-audit / 2024-10-gamma-rewarder-judging

7 stars 3 forks source link

Joyous Pistachio Lark - [GAS-3] Use Custom Errors #243

Closed sherlock-admin3 closed 2 weeks ago

sherlock-admin3 commented 2 weeks ago

Joyous Pistachio Lark

Low/Info

[GAS-3] Use Custom Errors

[GAS-3] Use Custom Errors

Source Instead of using error strings, to reduce deployment and runtime cost, you should use Custom Errors. This would save both deployment and runtime cost.

Instances (24):

File: GammaRewarder.sol

115:         require(_hypervisor != address(0), "Zero address not allowed");

116:         require(_rewardToken != address(0), "Zero address not allowed");

117:         require(_endBlockNum > _startBlockNum, "Invalid block range");

118:         require(_startBlockNum > block.number && (_endBlockNum - _startBlockNum) <= MAX_DISTRIBUTION_BLOCKS, "Distribution start block number is less than current block number or the duration is greater than 4 weeks.");

119:         require(_amount > 0, "Distribution Amount has to be greater than zero.");

120:         require((_endBlockNum - _startBlockNum) % blocksPerEpoch == 0, "Distribution length must be multiples of blocks per epoch");

121:         require(isWhitelistedRewardToken[_rewardToken] == 1, "Reward token has to be whitelisted.");

122:         require(IERC20(_rewardToken).allowance(msg.sender, address(this)) >= _amount, "Incentivisor did not approve enough tokens to Reward contract.");

123:         require(protocolFeeRecipient != address(0), "Zero address not allowed");

151:         require(vkHashes[_vkHash], "invalid vk");

165:         require(startBlock < endBlock && (endBlock - startBlock) % blocksPerEpoch == 0, "Claim period must be valid");

166:         require(startBlock >= params.startBlockNumber && endBlock <= params.endBlockNumber, "Claim range has to include distribution range.");

167:         require(lpTokenAddress == params.hypervisor && rewardTokenAddress == params.rewardToken && distributionAmountPerEpoch == params.distributionAmountPerEpoch, "Distribution params must match");

168:         require(totalRewardAmount > 0, "Rewards do not exist for you.");

172:         require(claim.amount == 0 , "Already claimed reward.");

188:         require(vkHashes[_vkHash], "invalid vk");

202:         require(startBlock < endBlock && (endBlock - startBlock) % blocksPerEpoch == 0, "Claim period must be valid");

203:         require(startBlock >= params.startBlockNumber && endBlock <= params.endBlockNumber, "Claim range has to include distribution range.");

204:         require(lpTokenAddress == params.hypervisor && rewardTokenAddress == params.rewardToken && distributionAmountPerEpoch == params.distributionAmountPerEpoch, "Distribution params must match");

205:         require(totalRewardAmount > 0, "Rewards do not exist for you.");

209:         require(claim.amount == 0 , "Already claimed reward.");

247:         require(_protocolFee < BASE_9, "Protocol fee is based on 10**9");
File: brevis/lib/BrevisApp.sol

24:         require(appCommitHash == keccak256(_appCircuitOutput), "failed to open output commitment");
File: brevis/lib/Lib.sol

82:         require(txType == 2, "not a DynamicFeeTxType");