20,000 USDC
View results
Submission Details
Severity: gas
Valid

Using `private` rather than `public` for constants, saves gas

Summary

Using private rather than public for constants, saves gas

Vulnerability Details

If needed, the values can be read from the verified contract
source code, or if there are multiple values there can be a
single getter function that
returns a tuple
of the values of all currently-public constants.
Saves 3406-3606 gas in deployment gas due to the compiler
not having to create non-payable getter functions for deployment
calldata, not having to store the bytes of the value outside of
where it's used, and not adding another entry to the method ID table.

File: src/Fees.sol
16: ISwapRouter public constant swapRouter =

Link to code - https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Fees.sol

File: src/Staking.sol
29: IERC20 public immutable TKN;
31: IERC20 public immutable WETH;

Link to code - https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Staking.sol

Tools Used

Code Review

Recommendations

Use private rather than public for constants

Auditor

NeoCrao

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.