Skip to content

InjectiveLabs/qa-python-injective-trading-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– QA Injective MM Bot | Professional Market Making System ๐Ÿš€

"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.

๐ŸŽฏ What This Bad Boy Does

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

๐ŸŒŸ Features That'll Make You Say "WAGMI"

๐ŸŽฎ Core Trading Features

  • ๐Ÿ”ฅ 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)

๐Ÿง  Market Intelligence

  • ๐Ÿ“ˆ 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

๐Ÿ”’ Security & Risk Management

  • ๐Ÿ” 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

๐Ÿ—๏ธ System Architecture

๐ŸŽฏ High-Level Architecture

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
Loading

๐Ÿ”„ Trading Flow Diagram

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)
Loading

๐Ÿ—๏ธ Component Architecture

๐Ÿš€ 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

๐ŸŒ Web Dashboard

The QA Injective MM Bot includes a modern web dashboard for real-time monitoring and control:

๐ŸŽฎ Dashboard Features

  • ๐Ÿ“Š 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

๐Ÿš€ Launching the Web Dashboard

  1. Start the Web Server:
cd web
python app.py
  1. Access the Dashboard:
  • Open your browser and go to: http://localhost:8000
  • The dashboard will automatically connect via WebSocket for real-time updates
  1. 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 Interface Architecture

๐ŸŒ 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

๐Ÿš€ Complete System Launch

๐ŸŽฏ Two Ways to Run the Bot

Option 1: ๐ŸŒ Web Dashboard (Recommended)

# 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

Option 2: ๐Ÿค– Command Line Only

# 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

๐Ÿ“‹ Prerequisites

  • 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)

๐Ÿ› ๏ธ Installation (The Setup of Champions)

  1. 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
  1. Configure Your Wallets ๐Ÿ”
cp env.example .env
# Edit .env with your wallet private keys (keep them secret!)
  1. 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
  1. 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
    }
  }
}
  1. 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

๐ŸŽฎ How It Works (The Magic Behind the Curtain)

๐Ÿ”„ Trading Logic Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    ๐Ÿค– 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 Parallel Execution

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    ๐ŸŽฏ 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                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”„ Trading Cycle

  1. ๐Ÿ“Š Price Check - Bot checks testnet vs mainnet prices
  2. ๐ŸŽฏ Decision Time - If price difference > 2%, it's time to make money!
  3. ๐ŸŽช Order Placement - Creates rich orderbook with randomized orders
  4. โฐ Wait & Repeat - 10-second cooldown, then repeat the cycle

๐Ÿ’ฐ Price Correction Logic

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!

๐ŸŽฒ Order Sizing (The Art of Looking Natural)

  • 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

๐Ÿ“Š Market Data Management

๐Ÿ” Market Comparison Tool

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 Directory Structure

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

โš™๏ธ Trading Parameters (The Settings of Success)

๐ŸŽฏ Order Sizing

  • 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

๐Ÿ“ˆ Price Levels

  • 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

โฐ Timing

  • 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

๐Ÿ› ๏ธ Development (For the Builders)

๐Ÿ“ Project Structure

โ”œโ”€โ”€ ๐Ÿ“ฑ 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

๐Ÿ”ง Adding New Features

  • 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

๐Ÿšจ Important Notes (Read This or Get Rekt)

๐Ÿงช Testnet Only

  • 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

โš ๏ธ Risk Disclaimer

  • 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

๐Ÿ“Š Performance Stats

  • 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

๐Ÿ”ฎ Future Enhancements (The Roadmap to Glory)

๐Ÿš€ Planned Features

  • ๐ŸŒ 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

๐Ÿ—๏ธ Clean Architecture

  • ๐Ÿ“ฑ Standalone Scripts: Self-contained trading functionality
  • ๐Ÿงฉ Modular Design: Easy to extend and modify
  • ๐ŸŽฏ Focused Purpose: Single responsibility per component
  • ๐Ÿ“ฆ Minimal Dependencies: Only essential libraries

๐Ÿ†˜ Troubleshooting (When Things Go Wrong)

๐Ÿ”ง Common Issues

  1. "No wallets found" - Check your .env file has the right format
  2. "Sequence mismatch" - Bot will auto-retry, just wait
  3. "Mainnet price failed" - Network issue, bot will retry
  4. "Ctrl+C not working" - Fixed! Now works immediately

๐Ÿ“ Logs

  • 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

๐Ÿ“ž Support (We Got Your Back)

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

๐ŸŽ‰ Success Stories

"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

๐Ÿ“š Quick Reference

๐Ÿš€ Essential Commands

# 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

๐ŸŒ Web Dashboard URLs

  • Main Dashboard: http://localhost:8000
  • API Status: http://localhost:8000/api/status
  • Bot Control: http://localhost:8000/api/control
  • WebSocket: ws://localhost:8000/ws

๐Ÿ“ Key Files

  • Bot Script: scripts/multi_wallet_trader.py
  • Web App: web/app.py
  • Configuration: config/markets_config.json
  • Environment: .env
  • Logs: logs/trading.log

๐ŸŽฏ Network Information

  • Trading Network: Injective Testnet
  • Price Reference: Injective Mainnet
  • Web Interface: Localhost (Port 8000)
  • WebSocket: Real-time updates

๐Ÿ† Final Words

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! ๐Ÿ˜‰

About

QA Python Injective Trading Bot - A comprehensive trading bot for the Injective Protocol

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published