Consider making some constants as non-public to save gas
Each function part of contract's external interface is part of the
function dispatch, i.e., every time a contract is called, it goes
through a switch statement (a set of eq ... JUMPI blocks in EVM)
matching the selector of each externally available functions with the
chosen function selector (the first 4 bytes of calldata).
This means that any unnecessary function that is part of contract's
external interface will lead to more gas for (almost) every single
function calls to the contract. There are several cases where constants
were made public. This is unnecessary; the constants can simply be read
from the verified contract, i.e., it is unnecessary to expose it with a
public function.
Examples
./contracts/v3/Harvester.sol:24: uint256 public constant ONE_HUNDRED_PERCENT = 10000;
./contracts/v3/Vault.sol:29: uint256 public constant MAX = 10000;
./contracts/v3/controllers/LegacyController.sol:20: uint256 public constant MAX = 10000;
./contracts/v3/strategies/BaseStrategy.sol:37: uint256 public constant ONE_HUNDRED_PERCENT = 10000;
./contracts/v3/Manager.sol:26: uint256 public constant PENDING_STRATEGIST_TIMELOCK = 7 days;
./contracts/v3/Manager.sol:27: uint256 public constant MAX_TOKENS = 256;
Handle
hrkrshnn
Vulnerability details
Consider making some constants as non-public to save gas
Each function part of contract's external interface is part of the function dispatch, i.e., every time a contract is called, it goes through a switch statement (a set of
eq ... JUMPI
blocks in EVM) matching the selector of each externally available functions with the chosen function selector (the first 4 bytes of calldata).This means that any unnecessary function that is part of contract's external interface will lead to more gas for (almost) every single function calls to the contract. There are several cases where constants were made public. This is unnecessary; the constants can simply be read from the verified contract, i.e., it is unnecessary to expose it with a public function.
Examples