Vanguard

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

Dead Code: addressTotalSwaps and addressPenaltyCount Declared but Never Written

Author Revealed upon completion

Root + Impact

Description

Two state variables are declared but never written to anywhere in the contract:

// Lines 55-56
mapping(address => uint256) public addressTotalSwaps;
mapping(address => uint256) public addressPenaltyCount;

These mappings are declared with public visibility (auto-generating getters) but:

  • No function ever writes to addressTotalSwaps

  • No function ever writes to addressPenaltyCount

This is either:

  1. Dead code that should be removed

  2. Missing functionality that was intended but not implemented

Impact

Low severity - informational:

  • Wastes gas on deployment (storage slot allocation)

  • Misleading interface (getters exist but always return 0)

  • If functionality was intended, it's missing

  • View functions that might rely on this data will be incorrect

Proof of Concept

# Search for writes to these variables
grep -n "addressTotalSwaps[" TokenLaunchHook.sol
# Result: Only line 55 (declaration)
grep -n "addressPenaltyCount[" TokenLaunchHook.sol
# Result: Only line 56 (declaration)

No writes found - these variables are never updated.

Recommended Mitigation

Option 1: Remove dead code

// Remove these lines if not needed:
// mapping(address => uint256) public addressTotalSwaps;
// mapping(address => uint256) public addressPenaltyCount;

Option 2: Implement intended functionality

function _beforeSwap(...) internal override returns (...) {
// ... existing logic ...
// Add tracking:
addressTotalSwaps[sender] += 1;
if (applyPenalty) {
addressPenaltyCount[sender] += 1;
}
}

Support

FAQs

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

Give us feedback!