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

1 stars 0 forks source link

Make full use of immutable keyword in ConvexStakingWrapper #81

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

TomFrenchBlockchain

Vulnerability details

Impact

Gas savings

Proof of Concept

We have a number of variables in ConvexStakingWrapper which appear to only be set on construction and never again.

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

We can then make use of the immutable keyword to save on gas.

Recommended Mitigation Steps

Make use of immutable keyword for variables which are only set on construction

iamsahu commented 2 years ago

Immutable variables cannot be read during contract creation time. Making the suggested variables immutable would lead to https://github.com/code-423n4/2022-01-yield/blob/e946f40239b33812e54fafc700eb2298df1a2579/contracts/ConvexStakingWrapper.sol#L77-L78 to fail.

devtooligan commented 2 years ago

dup of #124