We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Removing unused function parameters can save gas. And it improves code clarity.
IHook.hook() DepositHook.hook() WithdrawHook.hook()
Remove unused function parameter initialAmount.
initialAmount
Reading array length at each iteration of the loop takes 6 gas (3 for mload and 3 to place memory_offset) in the stack.
Caching the array length in the stack saves around 3 gas per iteration.
AccountAccessController.allowAccounts() AccountAccessController.blockAccounts()
AccountAccessController.allowAccounts()
uint length = _accounts.length; for (uint256 _i = 0; _i < length; _i++) { _allowedAccounts[_allowedAccountsIndex][_accounts[_i]] = true; emit AccountAllowed(_accounts[_i]); }
AccountAccessController.blockAccounts()
uint length = _accounts.length; for (uint256 _i = 0; _i < length; _i++) { _blockedAccounts[_blockedAccountsIndex][_accounts[_i]] = true; emit AccountBlocked(_accounts[_i]); }
Reading the same variable from storage multiple times consumes unnecessary gas because SLOADs are expensive.
Repetitive storage access of variable: _accounts[_i]
_accounts[_i]
1st access - L45 2nd access - L46
1st access - L56 2nd access - L57
Read the variable from storage once and store it in a temporary variable in memory for repetitive read access.
Removing unused named return variables can reduce gas usage and improve code clarity.
Remove the unused named return variables or use them instead of creating additional variables.
PrePOMarketFactory.sol
L98 unnecessary named returns _newLongToken & _newShortToken
_newLongToken
_newShortToken
The text was updated successfully, but these errors were encountered:
berndartmueller issue #112
9f7376a
Unused parameter - duplicate of #4 Caching recs duplicate of #5 and #18 Unused named returns is valid and we will take into consideration.
Sorry, something went wrong.
No branches or pull requests
Gas Optimizations
Removing unused function parameter can save gas
Description
Removing unused function parameters can save gas. And it improves code clarity.
Findings
IHook.hook()
DepositHook.hook()
WithdrawHook.hook()
Recommended mitigation steps
Remove unused function parameter
initialAmount
.An array's length should be cached to save gas in for-loops
Reading array length at each iteration of the loop takes 6 gas (3 for mload and 3 to place memory_offset) in the stack.
Caching the array length in the stack saves around 3 gas per iteration.
Findings
AccountAccessController.allowAccounts()
AccountAccessController.blockAccounts()
Recommended mitigation steps
AccountAccessController.allowAccounts()
AccountAccessController.blockAccounts()
Use a temporary variable to cache repetitive storage reads
Reading the same variable from storage multiple times consumes unnecessary gas because SLOADs are expensive.
Findings
AccountAccessController.allowAccounts()
Repetitive storage access of variable:
_accounts[_i]
1st access - L45
2nd access - L46
AccountAccessController.blockAccounts()
Repetitive storage access of variable:
_accounts[_i]
1st access - L56
2nd access - L57
Recommended mitigation steps
Read the variable from storage once and store it in a temporary variable in memory for repetitive read access.
Unused named returns can be removed
Description
Removing unused named return variables can reduce gas usage and improve code clarity.
Recommended mitigation steps
Remove the unused named return variables or use them instead of creating additional variables.
Findings
PrePOMarketFactory.sol
L98 unnecessary named returns
_newLongToken
&_newShortToken
The text was updated successfully, but these errors were encountered: