Vanguard

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

lastPhaseUpdateBlock State Variable Never Read

Author Revealed upon completion

Description

  • The lastPhaseUpdateBlock state variable is assigned during phase transitions but is never read anywhere in the contract.

uint256 public lastPhaseUpdateBlock; // @> Declared
function _beforeSwap(...) internal override returns (...) {
// ...
if (newPhase != currentPhase) {
_resetPerAddressTracking();
currentPhase = newPhase;
lastPhaseUpdateBlock = block.number; // @> Assigned but never read
}
// ...
}

Risk

Likelihood: N/A

Impact:

  • Wasted gas on storage writes

  • Misleading - suggests functionality that doesn't exist

  • Could be intended for off-chain monitoring but has no on-chain use

Proof of Concept

Grep for lastPhaseUpdateBlock - only written, never read.

Recommended Mitigation

Remove the variable, or use it for per-user phase reset logic.

Option 1: Remove if not needed

- uint256 public lastPhaseUpdateBlock;
function _beforeSwap(...) internal override returns (...) {
// ...
if (newPhase != currentPhase) {
_resetPerAddressTracking();
currentPhase = newPhase;
- lastPhaseUpdateBlock = block.number;
}
// ...
}

Option 2: Use it for reset logic (if intended)

function _beforeSwap(...) internal override returns (...) {
// ...
+ // Reset tracking if user's last swap was before this phase started
+ if (addressLastSwapBlock[sender] < lastPhaseUpdateBlock) {
+ addressSwappedAmount[sender] = 0;
+ addressLastSwapBlock[sender] = 0;
+ }
// ...
}

Support

FAQs

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

Give us feedback!