code-423n4 / 2022-01-yield-findings

1 stars 0 forks source link

Using immutable variable can save gas #103

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

WatchPug

Vulnerability details

https://github.com/code-423n4/2022-01-yield/blob/e946f40239b33812e54fafc700eb2298df1a2579/contracts/ConvexStakingWrapper.sol#L41-L45

address public curveToken;
address public convexToken;
address public convexPool;
address public collateralVault;
uint256 public convexPoolId;

Considering that curveToken, convexToken, convexPool, and convexPoolId will never change, changing them to immutable variables instead of storages variable can save gas.

Other examples include:

https://github.com/code-423n4/2022-01-yield/blob/e946f40239b33812e54fafc700eb2298df1a2579/contracts/Cvx3CrvOracle.sol#L24-L25

bytes32 public cvx3CrvId;
bytes32 public ethId;

cvx3CrvId and ethId in Cvx3CrvOracle.sol.

devtooligan commented 2 years ago

dup #42 and also cant make bytes immutable

GalloDaSballo commented 2 years ago

Duplicate of #42