Vanguard

First Flight #56
Beginner FriendlyDeFiFoundry
0 EXP
Submission Details
Impact: low
Likelihood: low

Unused State Variables

Author Revealed upon completion

Unused State Variables

Description

Normal behavior:
When a protocol declares state variables intended for accounting (e.g. tracking penalties collected, per-address swap counts, or penalty occurrences), these variables are expected to be consistently updated and used as part of the protocol’s logic, monitoring, or administrative controls.

Specific issue:
TokenLaunchHook declares multiple state variables that suggest tracking of penalties and per-address activity, but these variables are never written to, updated, or read from anywhere in the contract logic. As a result, they remain permanently zero and provide no functional value, while giving a misleading impression that such accounting is enforced.

// TokenLaunchHook.sol
uint256 public totalPenaltyFeesCollected; // @> Never updated or used
mapping(address => uint256) public addressTotalSwaps; // @> Never updated or used
mapping(address => uint256) public addressPenaltyCount; // @> Never updated or used

The actual swap and penalty logic does not reference or mutate these variables, meaning the contract’s observable state does not reflect real protocol activity.

Risk

Likelihood: Low

  • There is no attacker-controlled interaction that can exploit these variables directly.

  • The issue does not depend on adversarial behavior and arises from incomplete or abandoned implementation rather than malicious input.

  • The variables are inert and do not influence execution flow.

Impact: Low

  • No direct financial loss, fund lock, or privilege escalation results from this issue alone.

  • However, the presence of unused accounting variables can:

    • Mislead integrators, auditors, or operators into believing penalties and usage are being tracked.

    • Obscure the true operational state of the protocol.

    • Increase the risk of incorrect assumptions in off-chain monitoring, governance, or future upgrades.

Proof of Concept

The issue can be verified by simple inspection and runtime observation:

  1. Review the contract source TokenLaunchHook.sol and observe that:

    • totalPenaltyFeesCollected

    • addressTotalSwaps

    • addressPenaltyCount
      are never assigned to outside of their default initialization.

  2. Execute any number of swaps, including swaps that trigger penalty logic.

  3. Observe that all three variables remain equal to 0, regardless of protocol activity.

This demonstrates that the variables are unused and do not reflect real system behavior.

Recommended Mitigation

Either fully implement the intended accounting logic or remove the unused variables to avoid confusion and reduce surface area.

Option 1 — Implement accounting logic OR

Option 2 — Remove unused variables (preferred if not required)

- uint256 public totalPenaltyFeesCollected;
- mapping(address => uint256) public addressTotalSwaps;
- mapping(address => uint256) public addressPenaltyCount;

Support

FAQs

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

Give us feedback!