Advanced BNB Chain sniper bot for detecting and buying tokens instantly on Pancakeswap platform.
- Real-time Token Detection: Monitors PancakeSwap factory for new token pair creations
- Auto-Buy: Instantly purchases tokens upon detection with competitive gas pricing
- Auto-Sell: Monitors price and automatically sells when take-profit target is reached
- Multi-RPC Broadcasting: Submits transactions to multiple RPC endpoints for faster propagation
- Atomic Nonce Management: Prevents race conditions with proper nonce locking
- Emergency Sell: Automatic sell after timeout to prevent stuck positions
- Trade Metrics: Tracks profit percentage, duration, and entry/exit prices
- Error Recovery: Automatic unlock mechanism prevents bot from getting stuck
Required:
PRIVATE_KEY- Your wallet private keySNIPER_CONTRACT_ADDRESS- Your sniper contract addressWS_PROVIDER_URL- WebSocket provider URL for event monitoringRPC_PROVIDER_URL- RPC provider URL for transactionsSEND_BNB- Amount of BNB to send per trade (e.g., "0.0005"). Default: "0.000001"
Optional:
TAKE_PROFIT_PERCENT- Take profit percentage (default: 5). Bot will sell when price reaches this percentage above entryEMERGENCY_SELL_TIMEOUT- Timeout in milliseconds before emergency sell triggers (default: 600000 = 10 minutes)TOKEN_NAME_CONTAINS- Filter out tokens by name (see Token Filtering section) - Available in index.tsMIN_LIQUIDITY_BNB- Minimum liquidity filter (see Liquidity Filtering section) - Available in index.ts
The bot automatically monitors the price after buying and sells when the target is reached:
# Sell when price reaches +5% above entry (default)
TAKE_PROFIT_PERCENT=5
# Sell when price reaches +10% above entry
TAKE_PROFIT_PERCENT=10
# Sell when price reaches +20% above entry
TAKE_PROFIT_PERCENT=20If the take-profit target is not reached within the timeout period, the bot will automatically sell to prevent stuck positions:
# Emergency sell after 5 minutes (300000 ms)
EMERGENCY_SELL_TIMEOUT=300000
# Emergency sell after 10 minutes (600000 ms) - default
EMERGENCY_SELL_TIMEOUT=600000
# Emergency sell after 15 minutes (900000 ms)
EMERGENCY_SELL_TIMEOUT=900000You can filter out tokens by name before buying. Add this to your .env file:
TOKEN_NAME_CONTAINS- Tokens with names containing these strings will be SKIPPED (case-insensitive)- Multiple keywords can be separated by commas
- The bot will SKIP tokens if the name contains ANY of the specified keywords
- The bot will BUY all other tokens that don't match the filter
Examples:
# Skip tokens where name contains "Moon" (buy everything else)
TOKEN_NAME_CONTAINS=Moon
# Skip tokens where name contains "Moon" OR "DOGE" OR "Pepe" (buy everything else)
TOKEN_NAME_CONTAINS=Moon,DOGE,Pepe
# Skip tokens where name contains "Safe" OR "Moon" OR "Rocket" (buy everything else)
TOKEN_NAME_CONTAINS=Safe,Moon,RocketNote:
- If
TOKEN_NAME_CONTAINSis not set or empty, the bot will buy all detected tokens - Filtering is case-insensitive
- Keywords are separated by commas (spaces around commas are automatically trimmed)
- This is a blacklist filter - tokens matching the keywords are excluded
You can filter tokens by minimum liquidity before buying. Add this to your .env file:
MIN_LIQUIDITY_BNB- Minimum total liquidity required in BNB (e.g., "1.0" for 1 BNB minimum)- Pools with less liquidity than this will be skipped
- Total liquidity = 2 × WBNB reserve (since AMM pools maintain equal value on both sides)
Examples:
# Only buy tokens with at least 1 BNB total liquidity
MIN_LIQUIDITY_BNB=1.0
# Only buy tokens with at least 5 BNB total liquidity
MIN_LIQUIDITY_BNB=5.0
# Only buy tokens with at least 0.5 BNB total liquidity
MIN_LIQUIDITY_BNB=0.5Note:
- If
MIN_LIQUIDITY_BNBis not set or 0, liquidity filtering is disabled - The bot calculates total liquidity as 2 × WBNB reserve
- This helps avoid low-liquidity tokens that may be rug pulls or have high slippage
- Event Monitoring: Bot listens to
PairCreatedevents from PancakeSwap Factory contract via WebSocket - Token Detection: When a new WBNB pair is created, the bot immediately identifies the new token
- Buy Execution: Bot executes a buy transaction with competitive gas pricing and multi-RPC broadcasting
- Price Monitoring: After buy confirmation, bot polls pair reserves every second to track price
- Take Profit: When price reaches the target percentage, bot automatically executes sell
- Emergency Exit: If target not reached within timeout, bot sells to prevent stuck positions
- State Management: Bot locks during active trades and unlocks after completion or failure
The bot tracks and logs:
- Entry price
- Exit price
- Profit percentage
- Trade duration
- Buy and sell transaction hashes
- Automatic nonce synchronization to prevent transaction failures
- State unlock mechanism prevents bot from getting stuck
- Retry logic for failed sell attempts (up to 3 attempts)
- Graceful error recovery with proper state cleanup
- Monitoring (Completed)
- Sniping (Completed)
- Sniping as first buyer (Completed)
- Selling logic (Completed)
- Token filtering (Available in index.ts)
- Liquidity filtering (Available in index.ts)
- Trade metrics (Completed)
- Emergency sell timeout (Completed)
For inquiries, custom integrations, or tailored solutions, reach out via:
Telegram: @trum3it