feat: create v2-prep branch with comprehensive planning
Restructured project for V2 refactor: **Structure Changes:** - Moved all V1 code to orig/ folder (preserved with git mv) - Created docs/planning/ directory - Added orig/README_V1.md explaining V1 preservation **Planning Documents:** - 00_V2_MASTER_PLAN.md: Complete architecture overview - Executive summary of critical V1 issues - High-level component architecture diagrams - 5-phase implementation roadmap - Success metrics and risk mitigation - 07_TASK_BREAKDOWN.md: Atomic task breakdown - 99+ hours of detailed tasks - Every task < 2 hours (atomic) - Clear dependencies and success criteria - Organized by implementation phase **V2 Key Improvements:** - Per-exchange parsers (factory pattern) - Multi-layer strict validation - Multi-index pool cache - Background validation pipeline - Comprehensive observability **Critical Issues Addressed:** - Zero address tokens (strict validation + cache enrichment) - Parsing accuracy (protocol-specific parsers) - No audit trail (background validation channel) - Inefficient lookups (multi-index cache) - Stats disconnection (event-driven metrics) Next Steps: 1. Review planning documents 2. Begin Phase 1: Foundation (P1-001 through P1-010) 3. Implement parsers in Phase 2 4. Build cache system in Phase 3 5. Add validation pipeline in Phase 4 6. Migrate and test in Phase 5 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
337
orig/config/arbitrum_optimized.yaml
Normal file
337
orig/config/arbitrum_optimized.yaml
Normal file
@@ -0,0 +1,337 @@
|
||||
# Arbitrum-Optimized MEV Bot Configuration
|
||||
# Based on Layer 2 Research and Best Practices (November 2025)
|
||||
#
|
||||
# USAGE:
|
||||
# This config can be merged with arbitrum_production.yaml for testing
|
||||
# All changes are non-breaking and can be enabled via feature flags
|
||||
#
|
||||
# RESEARCH FINDINGS:
|
||||
# - Arbitrum block time: ~250ms (vs 12s Ethereum)
|
||||
# - Opportunity window: 10-20 blocks (2.5-5 seconds)
|
||||
# - Cyclic arbitrage: ~7% of gas usage
|
||||
# - Profitable arbitrage: 0.03%-0.05% of trade volume
|
||||
#
|
||||
# See: docs/L2_MEV_BOT_RESEARCH_REPORT.md for full analysis
|
||||
|
||||
# =============================================================================
|
||||
# FEATURE FLAGS - Enable/Disable Optimizations
|
||||
# =============================================================================
|
||||
features:
|
||||
# Phase 1: Configuration tuning (LOW RISK)
|
||||
use_arbitrum_optimized_timeouts: true # Adjust for 250ms blocks
|
||||
use_dynamic_ttl: true # Calculate TTL based on block time
|
||||
|
||||
# Phase 2: Transaction filtering (MEDIUM RISK)
|
||||
enable_dex_prefilter: false # Filter non-DEX transactions (80-90% reduction)
|
||||
log_filtered_transactions: true # Monitor for missed opportunities
|
||||
|
||||
# Phase 3: Sequencer optimizations (MEDIUM RISK)
|
||||
use_direct_sequencer_feed: false # Direct WebSocket to sequencer
|
||||
sequencer_feed_fallback: true # Keep RPC as fallback
|
||||
|
||||
# Phase 4: Timeboost (HIGH RISK - Future)
|
||||
enable_timeboost: false # Express lane integration
|
||||
timeboost_monitoring_only: false # Monitor without bidding
|
||||
|
||||
# =============================================================================
|
||||
# ARBITRUM-SPECIFIC NETWORK CONFIGURATION
|
||||
# =============================================================================
|
||||
arbitrum_l2:
|
||||
# Network characteristics
|
||||
chain_id: 42161
|
||||
average_block_time_ms: 250 # Arbitrum typical
|
||||
blocks_per_second: 4 # 1000ms / 250ms
|
||||
|
||||
# Transaction ordering
|
||||
ordering_policy: "fcfs" # First-Come-First-Served
|
||||
has_public_mempool: false # No mempool on L2
|
||||
gas_price_affects_ordering: false # FCFS = gas price doesn't matter
|
||||
|
||||
# Sequencer configuration
|
||||
sequencer_endpoint: "wss://arb1-sequencer.arbitrum.io/feed"
|
||||
sequencer_publish_delay_ms: 0 # Transactions published immediately
|
||||
|
||||
# Timeboost configuration (if enabled)
|
||||
timeboost:
|
||||
auction_contract: "0x0000000000000000000000000000000000000000" # TBD when launched
|
||||
express_lane_duration_seconds: 60 # 60-second rounds
|
||||
auction_type: "sealed_bid_second_price" # Auction mechanism
|
||||
min_express_lane_bid_wei: 1000000000000000 # 0.001 ETH minimum
|
||||
|
||||
# Gattaca Kairos integration (Timeboost relay)
|
||||
kairos:
|
||||
enabled: false # Phase 5
|
||||
endpoint: "https://kairos.gattaca.com" # Gattaca Timeboost relay
|
||||
api_key_env: "KAIROS_API_KEY" # Environment variable for key
|
||||
sub_auction_interval_ms: 100 # ~100ms sub-auctions
|
||||
|
||||
# =============================================================================
|
||||
# OPTIMIZED ARBITRAGE TIMING (Phase 1)
|
||||
# =============================================================================
|
||||
arbitrage_optimized:
|
||||
# CRITICAL: Tuned for Arbitrum's 250ms blocks
|
||||
# Research shows opportunities last 10-20 blocks (2.5-5 seconds)
|
||||
|
||||
# Opportunity lifecycle
|
||||
opportunity_ttl: "5s" # 20 blocks @ 250ms (was 30s)
|
||||
opportunity_window_blocks: 20 # ~5 seconds
|
||||
|
||||
# Path caching
|
||||
max_path_age: "10s" # 40 blocks @ 250ms (was 60s)
|
||||
cache_ttl_blocks: 40 # Blocks before cache expires
|
||||
|
||||
# Execution deadlines
|
||||
execution_deadline: "3s" # 12 blocks @ 250ms
|
||||
max_execution_blocks: 12 # Must execute within 12 blocks
|
||||
|
||||
# Revalidation before execution
|
||||
revalidate_before_exec: true # Re-check prices before execution
|
||||
max_price_deviation_percent: 1.0 # Cancel if price moved >1%
|
||||
|
||||
# Dynamic TTL calculation (if use_dynamic_ttl enabled)
|
||||
dynamic_ttl:
|
||||
min_ttl_blocks: 10 # Minimum 10 blocks (2.5s)
|
||||
max_ttl_blocks: 20 # Maximum 20 blocks (5s)
|
||||
profit_multiplier: true # Higher profit = longer TTL
|
||||
volatility_adjustment: true # High volatility = shorter TTL
|
||||
|
||||
# =============================================================================
|
||||
# TRANSACTION PRE-FILTERING (Phase 2)
|
||||
# =============================================================================
|
||||
dex_filter:
|
||||
enabled: false # Set features.enable_dex_prefilter to enable
|
||||
|
||||
# Known DEX addresses on Arbitrum
|
||||
known_dex_addresses:
|
||||
# Uniswap V3
|
||||
- "0x1F98431c8aD98523631AE4a59f267346ea31F984" # Factory
|
||||
- "0xE592427A0AEce92De3Edee1F18E0157C05861564" # Router
|
||||
- "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45" # Router V2
|
||||
|
||||
# Camelot
|
||||
- "0x6EcCab422D763aC031210895C81787E87B43A652" # Factory
|
||||
- "0xc873fEcbd354f5A56E00E710B90EF4201db2448d" # Router
|
||||
|
||||
# SushiSwap
|
||||
- "0xc35DADB65012eC5796536bD9864eD8773aBc74C4" # Factory
|
||||
- "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506" # Router
|
||||
|
||||
# Curve
|
||||
- "0x5ffe7FB82894076ECB99A30D6A32e969e6e35E98" # Address Provider
|
||||
|
||||
# Balancer V2
|
||||
- "0xBA12222222228d8Ba445958a75a0704d566BF2C8" # Vault
|
||||
|
||||
# Ramses
|
||||
- "0xAAA87963EFeB6f7E0a2711F397663105Acb1805e" # Router
|
||||
|
||||
# KyberSwap Elastic
|
||||
- "0x5F1dddbf348aC2fbe22a163e30F99F9ECE3DD50a" # Factory
|
||||
- "0xC1e7dFE73E1598E3910EF4C7845B68A9Ab6F4c83" # Router
|
||||
|
||||
# Swap function signatures
|
||||
known_swap_signatures:
|
||||
- "0x128acb08" # swap(address,bool,int256,uint160,bytes)
|
||||
- "0xc04b8d59" # exactInputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160))
|
||||
- "0x414bf389" # exactInputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160))
|
||||
- "0xb858183f" # multicall(uint256,bytes[])
|
||||
- "0x38ed1739" # swapExactTokensForTokens
|
||||
- "0x8803dbee" # swapTokensForExactTokens
|
||||
- "0x022c0d9f" # swap(uint256,uint256,address,bytes)
|
||||
- "0x5ae401dc" # multicall(uint256,bytes[])
|
||||
|
||||
# Filtering behavior
|
||||
filter_mode: "whitelist" # "whitelist" or "blacklist"
|
||||
log_filtered: true # Log filtered transactions
|
||||
filtered_log_sample_rate: 0.01 # Log 1% of filtered tx (avoid spam)
|
||||
|
||||
# Performance tuning
|
||||
cache_lookups: true # Cache address lookups
|
||||
cache_ttl: "5m" # Cache for 5 minutes
|
||||
|
||||
# =============================================================================
|
||||
# SEQUENCER FEED OPTIMIZATION (Phase 3)
|
||||
# =============================================================================
|
||||
sequencer_feed:
|
||||
enabled: false # Set features.use_direct_sequencer_feed to enable
|
||||
|
||||
# Connection settings
|
||||
websocket_url: "wss://arb1-sequencer.arbitrum.io/feed"
|
||||
connection_timeout: "30s"
|
||||
read_timeout: "10s"
|
||||
write_timeout: "10s"
|
||||
|
||||
# Reconnection logic
|
||||
auto_reconnect: true
|
||||
max_reconnect_attempts: 10
|
||||
reconnect_backoff_ms: 1000 # Start at 1s
|
||||
reconnect_backoff_max_ms: 30000 # Max 30s
|
||||
|
||||
# Message processing
|
||||
message_buffer_size: 100000 # Large buffer for high throughput
|
||||
decode_concurrency: 10 # Parallel decoding workers
|
||||
enable_transaction_cache: true # Cache decoded transactions
|
||||
|
||||
# Latency optimization
|
||||
priority_processing: true # Process DEX transactions first
|
||||
skip_non_dex: true # Don't decode non-DEX transactions
|
||||
|
||||
# Fallback to RPC
|
||||
fallback_on_disconnect: true # Use RPC if sequencer disconnects
|
||||
fallback_delay_ms: 5000 # Wait 5s before falling back
|
||||
|
||||
# =============================================================================
|
||||
# ENHANCED PROFIT VALIDATION (Non-Breaking Addition)
|
||||
# =============================================================================
|
||||
profit_validation:
|
||||
# Pre-execution validation
|
||||
revalidate_before_submission: true # Check profit before submitting
|
||||
min_profit_after_revalidation_wei: 800000000000000 # 0.0008 ETH ($1.60)
|
||||
|
||||
# Price movement thresholds
|
||||
max_price_movement_percent: 2.0 # Cancel if price moved >2%
|
||||
alert_on_large_movement: true # Alert if movement >1%
|
||||
|
||||
# Slippage protection
|
||||
use_dynamic_slippage: true # Adjust slippage based on pool depth
|
||||
min_slippage_bps: 10 # 0.1% minimum
|
||||
max_slippage_bps: 500 # 5% maximum
|
||||
|
||||
# Multi-hop specific
|
||||
max_hops_with_revalidation: 3 # Revalidate 3+ hop paths
|
||||
per_hop_validation: true # Check each hop individually
|
||||
|
||||
# =============================================================================
|
||||
# COMPETITIVE OPTIMIZATION
|
||||
# =============================================================================
|
||||
competition:
|
||||
# Latency targets for Arbitrum (250ms blocks)
|
||||
target_detection_latency_ms: 50 # Detect within 50ms
|
||||
target_execution_latency_ms: 150 # Execute within 150ms
|
||||
total_latency_budget_ms: 200 # Total <200ms (80% of block time)
|
||||
|
||||
# Gas optimization for competition
|
||||
base_gas_price_gwei: 0.1 # Arbitrum typical
|
||||
priority_gas_multiplier: 1.0 # No priority on FCFS
|
||||
min_gas_price_gwei: 0.05 # Minimum
|
||||
max_gas_price_gwei: 1.0 # Maximum
|
||||
|
||||
# Express lane (Timeboost) strategy
|
||||
express_lane_min_profit_wei: 50000000000000000 # $100 minimum to use express lane
|
||||
express_lane_max_bid_percent: 10.0 # Bid up to 10% of profit
|
||||
express_lane_compete_above_profit: 100000000000000000 # $200+ always compete
|
||||
|
||||
# =============================================================================
|
||||
# A/B TESTING FRAMEWORK
|
||||
# =============================================================================
|
||||
ab_testing:
|
||||
enabled: false # Enable A/B testing
|
||||
|
||||
# Test groups
|
||||
control_group_percentage: 50 # 50% use old config
|
||||
treatment_group_percentage: 50 # 50% use new config
|
||||
|
||||
# Metrics to track
|
||||
track_metrics:
|
||||
- "opportunities_detected"
|
||||
- "opportunities_executed"
|
||||
- "total_profit"
|
||||
- "average_latency"
|
||||
- "success_rate"
|
||||
|
||||
# Duration
|
||||
test_duration_hours: 24 # Run for 24 hours
|
||||
min_sample_size: 100 # Minimum 100 opportunities per group
|
||||
|
||||
# =============================================================================
|
||||
# MONITORING AND ALERTING
|
||||
# =============================================================================
|
||||
l2_monitoring:
|
||||
# Performance tracking
|
||||
track_block_times: true # Monitor actual block times
|
||||
track_opportunity_window: true # Measure actual opportunity duration
|
||||
track_competition: true # Monitor express lane activity
|
||||
|
||||
# Alerts
|
||||
alert_on_long_block_time: true # Alert if block time >500ms
|
||||
alert_on_missed_opportunities: true # Alert if we're being consistently outbid
|
||||
alert_on_low_success_rate: true # Alert if success rate <5%
|
||||
|
||||
# Logging
|
||||
log_opportunity_lifecycle: true # Detailed lifecycle logging
|
||||
log_execution_timing: true # Log all timing metrics
|
||||
log_comparison_with_mainnet: false # Don't log L1 comparisons (not relevant)
|
||||
|
||||
# =============================================================================
|
||||
# BACKWARD COMPATIBILITY
|
||||
# =============================================================================
|
||||
legacy_config:
|
||||
# Keep old values for rollback
|
||||
opportunity_ttl_legacy: "30s"
|
||||
max_path_age_legacy: "60s"
|
||||
|
||||
# Rollback procedure
|
||||
enable_legacy_mode: false # Emergency rollback
|
||||
auto_rollback_on_failure: true # Auto-rollback if >50% failure rate
|
||||
rollback_threshold_failures: 10 # Rollback after 10 consecutive failures
|
||||
|
||||
# =============================================================================
|
||||
# DEPLOYMENT PHASES
|
||||
# =============================================================================
|
||||
deployment_phases:
|
||||
current_phase: 1 # Which phase we're in
|
||||
|
||||
# Phase 1: Configuration tuning (Week 1)
|
||||
phase_1:
|
||||
enabled: true
|
||||
features:
|
||||
- "use_arbitrum_optimized_timeouts"
|
||||
- "use_dynamic_ttl"
|
||||
rollback_ready: true
|
||||
|
||||
# Phase 2: Transaction filtering (Week 2)
|
||||
phase_2:
|
||||
enabled: false
|
||||
features:
|
||||
- "enable_dex_prefilter"
|
||||
- "log_filtered_transactions"
|
||||
rollback_ready: true
|
||||
|
||||
# Phase 3: Sequencer optimization (Week 3)
|
||||
phase_3:
|
||||
enabled: false
|
||||
features:
|
||||
- "use_direct_sequencer_feed"
|
||||
- "sequencer_feed_fallback"
|
||||
rollback_ready: true
|
||||
|
||||
# Phase 4: Timeboost monitoring (Week 4)
|
||||
phase_4:
|
||||
enabled: false
|
||||
features:
|
||||
- "timeboost_monitoring_only"
|
||||
rollback_ready: true
|
||||
|
||||
# Phase 5: Timeboost execution (Month 2+)
|
||||
phase_5:
|
||||
enabled: false
|
||||
features:
|
||||
- "enable_timeboost"
|
||||
rollback_ready: false # High risk, careful rollout
|
||||
|
||||
# =============================================================================
|
||||
# VALIDATION AND TESTING
|
||||
# =============================================================================
|
||||
validation:
|
||||
# Pre-deployment validation
|
||||
run_config_validation: true # Validate config before starting
|
||||
require_all_dex_addresses: true # Ensure all DEXes configured
|
||||
require_sequencer_connectivity: false # Don't require for Phase 1
|
||||
|
||||
# Runtime validation
|
||||
continuous_validation: true # Monitor config consistency
|
||||
alert_on_misconfiguration: true # Alert on detected issues
|
||||
|
||||
# Test mode
|
||||
dry_run_mode: false # Set to true for testing without execution
|
||||
log_would_be_executed: true # Log what would execute in dry run
|
||||
Reference in New Issue
Block a user