Vanguard

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

getCurrentPhase() View Function Mismatches Actual Phase Logic

Author Revealed upon completion

Description

The view function should return the same phase that will be used during actual swap execution.

getCurrentPhase() uses < while _beforeSwap() uses <=. At boundary blocks, the view function reports the wrong phase.

// Line 139: _beforeSwap (actual enforcement)
if (blocksSinceLaunch <= phase1Duration) { // @> Uses <=
newPhase = 1;
} else if (blocksSinceLaunch <= phase1Duration + phase2Duration) {
newPhase = 2;
}
// Line 197: getCurrentPhase (view function)
if (blocksSinceLaunch < phase1Duration) { // @> Uses <
return 1;
} else if (blocksSinceLaunch < phase1Duration + phase2Duration) {
return 2;
}

Risk

Likelihood:

  • Occurs at every phase boundary block

  • Any user swapping at exactly boundary blocks affected

Impact:

  • Users check getCurrentPhase() and see Phase 2

  • Users expect Phase 2 rules (lower penalties)

  • Users swap and actually get Phase 1 rules (higher penalties)

  • Frontends/dApps display incorrect phase information

Recommended Mitigation

function getCurrentPhase() public view returns (uint256) {
- if (blocksSinceLaunch < phase1Duration) {
+ if (blocksSinceLaunch <= phase1Duration) {
return 1;
- } else if (blocksSinceLaunch < phase1Duration + phase2Duration) {
+ } else if (blocksSinceLaunch <= phase1Duration + phase2Duration) {
return 2;
}
}

Support

FAQs

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

Give us feedback!