20,000 USDC
View results
Submission Details
Severity: gas

## [G-19] State varaibles only set in the Constructor should be declared Immutable

Summary

[G-19] State varaibles only set in the Constructor should be declared Immutable

Avoids a Gsset (20000 gas) in the constructor, and replaces the first access in each transaction (Gcoldsload - 2100 gas) and each access thereafter (Gwarmacces - 100 gas) with a PUSH32 (3 gas).

While strings are not value types, and therefore cannot be immutable/constant if not hard-coded outside of the constructor, the same behavior can be achieved by making the current contract abstract with virtual functions for the string accessors, and having a child contract override the functions with the hard-coded implementation-specific values.

file: /src/Lender.sol
/// @audit ' feeReceiver ' on line 67
74 feeReceiver = msg.sender;

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

file: /src/utils/Ownable.sol
/// @audit ' owner ' on line 8
15 owner = _owner;

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

Support

FAQs

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