diff --git a/.env.production.safe b/.env.production.safe new file mode 100644 index 0000000..c588dbf --- /dev/null +++ b/.env.production.safe @@ -0,0 +1,205 @@ +# MEV Bot V2 - Production Safety Configuration +# ================================================ +# DO NOT deploy without reviewing ALL settings below +# This configuration prioritizes safety over profitability + +# ================================ +# BLOCKCHAIN CONNECTION +# ================================ +# CRITICAL: Use archive RPC provider for production +RPC_URL=https://arb-mainnet.g.alchemy.com/v2/YOUR_ALCHEMY_KEY +WS_URL=wss://arb-mainnet.g.alchemy.com/v2/YOUR_ALCHEMY_KEY +SEQUENCER_WS_URL=wss://arb1.arbitrum.io/ws +CHAIN_ID=42161 + +# ================================ +# WALLET CONFIGURATION +# ================================ +# WARNING: Protect this key - use hardware wallet for large funds +PRIVATE_KEY=your_private_key_here + +# EXECUTOR CONTRACT: Set to your deployed flashloan contract address +# Leave as 0x0 if not using flashloans +EXECUTOR_CONTRACT=0x0000000000000000000000000000000000000000 + +# ================================ +# SAFETY MODE +# ================================ +# DRY RUN: Set to "true" for simulation-only (NO REAL TRANSACTIONS) +# ONLY set to "false" after thorough testing +DRY_RUN_MODE=true + +# EXECUTION: Disable actual execution until validated +ENABLE_EXECUTION=false + +# SIMULATION: Always keep enabled for safety checks +ENABLE_SIMULATION=true + +# FRONT-RUNNING: Disable until profit calculations validated +ENABLE_FRONT_RUNNING=false + +# ================================ +# PROFIT THRESHOLDS (Conservative) +# ================================ +# Minimum profit required (in wei): 0.05 ETH = very conservative +MIN_PROFIT_WEI=50000000000000000 + +# Minimum ROI: 5% = conservative (rejects marginal opportunities) +MIN_ROI=0.05 + +# Minimum swap amount to consider (in wei): 0.1 ETH +MIN_SWAP_AMOUNT=100000000000000000 + +# Minimum pool liquidity (in wei): $50,000 equivalent +MIN_POOL_LIQUIDITY=50000000000000000000000 + +# ================================ +# RISK LIMITS (Strict) +# ================================ +# Maximum position size per trade: 1 ETH = very conservative +MAX_POSITION_SIZE=1000000000000000000 + +# Maximum daily trading volume: 10 ETH = strict daily limit +MAX_DAILY_VOLUME=10000000000000000000 + +# Maximum slippage tolerance: 1% = strict (prevents sandwich attacks) +MAX_SLIPPAGE_BPS=100 + +# Maximum gas limit per transaction: 1.5M gas +MAX_GAS_LIMIT=1500000 + +# Maximum gas price: 50 gwei (prevents overpaying during spikes) +MAX_GAS_PRICE_GWEI=50 + +# ================================ +# CIRCUIT BREAKER THRESHOLDS +# ================================ +# Stop trading after this many consecutive losses +MAX_CONSECUTIVE_LOSSES=3 + +# Stop trading if hourly loss exceeds this (in wei): 0.1 ETH +MAX_HOURLY_LOSS=100000000000000000 + +# Stop trading if daily loss exceeds this (in wei): 0.5 ETH +MAX_DAILY_LOSS=500000000000000000 + +# Cooldown period after circuit breaker trips (seconds): 1 hour +CIRCUIT_BREAKER_COOLDOWN=3600 + +# ================================ +# GAS STRATEGY (Conservative) +# ================================ +# Gas price strategy: "safe" = lower gas, slower inclusion +# Options: safe, standard, fast, ultra +GAS_PRICE_STRATEGY=safe + +# Gas price multiplier: 1.0 = no markup (safer) +GAS_PRICE_MULTIPLIER=1.0 + +# ================================ +# EXECUTION SETTINGS +# ================================ +# Use private RPC for transaction submission (reduces MEV risk) +USE_PRIVATE_RPC=false +PRIVATE_RPC_URL= + +# Transaction confirmation blocks: 1 for Arbitrum +CONFIRMATION_BLOCKS=1 + +# Transaction timeout: 2 minutes +TX_TIMEOUT_SECONDS=120 + +# Maximum retries for failed transactions +MAX_TX_RETRIES=2 + +# ================================ +# ARBITRAGE DETECTION +# ================================ +# Maximum hops in arbitrage path: 2 = simple, safer +MAX_HOPS=2 + +# Maximum paths to evaluate per opportunity: 50 = focused +MAX_PATHS=50 + +# Maximum concurrent opportunity evaluations: 5 = conservative +MAX_CONCURRENT_DETECTION=5 + +# ================================ +# POOL DISCOVERY +# ================================ +# Maximum pools to discover and monitor: 100 = focused set +MAX_POOLS_TO_DISCOVER=100 + +# Pool discovery interval (seconds): 5 minutes +POOL_DISCOVERY_INTERVAL=300 + +# ================================ +# PERFORMANCE +# ================================ +# Worker count for parallel processing: 4 = moderate +WORKER_COUNT=4 + +# Buffer size for event processing: 100 +BUFFER_SIZE=100 + +# ================================ +# MONITORING & ALERTS +# ================================ +# Metrics server port +METRICS_PORT=9090 + +# Enable detailed logging +LOG_LEVEL=info + +# Alert webhook URL (for Slack/Discord/Telegram) +ALERT_WEBHOOK_URL= + +# Alert on circuit breaker trip +ALERT_ON_CIRCUIT_BREAKER=true + +# Alert on large loss (threshold in wei): 0.05 ETH +ALERT_LOSS_THRESHOLD=50000000000000000 + +# ================================ +# EMERGENCY CONTROLS +# ================================ +# Emergency stop file path - create this file to stop bot immediately +EMERGENCY_STOP_FILE=/tmp/mev-bot-emergency-stop + +# Auto-restart after emergency stop (dangerous - keep false) +AUTO_RESTART_AFTER_EMERGENCY_STOP=false + +# ================================ +# ADDITIONAL SAFETY FEATURES +# ================================ +# Require manual confirmation for each trade (testing only) +REQUIRE_MANUAL_CONFIRMATION=true + +# Maximum trades per hour: 10 = rate limiting +MAX_TRADES_PER_HOUR=10 + +# Blacklist pools (comma-separated addresses of problematic pools) +BLACKLISTED_POOLS= + +# Whitelist tokens only (comma-separated addresses - empty = allow all) +WHITELISTED_TOKENS= + +# ================================ +# NOTES FOR PRODUCTION +# ================================ +# Before deploying to production: +# +# 1. Set DRY_RUN_MODE=true initially and monitor for 24+ hours +# 2. Verify profit calculations match expected values +# 3. Ensure circuit breaker triggers correctly +# 4. Test emergency stop mechanism +# 5. Set up monitoring/alerting +# 6. Start with minimal position sizes +# 7. Gradually increase limits after validating profitability +# 8. NEVER set ENABLE_EXECUTION=true without thorough testing +# +# Recommended deployment sequence: +# Day 1: DRY_RUN_MODE=true (monitor only) +# Day 2-3: If stable, test with ENABLE_EXECUTION=true but MAX_POSITION_SIZE=0.1 ETH +# Day 4-7: If profitable, increase to MAX_POSITION_SIZE=0.5 ETH +# Week 2+: If consistently profitable, gradually increase limits diff --git a/PRODUCTION_DEPLOYMENT_GUIDE.md b/PRODUCTION_DEPLOYMENT_GUIDE.md new file mode 100644 index 0000000..989e5b6 --- /dev/null +++ b/PRODUCTION_DEPLOYMENT_GUIDE.md @@ -0,0 +1,561 @@ +# MEV Bot V2 - Production Deployment Safety Guide + +**STATUS:** ⚠️ **PRE-PRODUCTION - NOT SAFE FOR LARGE CAPITAL YET** + +--- + +## 🚨 CRITICAL: Read This First + +**DO NOT deploy to production with significant capital until:** +1. ✅ All safety mechanisms are tested +2. ✅ Profit calculations validated with known scenarios +3. ✅ 24+ hours of dry-run monitoring completed +4. ✅ Emergency stop tested and working +5. ✅ Monitoring/alerting configured and tested + +**Current Status:** Bot is in TESTING phase. Suitable for small-scale testing only. + +--- + +## Safety-First Deployment Sequence + +### Phase 1: Dry-Run Validation (Days 1-3) + +**Objective:** Validate detection without risking capital + +**Configuration:** +```bash +DRY_RUN_MODE=true +ENABLE_EXECUTION=false +ENABLE_SIMULATION=true +MIN_PROFIT_WEI=50000000000000000 # 0.05 ETH - conservative +``` + +**Actions:** +1. Deploy with `.env.production.safe` configuration +2. Monitor logs for 24+ hours continuously +3. Verify opportunities are detected correctly +4. Check profit calculations match expected values +5. Ensure no false positives + +**Success Criteria:** +- ✅ Bot runs stable for 24+ hours +- ✅ No crashes or errors +- ✅ Profit calculations look reasonable +- ✅ Pool data updates correctly + +**DO NOT PROCEED** if success criteria not met. + +--- + +### Phase 2: Testnet Validation (Days 4-7) + +**Objective:** Test execution logic without real money + +**Configuration:** +```bash +# Use Arbitrum Sepolia/Goerli testnet +CHAIN_ID=421614 # Arbitrum Sepolia +RPC_URL=https://sepolia-rollup.arbitrum.io/rpc +ENABLE_EXECUTION=true +MAX_POSITION_SIZE=100000000000000000 # 0.1 ETH testnet funds +``` + +**Actions:** +1. Get testnet ETH from faucet +2. Deploy on testnet +3. Execute actual transactions +4. Monitor profit/loss carefully +5. Test circuit breaker triggers +6. Test emergency stop + +**Success Criteria:** +- ✅ Transactions execute successfully +- ✅ Profit calculations accurate (compare pre/post trade) +- ✅ Circuit breaker stops trading after losses +- ✅ Emergency stop works immediately +- ✅ No unexpected behavior + +**DO NOT PROCEED** to mainnet if any failures. + +--- + +### Phase 3: Mainnet Micro-Testing (Days 8-14) + +**Objective:** Validate on mainnet with minimal capital + +**Configuration:** +```bash +# Mainnet with strict safety limits +CHAIN_ID=42161 +RPC_URL=https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY # Archive RPC required! +ENABLE_EXECUTION=true +MAX_POSITION_SIZE=100000000000000000 # 0.1 ETH - TINY positions +MAX_DAILY_VOLUME=500000000000000000 # 0.5 ETH daily max +MAX_TRADES_PER_HOUR=5 # Rate limit +``` + +**Capital Required:** 0.5-1 ETH (amount you're willing to lose) + +**Actions:** +1. Fund wallet with SMALL amount only +2. Enable execution with strict limits +3. Monitor CONTINUOUSLY for first 24 hours +4. Track every trade manually +5. Calculate actual profit/loss +6. Verify gas costs match predictions + +**Success Criteria:** +- ✅ Net profitable over 7 days (including gas) +- ✅ No unexpected losses +- ✅ Circuit breaker triggers appropriately +- ✅ Monitoring/alerts working + +**IF UNPROFITABLE:** Stop immediately, debug issues + +--- + +### Phase 4: Gradual Scale-Up (Weeks 3-8) + +**Objective:** Slowly increase capital if consistently profitable + +**Only if Phase 3 was net profitable:** + +| Week | Max Position | Max Daily Volume | Notes | +|------|--------------|------------------|-------| +| 3 | 0.25 ETH | 1 ETH | Still testing | +| 4 | 0.5 ETH | 2 ETH | Monitor closely | +| 5 | 1 ETH | 5 ETH | If profitable, continue | +| 6 | 2 ETH | 10 ETH | Standard operation | +| 7-8 | 3-5 ETH | 20 ETH | Mature operation | + +**Rules:** +- If ANY week is unprofitable, revert to previous week's limits +- Track ROI weekly - stop if declining +- Monitor gas costs - stop if eating profits + +--- + +## 🛡️ Safety Mechanisms + +### 1. Circuit Breaker + +**Triggers:** +- 3 consecutive losing trades +- Hourly loss > 0.1 ETH +- Daily loss > 0.5 ETH + +**Action:** Immediately stop trading for 1 hour cooldown + +**Testing:** +```bash +# Manually trigger by creating test scenario +# Verify bot stops and doesn't restart automatically +``` + +### 2. Emergency Stop + +**File-based kill switch:** +```bash +# Create this file to stop bot immediately +touch /tmp/mev-bot-emergency-stop + +# Bot checks this file every 10 seconds +# Gracefully stops all operations +``` + +**Testing:** +```bash +# While bot running in testnet: +touch /tmp/mev-bot-emergency-stop +# Bot should log "Emergency stop detected" and exit within 10s +``` + +### 3. Position Size Limits + +**Prevents large losses from single trade:** +- MAX_POSITION_SIZE enforced before execution +- MAX_DAILY_VOLUME enforced cumulatively +- Transactions rejected if limits exceeded + +### 4. Slippage Protection + +**Prevents sandwich attacks and price manipulation:** +- MAX_SLIPPAGE_BPS: 100 (1%) - very strict +- Simulation runs before every trade +- Trade rejected if simulated output < expected + +### 5. Gas Price Limits + +**Prevents overpaying during network congestion:** +- MAX_GAS_PRICE_GWEI: 50 gwei +- Transactions rejected if gas price higher +- Use GAS_PRICE_STRATEGY=safe for lower gas + +--- + +## 📊 Monitoring Requirements + +### Essential Metrics to Track + +**1. Profitability Metrics** +- Gross profit per trade +- Net profit after gas +- ROI percentage +- Win rate (profitable trades / total trades) + +**2. Execution Metrics** +- Trade execution latency +- Gas costs per trade +- Failed transactions +- Successful vs failed trade ratio + +**3. Safety Metrics** +- Circuit breaker triggers +- Emergency stops +- Position size violations +- Daily volume tracking + +**4. System Health** +- RPC connection status +- WebSocket connection status +- Pool cache size +- Memory/CPU usage + +### Monitoring Tools + +**Prometheus + Grafana** (included in repo): +```bash +docker-compose up -d prometheus grafana +# Access Grafana at http://localhost:3000 +``` + +**Log Monitoring:** +```bash +# Tail logs in real-time +docker logs -f mev-bot-v2 + +# Filter for profits +docker logs mev-bot-v2 | grep "profit" + +# Filter for errors +docker logs mev-bot-v2 | grep "ERROR\|WARN" +``` + +**Alerting** (recommended): +- Set up Slack/Discord/Telegram webhook +- Alert on circuit breaker triggers +- Alert on large losses (> 0.05 ETH) +- Alert on system errors + +--- + +## 🔧 Production Infrastructure + +### Required Infrastructure + +**1. Archive RPC Provider** (CRITICAL) +- ❌ Public RPC insufficient +- ✅ Use: Alchemy, QuickNode, or Infura +- Cost: ~$200-500/month for archive access +- Required for pool discovery and state queries + +**2. Private RPC (Recommended)** +- Reduces MEV risk on transaction submission +- Flashbots Protect or private mempool +- Cost: Free (Flashbots) or ~$100/month + +**3. Dedicated Server** +- Minimum: 4 CPU cores, 8GB RAM +- Recommended: 8 CPU cores, 16GB RAM +- Low latency network connection to RPC +- Uptime: 99.9%+ + +**4. Monitoring Stack** +- Prometheus for metrics +- Grafana for visualization +- Alerting service (PagerDuty, Slack, etc.) + +--- + +## ⚠️ Known Limitations & Risks + +### Technical Limitations + +1. **WebSocket Sequencer Connection** + - Status: Not fully stable on Anvil fork + - Impact: May miss some pending transactions + - Mitigation: Test on live testnet/mainnet + +2. **Pool Discovery** + - Currently uses hardcoded pools for testing + - Production needs archive RPC for discovery + - May miss new pools initially + +3. **Gas Estimation** + - Estimates may be inaccurate under high load + - May overpay or fail transactions + - Needs more testing + +4. **Profit Calculations** + - Not validated against known scenarios yet + - Risk of calculation errors + - MUST test extensively before large capital + +### Market Risks + +1. **Competition** + - Other MEV bots may front-run + - Profits may be lower than expected + - Need low latency connection + +2. **Gas Price Volatility** + - Network congestion can spike gas + - May eat into profits + - Circuit breaker helps limit damage + +3. **Smart Contract Risks** + - DEX contracts could have bugs + - Pools could be manipulated + - Use whitelisted pools only initially + +4. **Slippage & Sandwich Attacks** + - Larger trades more susceptible + - Strict slippage limits help + - Consider splitting large trades + +--- + +## 📋 Pre-Deployment Checklist + +### Infrastructure + +- [ ] Archive RPC provider configured and tested +- [ ] Private RPC configured (optional but recommended) +- [ ] Server meets minimum specs +- [ ] Monitoring stack deployed (Prometheus + Grafana) +- [ ] Alerting configured and tested +- [ ] Backup wallet key secured (hardware wallet recommended) + +### Configuration + +- [ ] `.env.production.safe` reviewed and customized +- [ ] All safety limits set conservatively +- [ ] DRY_RUN_MODE=true initially +- [ ] ENABLE_EXECUTION=false initially +- [ ] Gas limits appropriate +- [ ] Slippage tolerance conservative + +### Testing + +- [ ] Dry-run completed (24+ hours) +- [ ] Profit calculations validated +- [ ] Circuit breaker tested +- [ ] Emergency stop tested +- [ ] Testnet deployment successful +- [ ] Manual trades verified profitable + +### Monitoring + +- [ ] Grafana dashboards configured +- [ ] Alerts set up for losses +- [ ] Alerts set up for circuit breaker +- [ ] Alerts set up for system errors +- [ ] Log rotation configured +- [ ] Backup/restore tested + +### Safety + +- [ ] Emergency stop file path configured +- [ ] Circuit breaker thresholds set +- [ ] Position limits conservative +- [ ] Daily volume limits set +- [ ] Gas price limits set +- [ ] Whitelist/blacklist configured (if needed) + +--- + +## 🚀 Deployment Commands + +### Step 1: Build Docker Image + +```bash +docker build -t mev-bot-v2:production . +``` + +### Step 2: Configure Environment + +```bash +# Copy safe configuration +cp .env.production.safe .env.production + +# Edit with your keys and RPC endpoints +nano .env.production + +# CRITICAL: Verify DRY_RUN_MODE=true for first deployment +grep DRY_RUN_MODE .env.production +``` + +### Step 3: Deploy with Docker + +```bash +# Start in dry-run mode +docker run -d \ + --name mev-bot-v2-production \ + --restart unless-stopped \ + --env-file .env.production \ + -v $(pwd)/logs:/app/logs \ + -p 9090:9090 \ + mev-bot-v2:production + +# Monitor logs in real-time +docker logs -f mev-bot-v2-production +``` + +### Step 4: Monitor & Validate + +```bash +# Check status +docker ps | grep mev-bot + +# View metrics +curl http://localhost:9090/metrics + +# Check for errors +docker logs mev-bot-v2-production | grep ERROR | tail -50 + +# Monitor circuit breaker status +docker logs mev-bot-v2-production | grep "circuit_breaker" +``` + +### Step 5: Emergency Stop (if needed) + +```bash +# Method 1: File-based stop +docker exec mev-bot-v2-production touch /tmp/mev-bot-emergency-stop + +# Method 2: Graceful stop +docker stop mev-bot-v2-production + +# Method 3: Immediate stop +docker kill mev-bot-v2-production +``` + +--- + +## 📞 Support & Troubleshooting + +### Common Issues + +**Issue: Bot not finding opportunities** +- Check RPC connection is working +- Verify pool discovery running +- Check MIN_PROFIT_WEI isn't too high +- Review MIN_POOL_LIQUIDITY setting + +**Issue: High gas costs eating profits** +- Lower MAX_GAS_PRICE_GWEI +- Use GAS_PRICE_STRATEGY=safe +- Increase MIN_PROFIT_WEI threshold + +**Issue: Circuit breaker triggering frequently** +- Review trade profitability +- Check profit calculations +- Verify gas estimation accurate +- May need to adjust MIN_PROFIT_WEI higher + +**Issue: Missing transactions** +- Check WebSocket connection stable +- Verify archive RPC working +- Review worker count settings +- Check buffer size adequate + +### Logs to Check + +```bash +# All errors +docker logs mev-bot-v2-production 2>&1 | grep "ERROR" + +# Profitable trades +docker logs mev-bot-v2-production | grep "profit.*ETH" + +# Circuit breaker events +docker logs mev-bot-v2-production | grep "circuit_breaker" + +# RPC issues +docker logs mev-bot-v2-production | grep "RPC\|connection" +``` + +--- + +## ⚖️ Legal & Compliance + +**DISCLAIMER:** +- MEV trading may be considered front-running in some jurisdictions +- Ensure compliance with local regulations +- This software is provided AS-IS with no warranties +- Use at your own risk +- Author not responsible for losses + +**Recommendations:** +- Consult legal counsel before deployment +- Understand local securities/trading laws +- Consider tax implications of trading +- Maintain detailed trade records + +--- + +## 📝 Post-Deployment Monitoring + +### Daily Checks (First Week) + +- [ ] Review all trades from last 24 hours +- [ ] Calculate net profit/loss (including gas) +- [ ] Check circuit breaker events +- [ ] Review error logs +- [ ] Verify RPC connection stable +- [ ] Check wallet balance + +### Weekly Checks (Ongoing) + +- [ ] Calculate weekly ROI +- [ ] Review most/least profitable pools +- [ ] Analyze gas cost trends +- [ ] Review system resource usage +- [ ] Update pool blacklist if needed +- [ ] Adjust parameters based on performance + +### Monthly Reviews + +- [ ] Comprehensive profit/loss analysis +- [ ] Compare to market conditions +- [ ] Review and update safety limits +- [ ] Update dependencies/security patches +- [ ] Backup configuration and logs +- [ ] Review and optimize strategies + +--- + +## 🎯 Success Criteria + +**Minimum viable production deployment:** +- ✅ Profitable for 7+ consecutive days +- ✅ ROI > 5% after gas costs +- ✅ Win rate > 60% +- ✅ No circuit breaker triggers from bugs +- ✅ Emergency stop tested and working +- ✅ Monitoring functional and alerting + +**Ready for capital scale-up:** +- ✅ Profitable for 30+ days +- ✅ ROI > 10% monthly +- ✅ Win rate > 70% +- ✅ All safety mechanisms tested +- ✅ No unexpected losses +- ✅ Stable system performance + +--- + +**Last Updated:** 2025-11-10 +**Version:** 1.0.0-rc1 +**Status:** Pre-Production diff --git a/SAFETY_CHECKLIST.md b/SAFETY_CHECKLIST.md new file mode 100644 index 0000000..4855842 --- /dev/null +++ b/SAFETY_CHECKLIST.md @@ -0,0 +1,179 @@ +# MEV Bot V2 - Production Safety Checklist + +⚠️ **DO NOT SKIP ANY ITEMS** - Each one prevents potential losses + +--- + +## Pre-Deployment (MANDATORY) + +### Configuration +- [ ] `.env.production.safe` copied and customized +- [ ] `DRY_RUN_MODE=true` initially +- [ ] `ENABLE_EXECUTION=false` initially +- [ ] Archive RPC provider configured (Alchemy/QuickNode) +- [ ] Private key stored securely (hardware wallet recommended) +- [ ] All safety limits set conservatively + +### Testing +- [ ] 24+ hours dry-run monitoring completed +- [ ] Profit calculations manually verified +- [ ] Circuit breaker tested (triggers on losses) +- [ ] Emergency stop tested (creates file successfully) +- [ ] Testnet deployment successful (if applicable) + +### Infrastructure +- [ ] Monitoring stack deployed (Prometheus + Grafana) +- [ ] Alerting configured (Slack/Discord/Telegram) +- [ ] Server meets minimum specs (4 CPU, 8GB RAM) +- [ ] Low latency RPC connection verified (<100ms) + +--- + +## Deployment Day + +### Initial Launch (Dry-Run) +- [ ] Deploy with `DRY_RUN_MODE=true` +- [ ] Monitor logs continuously for 24 hours +- [ ] Verify opportunities detected correctly +- [ ] Check profit estimates look reasonable +- [ ] No errors or warnings in logs + +### Switch to Live Trading (If Dry-Run Successful) +- [ ] Start with `MAX_POSITION_SIZE=0.1` ETH +- [ ] Fund wallet with SMALL amount (0.5-1 ETH max) +- [ ] Set `ENABLE_EXECUTION=true` +- [ ] Monitor EVERY trade for first hour +- [ ] Manually calculate profit/loss for first 10 trades + +--- + +## Daily Monitoring (First Week) + +- [ ] Check bot still running +- [ ] Review all trades from last 24 hours +- [ ] Calculate net P/L (including gas costs) +- [ ] Check circuit breaker events +- [ ] Review error logs +- [ ] Verify wallet balance matches expectations + +**If ANY day shows net loss: STOP and investigate** + +--- + +## Weekly Review + +- [ ] Calculate weekly ROI +- [ ] Win rate > 60%? +- [ ] Gas costs < 30% of profits? +- [ ] No unexpected circuit breaker triggers? +- [ ] System stable (no crashes)? +- [ ] Adjust parameters if needed + +**If unprofitable: DO NOT increase limits** + +--- + +## Red Flags - STOP IMMEDIATELY If: + +🚨 **Circuit breaker triggering frequently** (>3 times/day) +🚨 **Consecutive losing days** (2+ days) +🚨 **Gas costs exceeding profits** +🚨 **Unexpected large losses** (>0.1 ETH single trade) +🚨 **System errors or crashes** +🚨 **RPC connection issues** + +--- + +## Emergency Procedures + +### Immediate Stop +```bash +# Method 1: Emergency file +docker exec mev-bot-v2-production touch /tmp/mev-bot-emergency-stop + +# Method 2: Container stop +docker stop mev-bot-v2-production + +# Method 3: Kill immediately +docker kill mev-bot-v2-production +``` + +### Post-Stop Actions +1. Export all logs for analysis +2. Calculate total P/L +3. Identify root cause +4. Fix issues before restart +5. Test fixes on testnet +6. Only restart if confident in fix + +--- + +## Capital Scale-Up (ONLY if Profitable) + +| Week | Condition | Max Position | Max Daily Volume | +|------|-----------|--------------|------------------| +| 1 | Testing | 0.1 ETH | 0.5 ETH | +| 2 | Profitable Week 1 | 0.25 ETH | 1 ETH | +| 3 | Profitable Week 2 | 0.5 ETH | 2 ETH | +| 4+ | Profitable Week 3 | 1 ETH+ | 5 ETH+ | + +**Rules:** +- Each week must be NET profitable before increasing +- ANY losing week = revert to previous limits +- NEVER increase >2x in single week + +--- + +## Safety Limits (NEVER Exceed Without Testing) + +| Parameter | Conservative | Moderate | Aggressive | +|-----------|--------------|----------|------------| +| MAX_POSITION_SIZE | 0.1 ETH | 1 ETH | 5 ETH | +| MAX_DAILY_VOLUME | 0.5 ETH | 5 ETH | 20 ETH | +| MIN_PROFIT_WEI | 0.05 ETH | 0.02 ETH | 0.01 ETH | +| MIN_ROI | 5% | 2% | 1% | +| MAX_SLIPPAGE_BPS | 100 (1%) | 200 (2%) | 300 (3%) | +| MAX_GAS_PRICE_GWEI | 25 | 50 | 100 | + +**Start conservative, increase gradually ONLY if profitable** + +--- + +## Required Metrics Tracking + +### Profitability +- [ ] Gross profit per trade +- [ ] Net profit after gas +- [ ] ROI percentage +- [ ] Win rate +- [ ] Largest win/loss + +### Safety +- [ ] Circuit breaker triggers +- [ ] Emergency stops +- [ ] Daily volume used +- [ ] Position size violations + +### Performance +- [ ] Trade execution latency +- [ ] Gas cost per trade +- [ ] Failed transaction rate +- [ ] Opportunities detected vs executed + +--- + +## Contact & Support + +**Before reaching out:** +1. Export logs: `docker logs mev-bot-v2-production > debug.log` +2. Calculate exact P/L +3. Note specific error messages +4. Check this checklist for missed items + +**GitHub Issues:** https://github.com/your-org/mev-bot-v2/issues + +--- + +**Remember: It's better to miss opportunities than lose capital** + +**Start small, scale slowly, stop quickly if problems occur**