This commit adds complete automation for Phase 1 (mainnet dry-run) deployment with comprehensive wallet configuration guide. ## New Files ### 1. scripts/deploy_phase1.sh Automated Phase 1 deployment script that: - Validates .env configuration - Checks for PRIVATE_KEY (warns if missing) - Verifies RPC connectivity to Arbitrum mainnet - Creates Phase 1 configuration (.env.phase1) - Deploys bot in dry-run mode (NO execution) - Displays monitoring commands and instructions **Safety Features:** - Forces ENABLE_EXECUTION=false - Forces DRY_RUN_MODE=true - Ultra-conservative detection thresholds - Automatic validation of prerequisites **Usage:** ```bash ./scripts/deploy_phase1.sh ``` ### 2. WALLET_SETUP.md Complete wallet configuration guide covering: **Wallet Options:** - Generate new wallet (recommended for testing) - Use existing wallet (MetaMask export) - Generate deterministic test wallet **Configuration:** - Step-by-step .env setup - Private key format validation - Funding requirements by phase - Balance checking commands **Security Best Practices:** - Never commit .env to git - Use dedicated wallet for bot - Limit funds (0.01-0.5 ETH) - Secure backup procedures - Emergency procedures if compromised **Verification:** - Checklist before deployment - Validation commands - Common issues troubleshooting ## Docker Image Tagging Tagged production-ready build: ```bash mev-bot-v2:phase1-ready (5c5ac1755d03) ``` ## Phase 1 Deployment Workflow 1. **Setup Wallet:** - Generate or import private key - Add to .env file - Verify with validation commands 2. **Run Deployment:** ```bash chmod +x scripts/deploy_phase1.sh ./scripts/deploy_phase1.sh ``` 3. **Monitor (48 hours):** ```bash podman logs -f mev-bot-v2-phase1 podman logs mev-bot-v2-phase1 | grep -i "opportunity" ``` 4. **Assess Results:** - Opportunities detected? - No crashes/errors? - Profit calculations reasonable? 5. **Decision:** - Success → Proceed to Phase 3 (minimal capital) - Failure → Analyze and iterate ## Configuration **Phase 1 Settings (Ultra-Safe):** ``` ENABLE_EXECUTION=false # No trades DRY_RUN_MODE=true # Monitoring only MIN_PROFIT_THRESHOLD=0.001 # Detect more opportunities MAX_POSITION_SIZE_ETH=0.01 # Conservative (not used in dry-run) ``` ## Safety Guarantees **Financial Risk: ZERO** - ENABLE_EXECUTION hardcoded to false - DRY_RUN_MODE hardcoded to true - No transactions will be broadcast - Wallet not required (but recommended for testing) **Purpose:** - Validate arbitrage detection on real mainnet - Verify RPC connectivity stability - Test opportunity quality - Prove profitability potential ## Next Steps After Phase 1 completes successfully (48h): 1. Review `PRODUCTION_DEPLOYMENT.md` for Phase 3 2. Fund wallet with 0.1 ETH for minimal capital test 3. Adjust risk parameters if needed 4. Enable execution with ultra-conservative limits 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
182 lines
5.6 KiB
Bash
Executable File
182 lines
5.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# MEV Bot V2 - Phase 1 Deployment Script (Mainnet Dry-Run)
|
|
# This script deploys the bot in monitoring-only mode to validate arbitrage detection
|
|
|
|
set -e
|
|
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${GREEN}========================================${NC}"
|
|
echo -e "${GREEN}MEV Bot V2 - Phase 1 Deployment${NC}"
|
|
echo -e "${GREEN}Mode: Mainnet Dry-Run (48 hours)${NC}"
|
|
echo -e "${GREEN}========================================${NC}"
|
|
echo ""
|
|
|
|
# Check if .env exists
|
|
if [ ! -f .env ]; then
|
|
echo -e "${RED}ERROR: .env file not found${NC}"
|
|
echo "Please create .env file with required configuration"
|
|
exit 1
|
|
fi
|
|
|
|
# Check for PRIVATE_KEY
|
|
if ! grep -q "^PRIVATE_KEY=" .env || grep -q "^PRIVATE_KEY=$" .env || grep -q "^PRIVATE_KEY=???$" .env; then
|
|
echo -e "${YELLOW}WARNING: PRIVATE_KEY not configured in .env${NC}"
|
|
echo ""
|
|
echo "To generate a new wallet:"
|
|
echo " cast wallet new"
|
|
echo ""
|
|
echo "To use existing wallet, add to .env:"
|
|
echo " PRIVATE_KEY=<your_64_character_hex_key>"
|
|
echo ""
|
|
read -p "Continue without private key? (bot will not be able to execute trades) [y/N]: " confirm
|
|
if [[ ! $confirm =~ ^[Yy]$ ]]; then
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Verify RPC connectivity
|
|
echo -e "${YELLOW}Verifying RPC connectivity...${NC}"
|
|
RPC_URL=$(grep "^ARBITRUM_RPC_ENDPOINT=" .env | cut -d'=' -f2)
|
|
if [ -z "$RPC_URL" ]; then
|
|
RPC_URL="https://arb1.arbitrum.io/rpc"
|
|
fi
|
|
|
|
if command -v cast &> /dev/null; then
|
|
if cast block-number --rpc-url "$RPC_URL" &> /dev/null; then
|
|
BLOCK=$(cast block-number --rpc-url "$RPC_URL")
|
|
echo -e "${GREEN}✓ RPC connected - Block: $BLOCK${NC}"
|
|
else
|
|
echo -e "${RED}✗ RPC connection failed${NC}"
|
|
echo "Please verify ARBITRUM_RPC_ENDPOINT in .env"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo -e "${YELLOW}⚠ Cannot verify RPC (cast not installed)${NC}"
|
|
fi
|
|
|
|
# Stop existing container if running
|
|
echo ""
|
|
echo -e "${YELLOW}Checking for existing deployment...${NC}"
|
|
if podman ps -a | grep -q "mev-bot-v2-phase1"; then
|
|
echo "Stopping existing container..."
|
|
podman stop mev-bot-v2-phase1 2>/dev/null || true
|
|
podman rm mev-bot-v2-phase1 2>/dev/null || true
|
|
fi
|
|
|
|
# Create Phase 1 environment file
|
|
echo ""
|
|
echo -e "${YELLOW}Creating Phase 1 configuration...${NC}"
|
|
cat > .env.phase1 << 'EOF'
|
|
# Phase 1: Mainnet Dry-Run Configuration
|
|
# Duration: 48 hours minimum
|
|
# Risk: NONE (monitoring only, no execution)
|
|
|
|
# === SAFETY SETTINGS (ULTRA-CONSERVATIVE) ===
|
|
ENABLE_EXECUTION=false
|
|
DRY_RUN_MODE=true
|
|
ENABLE_SIMULATION=true
|
|
ENABLE_FRONT_RUNNING=false
|
|
|
|
# === DETECTION THRESHOLDS ===
|
|
MIN_PROFIT_THRESHOLD=0.001 # 0.1% minimum (detect more opportunities)
|
|
MAX_SLIPPAGE_TOLERANCE=0.005 # 0.5% max slippage
|
|
|
|
# === RISK LIMITS (NOT USED IN DRY-RUN BUT LOGGED) ===
|
|
MAX_POSITION_SIZE_ETH=0.01 # 0.01 ETH
|
|
MAX_DAILY_VOLUME_ETH=0.1 # 0.1 ETH
|
|
MAX_CONSECUTIVE_LOSSES=1 # Stop after 1 loss
|
|
MAX_HOURLY_LOSS_ETH=0.01 # 0.01 ETH hourly
|
|
MAX_DAILY_LOSS_ETH=0.05 # 0.05 ETH daily
|
|
|
|
# === MONITORING ===
|
|
METRICS_ENABLED=true
|
|
METRICS_PORT=9090
|
|
LOG_LEVEL=info
|
|
EOF
|
|
|
|
# Merge with base .env
|
|
cp .env .env.phase1.bak
|
|
cat .env .env.phase1 > .env.phase1.merged
|
|
mv .env.phase1.merged .env.phase1
|
|
|
|
echo -e "${GREEN}✓ Phase 1 configuration created: .env.phase1${NC}"
|
|
|
|
# Deploy container
|
|
echo ""
|
|
echo -e "${YELLOW}Deploying MEV Bot V2 (Phase 1)...${NC}"
|
|
podman run -d \
|
|
--name mev-bot-v2-phase1 \
|
|
--network host \
|
|
--restart unless-stopped \
|
|
--env-file .env.phase1 \
|
|
-v $(pwd)/logs:/app/logs:z \
|
|
mev-bot-v2:phase1-ready
|
|
|
|
# Wait for startup
|
|
echo ""
|
|
echo -e "${YELLOW}Waiting for bot to initialize...${NC}"
|
|
sleep 5
|
|
|
|
# Check if container is running
|
|
if ! podman ps | grep -q "mev-bot-v2-phase1"; then
|
|
echo -e "${RED}✗ Container failed to start${NC}"
|
|
echo ""
|
|
echo "Logs:"
|
|
podman logs mev-bot-v2-phase1
|
|
exit 1
|
|
fi
|
|
|
|
echo -e "${GREEN}✓ Bot deployed successfully${NC}"
|
|
|
|
# Display initial logs
|
|
echo ""
|
|
echo -e "${GREEN}========================================${NC}"
|
|
echo -e "${GREEN}Initial Bot Logs${NC}"
|
|
echo -e "${GREEN}========================================${NC}"
|
|
podman logs --tail 50 mev-bot-v2-phase1
|
|
|
|
# Display monitoring instructions
|
|
echo ""
|
|
echo -e "${GREEN}========================================${NC}"
|
|
echo -e "${GREEN}Phase 1 Deployment Complete${NC}"
|
|
echo -e "${GREEN}========================================${NC}"
|
|
echo ""
|
|
echo -e "${YELLOW}Container:${NC} mev-bot-v2-phase1"
|
|
echo -e "${YELLOW}Mode:${NC} Dry-Run (monitoring only, NO trades)"
|
|
echo -e "${YELLOW}Duration:${NC} 48 hours minimum"
|
|
echo ""
|
|
echo -e "${GREEN}Monitoring Commands:${NC}"
|
|
echo " # View real-time logs"
|
|
echo " podman logs -f mev-bot-v2-phase1"
|
|
echo ""
|
|
echo " # Check for opportunities"
|
|
echo " podman logs mev-bot-v2-phase1 | grep -i 'opportunity'"
|
|
echo ""
|
|
echo " # Check for errors"
|
|
echo " podman logs mev-bot-v2-phase1 | grep -i 'error'"
|
|
echo ""
|
|
echo " # View safety configuration"
|
|
echo " podman logs mev-bot-v2-phase1 | grep -A20 'SAFETY CONFIGURATION'"
|
|
echo ""
|
|
echo -e "${GREEN}Emergency Stop:${NC}"
|
|
echo " # Method 1: Graceful shutdown"
|
|
echo " podman exec mev-bot-v2-phase1 touch /tmp/mev-bot-emergency-stop"
|
|
echo ""
|
|
echo " # Method 2: Immediate stop"
|
|
echo " podman stop mev-bot-v2-phase1"
|
|
echo ""
|
|
echo -e "${YELLOW}Next Steps:${NC}"
|
|
echo "1. Monitor logs every 4 hours"
|
|
echo "2. Look for arbitrage opportunities being detected"
|
|
echo "3. Verify no crashes or connection issues"
|
|
echo "4. After 48 hours, review logs and assess if opportunities exist"
|
|
echo "5. If successful, proceed to Phase 3 (minimal capital test)"
|
|
echo ""
|
|
echo -e "${RED}IMPORTANT: DO NOT enable ENABLE_EXECUTION until Phase 1 validates opportunities${NC}"
|
|
echo ""
|