Vanguard

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

Buy swaps are incorrectly subject to sell limits and penalty fees

Author Revealed upon completion

Root + Impact

Description

  • The protocol is intended to prevent excessive selling during token launches by enforcing limits, cooldowns, and penalty fees on sell-side swaps in early phases.

  • The hook applies swap limits and penalties to all swaps, without distinguishing between buy and sell directions. As a result, buy transactions are treated the same as sells and can incorrectly trigger penalties.

uint256 swapAmount =
params.amountSpecified < 0
? uint256(-params.amountSpecified)
: uint256(params.amountSpecified);
// @> No distinction between buy and sell swaps
if (!applyPenalty && addressSwappedAmount[sender] + swapAmount > maxSwapAmount) {
applyPenalty = true;
}

The swap amount is always treated as a positive value, and no logic checks whether the swap represents a sell of the launched token. This causes legitimate buy activity to count toward per-address limits and cooldowns.

Risk

Likelihood:

  • The issue occurs for every buy swap during phase 1 and phase 2.

  • No directional checks exist to exempt buy-side swaps from penalties.

Impact:

  • Legitimate buyers can be penalized or charged excessive fees.

  • Early demand is artificially suppressed during launch.

  • Price discovery becomes distorted, undermining the fairness of the launch process.

Proof of Concept

// Conceptual PoC
// User performs a buy swap during phase 1
params.amountSpecified = -1000; // Buy token
// swapAmount is treated as positive
swapAmount = 1000;
// Buy swap contributes to limits and cooldowns
addressSwappedAmount[sender] += 1000;
// Penalty fees may be applied despite no selling activity

No tests assert that buy swaps should be penalized, and the project documentation only references penalties for excessive selling.

Recommended Mitigation

Explicitly distinguish between buy and sell swaps and only apply limits and penalties to sell-side activity.

- uint256 swapAmount =
- params.amountSpecified < 0
- ? uint256(-params.amountSpecified)
- : uint256(params.amountSpecified);
+ bool isSell = /* determine sell direction based on token ordering */;
+ uint256 swapAmount = isSell
+ ? (params.amountSpecified < 0
+ ? uint256(-params.amountSpecified)
+ : uint256(params.amountSpecified))
+ : 0;

Alternatively, bypass anti-bot enforcement entirely for buy-side swaps.

Support

FAQs

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

Give us feedback!