Skip to content
Smart contracts Audit finding Beginner

In Yeet.sol, storage slots only set in constructor should be declared immutable.

Several state variables in the Yeet contract are assigned only in the constructor but are not declared immutable, so their values occupy storage slots instead of being embedded in the bytecode. This causes unnecessary storage usage and higher gas costs during contract interactions.

Victor_TheOracle Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#41766 [SC-Insight] In `Yeet.sol`, storage slots only set in constructor should be declared `immutable`.

Submitted on Mar 18th 2025 at 08:10:37 UTC by @Victor_TheOracle for Audit Comp | Yeet

Description

Brief/Intro

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.

Vulnerability Details

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:

Solidity
/// @notice yeetTokenAddress is the address of the YeetToken contract
//@audit (info) -----> Should be immutable
address public yeetTokenAddress;
/// @notice rewardsContract is the Reward contract
//@audit (info) -----> Should be immutable
Reward public rewardsContract;
/// @notice gameSettings is the YeetGameSettings contract
//@audit (info) -----> Should be immutable
YeetGameSettings public gameSettings;
/// @notice yeetback is the Yeetback contract
//@audit (info) -----> Should be immutable
Yeetback public yeetback;

Impact Details

The primary impact of this issue is increased gas consumption during contract execution.

References

Links to relevant lines:

  1. https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Yeet.sol#L111
  2. https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Yeet.sol#L113
  3. https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Yeet.sol#L117
  4. https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Yeet.sol#L121

Proof of Concept

Proof of Concept

The original report as published on Immunefi, by Victor_TheOracle. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The developer did not mark constructor-only state variables as immutable, so the compiler stores them in storage slots rather than embedding them in the bytecode.

Impact

The issue increases gas consumption during contract execution; it is a gas optimisation insight, not an exploitable vulnerability.

What the attacker needed

None

The fix

The variables should be declared immutable so their values are embedded in the bytecode and storage is not used.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

In a smart contract, some values are set once when the contract is created and never change. If they are stored in the contract's permanent memory (storage), every use costs extra gas, which is the fee paid to run code on the blockchain. Marking them immutable lets the compiler bake the values directly into the code, making reads cheaper.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by Victor_TheOracle

View all

4 more disclosed reports, best first.

More from Yeet

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.