code-423n4 / 2022-01-trader-joe-findings

2 stars 0 forks source link

Mark unchanging variables immutable #274

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

Czar102

Vulnerability details

Impact

Storage variable reads are gas-intensive, mark unchanging variables immutable in the case of non-upgradeable contracts.

Examples

RochetJoeStaking.sol#33: IERC20Upgradeable public joe;
RochetJoeStaking.sol#41: RocketJoeToken public rJoe;
RochetJoeFactory.sol#23: address public override rJoe;
RochetJoeFactory.sol#25: address public override wavax;

Tools Used

Manual analysis

cryptofish7 commented 2 years ago

Duplicate of #62

dmvt commented 2 years ago

This one is partially valid. RocketJoeStaking is proxied so you can't make the variables immutable. RocketJoeFactory rJoe can be set to a different value after the constructor is called.

RocketJoeFactory wavax, however, is only set during the constructor and is never changed. Using immutable here would save some gas.