Vanguard

First Flight #56
Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Impact: low
Likelihood: high
Invalid

[L-02] Unused State Variables

Root + Impact

Description

addressTotalSwaps and addressPenaltyCount are declared but never written to.

Location: src/TokenLaunchHook.sol:55-56

mapping(address => uint256) public addressTotalSwaps; // Never written
mapping(address => uint256) public addressPenaltyCount; // Never written

Risk

Likelihood: Always present in deployed bytecode.

Impact:

  • Wasted contract storage space

  • Misleading API for integrators

  • Dead code

Proof of Concept

function test_PoC_L02_UnusedStateVariables() public {
// Do multiple swaps
_swap(user1, 0.001 ether);
_swap(user1, 0.001 ether);
_swap(user2, 0.001 ether);
// These mappings exist but are never written to
uint256 user1TotalSwaps = hook.addressTotalSwaps(user1);
uint256 user1PenaltyCount = hook.addressPenaltyCount(user1);
uint256 routerTotalSwaps = hook.addressTotalSwaps(address(swapRouter));
uint256 routerPenaltyCount = hook.addressPenaltyCount(address(swapRouter));
// All remain at default value (0) despite swaps occurring
assertEq(user1TotalSwaps, 0, "addressTotalSwaps never written");
assertEq(user1PenaltyCount, 0, "addressPenaltyCount never written");
assertEq(routerTotalSwaps, 0, "addressTotalSwaps never written");
assertEq(routerPenaltyCount, 0, "addressPenaltyCount never written");
}

Recommendations

Either implement the tracking or remove the variables.

Updates

Lead Judging Commences

chaossr Lead Judge
about 1 month ago

Appeal created

chaossr Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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

Give us feedback!