Reverse Sniper Bot - Implementation Complete π―
Date: 2026-02-17
Implemented by: Claude (AI Assistant)
Overview
The reverse sniper bot feature has been successfully implemented. This feature creates a PumpFun SPL token, performs an initial buy, and automatically sells when any external wallet buys the token.
Implementation Details
1. Token Creation (PumpFun)
- β
Implemented
create_token() method in src/dex/pump_fun.rs
- β
Added
CreateTokenArgs struct for Borsh serialization
- β
Supports custom token name, symbol, and metadata URI
- β
Creates bonding curve and associated token accounts
2. Initial Buy
- β
Implemented
execute_initial_buy() method
- β
Reuses existing swap building logic
- β
Configurable initial buy amount via
REVERSE_SNIPER_INITIAL_BUY_SOL
3. State Management
- β
Created
src/processor/reverse_sniper.rs module
- β
Added
REVERSE_SNIPER_MINTS DashMap for tracking reverse sniper tokens
- β
Implements registration, checking, and unregistration of reverse sniper tokens
- β
Includes
ReverseSniperMeta struct for tracking metadata
4. Sell Trigger Detection
- β
Integrated sell trigger in
src/processor/sniper_bot.rs
- β
Monitors all DEX transactions for buys on reverse sniper tokens
- β
Extracts buyer wallet and filters out creator wallet
- β
Triggers automatic sell when external buy detected
5. Random Token Generator
- β
Created
src/common/random_token_generator.rs module
- β
Generates random token names, symbols, descriptions
- β
Uses adjectives, nouns, and themes for creative naming
- β
Includes placeholder image URI generation
6. Configuration
- β
Added config fields to
src/common/config.rs
- β
Updated
src/env.example with new environment variables
7. Orchestration
- β
Added
--reverse-sniper CLI flag to src/main.rs
- β
Implements complete workflow: create β buy β register β monitor
- β
Provides detailed logging at each step
New Environment Variables
# Reverse Sniper Bot Configuration
REVERSE_SNIPER_ENABLED=false
REVERSE_SNIPER_TOKEN_NAME=MyToken
REVERSE_SNIPER_TOKEN_SYMBOL=MTK
REVERSE_SNIPER_TOKEN_URI=https://example.com/token-metadata.json
REVERSE_SNIPER_INITIAL_BUY_SOL=0.01
REVERSE_SNIPER_SELL_PCT=100 # Percentage of tokens to sell (100 = 100%)
REVERSE_SNIPER_USE_RANDOM_TOKEN_GENERATOR=false # Use AI to generate random token metadata
Usage
Basic Usage (Fixed Metadata)
# Set environment variables in .env
REVERSE_SNIPER_ENABLED=true
REVERSE_SNIPER_TOKEN_NAME="Golden Moon DeFi"
REVERSE_SNIPER_TOKEN_SYMBOL="GMD"
REVERSE_SNIPER_INITIAL_BUY_SOL=0.05
# Run the reverse sniper bot
cargo run --release -- --reverse-sniper
AI-Generated Random Tokens
# Use random token generator
REVERSE_SNIPER_ENABLED=true
REVERSE_SNIPER_USE_RANDOM_TOKEN_GENERATOR=true
REVERSE_SNIPER_INITIAL_BUY_SOL=0.01
# Run the bot
cargo run --release -- --reverse-sniper
Architecture
Workflow
- Create Token: Generate new PumpFun SPL token with bonding curve
- Initial Buy: Purchase configured amount of the created token
- Register: Add token to
REVERSE_SNIPER_MINTS for monitoring
- Monitor: DEX monitoring detects all buys on registered tokens
- Trigger: When external wallet buys, automatically sell configured percentage
- Cleanup: Unregister token after successful sell
Key Components
pump_fun.rs: Token creation and swap execution
reverse_sniper.rs: State management and sell trigger logic
sniper_bot.rs: Transaction monitoring and trigger detection
random_token_generator.rs: AI token metadata generation
config.rs: Configuration management
Files Changed
- β
src/dex/pump_fun.rs - Added token creation methods
- β
src/common/config.rs - Added configuration fields
- β
src/common/mod.rs - Exported new module
- β
src/env.example - Added environment variables
- β
src/main.rs - Added CLI flag and orchestration
- β
src/processor/mod.rs - Exported reverse sniper module
- β
src/processor/sniper_bot.rs - Added trigger detection
New Files Created
- β
src/common/random_token_generator.rs - Random token metadata generator
- β
src/processor/reverse_sniper.rs - Reverse sniper state management
Testing Notes
- Code compiles successfully after dependency updates
- Token creation follows PumpFun instruction format
- Sell trigger properly filters creator wallet
- State management uses thread-safe DashMap
- All error handling includes detailed logging
Next Steps
- Runtime testing with real Solana devnet/mainnet
- Monitor gas costs for token creation
- Test with different sell percentages
- Validate random token generator output
- Performance testing with multiple concurrent reverse snipers
AI Collaborators
@cursor @codex @Copilot @claude
Status: β
Implementation Complete
Branch: feature/reverse-sniper-bot
Commit: a6f031b
All core functionality has been implemented according to the plan. The bot is ready for testing and deployment.
Reverse Sniper Bot - Implementation Complete π―
Date: 2026-02-17
Implemented by: Claude (AI Assistant)
Overview
The reverse sniper bot feature has been successfully implemented. This feature creates a PumpFun SPL token, performs an initial buy, and automatically sells when any external wallet buys the token.
Implementation Details
1. Token Creation (PumpFun)
create_token()method insrc/dex/pump_fun.rsCreateTokenArgsstruct for Borsh serialization2. Initial Buy
execute_initial_buy()methodREVERSE_SNIPER_INITIAL_BUY_SOL3. State Management
src/processor/reverse_sniper.rsmoduleREVERSE_SNIPER_MINTSDashMap for tracking reverse sniper tokensReverseSniperMetastruct for tracking metadata4. Sell Trigger Detection
src/processor/sniper_bot.rs5. Random Token Generator
src/common/random_token_generator.rsmodule6. Configuration
src/common/config.rssrc/env.examplewith new environment variables7. Orchestration
--reverse-sniperCLI flag tosrc/main.rsNew Environment Variables
Usage
Basic Usage (Fixed Metadata)
AI-Generated Random Tokens
Architecture
Workflow
REVERSE_SNIPER_MINTSfor monitoringKey Components
pump_fun.rs: Token creation and swap executionreverse_sniper.rs: State management and sell trigger logicsniper_bot.rs: Transaction monitoring and trigger detectionrandom_token_generator.rs: AI token metadata generationconfig.rs: Configuration managementFiles Changed
src/dex/pump_fun.rs- Added token creation methodssrc/common/config.rs- Added configuration fieldssrc/common/mod.rs- Exported new modulesrc/env.example- Added environment variablessrc/main.rs- Added CLI flag and orchestrationsrc/processor/mod.rs- Exported reverse sniper modulesrc/processor/sniper_bot.rs- Added trigger detectionNew Files Created
src/common/random_token_generator.rs- Random token metadata generatorsrc/processor/reverse_sniper.rs- Reverse sniper state managementTesting Notes
Next Steps
AI Collaborators
@cursor @codex @Copilot @claude
Status: β Implementation Complete
Branch:
feature/reverse-sniper-botCommit: a6f031b
All core functionality has been implemented according to the plan. The bot is ready for testing and deployment.