High-performance Rust bot that monitors wallets and DEX activity on Solana and automatically copies/snipes trades. It supports PumpFun, PumpSwap, Raydium launchpad, Raydium Cpmm, Raydium Amm, Meteora DBC and Meteora Damm. It integrates a configurable selling engine with dynamic trailing stops. Jupiter is used for token liquidation.
- Real-time monitoring: Yellowstone gRPC stream, parallel task processing
- Protocols: PumpFun (trade), PumpSwap (notify-only by default)
- Copy trading: Follow one or many target wallets with exclusions
- Risk & selling: Take profit, stop loss, dynamic trailing stop, copy-selling of existing balances
- Tx landing: Zeroslot or normal mode, configurable priority fees
- Utilities: Wrap/unwrap SOL, close empty token accounts, sell all tokens via Jupiter
- Load
.env
, buildConfig
and initialize clients (RPC, Yellowstone, ZeroSlot, wallet). - Start the
BlockhashProcessor
, token-account cache, and cache maintenance. - Initialize
SellingEngine
from env and optionally start copy-selling for existing tokens. - Launch two monitors in parallel:
- Target wallet monitoring (
processor/sniper_bot.rs
) - DEX monitoring (
processor/sniper_bot.rs
), protocol auto-detection or preference
- Target wallet monitoring (
- Parse candidate transactions/logs, filter excluded addresses and apply limits.
- Execute swaps. Apply slippage and priority-fee settings; optionally use ZeroSlot mode.
- Manage positions with the selling strategy (TP/SL/dynamic trailing). Liquidation paths use Jupiter.
- Maintain a per-token 20-slot time-series (price, buy/sell volume) to detect post-drop bottoms, enabling sniper entries and informed copy trades.
flowchart TD
A[Start] --> B[Load .env]
B --> C[Init RPC, Yellowstone, ZeroSlot, Wallet]
C --> D[Start Blockhash Processor]
D --> E[Init Token Account Cache]
E --> F[Start Cache Maintenance]
F --> G[Init Selling Engine]
G --> H{Run monitors in parallel}
H --> I[Target Wallet Monitoring]
H --> J[DEX Monitoring]
I --> K[Parse txs/logs]
J --> K
K --> L{Protocol match}
L --> |PumpFun| M[Execute swap]
L --> |PumpSwap| N[Notify only]
M --> O[Update selling / copy-sell]
O --> P[Dynamic trailing / TP / SL]
P --> Q[Jupiter sell path]
K --> R[Update 20-slot time series]
R --> S{Bottom detected?}
S --> |Yes| M
S --> |No| H
N --> Q
src/
common/ # config, constants, logger, caches
common/timeseries.rs # 20-slot price & volume time-series, bottom detection
library/ # blockhash processor, jupiter client, rpc, zeroslot
processor/ # monitoring, swap/execution, selling, risk mgmt, parsing
dex/ # protocol adapters: pump_fun.rs, pump_swap.rs, raydium_launchpad.rs
block_engine/ # helpers for token accounts & txs
error/ # error types
main.rs # entrypoint & CLI helpers (wrap/unwrap/sell/close)
Important files:
src/main.rs
: starts services, parallel monitors, CLI helpers (--wrap
,--unwrap
,--sell
,--close
).src/common/config.rs
: loads env, buildsConfig
, RPC/yellowstone clients, wallet, slippage, fees.src/processor/sniper_bot.rs
: wallet/DEX monitoring orchestration.src/processor/selling_strategy.rs
: selling engine with dynamic trailing stop.src/library/jupiter_api.rs
: quotes and executes swaps for liquidation.src/library/blockhash_processor.rs
: keeps recent blockhashes updated.
Prerequisites:
- Rust toolchain (stable), Cargo
- Access to a Solana RPC (
RPC_HTTP
) and Yellowstone gRPC endpoint
- Clone and create env file
cp src/env.example .env
# Edit .env with your keys and endpoints
- Build
cargo build --release
- Run
cargo run --release
CLI helpers (run one at a time):
cargo run --release -- --wrap # Wrap WRAP_AMOUNT SOL to WSOL
cargo run --release -- --unwrap # Unwrap WSOL back to SOL
cargo run --release -- --sell # Sell all tokens via Jupiter
cargo run --release -- --close # Close all token accounts (excl. WSOL with balance)
Copy from src/env.example
and adjust. Key settings (not exhaustive):
-
Targeting & trading
COPY_TRADING_TARGET_ADDRESS
: comma-separated wallet list to followIS_MULTI_COPY_TRADING
:true
/false
EXCLUDED_ADDRESSES
: comma-separated addresses to ignoreCOUNTER_LIMIT
: max number of tradesTOKEN_AMOUNT
: buy amount (qty ifSwapInType::Qty
)SLIPPAGE
: basis points (e.g. 3000 = 30%)TRANSACTION_LANDING_SERVICE
:0|zeroslot
or1|normal
-
Fees & priority
SELLING_UNIT_PRICE
: priority fee for selling txs (default 4_000_000)SELLING_UNIT_LIMIT
: compute units for sellingZERO_SLOT_TIP_VALUE
: tip used in zeroslot mode
-
Selling strategy
COPY_SELLING_LIMIT
: initial multiple to start copy-sellingTAKE_PROFIT
,STOP_LOSS
,MAX_HOLD_TIME
DYNAMIC_TRAILING_STOP_THRESHOLDS
: e.g.20:5,50:10,100:30,200:100,500:100,1000:100
DYNAMIC_RETRACEMENT_PERCENTAGE
,RETRACEMENT_PNL_THRESHOLD
,RETRACEMENT_THRESHOLD
MIN_LIQUIDITY
- Time-series bottom detection (optional, future envs):
BOTTOM_MIN_DROP_PCT
,BOTTOM_SELL_DECLINE_PCT
,BOTTOM_STABILIZE_SLOTS
-
Sniper focus
FOCUS_DROP_THRESHOLD_PCT
: fraction drop to mark token as droppedFOCUS_TRIGGER_SOL
: buy trigger size after drop (in SOL)
-
Endpoints
RPC_HTTP
: HTTP RPC endpointRPC_WSS
: optional WSS endpointYELLOWSTONE_GRPC_HTTP
: Yellowstone gRPC URLYELLOWSTONE_GRPC_TOKEN
: Yellowstone tokenZERO_SLOT_URL
,ZERO_SLOT_HEALTH
: ZeroSlot endpoints
-
Wallet
PRIVATE_KEY
: base58-encoded keypair stringWRAP_AMOUNT
: SOL amount for--wrap
Example .env
snippet:
RPC_HTTP=https://rpc.shyft.to?api_key=YOUR_API_KEY
YELLOWSTONE_GRPC_HTTP=https://grpc.ny.shyft.to
YELLOWSTONE_GRPC_TOKEN=YOUR_GRPC_TOKEN
PRIVATE_KEY=YOUR_BASE58_PRIVATE_KEY
COPY_TRADING_TARGET_ADDRESS=ADDRESS1,ADDRESS2
IS_MULTI_COPY_TRADING=true
EXCLUDED_ADDRESSES=675kPX9MHTj...,CPMMoo8L3F...
TOKEN_AMOUNT=0.001
SLIPPAGE=3000
TRANSACTION_LANDING_SERVICE=zeroslot
SELLING_UNIT_PRICE=4000000
SELLING_UNIT_LIMIT=2000000
ZERO_SLOT_TIP_VALUE=0.0025
TAKE_PROFIT=8.0
STOP_LOSS=-2
MAX_HOLD_TIME=3600
DYNAMIC_TRAILING_STOP_THRESHOLDS=20:5,50:10,100:30,200:100,500:100,1000:100
- PumpSwap is configured as notification-only by default. Extend
dex/pump_swap.rs
to enable execution. - Ensure your
PRIVATE_KEY
is a base58 string of sufficient length; the app validates it at startup. - If
SLIPPAGE
exceeds 10000 (100%), it is capped.
For personal/educational use. Review and comply with your jurisdiction and exchange/DEX terms.