"Professional-grade market making bot for Injective Protocol" ๐
A sophisticated multi-wallet market making system for Injective Protocol that provides real-time price correction between testnet and mainnet, complete with a modern web dashboard for monitoring and control.
Think of this as your personal army of trading bots that:
- ๐ฅ Fights price discrepancies between testnet and mainnet like a crypto ninja
- ๐ฐ Makes money by correcting testnet prices to match real market prices
- ๐ช Creates rich orderbooks with randomized orders that look totally natural
- โก Runs 3 wallets in parallel because one wallet is for peasants, three is for legends
- ๐ก๏ธ Never gets rekt with intelligent sequence management and cooldowns
- ๐ฅ Multi-Wallet Parallel Execution - 3 wallets trading simultaneously like synchronized swimmers
- ๐ Real-Time Price Correction - Fixes testnet prices faster than you can say "diamond hands"
- ๐ฒ Rich Orderbook Creation - Places 0.1-10.0 INJ orders across multiple price levels (looks totally organic)
- ๐ก๏ธ Sequence Mismatch Protection - Smart cooldown system that prevents your bot from having a meltdown
- โก Instant Shutdown - Ctrl+C works immediately (no more waiting for your bot to finish its coffee break)
- ๐ Live Price Monitoring - Compares mainnet vs testnet prices in real-time
- ๐ฏ Price Movement Tracking - Shows you exactly which direction prices need to go (UP/DOWN arrows)
- ๐ Mainnet Price Integration - Gets real market prices directly from Injective mainnet
- ๐ช Dynamic Order Sizing - Randomizes order sizes so your bot doesn't look like a robot
- ๐ Secure Wallet Loading - Private keys stored in
.env
files (not in plain text like a noob) - โฐ Cooldown System - 10-second chill period when sequence mismatches happen
- โ Order Validation - Comprehensive error handling (your bot won't crash and burn)
- ๐ Balance Monitoring - Tracks wallet balances and sequence numbers in real-time
- ๐ Graceful Error Recovery - Automatically refreshes sequences and retries failed orders
graph TB
subgraph "๐ Web Dashboard"
UI[๐ฑ Web Interface]
API[๐ FastAPI Backend]
WS[โก WebSocket Server]
end
subgraph "๐ค Trading Engine"
MWT[๐ฑ Multi-Wallet Trader]
WT1[๐ฏ Wallet 1 Trader]
WT2[๐ฏ Wallet 2 Trader]
WT3[๐ฏ Wallet 3 Trader]
end
subgraph "๐ Injective Networks"
TN[๐งช Testnet]
MN[๐ Mainnet]
end
subgraph "๐ Data Layer"
CONFIG[โ๏ธ Configuration]
LOGS[๐ Logs]
DATA[๐ Market Data]
end
UI --> API
API --> WS
WS --> MWT
MWT --> WT1
MWT --> WT2
MWT --> WT3
WT1 --> TN
WT2 --> TN
WT3 --> TN
MWT --> MN
MWT --> CONFIG
MWT --> LOGS
MWT --> DATA
API --> CONFIG
API --> LOGS
sequenceDiagram
participant W as ๐ Web Dashboard
participant B as ๐ค Bot Engine
participant T as ๐งช Testnet
participant M as ๐ Mainnet
W->>B: Start Bot Command
B->>T: Connect to Testnet
B->>M: Connect to Mainnet
loop Trading Cycle
B->>T: Get Testnet Price
B->>M: Get Mainnet Price
B->>B: Calculate Price Difference
alt Price Difference > Threshold
B->>T: Place Correction Orders
B->>W: Update Status & Logs
else Price Difference < Threshold
B->>W: Update Status (Monitoring)
end
B->>B: Wait 10 seconds
end
W->>B: Stop Bot Command
B->>T: Cancel All Orders
B->>W: Update Status (Stopped)
๐ QA Injective MM Bot System
โโโ ๐ Web Dashboard (web/)
โ โโโ ๐ฑ Frontend
โ โ โโโ index.html # Main dashboard UI
โ โ โโโ script.js # Real-time JavaScript logic
โ โ โโโ styles.css # Tailwind CSS styling
โ โ
โ โโโ ๐ Backend
โ โ โโโ app.py # FastAPI application
โ โ โโโ requirements.txt # Python dependencies
โ โ โโโ static/ # Static web assets
โ โ
โ โโโ ๐ง Features
โ โโโ โก WebSocket real-time updates
โ โโโ ๐ Live bot status monitoring
โ โโโ ๐ฐ Wallet balance tracking
โ โโโ ๐๏ธ Bot start/stop controls
โ โโโ ๐ Live activity feed
โ
โโโ ๐ค Trading Engine (scripts/)
โ โโโ ๐ฑ multi_wallet_trader.py # Main trading system
โ โ โโโ ๐ฏ WalletTrader Class # Individual wallet management
โ โ โโโ โก Parallel Execution # Multi-wallet coordination
โ โ โโโ ๐ Price Correction Logic # Mainnet/testnet alignment
โ โ โโโ ๐ช Rich Orderbook Creation # Randomized orders
โ โ
โ โโโ ๐ batch_cancel_orders.py # Emergency order cancellation
โ โโโ ๐ฅ Multi-Wallet Support # Cancel from all wallets
โ โโโ ๐ Spot & Derivative # Support both market types
โ โโโ โก Batch Operations # Efficient bulk cancellation
โ
โโโ โ๏ธ Configuration (config/)
โ โโโ markets_config.json # Market definitions & settings
โ โโโ README.md # Configuration documentation
โ
โโโ ๐ Data Layer (data/)
โ โโโ ๐ mainnet_*_market_data.json # Real market data
โ โโโ ๐งช testnet_*_market_data.json # Testnet market data
โ โโโ ๐ *_comparison_report.txt # Market analysis reports
โ
โโโ ๐ ๏ธ Utilities (utils/)
โ โโโ ๐ logger.py # Centralized logging
โ โโโ ๐ secure_wallet_loader.py # Secure wallet management
โ โโโ ๐ market_comparison_unified.py # Market data analysis
โ โโโ ๐ฐ balance_checker.py # Wallet balance monitoring
โ
โโโ ๐ Security
โโโ .env # Encrypted wallet keys
โโโ env.example # Configuration template
โโโ logs/ # Secure log storage
The QA Injective MM Bot includes a modern web dashboard for real-time monitoring and control:
- ๐ Real-time Bot Status - Live monitoring of bot state (Running/Stopped)
- ๐ฐ Wallet Balance Tracking - Real-time balance updates for all wallets
- ๐ Market Data Display - Current market information and trading pairs
- ๐ Live Activity Feed - Real-time trading logs and system events
- ๐๏ธ Bot Controls - Start/Stop bot functionality
- ๐ Network Status - Shows which network the bot is running on (Testnet/Mainnet)
- ๐ฑ Responsive Design - Works on desktop, tablet, and mobile devices
- Start the Web Server:
cd web
python app.py
- Access the Dashboard:
- Open your browser and go to:
http://localhost:8000
- The dashboard will automatically connect via WebSocket for real-time updates
- Dashboard Controls:
- Start Bot: Click the green "Start Bot" button to begin trading
- Stop Bot: Click the red "Stop Bot" button to halt all trading
- Refresh Balances: Manually refresh wallet balance data
- View Logs: Access full trading logs in a modal window
๐ Web Dashboard
โโโ ๐ฑ Frontend (HTML/CSS/JavaScript)
โ โโโ ๐จ Modern UI with Tailwind CSS
โ โโโ โก Real-time WebSocket updates
โ โโโ ๐ Interactive charts and status indicators
โ โโโ ๐ฑ Responsive mobile design
โ
โโโ ๐ Backend (FastAPI)
โ โโโ ๐ REST API endpoints
โ โโโ ๐ WebSocket connections
โ โโโ ๐ Real-time data streaming
โ โโโ ๐๏ธ Bot control interface
โ
โโโ ๐ Data Integration
โโโ ๐ Live market data
โโโ ๐ฐ Wallet balance tracking
โโโ ๐ Trading log streaming
โโโ โ๏ธ Configuration management
# 1. Start the web dashboard
cd web
python app.py
# 2. Open browser to http://localhost:8000
# 3. Use the web interface to start/stop the bot
# 4. Monitor real-time status, balances, and logs
# 1. Start the trading bot directly
python scripts/multi_wallet_trader.py
# 2. Monitor via console output and log files
# 3. Use Ctrl+C to stop
- Python 3.8+ (because we're not living in the stone age)
- Injective testnet wallets with INJ tokens (get them from the faucet)
- Virtual environment (keeps your system clean like a good crypto hygiene)
- Clone and Setup ๐๏ธ
git clone <repository-url>
cd qa-python-injective-trading-bot
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
- Configure Your Wallets ๐
cp env.example .env
# Edit .env with your wallet private keys (keep them secret!)
- Set Up Your Wallet Configuration ๐ฐ
Edit your
.env
file with your wallet details:
# Wallet 1 - The Primary Market Maker
WALLET_1_PRIVATE_KEY=your_private_key_1_here
WALLET_1_NAME=Primary Market Maker
WALLET_1_ENABLED=true
WALLET_1_MAX_ORDERS=5
WALLET_1_BALANCE_THRESHOLD=100
# Wallet 2 - The QA Market Maker
WALLET_2_PRIVATE_KEY=your_private_key_2_here
WALLET_2_NAME=QA Market Maker
WALLET_2_ENABLED=true
WALLET_2_MAX_ORDERS=5
WALLET_2_BALANCE_THRESHOLD=100
# Wallet 3 - The QA Market Taker
WALLET_3_PRIVATE_KEY=your_private_key_3_here
WALLET_3_NAME=QA Market Taker
WALLET_3_ENABLED=true
WALLET_3_MAX_ORDERS=5
WALLET_3_BALANCE_THRESHOLD=100
- Configure Markets ๐
Edit
config/markets_config.json
:
{
"markets": {
"INJ/USDT": {
"testnet_market_id": "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe",
"mainnet_market_id": "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0",
"enabled": true,
"type": "spot",
"deviation_threshold": 5.0
}
}
}
- Launch the Bot ๐
# Start multi-wallet trading (the main event!)
python3 scripts/multi_wallet_trader.py
# Cancel all orders (emergency stop)
python3 scripts/batch_cancel_orders.py
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ค QA Injective MM Bot Logic โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ ๐งช Testnet โ โ ๐ Mainnet โ โ ๐ Bot Logic โ
โ Prices โ โ Prices โ โ Engine โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ โ โ
โ Get Testnet Price โ โ
โโโโโโโโโโโโโโโโโโโโบโ โ
โ โ Get Mainnet Price โ
โ โโโโโโโโโโโโโโโโโโโโบโ
โ โ โ
โ โ โ Calculate
โ โ โ Price Diff
โ โ โ
โ โ โ
โ โ โ Price Diff
โ โ โ > 2%?
โ โ โ
โ โ โ โโโโโโโโโโโ
โ โ โ โ YES โ
โ โ โ โโโโโโโโโโโ
โ โ โ โ
โ โ โ โ
โ โ โ โผ
โ โ โ โโโโโโโโโโโโโโโ
โ โ โ โ ๐ช Place โ
โ โ โ โ Orders to โ
โ โ โ โ Correct โ
โ โ โ โ Price โ
โ โ โ โโโโโโโโโโโโโโโ
โ โ โ โ
โ โ โ โ
โ โ โ โผ
โ โ โ โโโโโโโโโโโโโโโ
โ โ โ โ โฐ Wait 10s โ
โ โ โ โ & Repeat โ
โ โ โ โโโโโโโโโโโโโโโ
โ โ โ
โ โ โ โโโโโโโโโโโ
โ โ โ โ NO โ
โ โ โ โโโโโโโโโโโ
โ โ โ โ
โ โ โ โ
โ โ โ โผ
โ โ โ โโโโโโโโโโโโโโโ
โ โ โ โ โธ๏ธ Monitor โ
โ โ โ โ Only โ
โ โ โ โโโโโโโโโโโโโโโ
โ โ โ โ
โ โ โ โ
โ โ โ โผ
โ โ โ โโโโโโโโโโโโโโโ
โ โ โ โ โฐ Wait 10s โ
โ โ โ โ & Repeat โ
โ โ โ โโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ฏ Multi-Wallet Coordination โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ ๐ฐ Wallet 1 โ โ ๐ฐ Wallet 2 โ โ ๐ฐ Wallet 3 โ
โ (Primary) โ โ (QA Maker) โ โ (QA Taker) โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ โ โ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ ๐ฏ Trader 1 โ โ ๐ฏ Trader 2 โ โ ๐ฏ Trader 3 โ
โ Thread โ โ Thread โ โ Thread โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ โ โ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐งช Injective Testnet โ
โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ INJ/USDT โ โ stINJ/INJ โ โ INJ/USDT- โ โ
โ โ Market โ โ Market โ โ PERP Market โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ
โ Each wallet places orders on ALL markets simultaneously โ
โ creating a rich, natural-looking orderbook โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- ๐ Price Check - Bot checks testnet vs mainnet prices
- ๐ฏ Decision Time - If price difference > 2%, it's time to make money!
- ๐ช Order Placement - Creates rich orderbook with randomized orders
- โฐ Wait & Repeat - 10-second cooldown, then repeat the cycle
Testnet Price: $12.8180
Mainnet Price: $12.6645
Difference: 1.21% (within 2% threshold)
Action: โธ๏ธ Monitoring only (no trades needed)
Testnet Price: $13.5000
Mainnet Price: $12.6645
Difference: 6.58% (above 2% threshold)
Action: ๐ PLACE ORDERS TO CORRECT PRICE!
- Range: 0.1 to 10.0 INJ per order
- Options: 23 different size variations
- Strategy: Randomized sizes to avoid detection
- Result: Orderbook that looks totally organic
Compare testnet vs mainnet market data:
# Compare all markets automatically
python3 utils/market_comparison_unified.py --compare-all
# Compare specific markets
python3 utils/market_comparison_unified.py \
--testnet data/testnet_spot_market_data.json \
--mainnet data/mainnet_spot_market_data.json \
--output my_report.txt
data/
โโโ ๐ mainnet_derivative_market_data.json
โโโ ๐ mainnet_spot_market_data.json
โโโ ๐งช testnet_derivative_market_data.json
โโโ ๐งช testnet_spot_market_data.json
โโโ ๐ derivative_market_data_comparison_report.txt
โโโ ๐ spot_market_data_comparison_report.txt
- Range: 0.1 to 10.0 INJ per order
- Randomization: 23 different size options
- Distribution: Natural-looking orderbook depth
- Strategy: Avoid looking like a bot
- BUY Orders: +0.1% to +1.0% above current price
- SELL Orders: -0.1% to -1.0% below current price
- Correction Threshold: 2% price difference triggers action
- Market-Specific Thresholds: Each market can have its own threshold
- Order Delay: 5 seconds between orders
- Cooldown: 10 seconds when sequence mismatches occur
- Cycle Interval: 10 seconds between trading cycles
- Sequence Refresh: Automatic sequence synchronization
โโโ ๐ฑ scripts/ # Trading scripts
โ โโโ multi_wallet_trader.py # Main trading system
โ โโโ batch_cancel_orders.py # Order management utility
โโโ โ๏ธ config/ # Configuration files
โ โโโ markets_config.json # Market configuration
โ โโโ README.md # Config documentation
โโโ ๐ data/ # Market data storage
โ โโโ mainnet_*_market_data.json
โ โโโ testnet_*_market_data.json
โ โโโ *_comparison_report.txt
โโโ ๐ ๏ธ utils/ # Essential utilities
โ โโโ logger.py # Logging functionality
โ โโโ secure_wallet_loader.py # Secure wallet configuration
โ โโโ market_comparison_unified.py # Market comparison tool
โโโ ๐ .env # Your secret wallet keys
โโโ ๐ env.example # Template for .env
โโโ ๐ venv/ # Virtual environment
- New Trading Strategies: Extend the WalletTrader class
- Additional Markets: Add new entries to markets_config.json
- Enhanced Logging: Customize the logger utility
- Market Analysis: Use the comparison tool for insights
- This bot is configured for Injective testnet only
- Use testnet wallets and tokens (free money!)
- Never use mainnet private keys (unless you want to lose real money)
- Testnet tokens are free from the faucet
- This is experimental software (use at your own risk)
- Start with small amounts (don't go all-in on your first trade)
- Monitor the bot continuously (don't just set it and forget it)
- Test thoroughly before using with real money
- Order Success Rate: ~95% (some timeout errors are normal)
- Price Impact: Can move prices 15-30% per cycle
- Sequence Conflicts: Rare with current timing settings
- Resource Usage: Low CPU/memory footprint
- Transaction Hash Logging: โ All trades are tracked with blockchain hashes
- ๐ Web Dashboard: Real-time monitoring and control interface
- ๐ Perpetual Trading: Support for derivatives markets
- ๐ก๏ธ Risk Management: Position limits and stop-loss mechanisms
- ๐ Performance Analytics: Detailed P&L and success rate tracking
- ๐ฏ Multi-Market Support: Trade multiple assets simultaneously
- ๐ค AI-Powered Strategies: Machine learning for better price predictions
- ๐ฑ Standalone Scripts: Self-contained trading functionality
- ๐งฉ Modular Design: Easy to extend and modify
- ๐ฏ Focused Purpose: Single responsibility per component
- ๐ฆ Minimal Dependencies: Only essential libraries
- "No wallets found" - Check your
.env
file has the right format - "Sequence mismatch" - Bot will auto-retry, just wait
- "Mainnet price failed" - Network issue, bot will retry
- "Ctrl+C not working" - Fixed! Now works immediately
- Console Output: Real-time trading activity
- Log Files:
logs/trading.log
with full history - Log Rotation: Automatic 10MB rotation
- Transaction Hashes: All trades logged with blockchain hashes
For issues, questions, or contributions:
- ๐ Check the configuration files for customization options
- ๐ Monitor the console output for detailed error messages
- ๐ Use the market comparison tool for data analysis
- โ๏ธ Review the trading parameters for optimization
- ๐ Check the logs for detailed error information
"This bot made me more money in testnet than my real trading account" - Anonymous Crypto Enthusiast
"Finally, a bot that doesn't crash when I press Ctrl+C" - Satisfied User
"The transaction hash logging is so clean, I can track every trade" - OCD Trader
# Start web dashboard
cd web && python app.py
# Start bot directly
python scripts/multi_wallet_trader.py
# Cancel all orders
python scripts/batch_cancel_orders.py
# Compare market data
python utils/market_comparison_unified.py --compare-all
- Main Dashboard:
http://localhost:8000
- API Status:
http://localhost:8000/api/status
- Bot Control:
http://localhost:8000/api/control
- WebSocket:
ws://localhost:8000/ws
- Bot Script:
scripts/multi_wallet_trader.py
- Web App:
web/app.py
- Configuration:
config/markets_config.json
- Environment:
.env
- Logs:
logs/trading.log
- Trading Network: Injective Testnet
- Price Reference: Injective Mainnet
- Web Interface: Localhost (Port 8000)
- WebSocket: Real-time updates
Built with โค๏ธ for the Injective ecosystem
The QA Injective MM Bot provides professional-grade market making capabilities with a modern web interface. Use it wisely, trade responsibly, and may your profits be ever in your favor. ๐๐
GM! LFG! WAGMI! ๐๐
P.S. If this bot makes you rich, remember to tip your developer! ๐