#41766 [SC-Insight] In `Yeet.sol`, storage slots only set in constructor should be declared `immutable`.
Was this helpful?
Was this helpful?
Submitted on Mar 18th 2025 at 08:10:37 UTC by @Victor_TheOracle for
Report ID: #41766
Report Type: Smart Contract
Report severity: Insight
Target: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/Yeet.sol
Impacts:
In Yeet.sol
, several state variables that are only set in the constructor are not declared as immutable
. This oversight leads to unnecessary storage usage and higher gas costs during contract interactions.
The Solidity compiler offers the immutable
keyword for variables that are assigned only once during construction. By marking these variables as immutable
, their values are embedded directly in the bytecode rather than stored in a storage slot, leading to significant gas optimizations. In Yeet.sol
, the following variables are set exclusively in the constructor but are not marked as immutable:
The primary impact of this issue is increased gas consumption during contract execution.
Links to relevant lines:
https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Yeet.sol#L111
https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Yeet.sol#L113
https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Yeet.sol#L117
https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Yeet.sol#L121