-
Notifications
You must be signed in to change notification settings - Fork 1
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 #97
Comments
Modifiers generate a lot of gas cost (Disputed)This optimizes the deployment costs but reduces the readability of the code. Instead of using a modifier, a private view function could be used and it would not generate gas costs (Disputed)This optimizes the deployment costs but reduces the readability of the code. |
These operations can be unchecked since it is not possible to generate an underflow (Disputed)
We can’t guarantee that the balance after is more/equal than before or the other way around (with an exotic token). |
Using Errors in solidity can reduce the deployment gas cost. (Duplicated) |
It is not necessary to initialize variables to their default value (Duplicated)Duplicated of #2 at For loop optimizaion use a for loop with i++ instead of ++i unchecked (Duplicated)Duplicated of #2 at For loop optimizaion |
Nested Factory.sol
L66/99/107/122/125/153/160/161/168/169/191/250/251/252/286/288/289/312/313/330/331/359/379/406/407 /428/469/495/543/544/551/612/656 - It uses require but using Errors in solidity can reduce the deployment gas cost.
L98/106 - Modifiers generate a lot of gas cost, which can be modified by a private view function.
L124/136/196/256/315/333/369/412/651 - It is not necessary to initialize variables to their default value, this generates an extra gas cost (-2246 gas cost/ within a cycle for -19500 gas cost).
L124/136/196/256/315/333/369/412/651 - use a for loop with i++ instead of ++i unchecked = (in 10 iterations -21,136, in 100 iterations -32,656 gas).
L124/651- Instead of traversing an array and obtaining its length, directly obtain the length in a variable in memory and use it within the for loop.
L138 - Instead of doing a "variable - 1" or "variable + 1" operation, it is less expensive to do: ++variable or --variable.
OperatorResolver.sol
L27/39/57- It uses require but using Errors in solidity can reduce the deployment gas cost.
L40/60/75 - use a for loop with i++ instead of ++i unchecked = (in 10 iterations -21,136, in 100 iterations -32,656 gas).
L40/60/75 - It is not necessary to initialize variables to their default value, this generates an extra gas expense (-2246 gas cost/ within a cycle for -19500 gas cost).
L57/60/75 - If a local variable is generated, instead of using the length of an array inside the for, less gas is generated.
MixinOperatorResolver.sol
L23/77 - It uses require but using Errors in solidity can reduce the deployment gas cost.
L37/56 - use a for loop with i++ instead of ++i unchecked = (in 10 iterations -21,136, in 100 iterations -32,656 gas).
L37/56 - It is not necessary to initialize variables to their default value, this generates an extra gas expense (-2246 gas cost/ within a cycle for -19500 gas cost).
L37/56 - If a local variable is generated, instead of using the length of an array inside the for, less gas is generated.
OwnableProxyDelegation.sol
L25/26/27/41/57 - It uses require but using Errors in solidity can reduce the deployment gas cost.
L40 - Instead of using a modifier, a private view function could be used and it would not generate gas costs.
BeefyVaultOperator.sol
L18 - use a for loop with i++ instead of ++i unchecked = (in 10 iterations -21,136, in 100 iterations -32,656 gas).
L52/53/93/94 - These operations can be unchecked since it is not possible to generate an underflow.
BeefyZapBiswapLPVaultOperator.sol
L23/52/54/64/65/97/99/108/109/142/187/198/271/272 - It uses require but using Errors in solidity can reduce the deployment gas cost.
L27 - use a for loop with i++ instead of ++i unchecked = (in 10 iterations -21,136, in 100 iterations -32,656 gas).
L106/107 - These operations can be unchecked since it is not possible to generate an underflow.
StakingLPVaultHelpers.sol
The text was updated successfully, but these errors were encountered: