veToken Finance contest - delfin454000's results

Lock more veAsset permanently.

General Information

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

veToken Finance

Findings Distribution

Researcher Performance

Rank: 48/71

Findings: 2

Award: $152.34

🌟 Selected for report: 0

🚀 Solo Findings: 0

Typos

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L31

    // platoform fee

Change platoform to platform

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L148

        //reward factory only allow this to be called once even if owner

Change allow to allows

The same typo (seperate) occurs in both lines below:

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L363

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L414

Example:

        //some gauges claim rewards when depositing, stash them in a seperate contract until next claim

Change separate to separate in both cases

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeAssetDepositor.sol#L93

        //increase ammount

Change ammount to amount

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeAssetDepositor.sol#L124

    //can locking immediately or defer locking to someone else by paying a fee.

Change locking immediately to lock immediately

Issue: Update sensitive terms

Explanation: Terms incorporating "white," "black," "master" or "slave" are potentially problematic. Substituting more neutral terminology is becoming common practice

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L204

        //fees dont apply until whitelist+veVeAsset lock begins so will report

Suggestion: Change whitelist to allowlist

#0 - GalloDaSballo

2022-07-07T00:02:02Z

Typos

Valid NC

Issue: Update sensitive terms

Valid NC

#1 - GalloDaSballo

2022-07-07T00:02:05Z

2NC

Issue: Use of '&&' within a require function Explanation: Splitting the require into separate requires instead of using '&&' will save gas

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L261

        require(msg.sender == poolManager && !isShutdown, "!add");

Recommendation:

        require(msg.sender == poolManager, "!auth");
        require(!isShutdown, "shutdown");

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L262

        require(_gauge != address(0) && _lptoken != address(0), "!param");

Recommendation:

        require(_gauge != address(0), "!param");
        require(_lptoken != address(0), "!param");

Issue: Should use != 0 instead of > 0 in a require statement if variable is an unsigned integer

Explanation: != 0 should be used where possible since > 0 costs more gas

Identical require occurs in all five lines below:

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L173

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L196

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L210

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L234

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L253

        require(_amount > 0, "RewardPool : Cannot stake 0");

Change _amount > 0 to _amount != 0 in all cases

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeAssetDepositor.sol#L132

        require(_amount > 0, "!>0");

Change _amount > 0 to _amount != 0

Issue: Variables should not be initialized to their default values

Explanation: For example, initializing uint variables to their default value of zero is unnecessary and costs gas

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L66

    uint256 public periodFinish = 0;

Change to uint256 public periodFinish;

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L67

    uint256 public rewardRate = 0;

Change to uint256 public rewardRate;

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L70

    uint256 public queuedRewards = 0;

Change to uint256 public queuedRewards;

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L71

    uint256 public currentRewards = 0;

Change to uint256 public currentRewards;

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L72

    uint256 public historicalRewards = 0;

Change to uint256 public historicalRewards;

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeAssetDepositor.sol#L28

    uint256 public incentiveVeAsset = 0;

Change to uint256 public incentiveVeAsset;

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L227

        uint256 _balance = 0;

Change to uint256 _balance;

Issue: Array length should not be looked up in every iteration of a for loop

Explanation: Calculating the array length costs gas

Recommendation: Read the length of the array from memory before executing the loop. In addition, do not initialize 'i' to zero (its default value) and use ++i instead of i++ since this is also cheaper

There are five for loops initialized using identical code in BaseRewardPool.sol The array length should be retrieved first, as shown in the recommendation below. The recommendation also includes the other gas-saving suggestions:

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L176

        for (uint256 i = 0; i < extraRewards.length; i++) {

Suggestion:

        uint256 totalExtraRewards = extraRewards.length; 
        for (uint256 i; i < totalExtraRewards; ++i) {

The remaining for loops in BaseRewardPool.solshould receive the same treatment:

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L199

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L218

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L245

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L282

The following for loops should also be modified similarly:

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L329

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L148

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L281

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L217

#0 - GalloDaSballo

2022-07-14T01:57:08Z

Will save less than 1k gas

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter