Beginner FriendlyFoundryBridge
100 EXP
View results
Submission Details
Severity: low
Invalid

`token` variable in L1Vault contract should be declared as `immutable` to save gas.

Summary

L1Vault's storage contains only one variable, called token. The declaration is as follows:

IERC20 public token;

Because the value of this variable never changes and is provided as input during the deployment, it would be better to declare it with the keyword immutable.

Vulnerability Details

Not using the immutable keyword for constant variables which have their value set in constructor will cost gas for no reason. Indeed, the immutable keyword directly integrates the value of the variable in the runtime bytecode wherever it is used. This way, there is no need to pay the gas associated with sload instruction each time the value is read.

Impact

The impact is LOW as it is just a gas related issue.

Tools Used

Manual

Recommendations

I suggest to replace the declaration of token variable with this declaration :

IERC20 public immutable token;

This will save gas for each call to approveTo function.

Updates

Lead Judging Commences

0xnevi Lead Judge
over 1 year ago
0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.