Closed code423n4 closed 2 years ago
WatchPug
In LockeERC20, decimals is defined as an immutable variable while it's not configured as a parameter of the constructor. Thus, it can be declared as constant to save gas.
LockeERC20
decimals
https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/LockeERC20.sol#L25-L25
uint8 public immutable decimals;
https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/LockeERC20.sol#L56-L74
constructor( address depositToken, uint256 streamId, uint32 endStream ) { // locke + depositTokenName + streamId = lockeUSD Coin-1 name = string(abi.encodePacked("locke", ERC20(depositToken).name(), ": ", toString(streamId))); // locke + Symbol + streamId = lockeUSDC1 // TODO: we could have start_time+stream_duration+depositlocktime as maturity-date // i.e. lockeETH8-AUG-14-2022 symbol = string(abi.encodePacked("locke", ERC20(depositToken).symbol(), toString(streamId))); decimals = 18; transferStartTime = endStream; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); }
Change to:
uint8 public constant decimals = 18;
dupe of #231
Handle
WatchPug
Vulnerability details
In
LockeERC20
,decimals
is defined as an immutable variable while it's not configured as a parameter of the constructor. Thus, it can be declared as constant to save gas.https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/LockeERC20.sol#L25-L25
https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/LockeERC20.sol#L56-L74
Recommendation
Change to: