MCPcopy Create free account
hub / github.com/chainstacklabs/pumpfun-bonkfun-bot

github.com/chainstacklabs/pumpfun-bonkfun-bot @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
773 symbols 2,787 edges 91 files ⚖ Apache-2.0 631 documented · 82% ● updated 3d ago★ 1,1036 open issues

Browse by type

⨍ Functions 708◇ Types & classes 65
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Labs

Chainstack is the leading suite of services connecting developers with Web3 infrastructure

• Homepage • Supported protocols • Chainstack blog • Blockchain API reference •

• Start for free •

A Solana trading bot for pump.fun and for letsbonk.fun, StonkFun and every other launchpad on Raydium LaunchLab. It watches for new coins, buys them, and sells on a strategy you configure. cookbook/ has one standalone script per action, useful even if you never run the bot.

For a step-by-step guide, see Solana: Creating a trading and sniping pump.fun bot. Where the guide and this README differ, follow the README.

Also by Chainstack — if you prefer a terminal interface or want to give an AI agent trading capabilities: - pumpfun-cli — CLI for trading on pump.fun and Raydium LaunchLab launchpads (letsbonk.fun, StonkFun) and launching pump.fun coins; routes each trade to the bonding curve, PumpSwap or Raydium CPMM. - pumpclaw — agent skill that lets AI assistants (OpenClaw, Claude Code, Cursor, Codex) use pumpfun-cli.


🚨 Scam alert: scam bots post in Issues with links to sites that drain your wallet. Never share your private key, and don't follow links in issue comments. Deleted comments were scams; genuine contributors are welcome. Chainstack has no token and doesn't endorse any. Token addresses in this repo are only examples.

⚠️ Not for production: this code is for learning. We take no responsibility for the code or how it is used.


Getting started

1. Prerequisites

Install uv, a fast Python package manager. The project needs Python 3.11+; uv uses your installed Python if it is new enough and downloads one otherwise.

2. Clone and install

git clone https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
cd pumpfun-bonkfun-bot

uv sync                        # create .venv and install dependencies
source .venv/bin/activate      # Unix/macOS — Windows: .venv\Scripts\activate
uv pip install -e .            # install the bot as an editable package

3. Set your credentials

cp .env.example .env

Fill in .env:

Variable Purpose
SOLANA_NODE_RPC_ENDPOINT HTTPS RPC endpoint
SOLANA_NODE_WSS_ENDPOINT WebSocket endpoint, for the logs and blocks listeners
SOLANA_PRIVATE_KEY Base58 private key of the trading wallet
GEYSER_ENDPOINT, GEYSER_API_TOKEN Geyser endpoint and token, for the geyser and shreds listeners; the bot takes the auth type from geyser.auth_type in its YAML
KEYSTORE_PASSWORD Optional: password of an encrypted keystore, if you use one instead of SOLANA_PRIVATE_KEY

Public RPC endpoints can't keep up with the bot. See Throughput and rate limits.

4. Configure a bot

Each YAML file in bots/ is one bot, and its comments explain the settings. Start from the one for the listener you want:

File Listener Platform
bot-sniper-1-geyser.yaml geyser — fastest, needs a Geyser endpoint pump_fun
bot-sniper-2-logs.yaml logs — logsSubscribe, supported by every provider pump_fun
bot-sniper-3-blocks.yaml blocks — blockSubscribe, not supported by every provider pump_fun
bot-sniper-5-shreds.yaml shreds — sees coins before geyser does, but misses coins created through a router pump_fun
bot-sniper-6-stonkfun.yaml geyser stonk_fun

platform is "pump_fun", "launchlab", "lets_bonk" or "stonk_fun". pump.fun works with all four listeners; the LaunchLab platforms work with blocks, geyser and shreds, not logs. The bot refuses an invalid pair at startup.

pump_bot runs every bot with enabled: true. Only bot-sniper-1-geyser.yaml ships enabled. Without a Geyser endpoint, disable it and enable another, or run one file with --config.

5. Run

Run from the folder that holds bots/:

pump_bot                                        # every enabled bot
pump_bot --config bots/bot-sniper-2-logs.yaml   # only this bot, even if it says enabled: false
pump_bot --verbose                              # every log line on the terminal, not only events
uv run src/bot_runner.py                        # same as pump_bot, without the installed command

Each bot logs its wallet address at startup. After that, the terminal shows one short colored line per event: a coin found, a buy, an exit, a sale with its profit or loss, a skipped coin, a warning. --verbose adds the detail (prices, confirmations, fees, cleanup). Set NO_COLOR=1 to turn color off.

A bot that can't start (an invalid config, a wallet that won't unlock, an rpc_endpoint that doesn't answer) is skipped with one line saying why. Exit status: 0 when every enabled bot ran without an error, 1 otherwise, 130 after Ctrl+C and 143 after SIGTERM. SIGTERM stops the bots the same way as Ctrl+C.

Output

The bot writes these files in the folder it runs from:

Path Contents
logs/<bot name>_<timestamp>.log Every log line, in full
trades/trades.log One JSON line per buy and sell
trades/sessions.log One JSON line per session summary
positions/<bot name>.json Open positions, resumed on the next start

Main fields in trades/trades.log:

  • bot — the bot that traded, so several bots can share the file (null for sell-all sales).
  • platform — where the coin launched.
  • venue — where the trade went: bonding curve, PumpSwap (pump.fun) or Raydium CPMM (LaunchLab).
  • price — for a buy, the fill price that take profit and stop loss count from; for a sell, the price per token received.
  • quote_amount — what the wallet received, negative when it spent, protocol fees included.
  • network_fee_sol, rent_deposit_sol, rent_refund_sol — the transaction fee, and rent paid into or returned from token accounts.
  • pnl — on a sell, that sale's realized profit or loss in the quote asset.
  • from_chain: false — the transaction couldn't be read in time, so the figures are estimates.

Profit and loss come from each trade's transaction. Every sale logs its PnL, and the sale that empties a position logs Final PnL, which for a SOL quote includes network fees. Rent for the wallet's own token accounts doesn't count as a loss, since cleanup returns it. Rent for an account the wallet can't close, such as pump.fun's creator fee vault, does.

When a bot stops, it prints a session summary — trades, exit reasons, realized PnL per quote asset, fees, rent, and positions left for the next start — and appends it to trades/sessions.log.

Configuration reference

The YAML files are commented inline. The main sections:

  • private_key or keystore — the trading wallet: a raw key, or the path to an encrypted keystore.
  • trade — buy_amount (in SOL), slippage, exit_strategy (time_based, tp_sl, manual), entry, max_open_positions and extreme_fast_mode.
  • min_wallet_balance (SOL, optional) — below this balance the bot stops buying; open positions still exit. Buying resumes once the balance is back above it. The check never delays a buy.
  • priority_fees — fixed or dynamic. Dynamic makes an extra RPC call, which slows the buy.
  • filters — listener_type, name and creator matching (match_string, and bro_address, the wallet that signed the launch), marry_mode (buy only, never sell) and yolo_mode (keep trading instead of stopping after one coin).
  • max_token_age (checked once, in seconds since the bot detected the coin, not its age on chain). A slow listener lets older coins through; set age_from: chain to count from the slot the coin was created in instead. It adds no RPC call to the buy.
  • checks (optional) — more checks before a buy: built-in mayhem and top_holders, or your own. See Pre-buy checks.
  • retries — submission attempts, and the waits after creation, after a buy and before the next coin.
  • timing.token_wait_timeout — with yolo_mode: false the bot trades one coin and exits; this is how long it waits for a coin that passes the filters. Default 120 seconds.
  • cleanup — when to close token accounts and get their rent back: disabled, on_fail (after a failed buy), after_sell (once each coin is sold) or post_session (when the session ends).
  • post_session closes the accounts of the coins it traded, then every other empty token account in the wallet. It never closes quote-asset accounts (wSOL, USDC) or those of coins still in the positions file.
  • force_close_with_burn — burn the tokens left in a traded coin's account before closing it. post_session burns nothing under exit_strategy: manual or marry_mode, since those coins are meant to be held.
  • burn_given_up_below (SOL, optional; needs after_sell or post_session) — at the end of a session, burn a coin the bot gave up selling if it is worth less than this, close its account and drop it from the positions file. Only SOL-quoted coins are burned.
  • with_priority_fee (default true) — send closes and burns with the bot's priority fee.
  • node.max_rps — requests per second; match it to your provider's plan. Default 25.

Extreme fast mode

With extreme_fast_mode: true, the bot buys a fixed number of tokens (extreme_fast_token_amount) without reading the price first. The buy goes out sooner, but you don't know the price per token in advance.

Usually the bot then makes no RPC call between detecting a coin and sending the buy. If the listener couldn't decode everything the buy needs, the bot reads the curve once first:

  • curve_refresh_budget (seconds, default 2.0) — how long that read may take before the bot skips the coin. Raise it to buy more coins on a slow endpoint; lower it to skip faster.
  • trust_create_event (default true) — set false to always read the curve first.

A coin that has already graduated trades in its pool: PumpSwap for pump.fun, Raydium CPMM for LaunchLab. This mode skips such coins, because a pool buy is sized from the pool. With the mode off, the bot buys them there for exactly the configured amount.

Migration entry

trade.entry sets what the bot buys:

  • new_launch (default) — new coins, on their bonding curve.
  • migration — coins as they graduate: a pump.fun coin in its new PumpSwap pool, a LaunchLab coin in its Raydium CPMM pool. LaunchLab coins that move to Raydium AMM v4 are not supported.
trade:
  entry: "migration"
  extreme_fast_mode: false   # required: a pool buy is sized from the pool

Every listener the platform supports reports migrations. Filters, quote_amounts and exit strategies work as for launches, except:

  • match_string checks the coin's on-chain metadata, and bro_address the creator its curve records.
  • max_token_age is checked once, counting from when the bot detected the migration, not from the coin's creation.
  • The bot waits for the new pool to be readable, then waits wait_after_creation and buys.
  • A LaunchLab coin is bought only if its curve uses a platform config the bot trades.

Several positions at once

By default the bot holds one coin at a time. With yolo_mode: true, trade.max_open_positions (1–100, default 1) lets it hold more:

trade:
  max_open_positions: 3

Buys still go out one at a time, and each position then runs its own exit. While every slot is taken, new coins wait in a queue, and max_token_age decides whether they are still bought. Positions under exit_strategy: manual or marry_mode are never sold, so they don't take a slot. On shutdown, open positions stay in the wallet and resume on the next start.

Positions survive a restart

The bot saves each position it monitors (tp_sl or time_based) to positions/<bot name>.json as soon as the buy is sent, and removes it once sold. On the next start it resumes them before taking new coins, under the current exit strategy (not under manual or marry_mode, which sell nothing): max_hold_time and wait_after_buy count from the original buy, take profit and stop loss from the entry price. A time_based position whose time ran out while the bot was down sells right away.

  • Pending buys. A buy whose outcome is unknown, after a timeout or a crash, is saved as pending with its signature. The bot looks the signature up and keeps the position at what the transaction shows, or clears it if the buy failed.
  • The wallet decides what's left. If the wallet no longer holds a coin (sold or burned by hand), the position is cleared, not sold again. If it holds less than was

Core symbols most depended-on inside this repo

browse all functions →

Shape

Method 366
Function 342
Class 65

Languages

Python100%

Modules by API surface

src/interfaces/core.py32 symbols
src/utils/idl_parser.py25 symbols
src/utils/idl_manager.py22 symbols
src/platforms/pumpfun/address_provider.py22 symbols
learning-examples/listen-new-tokens/compare_listeners.py22 symbols
src/platforms/__init__.py21 symbols
learning-examples/letsbonk-buy-sell/idl_parser.py20 symbols
src/geyser/generated/geyser_pb2_grpc.py19 symbols
learning-examples/manual_buy_geyser.py19 symbols
learning-examples/listen-new-tokens/generated/geyser_pb2_grpc.py19 symbols
src/platforms/letsbonk/address_provider.py18 symbols
src/core/client.py18 symbols

For agents

$ claude mcp add pumpfun-bonkfun-bot \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page