Vanguard

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

getCurrentPhase() View Function Mismatches Actual Phase Logic

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;
}
}
Updates

Appeal created

chaossr Lead Judge 17 days ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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

Give us feedback!