#41682 [SC-Insight] Code can be optimized to use save a lot of gas.

Submitted on Mar 17th 2025 at 14:39:34 UTC by @k1k1 for Audit Comp | Yeet

  • Report ID: #41682

  • Report Type: Smart Contract

  • Report severity: Insight

  • Target: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/Reward.sol

  • Impacts:

Description

Brief/Intro

The code uses YeetGameSettings contract for settings but the way the YeetGameSettings is defined is unoptimized , as the game settings address doesn't get re-initialized it must have been declared as immutable , as it's not optimized it consumes extra gas as a state variable would.

Vulnerability Details

look at line

YeetGameSettings public gameSettings;

and here also

    function copySettings() internal {
        YEET_TIME_SECONDS = gameSettings.YEET_TIME_SECONDS();
        POT_DIVISION = gameSettings.POT_DIVISION();
        TAX_PER_YEET = gameSettings.TAX_PER_YEET();
        TAX_TO_STAKERS = gameSettings.TAX_TO_STAKERS();
        TAX_TO_PUBLIC_GOODS = gameSettings.TAX_TO_PUBLIC_GOODS();
        TAX_TO_TREASURY = gameSettings.TAX_TO_TREASURY();
        YEETBACK_PERCENTAGE = gameSettings.YEETBACK_PERCENTAGE();
        COOLDOWN_TIME = gameSettings.COOLDOWN_TIME();
        BOOSTRAP_PHASE_DURATION = gameSettings.BOOSTRAP_PHASE_DURATION();
        MINIMUM_YEET_POINT = gameSettings.MINIMUM_YEET_POINT();
    }

now when ever restart function gets called this copySettings function gets triggered , which causes around 25841 more gas consumption for the transaction.

Impact Details

The caller has to pay more gas for the same operation which could be done using less gas.

References

Add any relevant links to documentation or code

Proof of Concept

Proof of Concept

Was this helpful?