code-423n4 / 2022-01-yield-findings

1 stars 0 forks source link

using ++rewardsLength can be saving more gas #50

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

Funen

Vulnerability details

Impact

Expensive Gas

Proof of Concept

rewardsLength += 1; the implementation can be saving more gas by using ++rewardsLength.

Tools Used

Manual Review

Recommended Mitigation Steps

            if (rewardsLength == 0) {
            RewardType storage reward = rewards.push();
            reward.reward_token = crv;
            reward.reward_pool = mainPool;
            rewardsLength += 1;
        }

change to

        if (rewardsLength == 0) {
            RewardType storage reward = rewards.push();
            reward.reward_token = crv;
            reward.reward_pool = mainPool;
            ++rewardsLength;
        }
alcueca commented 2 years ago

Duplicate of #14