Skip to content

Validate slippage range (0-100) in buy and sell commands #1

@smypmsa

Description

@smypmsa

Problem

--slippage accepts any integer with no bounds checking:

  • --slippage -5 → formula produces impossible min_tokens_out, guaranteed on-chain rejection
  • --slippage 999 → large negative integer → struct.error crash with Python traceback

Fix

Add validation in src/pumpfun_cli/commands/trade.py in both buy() and sell(), after _validate_mint():

if slippage < 0 or slippage > 100:
    error("Slippage must be between 0 and 100.", hint="Got: {slippage}")

Files to change

  • src/pumpfun_cli/commands/trade.py — add validation in buy() and sell()
  • tests/test_commands/test_trade_cmd.py — add tests for out-of-range slippage

How to test

uv run pytest tests/test_commands/test_trade_cmd.py -v

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions