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

1 stars 0 forks source link

Using pre-increment (++i) instead of post-increment (i++) can save gas #126

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

throttle

Vulnerability details

Impact

Gas savings

Proof of Concept

Using pre-increment instead of post-increment can save gas in following places:

ConvexStakingWrapper.addRewards()
ConvexStakingWrapper._calcCvxIntegral()
ConvexStakingWrapper._calcRewardIntegral()
ConvexStakingWrapper._checkpointAndClaim()
ConvexStakingWrapper.earned()
ConvexYieldWrapper.removeVault()
ConvexYieldWrapper._getDepositedBalance()

Tools Used

Manual review

Recommended Mitigation Steps

Change i++ to ++i

devtooligan commented 2 years ago

dup of #14