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 #77

Open
code423n4 opened this issue Jun 14, 2022 · 0 comments
Open

Gas Optimizations #77

code423n4 opened this issue Jun 14, 2022 · 0 comments
Labels
bug Something isn't working G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

G-1 Don't Initialize Variables with Default Value
Explicitly initializing a variable with it's default value costs unnecesary gas.
BridgeFacet.sol L#68
StableSwapFacet.sol L#415
VersionFacet.sol L#16
StableSwap.sol L#81
ConnextPriceOracle.sol L#176

G-2 Caching Array Length outside of loops saves gave per iteration
It saves reading it on each iteration, as long as the array's length is not changed during the loop.
ConnextPriceOracle.sol L#176
StableSwap.sol L#81
StableSwapFacet.sol L#415

G-3 Using != 0 instead of > 0 for Unsigned Integers Comparisons
It's cheaper using != 0 when dealing with unsigned integers types`
[StableSwap.sol L#82]https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/connext/helpers/StableSwap.sol#L8:~:text=i%2B%2B)%20%7B-,if%20(i%20%3E%200)%20%7B,-//%20Check%20if%20index

ConnextPrice Oracle L#150

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

No branches or pull requests

1 participant