"constants" expressions are expressions. As such, keccak assigned to a constant variable are re-computed at each use of the variable, which will consume gas unnecessarily. To save gas, Changing the variable from constant to immutable will make the computation run only once and therefore save gas.
Handle
Dravee
Vulnerability details
Impact
Increased gas costs
Proof of Concept
"constants" expressions are expressions. As such,
keccak
assigned to aconstant
variable are re-computed at each use of the variable, which will consume gas unnecessarily. To save gas, Changing the variable fromconstant
toimmutable
will make the computation run only once and therefore save gas.Places with the issue: https://github.com/code-423n4/2021-12-amun/blob/main/contracts/basket/contracts/facets/Basket/LibBasketStorage.sol#L7-L8 https://github.com/code-423n4/2021-12-amun/blob/main/contracts/basket/contracts/facets/Call/LibCallStorage.sol#L5-L6 https://github.com/code-423n4/2021-12-amun/blob/main/contracts/basket/contracts/facets/ERC20/LibERC20Storage.sol#L5-L9 https://github.com/code-423n4/2021-12-amun/blob/main/contracts/basket/contracts/facets/shared/Reentry/LibReentryProtectionStorage.sol#L5-L6
Tools Used
VS Code
Recommended Mitigation Steps
Change the variable from
constant
toimmutable