Skip to content

Repository files navigation

Base Token Sniper Bot (Uniswap V2)

Simple sniper for new tokens on Base using Uniswap V2. It listens for liquidity events, applies basic safety checks, computes a position size, and executes buys/sells. Includes a Telegram bot for viewing positions and placing sells.

Features

  • Base chain
  • Uniswap V2 router on Base
  • Event listeners for LP burn and pair creation
  • Basic token safety checks via token_scanner.py
  • Position logging to Parquet and Telegram notifications
  • Telegram commands: /positions, /sell

Requirements

  • Python 3.10+
  • A Base JSON-RPC endpoint (e.g., QuickNode)
  • Telegram bot token

Recommended Python packages (install into your venv):

pip install web3 pandas requests python-telegram-bot==13.* pyarrow

Setup

  1. Copy the example env file and fill in values
cp .env.example .env
  1. Required environment variables
  • WALLET_ADDRESS: Your EOA address on Base
  • PRIVATE_KEY: Private key for WALLET_ADDRESS (0x-prefixed hex)
  • QUICKNODE_URL_BASE: Base RPC URL (QuickNode or any reliable Base RPC)
  • TELEGRAM_BOT_TOKEN: Token for telegram_bot.py (BotFather)
  • BOT_TOKEN: Token used inside sniper_bot.py for Telegram notifications (can be same as TELEGRAM_BOT_TOKEN)

Optional

  • TENDERLY_KEY: If you enable transaction simulation
  • BASESCAN_API_KEY: Used by token_scanner.py for contract checks
  • ETHERSCAN_API_KEY: Only if you later re-enable Ethereum support
  1. Git hygiene The repo includes .gitignore and .env.example. Data artifacts like purchases.parquet and state.pkl are ignored.

How to Run

Run each component in separate terminals as needed.

  1. Buy listener (snipes new tokens)
python sniper_buy_bot.py

By default sniper_buy_bot.py instantiates the bot with test_mode=True. Set to False to broadcast real transactions.

  1. Sell monitor (takes profit / stop loss based on simple rules)
python sniper_sell_bot.py
  1. Telegram bot (positions and sell commands)
python telegram_bot.py

Commands:

  • /positions — shows current positions and PnL
  • /sell base <token_address> <sell_percentage> — e.g. /sell base 0xabc... 0.5

Configuration Notes

  • Slippage, thresholds, and sizing are in sniper_bot.py (see compute_buy_size, buy_token, sell_token).
  • Purchases are logged to purchases.parquet in the repo root.
  • Links in messages point to basescan.org.
  • Safety checks are basic heuristics; review token_scanner.py and adjust to your risk tolerance.

Troubleshooting

  • PRIVATE_KEY environment variable is not set: ensure .env is loaded in your shell or export vars explicitly.
  • Missing parquet dependencies: pip install pyarrow.
  • Telegram issues: verify TELEGRAM_BOT_TOKEN and that the bot has a conversation with your account.
  • RPC errors: confirm QUICKNODE_URL_BASE is reachable and synced.

Security

  • Never commit real private keys. Use environment variables.
  • Consider running from a dedicated wallet and small balances.

Disclaimer

This code is for educational purposes only. Trading tokens can be highly risky. Use at your own risk.

License

MIT

About

Simple sniper for new tokens on Base using Uniswap V2.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages