Omniscia AmpleSense Audit

StakingERC20 Code Style Findings

StakingERC20 Code Style Findings

SER-01C: Variable Mutability Specifiers

TypeSeverityLocation
Gas OptimizationInformationalStakingERC20.sol:L16, L17, L25, L26

Description:

The linked variables are assigned to only once during the contract's constructor.

Example:

contracts/StakingERC20.sol
14/// @dev handle to access ERC20 token token contract to make transfers
15IERC20 private _token;
16Distribute public staking_contract_eth;
17Distribute public staking_contract_token;
18
19event ProfitToken(uint256 amount);
20event ProfitEth(uint256 amount);
21event StakeChanged(uint256 total, uint256 timestamp);
22
23constructor(IERC20 stake_token, IERC20 reward_token, uint256 decimals) {
24 _token = stake_token;
25 staking_contract_eth = new Distribute(decimals, IERC20(address(0)));
26 staking_contract_token = new Distribute(decimals, reward_token);
27}

Recommendation:

We advise them to be set as immutable greatly optimizing their read access gas cost.

Alleviation:

Both variables are now set as immutable optimizing the codebase.