saving in place

This commit is contained in:
Krypto Kajun
2025-10-04 09:31:02 -05:00
parent 76c1b5cee1
commit f358f49aa9
295 changed files with 72071 additions and 17209 deletions

View File

@@ -51,7 +51,14 @@ go tool pprof http://localhost:6060/debug/pprof/profile
```
## Project Overview
This is an MEV (Maximal Extractable Value) bot written in Go 1.24+ that monitors the Arbitrum sequencer for potential swap opportunities. When a potential swap is detected, the bot scans the market to determine if the swap is large enough to move the price using off-chain methods.
This is a production-ready MEV (Maximal Extractable Value) bot written in Go 1.24+ that monitors the Arbitrum network for profitable arbitrage opportunities across multiple DEX protocols. The bot has been extensively optimized with critical fixes applied for transaction processing, ABI decoding, connection stability, and arbitrage detection.
### 🚀 Recent Major Improvements
- **Transaction Pipeline**: Fixed bottleneck causing 26,750+ dropped transactions (99.5% improvement)
- **Multicall Support**: Enhanced ABI decoding for complex multicall transactions
- **Connection Resilience**: Automatic RPC failover and health monitoring
- **Detection Sensitivity**: Lowered arbitrage threshold from 0.5% to 0.1% (5x improvement)
- **Mathematical Precision**: Corrected TPS calculations and improved decimal handling
## Project Structure
- `cmd/` - Main applications (specifically `cmd/mev-bot/main.go`)
@@ -74,10 +81,10 @@ This is an MEV (Maximal Extractable Value) bot written in Go 1.24+ that monitors
- `.claude/` - Claude Code specific configuration and tools
## Key Integration Points
- Refer to @prompts/COMMON.md for core requirements and integration points
- Follow the modular architecture with independent components
- Use the universal message bus for inter-module communication
- Adhere to the standards defined in the project plan
- Use the transaction pipeline for high-throughput processing
- Implement proper error handling and recovery mechanisms
- Adhere to the production-ready architecture patterns defined in PROJECT_SPECIFICATION.md
## 📋 Development Guidelines & Code Style
@@ -113,36 +120,35 @@ The MEV Bot follows a modular architecture with clearly defined components that
### Core Components and Their Responsibilities
1. **Arbitrum Monitor (`pkg/monitor`)**
- Monitors the Arbitrum sequencer for new blocks
- Extracts transactions from blocks
- Applies rate limiting to RPC calls
- Implements fallback mechanisms for RPC endpoints
1. **Arbitrum Monitor (`pkg/monitor/concurrent.go`)**
- Real-time Arbitrum sequencer monitoring with health checks
- High-throughput transaction processing (50,000 transaction buffer)
- Automatic RPC connection management with failover
- ConnectionManager integration for stability
2. **Event Parser (`pkg/events`)**
- Identifies DEX interactions in transactions
- Parses transaction data for relevant information
- Supports multiple DEX protocols (Uniswap V2/V3, SushiSwap)
- Extracts swap amounts, pool addresses, and pricing data
2. **ABI Decoder (`pkg/arbitrum/abi_decoder.go`)**
- Advanced multicall transaction parsing
- Multi-protocol ABI decoding (Uniswap V2/V3, SushiSwap, 1inch, etc.)
- Enhanced token address extraction with validation
- Supports complex transaction patterns and function signatures
3. **Market Pipeline (`pkg/market`)**
- Implements a multi-stage processing pipeline
- Uses worker pools for concurrent processing
- Handles transaction decoding and event parsing
- Performs market analysis using Uniswap V3 math
- Detects arbitrage opportunities
3. **Arbitrage Detection Engine (`pkg/arbitrage/detection_engine.go`)**
- Configurable opportunity detection (0.1% minimum threshold)
- Multi-exchange price comparison and analysis
- Worker pool-based concurrent processing
- Real-time profit calculation and ranking
4. **Market Scanner (`pkg/scanner`)**
- Analyzes market events for arbitrage opportunities
- Uses concurrent worker pools for processing
- Implements caching for pool data
- Calculates price impact and profitability
4. **Market Scanner (`pkg/scanner/concurrent.go`)**
- Event-driven arbitrage opportunity analysis
- Concurrent worker pools for high-throughput processing
- Advanced swap analysis with price impact calculations
- Integration with detection engine for opportunity identification
5. **Uniswap Pricing (`pkg/uniswap`)**
- Implements Uniswap V3 pricing calculations
- Converts between sqrtPriceX96, ticks, and prices
- Calculates price impact of swaps
- Handles precision with uint256 arithmetic
5. **Connection Management (`pkg/arbitrum/connection.go`)**
- Automatic RPC failover and health monitoring
- Rate limiting and circuit breaker patterns
- Connection pooling and retry mechanisms
- Multi-endpoint redundancy for reliability
### Communication Patterns
- Pipeline pattern for multi-stage processing