20,000 USDC
View results
Submission Details
Severity: gas

State variables only set in the constructor should be declared `immutable`

Summary

State variables only set in the constructor should be declared immutable

Vulnerability Details

Use immutable if you want to assign a permanent value at construction. Use constant if you already know the permanent value. Both get directly embedded in bytecode, saving SLOAD.
Variables only set in the constructor and never edited afterwards should be marked as immutable, as it would avoid the expensive storage-writing operation in the constructor (around 20_000 gas) and replace the expensive storage-reading operations (first time 2_100 gas, every other time 100 gas) to a less expensive value reading (3 gas)

67 address public feeReceiver;

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L67

8 address public owner;

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/utils/Ownable.sol#L8

Impact

Gas savings

Tools Used

Manual review

Recommendations

Set these variables as immutable

Support

FAQs

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