Loading...
Loading...
Loading...
1. [Project Overview & Architecture](#project-overview--architecture)
# ArbitragePro Configuration Guide: Complete Setup and Deployment
## Table of Contents
1. [Project Overview & Architecture](#project-overview--architecture)
2. [Prerequisites & System Requirements](#prerequisites--system-requirements)
3. [Installation & Setup](#installation--setup)
4. [Environment Configuration](#environment-configuration)
5. [Blockchain RPC Endpoints](#blockchain-rpc-endpoints)
6. [Wallet Configuration & Security](#wallet-configuration--security)
7. [Database Setup](#database-setup)
8. [Trading Strategy Configuration](#trading-strategy-configuration)
9. [Monitoring & Notifications](#monitoring--notifications)
10. [Performance Optimization](#performance-optimization)
11. [Deployment Strategies](#deployment-strategies)
12. [Validation & Testing](#validation--testing)
13. [Troubleshooting](#troubleshooting)
14. [Security Best Practices](#security-best-practices)
15. [Scaling & Migration](#scaling--migration)
---
## Project Overview & Architecture
### System Architecture
ArbitragePro is a multi-chain arbitrage trading system built with Rust, designed for high-performance automated trading across multiple blockchain networks.
```mermaid
graph TB
A[Web Dashboard] --> B[API Gateway]
B --> C[Orchestrator Engine]
C --> D[EVM Arbitrage Module]
C --> E[Solana Arbitrage Module]
C --> F[Flash Loan Module]
D --> G[Ethereum]
D --> H[BSC]
D --> I[Polygon]
D --> J[Avalanche]
D --> K[Arbitrum]
E --> L[Solana DEXs]
F --> M[Aave]
F --> N[Compound]
F --> O[dYdX]
C --> P[Risk Manager]
C --> Q[Price Monitor]
C --> R[Telegram Bot]
Q --> S[DEX APIs]
Q --> T[WebSocket Feeds]
```
### Workspace Structure
```
ArbitragePro/
├── common/ # Shared types, traits, and utilities
├── evm/ # EVM-compatible chains (Ethereum, BSC, Polygon, etc.)
├── solana/ # Solana blockchain support
├── core/ # Main application binary with feature flags
├── contracts/ # Solidity smart contracts (Foundry)
├── config/ # TOML configuration files
├── docs/ # Comprehensive documentation
└── scripts/ # Automation scripts (setup, deploy, migrate)
```
### Key Features
- **Multi-Chain Support**: Ethereum, BSC, Solana, Polygon, Avalanche, Arbitrum, Fantom, Optimism
- **Multiple Arbitrage Strategies**: Simple, Triangular, Flash Loan, Cross-Chain
- **MEV Protection**: Sandwich attack protection, frontrunning detection
- **Auto-Scaling**: Dynamic resource allocation based on market conditions
- **Real-Time Monitoring**: WebSocket feeds, Telegram notifications, Web dashboard
---
## Prerequisites & System Requirements
### Minimum System Requirements
**Current System Configuration (90% Utilization)**
```toml
[hardware]
cpu = "i7 12th gen or equivalent"
ram = "32GB"
storage = "1TB NVMe SSD"
network = "250Mbps stable connection"
[capacity]
max_concurrent_pairs = 4500
max_websocket_connections = 120
price_check_interval_ms = 1500
memory_usage_mb = 28800
cpu_cores_trading = 18
storage_daily_gb = 8
```
**Maximum System Configuration (Future Scaling)**
```toml
[hardware]
cpu = "32+ cores (Threadripper/Xeon)"
ram = "200GB+"
storage = "10TB NVMe SSD"
network = "10Gbps dedicated"
[capacity]
max_concurrent_pairs = 50000
max_websocket_connections = 2000
price_check_interval_ms = 500
memory_usage_mb = 160000
cpu_cores_trading = 32
storage_daily_gb = 50
```
### Software Dependencies
- **Rust**: 1.75+ (latest stable)
- **Node.js**: 18+ (for dashboard and scripts)
- **Docker & Docker Compose**: Latest version
- **PostgreSQL**: 14+ (for trade data storage)
- **Redis**: 6+ (for caching and session management)
- **Foundry**: Latest (for smart contract deployment)
---
## Installation & Setup
### Automated Setup
#### Linux/macOS
```bash
# Clone repository
git clone https://github.com/yourorg/ArbitragePro.git
cd ArbitragePro
# Run automated setup
chmod +x scripts/setup.sh
sudo ./scripts/setup.sh
# Copy environment template
cp .env.example .env
```
#### Windows
```powershell
# Clone repository
git clone https://github.com/yourorg/ArbitragePro.git
cd ArbitragePro
# Run setup script as Administrator
python .\scripts\setup.py
# Copy environment template
copy .env.example .env
```
### Manual Installation
#### 1. Install Rust
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
rustc --version # Verify installation
```
#### 2. Install Node.js
```bash
# Using Node Version Manager (recommended)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 18
nvm use 18
```
#### 3. Install Docker
```bash
# Ubuntu/Debian
sudo apt update
sudo apt install docker.io docker-compose
sudo systemctl start docker
sudo systemctl enable docker
# Add user to docker group
sudo usermod -aG docker $USER
```
#### 4. Install Foundry
```bash
curl -L https://foundry.paradigm.xyz | bash
foundryup
forge --version # Verify installation
```
#### 5. Install Databases
```bash
# PostgreSQL
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql
sudo systemctl enable postgresql
# Redis
sudo apt install redis-server
sudo systemctl start redis
sudo systemctl enable redis
```
### Build Configuration
#### EVM Chains (Default)
```bash
# Build for EVM-compatible chains
cargo build --package arbitrage-core --features evm --release
# Run EVM version
cargo run --package arbitrage-core --features evm --release -- --chains ethereum,bsc
```
#### Solana Support
```bash
# Enable Solana in Cargo.toml (uncomment "solana" member)
# Build for Solana
cargo build --package arbitrage-core --features solana --release
# Run Solana version
cargo run --package arbitrage-core --features solana --release -- --chains solana
```
> **Note**: Due to dependency conflicts between `ethers` and `solana-sdk` crates, you cannot build both EVM and Solana support in one binary. Use feature flags to build separate binaries.
---
## Environment Configuration
### Core Environment Variables
Edit your [`.env`](.env) file with the following essential configurations:
#### System Configuration
```bash
# Environment Settings
DEV_MODE=false
TESTNET_MODE=false
DRY_RUN_MODE=false
ENABLE_SIMULATIONS=true
PERFORMANCE_MONITORING=true
# Active Blockchain Networks (Start with 3 primary chains)
ACTIVE_CHAINS=ethereum,bsc,solana
# System Performance Settings
MAX_CONCURRENT_PAIRS=2700
PRICE_CHECK_INTERVAL_MS=1500
MAX_MEMORY_USAGE_MB=28800
CPU_CORES_TRADING=18
MAX_WEBSOCKET_CONNECTIONS=60
```
#### Trading Strategy Configuration
```bash
# Strategy Toggles
SIMPLE_ARBITRAGE_ENABLED=true
TRIANGULAR_ARBITRAGE_ENABLED=true
FLASH_LOAN_ARBITRAGE_ENABLED=false # Enable after testing
CROSS_CHAIN_ARBITRAGE_ENABLED=false # Enable for advanced users
# Risk Management Parameters
MIN_PROFIT_THRESHOLD=0.02 # 2% minimum profit required
MAX_SLIPPAGE=0.02 # 2% maximum acceptable slippage
MAX_LOSS_PER_TRADE=0.05 # 5% maximum loss per single trade
MAX_DAILY_LOSS=0.10 # 10% maximum daily loss limit
TRADE_AMOUNT_PERCENTAGE=0.03 # 3% of available balance per trade
```
#### MEV Protection
```bash
# MEV (Maximal Extractable Value) Protection
MEV_PROTECTION_ENABLED=true
SANDWICH_ATTACK_PROTECTION=true
FRONTRUNNING_DETECTION=true
PRIVATE_MEMPOOL_ENABLED=false # Requires private mempool access
FLASHBOTS_ENABLED=false # Enable for Ethereum MEV protection
```
### TOML Configuration Files
ArbitragePro uses TOML files in the [`config/`](config/) directory for advanced configuration:
#### [`config/arbitrage_pro_config.example.toml`](config/arbitrage_pro_config.example.toml)
Main configuration file with all available options:
```toml
# Active chains for trading
active_chains = ["ethereum", "bsc", "solana"]
available_chains = ["ethereum", "bsc", "solana", "polygon", "avalanche", "arbitrum"]
[environment]
hardware = "i7 12th gen, 32GB RAM, RTX 3060"
internet = "250Mbps Cable"
[performance]
max_concurrent_pairs = 2700
price_check_interval_ms = 1500
max_memory_usage_mb = 28800
cpu_cores_trading = 18
max_websocket_connections = 60
[trading]
min_profit_threshold = "0.005" # 0.5%
max_slippage = "0.002" # 0.2%
simple_arbitrage_enabled = true
triangular_arbitrage_enabled = true
flash_loan_arbitrage_enabled = false
```
#### [`config/current_system.toml`](config/current_system.toml)
Current hardware capacity settings:
```toml
hardware = "i7 12th gen, 32GB RAM, RTX 3060"
utilization = 0.90
[current_capacity]
max_concurrent_pairs = 4500
max_websocket_connections = 120
price_check_interval_ms = 1500
memory_usage_mb = 28800
cpu_cores_trading = 18
```
#### [`config/auto_scaling.toml`](config/auto_scaling.toml)
Auto-scaling configuration:
```toml
[scaling]
min_pairs = 1000
max_pairs = 5000
scale_up_threshold = 0.75
scale_down_threshold = 0.25
[instances]
min_instances = 1
max_instances = 5
scale_step = 1
```
---
## Blockchain RPC Endpoints
### Primary Chains (Active by Default)
#### 1. Ethereum Mainnet
**Recommended Providers:**
**Infura (Recommended for beginners)**
1. Visit [infura.io](https://infura.io)
2. Create free account → Create new project → Web3 API
3. Copy Project ID
4. Configure in [`.env`](.env):
```bash
ETHEREUM_RPC_URL=https://mainnet.infura.io/v3/YOUR_PROJECT_ID
ETHEREUM_WS_URL=wss://mainnet.infura.io/ws/v3/YOUR_PROJECT_ID
```
**Alchemy (Alternative)**
1. Visit [alchemy.com](https://alchemy.com)
2. Create account → Create App → Select Ethereum Mainnet
3. Copy API key from dashboard
4. Configure endpoints
**Free Tier Limits:**
- Infura: 100K requests/day
- Alchemy: 300M compute units/month
#### 2. Binance Smart Chain (BSC)
**Public RPC Endpoints (Free):**
```bash
BSC_RPC_URL=https://bsc-dataseed.binance.org/
BSC_WS_URL=wss://bsc-ws-node.nariox.org:443/
```
**Alternative Providers:**
- `https://bsc-dataseed1.defibit.io/`
- `https://bsc-dataseed1.ninicoin.io/`
- `https://bsc-dataseed2.defibit.io/`
#### 3. Solana Mainnet
**Public RPC Endpoint:**
```bash
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
SOLANA_WS_URL=wss://api.mainnet-beta.solana.com/
```
**Premium Providers:**
- **Alchemy Solana**: [alchemy.com/solana](https://alchemy.com/solana)
- **QuickNode**: Premium endpoints with better performance
- **Helius**: Specialized Solana infrastructure
### Secondary Chains (Enable When Scaling)
#### Layer 2 Solutions
```bash
# Polygon (MATIC)
POLYGON_RPC_URL=https://polygon-rpc.com/
POLYGON_WS_URL=wss://polygon-mainnet.g.alchemy.com/v2/YOUR_ALCHEMY_KEY
# Arbitrum
ARBITRUM_RPC_URL=https://arb1.arbitrum.io/rpc
ARBITRUM_WS_URL=wss://arb1.arbitrum.io/ws
# Optimism
OPTIMISM_RPC_URL=https://mainnet.optimism.io/
OPTIMISM_WS_URL=wss://ws-mainnet.optimism.io/
```
#### Alternative Layer 1s
```bash
# Avalanche C-Chain
AVALANCHE_RPC_URL=https://api.avax.network/ext/bc/C/rpc
AVALANCHE_WS_URL=wss://api.avax.network/ext/bc/C/ws
# Fantom Opera
FANTOM_RPC_URL=https://rpc.ftm.tools/
FANTOM_WS_URL=wss://wsapi.fantom.network/
```
### RPC Configuration in TOML
Configure RPC endpoints in [`config/arbitrage_pro_config.example.toml`](config/arbitrage_pro_config.example.toml):
```toml
[rpc_endpoints.ethereum]
rpc_url = "https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID"
ws_url = "wss://mainnet.infura.io/ws/v3/YOUR_INFURA_PROJECT_ID"
chain_id = 1
is_active = true
[rpc_endpoints.bsc]
rpc_url = "https://bsc-dataseed.binance.org/"
ws_url = "wss://bsc-ws-node.nariox.org:443"
chain_id = 56
is_active = true
```
---
## Wallet Configuration & Security
> 🚨 **CRITICAL SECURITY WARNING**: Private keys control your funds. Never share them or store them insecurely.
### Creating New Wallets
#### 1. EVM Chains (Ethereum, BSC, Polygon, etc.)
**Method 1: MetaMask (Recommended)**
1. Install MetaMask browser extension
2. Create new wallet → **Save seed phrase securely offline**
3. Go to Account Details → Export Private Key
4. Copy private key (64-character hex string starting with 0x)
5. Add to [`.env`](.env):
```bash
ETHEREUM_PRIVATE_KEY=0x1234567890abcdef...
BSC_PRIVATE_KEY=0x1234567890abcdef...
```
**Method 2: Hardware Wallet (Most Secure)**
1. Use Ledger or Trezor hardware wallet
2. Generate new account
3. Export private key for trading (keep minimal funds)
4. Store majority of funds on hardware wallet
**Method 3: Command Line (Advanced)**
```bash
# Generate random private key using OpenSSL
openssl rand -hex 32
# Verify with cast (Foundry tool)
cast wallet new
```
#### 2. Solana Wallets
**Method 1: Solana CLI**
```bash
# Install Solana CLI
curl -sSfL https://release.solana.com/v1.18.0/install | sh
source ~/.profile
# Generate new keypair
solana-keygen new --outfile ~/solana-wallet.json
# Get public key
solana-keygen pubkey ~/solana-wallet.json
# Get private key (base58 format)
cat ~/solana-wallet.json
```
**Method 2: Phantom Wallet**
1. Install Phantom browser extension
2. Create new wallet → **Save seed phrase securely**
3. Settings → Export Private Key
4. Add to [`.env`](.env):
```bash
SOLANA_PRIVATE_KEY=your_base58_private_key_here
```
### Wallet Funding Strategy
#### Initial Capital Requirements
- **Minimum per chain**: $1,000-$5,000 for meaningful arbitrage
- **Recommended**: $10,000+ per active chain
- **Gas reserves**: Always maintain 10-20% for transaction fees
#### Funding Sources
1. **Centralized Exchanges**
- Binance, Coinbase, Kraken, FTX
- Buy native tokens: ETH, BNB, SOL, MATIC, AVAX
2. **Bridge Services** (for Layer 2s)
- Arbitrum Bridge: [bridge.arbitrum.io](https://bridge.arbitrum.io)
- Optimism Gateway: [app.optimism.io/bridge](https://app.optimism.io/bridge)
- Polygon Bridge: [wallet.polygon.technology](https://wallet.polygon.technology)
#### Gas Fee Reserves by Chain
```bash
# Minimum gas reserves (in native tokens)
ETHEREUM_MIN_GAS_RESERVE=0.1 # ETH
BSC_MIN_GAS_RESERVE=0.01 # BNB
SOLANA_MIN_GAS_RESERVE=0.1 # SOL
POLYGON_MIN_GAS_RESERVE=10 # MATIC
AVALANCHE_MIN_GAS_RESERVE=0.1 # AVAX
ARBITRUM_MIN_GAS_RESERVE=0.01 # ETH
FANTOM_MIN_GAS_RESERVE=10 # FTM
OPTIMISM_MIN_GAS_RESERVE=0.01 # ETH
```
### Gas Price Configuration
Configure maximum gas prices in [`.env`](.env):
```bash
# Gas Price Limits (in Gwei for EVM chains)
ETHEREUM_MAX_GAS_PRICE_GWEI=50
BSC_MAX_GAS_PRICE_GWEI=10
POLYGON_MAX_GAS_PRICE_GWEI=100
AVALANCHE_MAX_GAS_PRICE_GWEI=30
ARBITRUM_MAX_GAS_PRICE_GWEI=2
FANTOM_MAX_GAS_PRICE_GWEI=200
OPTIMISM_MAX_GAS_PRICE_GWEI=2
```
### Dynamic Gas Price APIs
**Real-time Gas Price Sources:**
1. **ETH Gas Station**
- API: `https://ethgasstation.info/api/ethgasAPI.json`
- Free tier available
2. **GasNow (Ethereum)**
- API: `https://www.gasnow.org/api/v3/gas/price`
- Real-time gas prices
3. **BSC Gas Tracker**
- API: `https://api.bscscan.com/api?module=gastracker&action=gasoracle`
- Free with API key
---
## Database Setup
### PostgreSQL Configuration
#### Local Installation
**Ubuntu/Debian:**
```bash
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql
sudo systemctl enable postgresql
# Create database and user
sudo -u postgres psql
CREATE DATABASE arbitrage_pro;
CREATE USER arbitrage_user WITH ENCRYPTED PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE arbitrage_pro TO arbitrage_user;
GRANT ALL ON SCHEMA public TO arbitrage_user;
\q
```
**macOS:**
```bash
brew install postgresql
brew services start postgresql
createdb arbitrage_pro
```
**Windows:**
1. Download from [postgresql.org](https://postgresql.org/download/windows/)
2. Run installer with default settings
3. Note down superuser password
4. Use pgAdmin to create database
#### Cloud Database Options
**1. AWS RDS PostgreSQL**
```bash
# Create RDS instance
aws rds create-db-instance \
--db-instance-identifier arbitrage-pro-db \
--db-instance-class db.t3.micro \
--engine postgres \
--master-username arbitrage_user \
--master-user-password your_secure_password \
--allocated-storage 20 \
--vpc-security-group-ids sg-xxxxxxxxx
# Get connection string
DATABASE_URL=postgresql://arbitrage_user:password@endpoint:5432/arbitrage_pro
```
**2. Google Cloud SQL**
```bash
# Create Cloud SQL instance
gcloud sql instances create arbitrage-pro-db \
--database-version=POSTGRES_14 \
--tier=db-f1-micro \
--region=us-central1
# Create database
gcloud sql databases create arbitrage_pro --instance=arbitrage-pro-db
```
**3. DigitalOcean Managed Database**
1. DigitalOcean Console → Databases
2. Create PostgreSQL cluster
3. Download CA certificate
4. Get connection details
#### Database Configuration in `.env`
```bash
# Local PostgreSQL
DATABASE_URL=postgresql://arbitrage_user:password@localhost:5432/arbitrage_pro
# Cloud PostgreSQL (example)
DATABASE_URL=postgresql://user:pass@host:5432/database?sslmode=require
```
### Redis Configuration
#### Local Installation
**Ubuntu/Debian:**
```bash
sudo apt install redis-server
sudo systemctl start redis
sudo systemctl enable redis
# Test connection
redis-cli ping # Should return PONG
```
**macOS:**
```bash
brew install redis
brew services start redis
```
**Docker (All platforms):**
```bash
docker run -d --name redis -p 6379:6379 redis:alpine
```
#### Cloud Redis Options
**1. AWS ElastiCache**
```bash
# Create ElastiCache cluster
aws elasticache create-cache-cluster \
--cache-cluster-id arbitrage-pro-redis \
--engine redis \
--cache-node-type cache.t3.micro \
--num-cache-nodes 1
# Connection string
REDIS_URL=redis://endpoint:6379/0
```
**2. Redis Cloud**
1. Visit [redislabs.com](https://redislabs.com)
2. Create free account → New subscription
3. Get endpoint and password
4. Format: `redis://username:password@endpoint:port/0`
#### Redis Configuration in `.env`
```bash
# Local Redis
REDIS_URL=redis://localhost:6379/0
# Cloud Redis (example)
REDIS_URL=redis://username:password@endpoint:port/0
```
### Database Migrations
Run database migrations after setup:
```bash
# Apply migrations
cargo run --package arbitrage-core --features evm --release -- migrate
# Verify migration
psql $DATABASE_URL -c "SELECT * FROM information_schema.tables WHERE table_schema = 'public';"
```
---
## Trading Strategy Configuration
### Strategy Overview
ArbitragePro supports multiple arbitrage strategies:
1. **Simple Arbitrage**: Price differences between two DEXs on the same chain
2. **Triangular Arbitrage**: Circular trades using three tokens (A→B→C→A)
3. **Flash Loan Arbitrage**: Zero-capital arbitrage using flash loans
4. **Cross-Chain Arbitrage**: Price differences across different blockchains
### Strategy Configuration
#### Enable/Disable Strategies in `.env`
```bash
# Strategy Toggles
SIMPLE_ARBITRAGE_ENABLED=true
TRIANGULAR_ARBITRAGE_ENABLED=true
FLASH_LOAN_ARBITRAGE_ENABLED=false # Requires careful setup
CROSS_CHAIN_ARBITRAGE_ENABLED=false # Advanced feature
```
#### Risk Management Parameters
```bash
# Profit & Loss Thresholds
MIN_PROFIT_THRESHOLD=0.02 # 2% minimum profit required
MAX_SLIPPAGE=0.02 # 2% maximum acceptable slippage
MAX_LOSS_PER_TRADE=0.05 # 5% maximum loss per single trade
MAX_DAILY_LOSS=0.10 # 10% maximum daily loss limit
TRADE_AMOUNT_PERCENTAGE=0.03 # 3% of available balance per trade
```
### DEX Configuration
Configure supported DEXs in [`config/arbitrage_pro_config.example.toml`](config/arbitrage_pro_config.example.toml):
#### Ethereum DEXs
```toml
[[dex_configs.ethereum]]
name = "Uniswap V2"
router_address = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
factory_address = "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f"
fee_percentage = "0.003"
is_active = true
supports_flash_loans = false
[[dex_configs.ethereum]]
name = "Sushiswap"
factory_address = "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac"
fee_percentage = "0.003"
is_active = true
supports_flash_loans = false
```
#### BSC DEXs
```toml
[[dex_configs.bsc]]
name = "PancakeSwap V2"
router_address = "0x10ED43C718714eb63d5aA57B78B54704E256024E"
factory_address = "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"
fee_percentage = "0.0025"
is_active = true
supports_flash_loans = false
```
### Token Configuration
Define tokens to monitor in [`config/arbitrage_pro_config.example.toml`](config/arbitrage_pro_config.example.toml):
#### Ethereum Tokens
```toml
[[token_configs.ethereum]]
symbol = "WETH"
address = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
decimals = 18
min_liquidity = "1000000.0" # $1M minimum liquidity
is_active = true
tier = "Tier1"
[[token_configs.ethereum]]
symbol = "USDC"
address = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
decimals = 6
min_liquidity = "5000000.0" # $5M minimum liquidity
is_active = true
tier = "Tier1"
```
#### Token Tiers and Liquidity Requirements
Configure minimum liquidity requirements in [`.env`](.env):
```bash
# Minimum Liquidity Requirements (USD per chain)
ETHEREUM_MIN_LIQUIDITY=500000 # $500K minimum
BSC_MIN_LIQUIDITY=100000 # $100K minimum
SOLANA_MIN_LIQUIDITY=100000 # $100K minimum
POLYGON_MIN_LIQUIDITY=50000 # $50K minimum
AVALANCHE_MIN_LIQUIDITY=100000 # $100K minimum
ARBITRUM_MIN_LIQUIDITY=50000 # $50K minimum
FANTOM_MIN_LIQUIDITY=25000 # $25K minimum
OPTIMISM_MIN_LIQUIDITY=50000 # $50K minimum
```
### Auto-Discovery Configuration
Enable automatic discovery of new profitable pairs:
```bash
# Auto-Discovery Settings
AUTO_DISCOVERY_ENABLED=true
AUTO_DISCOVERY_INTERVAL_HOURS=1
NEW_PAIR_TEST_DURATION_HOURS=24
```
---
## Performance Optimization
### Hardware-Based Configuration
Use the provided TOML templates in [`config/`](config/) to tune system capacity based on your hardware:
#### Current System Configuration
```toml
# config/current_system.toml
hardware = "i7 12th gen, 32GB RAM, RTX 3060"
utilization = 0.90
[current_capacity]
max_concurrent_pairs = 4500
max_websocket_connections = 120
price_check_interval_ms = 1500
memory_usage_mb = 28800
cpu_cores_trading = 18
storage_daily_gb = 8
```
#### Maximum System Configuration
```toml
# config/maximum_system.toml
hardware = "32 cores, 200GB RAM, 10Gbps Network"
utilization = 0.80
[max_capacity]
max_concurrent_pairs = 50000
max_websocket_connections = 2000
price_check_interval_ms = 500
memory_usage_mb = 160000
cpu_cores_trading = 32
storage_daily_gb = 50
```
### Auto-Scaling Configuration
Configure auto-scaling in [`config/auto_scaling.toml`](config/auto_scaling.toml):
```toml
[scaling]
min_pairs = 1000
max_pairs = 5000
scale_up_threshold = 0.75
scale_down_threshold = 0.25
[instances]
min_instances = 1
max_instances = 5
scale_step = 1
[monitoring]
check_interval_sec = 60
metric = "CPUUtilization"
```
### Performance Tuning Guidelines
#### Token Tier Performance Settings
- **Tier 1**: Highest liquidity, shortest intervals (500–1000 ms)
- **Tier 2**: Medium liquidity, moderate intervals (2000–3000 ms)
- **Tier 3**: Lower liquidity, longer intervals (5000 ms+)
#### Memory Optimization
```bash
# Adjust based on available RAM
MAX_MEMORY_USAGE_MB=28800 # 90% of 32GB
# For 16GB systems: MAX_MEMORY_USAGE_MB=14400
# For 64GB systems: MAX_MEMORY_USAGE_MB=57600
```
#### CPU Optimization
```bash
# Leave 2-4 cores for system operations
CPU_CORES_TRADING=18 # For 20-core system
# For 8-core system: CPU_CORES_TRADING=6
# For 32-core system: CPU_CORES_TRADING=28
```
---
## Deployment Strategies
### Local Development Deployment
#### Quick Start
```bash
# Clone and setup
git clone https://github.com/yourorg/ArbitragePro.git
cd ArbitragePro
# Automated setup (Linux/macOS)
chmod +x scripts/setup.sh
./scripts/setup.sh
# Windows setup
python scripts/setup.py
# Configure environment
cp .env.example .env
# Edit .env with your configuration
# Build and run
cargo build --package arbitrage-core --features evm --release
cargo run --package arbitrage-core --features evm --release
```
#### Docker Deployment
```bash
# Start services
docker-compose up -d
# Check logs
docker-compose logs -f
# Scale services
docker-compose up -d --scale arbitrage=3
```
### Production Deployment
#### AWS ECS Deployment
1. **Build and Push Docker Image**
```bash
# Login to ECR
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <account>.dkr.ecr.us-east-1.amazonaws.com
# Build and push
docker build -t arbitrage-pro .
docker tag arbitrage-pro:latest <account>.dkr.ecr.us-east-1.amazonaws.com/arbitrage-pro:latest
docker push <account>.dkr.ecr.us-east-1.amazonaws.com/arbitrage-pro:latest
```
2. **Update ECS Service**
```bash
aws ecs update-service \
--cluster arbitrage-pro-cluster \
--service arbitrage-pro-service \
--force-new-deployment
```
3. **Auto-Scaling Configuration**
```bash
# Use provided scripts
./scripts/deploy_current.sh # Deploy with current system config
./scripts/deploy_maximum.sh # Deploy with maximum system config
./scripts/auto_scale.sh # Enable auto-scaling
```
#### Kubernetes Deployment
```bash
# Apply configurations
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
kubectl apply -f k8s/configmap.yaml
```
---
## Validation & Testing
### Connection Testing Scripts
#### Database Connection Test
```javascript
// test-connections.js
const { Pool } = require('pg');
const Redis = require('redis');
// Test PostgreSQL
const testPostgreSQL = async () => {
const pool = new Pool({
connectionString: process.env.DATABASE_URL
});
try {
const result = await pool.query('SELECT NOW()');
console.log('✅ PostgreSQL connected successfully');
console.log('Current time:', result.rows[0].now);
} catch (error) {
console.error('❌ PostgreSQL connection failed:', error.message);
} finally {
await pool.end();
}
};
// Test Redis
const testRedis = async () => {
const redis = Redis.createClient({
url: process.env.REDIS_URL
});
try {
await redis.connect();
await redis.set('test', 'connection');
const result = await redis.get('test');
console.log('✅ Redis connected successfully');
console.log('Test value:', result);
} catch (error) {
console.error('❌ Redis connection failed:', error.message);
} finally {
await redis.quit();
}
};
// Run tests
testPostgreSQL();
testRedis();
```
#### RPC Endpoint Test
```javascript
// test-rpc.js
const Web3 = require('web3');
const testRPC = async (rpcUrl, chainName) => {
try {
const web3 = new Web3(rpcUrl);
const blockNumber = await web3.eth.getBlockNumber();
const gasPrice = await web3.eth.getGasPrice();
console.log(`✅ ${chainName} RPC working`);
console.log(` Latest block: ${blockNumber}`);
console.log(` Gas price: ${Web3.utils.fromWei(gasPrice, 'gwei')} Gwei`);
} catch (error) {
console.error(`❌ ${chainName} RPC failed:`, error.message);
}
};
// Test all configured RPCs
const testAllRPCs = async () => {
await testRPC(process.env.ETHEREUM_RPC_URL, 'Ethereum');
await testRPC(process.env.BSC_RPC_URL, 'BSC');
// Add other chains as needed
};
testAllRPCs();
```
#### Private Key Validation
```javascript
// validate-wallets.js
const Web3 = require('web3');
const validatePrivateKey = (privateKey, chainName) => {
try {
const web3 = new Web3();
const account = web3.eth.accounts.privateKeyToAccount(privateKey);
console.log(`✅ ${chainName} wallet valid`);
console.log(` Address: ${account.address}`);
return true;
} catch (error) {
console.error(`❌ Invalid ${chainName} private key:`, error.message);
return false;
}
};
// Validate all configured wallets
const validateAllWallets = () => {
validatePrivateKey(process.env.ETHEREUM_PRIVATE_KEY, 'Ethereum');
validatePrivateKey(process.env.BSC_PRIVATE_KEY, 'BSC');
// Add other chains as needed
};
validateAllWallets();
```
### Comprehensive Pre-Deployment Checklist
```markdown
## Pre-Deployment Validation Checklist
### Blockchain Connections
- [ ] Ethereum RPC responding with latest block
- [ ] BSC RPC responding with latest block
- [ ] Solana RPC responding with latest block
- [ ] WebSocket connections stable for 5+ minutes
- [ ] Gas price APIs accessible and returning data
### Wallet Security
- [ ] Private keys in valid format (64 hex chars for EVM)
- [ ] Wallet addresses generated correctly
- [ ] Sufficient balance for gas fees (>0.1 ETH, >0.01 BNB, >0.1 SOL)
- [ ] Test transactions successful on testnets
### External Services
- [ ] Telegram bot responding to test messages
- [ ] Database connection established and migrations applied
- [ ] Redis cache working and accessible
- [ ] All API keys valid and within rate limits
### System Resources
- [ ] Memory limits appropriate for hardware (90% max)
- [ ] CPU allocation sufficient (leave 2-4 cores for system)
- [ ] Disk space adequate (>100GB free recommended)
- [ ] Network bandwidth tested (>100Mbps recommended)
### Risk Management
- [ ] Profit thresholds reasonable (2-5% for beginners)
- [ ] Loss limits configured and tested
- [ ] Gas price limits set per chain
- [ ] Slippage tolerance appropriate (1-3%)
### Configuration Files
- [ ] .env file properly configured with all required variables
- [ ] TOML config files match your hardware specifications
- [ ] Token configurations include sufficient liquidity filters
- [ ] DEX configurations are active and addresses verified
```
---
## Troubleshooting
### Common Issues and Solutions
#### 1. Build and Compilation Errors
**Problem**: `Dependency conflict with zeroize crate`
```
error: failed to select a version for `zeroize`
```
**Solution**: Use feature flags to build only one blockchain target at a time:
```bash
# For EVM chains only
cargo build --package arbitrage-core --features evm --release
# For Solana only (uncomment solana in Cargo.toml first)
cargo build --package arbitrage-core --features solana --release
```
**Problem**: `Missing required features`
```
error: target `arbitrage-core` in package `arbitrage-core` requires the features: `evm`
```
**Solution**: Always specify feature flags:
```bash
# Correct
cargo run --package arbitrage-core --features evm --release
# Incorrect
cargo run --package arbitrage-core --release
```
#### 2. RPC Connection Failures
**Problem**: `Connection timeout` or `Invalid JSON RPC response`
**Solutions**:
```bash
# Test connectivity manually
curl -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
https://mainnet.infura.io/v3/YOUR_KEY
# Check rate limits
curl -I https://mainnet.infura.io/v3/YOUR_KEY
```
**Alternative RPC Providers**:
- **Ethereum**: Alchemy, QuickNode, Ankr, Moralis
- **BSC**: Multiple public endpoints, NodeReal, QuickNode
- **Polygon**: Alchemy, QuickNode, Moralis
- **Solana**: Alchemy, QuickNode, Helius
#### 3. Database Connection Issues
**Problem**: `Connection refused` or `Authentication failed`
**Solutions**:
```sql
-- Check PostgreSQL status
SELECT version();
-- Test connection with psql
psql postgresql://user:pass@host:5432/database
-- Grant proper permissions
GRANT ALL PRIVILEGES ON DATABASE arbitrage_pro TO arbitrage_user;
GRANT ALL ON SCHEMA public TO arbitrage_user;
GRANT USAGE ON SCHEMA public TO arbitrage_user;
```
**Docker Database Issues**:
```bash
# Restart database services
docker-compose down
docker-compose up -d postgres redis
# Check logs
docker-compose logs postgres
docker-compose logs redis
```
#### 4. Insufficient Gas Fees
**Problem**: `Transaction failed - insufficient gas`
**Solutions**:
```javascript
// Calculate required gas reserves
const calculateGasReserve = async (web3, chainName) => {
const gasPrice = await web3.eth.getGasPrice();
const estimatedGas = 200000; // Typical arbitrage transaction
const totalCost = gasPrice * estimatedGas;
const costInEth = web3.utils.fromWei(totalCost.toString(), 'ether');
console.log(`${chainName} gas reserve needed: ${costInEth} ETH`);
return costInEth;
};
// Maintain minimum balances
const MIN_GAS_BALANCE = {
ethereum: 0.1, // ETH
bsc: 0.01, // BNB
polygon: 10, // MATIC
avalanche: 0.1, // AVAX
arbitrum: 0.01, // ETH
fantom: 10, // FTM
optimism: 0.01 // ETH
};
```
#### 5. Telegram Bot Not Responding
**Problem**: Bot not sending notifications
**Solutions**:
```javascript
// Test bot manually
const testTelegramBot = async () => {
const token = process.env.TELEGRAM_BOT_TOKEN;
const chatId = process.env.TELEGRAM_CHAT_ID;
// Test bot info
const botInfo = await fetch(
`https://api.telegram.org/bot${token}/getMe`
);
console.log('Bot info:', await botInfo.json());
// Send test message
const response = await fetch(
`https://api.telegram.org/bot${token}/sendMessage`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
chat_id: chatId,
text: '🚀 ArbitragePro test notification'
})
}
);
console.log('Message sent:', await response.json());
};
testTelegramBot();
```
### Error Code Reference
| Error Code | Issue | Solution |
|------------|-------|----------|
| `ECONNREFUSED` | Database/Redis offline | Check service status, restart if needed |
| `ENOTFOUND` | DNS resolution failed | Verify URLs, check internet connection |
| `ETIMEDOUT` | Request timeout | Check network, increase timeout values |
| `429` | Rate limit exceeded | Implement backoff strategy, upgrade plan |
| `401` | Authentication failed | Verify API keys, check permissions |
| `403` | Insufficient permissions | Check account limits, upgrade if needed |
| `500` | Internal server error | Check RPC provider status, try alternative |
---
## Security Best Practices
### Environment Variable Security
#### 1. File Permissions
```bash
# Set restrictive permissions on .env file
chmod 600 .env
chown $USER:$USER .env
# Verify permissions
ls -la .env
# Should show: -rw------- 1 user user
```
#### 2. Environment Variable Validation
```javascript
// env-validator.js
const requiredVars = [
'ETHEREUM_PRIVATE_KEY',
'BSC_PRIVATE_KEY',
'TELEGRAM_BOT_TOKEN',
'DATABASE_URL',
'REDIS_URL'
];
const validateEnvironment = () => {
const missing = [];
requiredVars.forEach(varName => {
if (!process.env[varName]) {
missing.push(varName);
}
});
if (missing.length > 0) {
console.error('❌ Missing required environment variables:');
missing.forEach(var => console.error(` - ${var}`));
process.exit(1);
}
console.log('✅ All required environment variables present');
};
validateEnvironment();
```
#### 3. Secrets Management
**Using Docker Secrets:**
```bash
# Create secret files
echo "your_private_key" | docker secret create eth_private_key -
echo "your_bot_token" | docker secret create telegram_token -
# Use in docker-compose.yml
services:
arbitrage:
secrets:
- eth_private_key
- telegram_token
```
**Using HashiCorp Vault:**
```bash
# Store secrets
vault kv put secret/arbitrage \
eth_private_key="your_key" \
telegram_token="your_token"
# Retrieve in application
vault kv get -field=eth_private_key secret/arbitrage
```
### Multi-Environment Setup
#### Development Environment
```bash
# .env.development
DEV_MODE=true
TESTNET_MODE=true
DRY_RUN_MODE=true
LOG_LEVEL=debug
MIN_PROFIT_THRESHOLD=0.05 # Higher threshold for testing
```
#### Production Environment
```bash
# .env.production
DEV_MODE=false
TESTNET_MODE=false
DRY_RUN_MODE=false
LOG_LEVEL=info
MIN_PROFIT_THRESHOLD=0.02 # Lower threshold for real trading
```
### Operational Security (OpSec)
#### Risk Assessment Matrix
| Risk Level | Impact | Probability | Mitigation Strategy |
|------------|--------|-------------|-------------------|
| **Critical** | Private key theft | Medium | Hardware wallets, cold storage, key rotation |
| **High** | Flash loan attacks | Low | MEV protection, private mempools, slippage limits |
| **High** | Smart contract bugs | Medium | Thorough testing, code audits, gradual deployment |
| **Medium** | API key exposure | Medium | Regular rotation, monitoring, rate limiting |
| **Medium** | Regulatory changes | High | Legal compliance review, geographic restrictions |
| **Low** | Service downtime | Medium | Redundant providers, failover mechanisms |
#### Security Monitoring
```javascript
// security-monitor.js
const monitorSecurity = () => {
// Monitor for unusual transaction patterns
const checkTransactionPatterns = () => {
// Implement pattern detection logic
};
// Monitor wallet balances
const checkWalletBalances = () => {
// Alert if balances drop unexpectedly
};
// Monitor API usage
const checkAPIUsage = () => {
// Alert if API usage spikes unexpectedly
};
setInterval(() => {
checkTransactionPatterns();
checkWalletBalances();
checkAPIUsage();
}, 60000); // Check every minute
};
monitorSecurity();
```
---
## Scaling & Migration
### Horizontal Scaling Strategy
#### Phase 1: Single Chain Deployment (Week 1-2)
```bash
# Start with Ethereum only
ACTIVE_CHAINS=ethereum
MAX_CONCURRENT_PAIRS=1000
PRICE_CHECK_INTERVAL_MS=2000
```
#### Phase 2: Multi-Chain Expansion (Week 3-4)
```bash
# Add BSC and Solana
ACTIVE_CHAINS=ethereum,bsc,solana
MAX_CONCURRENT_PAIRS=2700
PRICE_CHECK_INTERVAL_MS=1500
```
#### Phase 3: Layer 2 Integration (Month 2)
```bash
# Add Layer 2 solutions
ACTIVE_CHAINS=ethereum,bsc,solana,polygon,arbitrum,optimism
MAX_CONCURRENT_PAIRS=4500
PRICE_CHECK_INTERVAL_MS=1000
```
#### Phase 4: Maximum Scaling (Month 3+)
```bash
# Full multi-chain deployment
ACTIVE_CHAINS=ethereum,bsc,solana,polygon,avalanche,arbitrum,fantom,optimism
MAX_CONCURRENT_PAIRS=10000+
PRICE_CHECK_INTERVAL_MS=500
```
### Vertical Scaling Guidelines
#### Hardware Upgrade Path
1. **Entry Level**: 16GB RAM, 8 cores → 1,200 pairs
2. **Current Level**: 32GB RAM, 18 cores → 4,500 pairs
3. **Professional**: 64GB RAM, 32 cores → 15,000 pairs
4. **Enterprise**: 128GB+ RAM, 64+ cores → 50,000+ pairs
#### Auto-Scaling Configuration
```toml
# config/auto_scaling.toml
[scaling]
min_pairs = 1000
max_pairs = 10000
scale_up_threshold = 0.75
scale_down_threshold = 0.25
[instances]
min_instances = 1
max_instances = 10
scale_step = 2
[monitoring]
check_interval_sec = 30
metric = "CPUUtilization"
```
### Migration Procedures
#### Database Migration
```bash
# Backup current database
pg_dump -U postgres arbitrage_pro > backup_$(date +%F).sql
# Apply new migrations
cargo run --package arbitrage-core --features evm --release -- migrate
# Verify migration
psql $DATABASE_URL -c "\dt"
```
#### Configuration Migration
```bash
# Migrate from single config to workspace structure
./scripts/migrate_to_workspace.sh
# Update configuration files
cp config/current_system.toml config/production_system.toml
# Edit production_system.toml with new hardware specs
```
#### Zero-Downtime Deployment
```bash
# Blue-green deployment
./scripts/deploy_blue_green.sh
# Rolling update
kubectl rollout restart deployment/arbitrage-pro
kubectl rollout status deployment/arbitrage-pro
```
---
## Emergency Procedures
### In Case of Security Compromise
#### Immediate Actions (First 5 minutes)
1. **Pause All Trading**
```bash
# Emergency stop
curl -X POST http://localhost:8080/api/emergency-stop
```
2. **Transfer Funds to Secure Wallets**
```bash
# Use emergency withdrawal script
./scripts/emergency_withdraw.sh
```
3. **Rotate All Credentials**
```bash
# Generate new API keys
./scripts/rotate_credentials.sh
```
#### Investigation Phase (Next 30 minutes)
1. **Review Transaction History**
```sql
SELECT * FROM trades
WHERE created_at > NOW() - INTERVAL '24 hours'
ORDER BY created_at DESC;
```
2. **Check System Logs**
```bash
# Check for suspicious activity
grep -i "error\|unauthorized\|failed" logs/arbitrage.log
```
3. **Assess Damage**
```bash
# Calculate losses
./scripts/calculate_losses.sh
```
#### Recovery Phase (Next 2 hours)
1. **Generate New Wallets**
```bash
# Create new secure wallets
./scripts/generate_new_wallets.sh
```
2. **Update All Configurations**
```bash
# Update .env with new credentials
./scripts/update_production_config.sh
```
3. **Implement Additional Security**
```bash
# Enable additional monitoring
./scripts/enable_enhanced_security.sh
```
### Maintenance Schedule
#### Daily Tasks (5 minutes)
- [ ] Check wallet balances across all chains
- [ ] Review trading performance metrics
- [ ] Monitor system resource usage
- [ ] Scan logs for errors or warnings
#### Weekly Tasks (30 minutes)
- [ ] Update gas price settings based on network conditions
- [ ] Review and adjust profit thresholds
- [ ] Check for software updates
- [ ] Backup transaction data
#### Monthly Tasks (2 hours)
- [ ] Comprehensive security audit
- [ ] Performance analysis and optimization
- [ ] Update dependencies and security patches
- [ ] Review and adjust trading parameters
- [ ] Financial reconciliation and tax preparation
---
## Resources and References
### Official Documentation
- [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/)
- [Binance Smart Chain Documentation](https://docs.binance.org/smart-chain/developer/rpc.html)
- [Solana RPC API Reference](https://docs.solana.com/developing/clients/jsonrpc-api)
- [Telegram Bot API](https://core.telegram.org/bots/api)
- [PostgreSQL Documentation](https://www.postgresql.org/docs/)
- [Redis Documentation](https://redis.io/documentation)
### Development Tools
- **MetaMask**: Browser wallet for EVM chains
- **Phantom**: Solana wallet and browser extension
- **Foundry**: Ethereum development framework
- **Hardhat**: Ethereum development environment
- **Anchor**: Solana development framework
### Monitoring and Analytics
- **DeFi Pulse**: Track DeFi protocol metrics
- **DeFiLlama**: TVL and yield tracking across chains
- **Dune Analytics**: On-chain data analysis and dashboards
- **Etherscan**: Ethereum blockchain explorer
- **BSCScan**: Binance Smart Chain explorer
- **Solscan**: Solana blockchain explorer
### Community Resources
- **Discord**: Join DeFi protocol communities for real-time updates
- **Telegram**: Follow announcement channels for each blockchain
- **Reddit**: r/ethdev, r/defi, r/solana, r/cryptocurrency
- **GitHub**: Open source arbitrage bots and trading strategies
- **Twitter**: Follow key developers and protocol updates
### Educational Resources
- **DeFi Academy**: Comprehensive DeFi education
- **Solana Cookbook**: Solana development guides
- **Ethereum.org**: Official Ethereum documentation
- **CoinGecko Learn**: Cryptocurrency and DeFi education
---
## Conclusion
This comprehensive guide provides everything needed to successfully deploy and operate ArbitragePro. The system is designed to scale from a single-chain deployment to a multi-chain arbitrage powerhouse.
### Key Success Factors
1. **Start Small**: Begin with 1-2 chains and gradually expand
2. **Security First**: Never compromise on private key security
3. **Monitor Continuously**: Use all available monitoring tools
4. **Scale Gradually**: Increase complexity as you gain experience
5. **Stay Updated**: Keep software and configurations current
### Next Steps
1. **Week 1**: Complete installation and basic configuration
2. **Week 2**: Deploy on testnet and validate all connections
3. **Week 3**: Start with small amounts on mainnet
4. **Month 2**: Scale to multiple chains and increase capital
5. **Month 3+**: Implement advanced strategies and auto-scaling
### Support and Community
- **GitHub Issues**: Report bugs and request features
- **Documentation**: Keep this guide updated with your learnings
- **Community**: Share experiences and best practices
- **Security**: Report security issues responsibly
---
*Last updated: December 2024*
> 📝 **Disclaimer**: This guide provides technical information for educational purposes. Cryptocurrency trading involves substantial risk of loss. Always conduct thorough testing and consider consulting with professionals before trading with significant amounts. The authors are not responsible for any financial losses incurred through the use of this software.
> 🔒 **Security Notice**: Never share private keys, API tokens, or other sensitive credentials. Always use secure, encrypted storage for sensitive data and follow best practices for operational security.
router_address = "0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F"
factory_address = "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac"
fee_percentage = "0.003"
is_active = true
supports_flash_loans = false
```
#### BSC DEXs
```toml
[[dex_configs.bsc]]
name = "PancakeSwap V2"
router_address = "0x10ED43C718714eb63d5aA57B78B54704E256024E"
factory_address = "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"
fee_percentage = "0.0025"
is_active = true
supports_flash_loans = false
```
### Token Configuration
Define tokens to monitor in [`config/arbitrage_pro_config.example.toml`](config/arbitrage_pro_config.example.toml):
#### Ethereum Tokens
```toml
[[token_configs.ethereum]]
symbol = "WETH"
address = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
decimals = 18
min_liquidity = "1000000.0" # $1M minimum liquidity
is_active = true
tier = "Tier1"
[[token_configs.ethereum]]
symbol = "USDC"
address = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
decimals = 6
min_liquidity = "5000000.0" # $5M minimum liquidity
is_active = true
tier = "Tier1"
```
#### Token Tiers and Liquidity Requirements
Configure minimum liquidity requirements in [`.env`](.env):
```bash
# Minimum Liquidity Requirements (USD per chain)
ETHEREUM_MIN_LIQUIDITY=500000 # $500K minimum
BSC_MIN_LIQUIDITY=100000 # $100K minimum
SOLANA_MIN_LIQUIDITY=100000 # $100K minimum
POLYGON_MIN_LIQUIDITY=50000 # $50K minimum
AVALANCHE_MIN_LIQUIDITY=100000 # $100K minimum
ARBITRUM_MIN_LIQUIDITY=50000 # $50K minimum
FANTOM_MIN_LIQUIDITY=25000 # $25K minimum
OPTIMISM_MIN_LIQUIDITY=50000 # $50K minimum
```
### Auto-Discovery Configuration
Enable automatic discovery of new profitable pairs:
```bash
# Auto-Discovery Settings
AUTO_DISCOVERY_ENABLED=true
AUTO_DISCOVERY_INTERVAL_HOURS=1
NEW_PAIR_TEST_DURATION_HOURS=24
```
---
## Monitoring & Notifications
### Telegram Bot Setup
#### Creating a Telegram Bot
1. **Start BotFather**
- Open Telegram → Search "@BotFather"
- Send `/start` command
2. **Create New Bot**
```
/newbot
→ Enter bot name: "ArbitragePro Bot"
→ Enter username: "arbitrageprobot" (must end with 'bot')
```
3. **Get Bot Token**
- BotFather provides token: `1234567890:ABCdefGHIjklMNOpqrsTUVwxyz`
- Add to [`.env`](.env):
```bash
TELEGRAM_BOT_TOKEN=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
```
4. **Get Chat ID**
- Message your bot first
- Visit: `https://api.telegram.org/bot<TOKEN>/getUpdates`
- Find `"chat":{"id":123456789}` in response
- Add to [`.env`](.env):
```bash
TELEGRAM_CHAT_ID=123456789
```
#### Test Telegram Bot
```javascript
// test-telegram.js
const fetch = require('node-fetch');
const testBot = async () => {
const token = process.env.TELEGRAM_BOT_TOKEN;
const chatId = process.env.TELEGRAM_CHAT_ID;
const response = await fetch(
`https://api.telegram.org/bot${token}/sendMessage`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
chat_id: chatId,
text: '🚀 ArbitragePro Bot is online and ready!'
})
}
);
const result = await response.json();
console.log('Test message sent:', result.ok);
};
testBot();
```
### Prometheus Metrics
Configure metrics endpoint in [`.env`](.env):
```bash
# Service Ports
METRICS_PORT=9090 # Prometheus metrics endpoint
DASHBOARD_PORT=3000 # Web dashboard interface
API_PORT=8080 # REST API endpoint
```
#### Prometheus Configuration
Create `prometheus.yml`:
```yaml
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'arbitrage_pro'
static_configs:
- targets: ['localhost:9090']
scrape_interval: 5s
metrics_path: /metrics
```
### Grafana Dashboard
1. Add Prometheus data source: `http://localhost:9090`
2. Create dashboard with panels for:
- Opportunities detected per minute
- Trades executed per hour
- Profit/Loss over time
- System resource usage (CPU, Memory)
- Gas fees spent per chain
- Success rate by strategy
### Logging Configuration
Configure logging in [`.env`](.env):
```bash
# Logging Configuration
LOG_LEVEL=info # trace, debug, info, warn, error
LOG_TO_FILE=true
LOG_FILE_PATH=./logs/arbitrage.log
```
#### Log Rotation
Configure log rotation in [`config/arbitrage_pro_config.example.toml`](config/arbitrage_pro_config.example.toml):
```toml
[monitoring]
log_level = "info"
log_to_file = true
log_file_path = "./logs/arbitrage_pro.log"
# Log rotation settings
log_max_size_mb = 100
log_max_files = 10
```
---
## Performance Optimization
### Hardware-Based Configuration**GitHub**:<https://github.com/HammerLynch/MSDS6306_Case_Study_2>
*Company Name : SK C&C*
Reference for building PL/SQL or Scala ETL pipelines. Types use PostgreSQL names as emitted by Diesel.
This document describes how to use the analytics system in the application.