4.8 KiB
MEV Bot Project - Claude Context
This file contains context information for Claude about the MEV Bot project.
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.
Project Structure
cmd/- Main applications (specificallycmd/mev-bot/main.go)internal/- Private application and library codeinternal/config- Configuration managementinternal/logger- Logging functionalityinternal/ratelimit- Rate limiting implementationsinternal/utils- Utility functions
pkg/- Library code that can be used by external projectspkg/events- Event processing systempkg/market- Market data handlingpkg/monitor- Arbitrum sequencer monitoringpkg/scanner- Market scanning functionalitypkg/test- Test utilities and helperspkg/uniswap- Uniswap V3 specific implementations
config/- Configuration files@prompts/- AI prompts for development assistancedocs/- Documentationscripts/- Scripts for building, testing, and deployment
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
Development Guidelines
- Focus on implementing the features outlined in the project plan
- Ensure all code follows Go best practices
- Write comprehensive tests for all functionality
- Document all public APIs and complex algorithms
- Follow the performance requirements outlined in COMMON.md
System Architecture
The MEV Bot follows a modular architecture with clearly defined components that communicate through well-defined interfaces.
Core Components and Their Responsibilities
-
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
-
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
-
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
-
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
-
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
Communication Patterns
- Pipeline pattern for multi-stage processing
- Worker pool pattern for concurrent execution
- Message passing through Go channels
- Shared memory access with proper synchronization
Claude's Primary Focus Areas
As Claude, you're particularly skilled at:
-
Code Architecture and Design Patterns
- Implementing clean, maintainable architectures
- Applying appropriate design patterns (pipeline, worker pool, etc.)
- Creating well-structured interfaces between components
- Ensuring loose coupling and high cohesion
-
System Integration and APIs
- Designing clear APIs between components
- Implementing proper data flow between modules
- Creating robust configuration management
- Building error handling and recovery mechanisms
-
Writing Clear Documentation
- Documenting complex algorithms and mathematical calculations
- Creating clear API documentation
- Writing architectural decision records
- Producing user guides and examples
-
Implementing Robust Error Handling
- Using Go's error wrapping with context
- Implementing retry mechanisms with exponential backoff
- Handling timeouts appropriately
- Creating comprehensive logging strategies
-
Creating Maintainable and Scalable Code Structures
- Organizing code for easy testing and maintenance
- Implementing performance monitoring and metrics
- Designing for horizontal scalability
- Ensuring code follows established patterns and conventions
When working on this project, please focus on these areas where your strengths will be most beneficial.