Platform: Code4rena
Start Date: 26/05/2022
Pot Size: $75,000 USDT
Total HM: 31
Participants: 71
Period: 7 days
Judge: GalloDaSballo
Total Solo HM: 18
Id: 126
League: ETH
Rank: 28/71
Findings: 2
Award: $544.82
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0x29A, 0xDjango, 0xNazgul, 0xf15ers, BouSalman, Chom, Deivitto, Dravee, ElKu, FSchmoede, Funen, GimelSec, Hawkeye, MiloTruck, Picodes, SecureZeroX, SmartSek, TerrierLover, WatchPug, _Adam, asutorufos, berndartmueller, c3phas, catchup, cccz, cogitoergosumsw, cryptphi, csanuragjain, delfin454000, dipp, ellahi, gzeon, hansfriese, horsefacts, hyh, kirk-baird, minhquanym, oyc_109, pauliax, reassor, robee, sashik_eth, shenwilly, simon135, sorrynotsorry, sseefried, unforgiven, xiaoming90, z3s
492.75 USDT - $492.75
Low
Contract BaseRewardPool
defines BLOCKS_PER_YEAR
that uses number of blocks a day multiplied by 365. This is inaccurate since for every year there is 365.25 days so the correct calcuation should be:
uint256 constant BLOCKS_PER_YEAR = BLOCKS_PER_DAY * 36525 / 100;
Manual Review / VSCode
It is recommended to use following calculation:
uint256 constant BLOCKS_PER_YEAR = BLOCKS_PER_DAY * 36525 / 100;
Low
Function VeTokenMinter.mint
does not follow checks-effects-interactions pattern which might lead to reentrancy attacks.
VeTokenMinter.sol
:
(..) veToken.safeTransfer(_to, _amount); totalSupply += _amount;
VeTokenMinter.sol
:
Manual Review / VSCode
It is recommended to first set the effects and then perform interactions such as external calls.
Low
Multiple contracts do not check for zero addresses which might lead to loss of funds, failed transactions and can break the protocol functionality.
VeTokenMinter.sol
:
veTokenAddress
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L26_newOperator
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L32_to
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L48_destination
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L77VeAssetDepositor.sol
:
_staker
, _minter
, _veAsset
, _escrow
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeAssetDepositor.sol#L39-L42_feeManager
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeAssetDepositor.sol#L53VoterProxy.sol
:
_veAsset
, _escrow
, _gaugeProxy
, _minter
, _escrowModle
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L43-L46_owner
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L62_operator
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L67_depositor
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L77_to
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L275Booster.sol
:
_staker
, _minter
, _veAsset
, _feeDistro
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L105-L108_owner
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L123_feeM
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L129_poolM
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L135_rfactory
, _sfactory
, _tfactory
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L142-L144_arb
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L162_voteDelegate
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L168_rewards
, _stakerRewards
, _stakerLockRewards
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L175-L177_treasury
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L243_to
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L445_address
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L600BaseRewardPool.sol
:
_for
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L195VE3DRewardPool.sol
:
stakingToken_
, rewardManager_
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L96_rewardToken
, _veAssetDeposits
, _ve3TokenRewards
, _ve3Token
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L103-L106_newOperator
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L114_operator
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L118_for
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L233_rewardToken
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L341_rewardToken
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L367Manual Review / VSCode
It is recommended to add zero address checks for listed parameters.
Low
Multiple contracts are not implementing events for critical functions. Lack of events makes it difficult for off-chain applications to monitor the protocol.
VeTokenMinter.sol
:
addOperator
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L32removeOperator
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L36updateveAssetWeight
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L41mint
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L48VoterProxy.sol
:
setOwner
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L62setOperator
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L67setDepositor
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L77setStashAccess
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L83deposit
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L91withdraw
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L109withdraw
(another withdraw) function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L123createLock
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L150increaseAmount
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L158increaseTime
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L166release
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L172voteGaugeWeight
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L207claimVeAsset
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L224claimRewards
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L256claimFees
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L262Booster.sol
:
setFeeInfo
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L193earmarkRewards
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L569earmarkFees
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L576rewardClaimed
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L598VE3DRewardPool.sol
:
addReward
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L102addOperator
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L114removeOperator
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L118addExtraReward
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L134clearExtraReward
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L141donate
function event - https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L336Manual Review / VSCode
It is recommended to add missing events to listed functions.
Low
Changing critical addresses such as ownership should be a two-step process where the first transaction (from the old/current address) registers the new address (i.e. grants ownership) and the second transaction (from the new address) replaces the old address with the new one. This gives an opportunity to recover from incorrect addresses mistakenly used in the first step. If not, contract functionality might become inaccessible.
VeTokenMinter.sol
:
owner
from Ownable
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L10VeAssetDepositor.sol
:
feeManager
via setFeeManager
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeAssetDepositor.sol#L53-L57VoterProxy.sol
:
owner
via setOwner
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L62-L65Booster.sol
:
owner
via setOwner
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L123-L127feeManager
via setFeeManager
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L129-L133poolManager
via setPoolManager
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L135-L139VE3DRewardPool.sol
:
owner
from Ownable
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L53Manual Review / VSCode
It is recommended to implement two-step process for changing critical addresses.
Non-Critical
Contract VeAssetDepositor
is using number of seconds in one day multiplied by 7 to define time units such as week. This might lead to confusion and accidental mistakes.
VeAssetDepositor.sol:18: uint256 private constant WEEK = 7 * 86400;
Manual Review / VSCode
It is recommended to use native time units such as seconds, minutes, hours, days, weeks and years.
Non-Critical
Defining big numbers that consists of many digits might lead to accidential errors and mistakes.
VeTokenMinter.sol
:
1e6
instead of 1000000
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L15Manual Review / VSCode
It is recommended to use scientific notation.
Non-Critical
Multiple contracts do not check for return values of executed functions. This might lead to accidents and errors since the created transaction is valid but the underlying code did not execute properly.
VeTokenMinter.sol
:
add
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L33remove
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L37VE3DRewardPool.sol
:
add
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L111add
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L115remove
- https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L119Manual Review / VSCode
It is recommended to check the return vallues of executed functions.
Non-Critical
Events should index addresses which helps off-chain applications in monitoring the protocol.
VeTokenMinter.sol:24: event Withdraw(address destination, uint256 amount);
Manual Review / VSCode
It is recommended to add indexing to address
type parameters.
Non-Critical
Protocol uses boolean values in if
and require
expressions.
VoterProxy.sol:70: operator == address(0) || IDeposit(operator).isShutdown() == true, VoterProxy.sol:110: require(stashPool[msg.sender] == true, "!auth"); VoterProxy.sol:113: if (protectedTokens[address(_asset)] == true) { Booster.sol:352: require(pool.shutdown == false, "pool is closed"); Booster.sol:498: require(pool.shutdown == false, "pool is closed"); VoterProxy.sol:93: if (protectedTokens[_token] == false) { VoterProxy.sol:96: if (protectedTokens[_gauge] == false) {
Manual Review / VSCode
It is recommended to remove boolean values from if
and require
expressions.
Non-Critical
Contracts are missing natspec comments which makes code more difficult to read and prone to errors.
BaseRewardPool.sol
Booster.sol
VE3DRewardPool.sol
VeAssetDepositor.sol
VeTokenMinter.sol
VoterProxy.sol
Manual Review / VSCode
It is recommended to add missing natspec comments.
#0 - GalloDaSballo
2022-07-08T00:44:57Z
Marking as NC because the solution will round off
Valid Low
Low
##Â 4. Missing events Valid NC
NC
##Â 6. Lack of using native time units Valid Refactoring
##Â 7. Use scientific notation R
Because those functions give a guarantee of inclusion and return false only if the operation bear no changes, I think this one is invalid
For that event, valid NC
Valid R
Valid NC
#1 - GalloDaSballo
2022-07-08T00:45:22Z
2L 3R 5NC
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0x29A, 0xKitsune, 0xNazgul, 0xf15ers, 0xkatana, Cityscape, Dravee, ElKu, FSchmoede, Funen, GalloDaSballo, Hawkeye, Kaiziron, MiloTruck, Randyyy, RoiEvenHaim, Ruhum, SecureZeroX, SmartSek, TerrierLover, TomJ, Tomio, WatchPug, Waze, _Adam, asutorufos, c3phas, catchup, cogitoergosumsw, delfin454000, ellahi, fatherOfBlocks, gzeon, hansfriese, horsefacts, jonatascm, minhquanym, oyc_109, pauliax, reassor, robee, sach1r0, saian, sashik_eth, simon135, z3s
52.0655 USDT - $52.07
Function VeAssetDepositor.setFees
checks if _lockIncentive
uint variable is bigger or equal to zero. That kind of check is obsolete since it returns true for all uint variables.
VeAssetDepositor.sol:62 if (_lockIncentive >= 0 && _lockIncentive <= 30) {
Manual Review / VSCode
It is recommended to just check if _lockIncentive <= 30
.
Caching the array length outside a loop saves reading it on each iteration, as long as the array's length is not changed during the loop.
Booster.sol:329: for (uint256 i = 0; i < poolInfo.length; i++) { BaseRewardPool.sol:176: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:199: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:218: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:245: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:282: for (uint256 i = 0; i < extraRewards.length; i++) { VE3DRewarDPool.sol:148: for (uint256 i = 0; i < rewardTokens.length(); i++) { VE3DRewarDPool.sol:256: uint256 length = extraRewards.length; VE3DRewarDPool.sol:281: for (uint256 i = 0; i < rewardTokens.length(); i++) { VoterProxy.sol:217: for (uint256 i = 0; i < _tokenVote.length; i++) {
Manual Review / VSCode
It is recommended to cache the array length outside of the for
loop.
Usage of custom errors reduces the gas cost.
Contracts that could be using custom errors:
BaseRewardPool.sol:122: require(msg.sender == rewardManager, "!authorized"); BaseRewardPool.sol:123: require(_reward != address(0), "!reward setting"); BaseRewardPool.sol:124: require(extraRewards.length < EXTRA_REWARD_POOLS, "!extra reward pools exceed"); BaseRewardPool.sol:132: require(msg.sender == rewardManager, "!authorized"); BaseRewardPool.sol:173: require(_amount > 0, "RewardPool : Cannot stake 0"); BaseRewardPool.sol:196: require(_amount > 0, "RewardPool : Cannot stake 0"); BaseRewardPool.sol:215: require(amount > 0, "RewardPool : Cannot withdraw 0"); BaseRewardPool.sol:301: require(msg.sender == operator, "!authorized"); Booster.sol:124: require(msg.sender == owner, "!auth"); Booster.sol:130: require(msg.sender == feeManager, "!auth"); Booster.sol:136: require(msg.sender == poolManager, "!auth"); Booster.sol:146: require(msg.sender == owner, "!auth"); Booster.sol:163: require(msg.sender == owner, "!auth"); Booster.sol:169: require(msg.sender == voteDelegate, "!auth"); Booster.sol:179: require(msg.sender == owner, "!auth"); Booster.sol:194: require(msg.sender == feeManager, "!auth"); Booster.sol:226: require(msg.sender == feeManager, "!auth"); Booster.sol:231: require(total <= MaxFees, ">MaxFees"); Booster.sol:244: require(msg.sender == feeManager, "!auth"); Booster.sol:261: require(msg.sender == poolManager && !isShutdown, "!add"); Booster.sol:262: require(_gauge != address(0) && _lptoken != address(0), "!param"); Booster.sol:309: require(msg.sender == poolManager, "!auth"); Booster.sol:326: require(msg.sender == owner, "!auth"); Booster.sol:350: require(!isShutdown, "shutdown"); Booster.sol:352: require(pool.shutdown == false, "pool is closed"); Booster.sol:360: require(gauge != address(0), "!gauge setting"); Booster.sol:448: require(msg.sender == rewardContract, "!auth"); Booster.sol:458: require(msg.sender == voteDelegate, "!auth"); Booster.sol:468: require(msg.sender == voteDelegate, "!auth"); Booster.sol:477: require(msg.sender == stash, "!auth"); Booster.sol:485: require(msg.sender == stash, "!auth"); Booster.sol:498: require(pool.shutdown == false, "pool is closed"); Booster.sol:570: require(!isShutdown, "shutdown"); Booster.sol:604: require(msg.sender == rewardContract || msg.sender == lockRewards, "!auth") VE3DRewardPool.sol:135: require(msg.sender == rewardManager, "!authorized"); VE3DRewardPool.sol:136: require(_reward != address(0), "!reward setting"); VE3DRewardPool.sol:142: require(msg.sender == rewardManager, "!authorized"); VE3DRewardPool.sol:210: require(_amount > 0, "RewardPool : Cannot stake 0"); VE3DRewardPool.sol:234: require(_amount > 0, "RewardPool : Cannot stake 0"); VE3DRewardPool.sol:253: require(_amount > 0, "RewardPool : Cannot withdraw 0"); VE3DRewardPool.sol:342: require(operators.contains(_msgSender()), "!authorized"); VeAssetDepositor.sol:54: require(msg.sender == feeManager, "!auth"); VeAssetDepositor.sol:60: require(msg.sender == feeManager, "!auth"); VeAssetDepositor.sol:69: require(msg.sender == feeManager, "!auth"); VeAssetDepositor.sol:132: require(_amount > 0, "!>0"); VeTokenMinter.sol:42: require(operators.contains(veAssetOperator), "not an veAsset operator"); VeTokenMinter.sol:49: require(operators.contains(_msgSender()), "not an operator"); VoterProxy.sol:63: require(msg.sender == owner, "!auth"); VoterProxy.sol:68: require(msg.sender == owner, "!auth"); -- VoterProxy.sol:69: require( operator == address(0) || IDeposit(operator).isShutdown() == true, "needs shutdown" ); -- VoterProxy.sol:78: require(msg.sender == owner, "!auth"); VoterProxy.sol:84: require(msg.sender == operator, "!auth"); VoterProxy.sol:92: require(msg.sender == operator, "!auth"); VoterProxy.sol:110: require(stashPool[msg.sender] == true, "!auth"); VoterProxy.sol:128: require(msg.sender == operator, "!auth"); VoterProxy.sol:139: require(msg.sender == operator, "!auth"); VoterProxy.sol:151: require(msg.sender == depositor, "!auth"); VoterProxy.sol:159: require(msg.sender == depositor, "!auth"); VoterProxy.sol:167: require(msg.sender == depositor, "!auth"); VoterProxy.sol:173: require(msg.sender == depositor, "!auth"); VoterProxy.sol:186: require(msg.sender == operator, "!auth"); VoterProxy.sol:211: require(msg.sender == operator, "!auth"); VoterProxy.sol:225: require(msg.sender == operator, "!auth"); VoterProxy.sol:257: require(msg.sender == operator, "!auth"); VoterProxy.sol:263: require(msg.sender == operator, "!auth"); VoterProxy.sol:279: require(msg.sender == operator, "!auth"); VoterProxy.sol:282: require(success, "!success");
Manual Review / VSCode
It is recommended to add custom errors to listed contracts.
++i
or --i
costs less gas compared to i++
, i += 1
, i--
or i -= 1
for unsigned integer as pre-increment/pre-decrement is cheaper (about 5 gas per iteration).
BaseRewardPool.sol:176: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:199: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:218: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:245: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:282: for (uint256 i = 0; i < extraRewards.length; i++) { Booster.sol:329: for (uint256 i = 0; i < poolInfo.length; i++) { VE3DRewardPool.sol:148: for (uint256 i = 0; i < rewardTokens.length(); i++) { VE3DRewardPool.sol:214: for (uint256 i = 0; i < length; i++) { VE3DRewardPool.sol:238: for (uint256 i = 0; i < length; i++) { VE3DRewardPool.sol:257: for (uint256 i = 0; i < length; i++) { VE3DRewardPool.sol:281: for (uint256 i = 0; i < rewardTokens.length(); i++) { VE3DRewardPool.sol:326: for (uint256 i = 0; i < length; i++) { VoterProxy.sol:217: for (uint256 i = 0; i < _tokenVote.length; i++) {
Manual Review / VSCode
It is recommended to use ++i
or --i
instead of i++
, i += 1
, i--
or i -= 1
to increment value of an unsigned integer variable.
Starting from solidity 0.8.0
there is built-in check for overflows/underflows. This mechanism automatically checks if the variable overflows or underflows and throws an error. Multiple contracts use increments that cannot overflow but consume additional gas for checks.
BaseRewardPool.sol:176: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:199: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:218: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:245: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:282: for (uint256 i = 0; i < extraRewards.length; i++) { Booster.sol:329: for (uint256 i = 0; i < poolInfo.length; i++) { VE3DRewardPool.sol:148: for (uint256 i = 0; i < rewardTokens.length(); i++) { VE3DRewardPool.sol:214: for (uint256 i = 0; i < length; i++) { VE3DRewardPool.sol:238: for (uint256 i = 0; i < length; i++) { VE3DRewardPool.sol:257: for (uint256 i = 0; i < length; i++) { VE3DRewardPool.sol:281: for (uint256 i = 0; i < rewardTokens.length(); i++) { VE3DRewardPool.sol:326: for (uint256 i = 0; i < length; i++) { VoterProxy.sol:217: for (uint256 i = 0; i < _tokenVote.length; i++) {
Manual Review / VSCode
It is recommended wrap incrementing with unchecked
block, for example: unchecked { ++i }
or unchecked { --i }
.
If a variable is not set/initialized, it is assumed to have the default value (0
for uint, false
for bool, address(0)
for addresses). Explicitly initializing it with its default value is an anti-pattern and waste of gas.
BaseRewardPool.sol:66: uint256 public periodFinish = 0; BaseRewardPool.sol:67: uint256 public rewardRate = 0; BaseRewardPool.sol:70: uint256 public queuedRewards = 0; BaseRewardPool.sol:71: uint256 public currentRewards = 0; BaseRewardPool.sol:72: uint256 public historicalRewards = 0; BaseRewardPool.sol:176: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:199: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:218: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:245: for (uint256 i = 0; i < extraRewards.length; i++) { BaseRewardPool.sol:282: for (uint256 i = 0; i < extraRewards.length; i++) { Booster.sol:329: for (uint256 i = 0; i < poolInfo.length; i++) { VE3DRewardPool.sol:148: for (uint256 i = 0; i < rewardTokens.length(); i++) { VE3DRewardPool.sol:214: for (uint256 i = 0; i < length; i++) { VE3DRewardPool.sol:238: for (uint256 i = 0; i < length; i++) { VE3DRewardPool.sol:257: for (uint256 i = 0; i < length; i++) { VE3DRewardPool.sol:281: for (uint256 i = 0; i < rewardTokens.length(); i++) { VE3DRewardPool.sol:326: for (uint256 i = 0; i < length; i++) { VeAssetDepositor.sol:28: uint256 public incentiveVeAsset = 0; VoterProxy.sol:217: for (uint256 i = 0; i < _tokenVote.length; i++) { VoterProxy.sol:227: uint256 _balance = 0;
Manual Review / VSCode
It is recommended to remove explicit initializations with default values.
When dealing with unsigned integer types, comparisons with != 0
are cheaper than with > 0
.
BaseRewardPool.sol:173: require(_amount > 0, "RewardPool : Cannot stake 0"); BaseRewardPool.sol:196: require(_amount > 0, "RewardPool : Cannot stake 0"); BaseRewardPool.sol:215: require(amount > 0, "RewardPool : Cannot withdraw 0"); BaseRewardPool.sol:273: if (reward > 0) { Booster.sol:517: if (veAssetBal > 0) { Booster.sol:526: if (treasury != address(0) && treasury != address(this) && platformFee > 0) { Booster.sol:541: if (_callIncentive > 0) { Booster.sol:551: if (_lockIncentive > 0) { Booster.sol:556: if (_stakerIncentive > 0) { Booster.sol:562: if (_stakerLockIncentive > 0) { Booster.sol:586: if (_lockFeesIncentive > 0) { Booster.sol:590: if (_stakerLockFeesIncentive > 0) { VE3DRewardPool.sol:210: require(_amount > 0, "RewardPool : Cannot stake 0"); VE3DRewardPool.sol:234: require(_amount > 0, "RewardPool : Cannot stake 0"); VE3DRewardPool.sol:253: require(_amount > 0, "RewardPool : Cannot withdraw 0"); VE3DRewardPool.sol:285: if (reward > 0) { VeAssetDepositor.sol:89: if (veAssetBalance > 0) { VeAssetDepositor.sol:117: if (incentiveVeAsset > 0) { VeAssetDepositor.sol:132: require(_amount > 0, "!>0"); VeAssetDepositor.sol:138: if (incentiveVeAsset > 0) { VoterProxy.sol:100: if (balance > 0) {
Manual Review / VSCode
It is recommended to use != 0
instead of > 0
.
#0 - GalloDaSballo
2022-07-18T23:25:33Z
Saves less than 500 gas