Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas Optimizations #85

Open
code423n4 opened this issue Apr 27, 2022 · 0 comments
Open

Gas Optimizations #85

code423n4 opened this issue Apr 27, 2022 · 0 comments
Labels

Comments

@code423n4
Copy link
Contributor

  1. ++i is less expensive than i++ (https://github.com/fei-protocol/xTRIBE/blob/master/src/xTRIBE.sol#L99 and https://github.com/fei-protocol/flywheel-v2/blob/main/src/rewards/FlywheelGaugeRewards.sol#L189)

  2. !=0 is cheaper and has the same effect as >0, since they’re uint variables (https://github.com/fei-protocol/flywheel-v2/blob/main/src/FlywheelCore.sol#L167 and https://github.com/fei-protocol/flywheel-v2/blob/main/src/FlywheelCore.sol#L218)

  3. In these lines x – x % y has the same effect as ( x / x ) * y and saves about 26 gas from remix calculations (This optimization can be also made when calculating the after multiple, as x + y - x % y)
    https://github.com/fei-protocol/flywheel-v2/blob/main/src/rewards/FlywheelGaugeRewards.sol#L103
    https://github.com/fei-protocol/flywheel-v2/blob/main/src/rewards/FlywheelGaugeRewards.sol#L135

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Apr 27, 2022
code423n4 added a commit that referenced this issue Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants