Elastic-Finance-DAO / eefi_contracts

0 stars 0 forks source link

[SDE-01C] Variable Mutability Specifier (Immutable) #104

Open stalker474 opened 3 weeks ago

stalker474 commented 3 weeks ago

SDE-01C: Variable Mutability Specifier (Immutable)

Type Severity Location
Gas Optimization StakingDoubleERC20.sol:L14

Description:

The linked variable is assigned to only once during the contract's constructor.

Example:

IERC20 private _token;
Distribute immutable public staking_contract_ohm;
Distribute immutable public staking_contract_eefi;

event ProfitOHM(uint256 amount);
event ProfitEEFI(uint256 amount);
event StakeChanged(uint256 total, uint256 timestamp);

constructor(IERC20 stake_token, uint256 stake_decimals, IERC20 eefi) {
    require(address(stake_token) != address(0), "StakingDoubleERC20: Invalid stake token");
    require(address(eefi) != address(0), "StakingDoubleERC20: Invalid eefi token");
    _token = stake_token;
    // we do not need to sanitize the decimals here because the Distribute contract will do it
    staking_contract_ohm = new Distribute(stake_decimals, 9, IERC20(0x64aa3364F17a4D01c6f1751Fd97C2BD3D7e7f1D5));
    staking_contract_eefi = new Distribute(stake_decimals, 18, eefi);
}

Recommendation:

We advise it to be set as immutable greatly optimizing its read-access gas cost.