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

use private for constant and immutable variables

Summary

Declare all constant and immutable variables as private

Vulnerability Details

The instances mentioned in above links have constant and immutable variables as public
By making them public it leads to more gas usage. All public variables result in free getter functions

Impact

uint256 public constant MAX_AUCTION_LENGTH = 3 days; // Lender.sol line 61 as one of the many examples
Take the above example public variable the compiler has to create non-payable getter functions for deployment calldata, and add another entry to the method ID table.If the variable is made private compiler does not have to create these free getter functions add this free getter function. The values of constants and immutables can be read directly instead from verified smart contract code

Tools Used

Manual Analysis

Recommendations

Ensure all instances in the links provided of public immutable or constant variables are made private see example below
Lender.sol line 61
uint256 public constant MAX_AUCTION_LENGTH = 3 days; -> uint256 private constant MAX_AUCTION_LENGTH = 3 days;

Support

FAQs

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