58 lines
1.7 KiB
Markdown
58 lines
1.7 KiB
Markdown
# MEV Bot Architecture
|
|
|
|
This document describes the high-level architecture of the MEV bot.
|
|
|
|
## Components
|
|
|
|
### 1. Arbitrum Monitor
|
|
Responsible for monitoring the Arbitrum sequencer for new blocks and transactions.
|
|
|
|
Key responsibilities:
|
|
- Connect to Arbitrum RPC endpoint
|
|
- Monitor new blocks as they are added
|
|
- Identify potential swap transactions
|
|
- Extract transaction details
|
|
|
|
### 2. Market Scanner
|
|
Analyzes potential swap transactions to determine if they create arbitrage opportunities.
|
|
|
|
Key responsibilities:
|
|
- Calculate price impact of swaps
|
|
- Scan for arbitrage opportunities across pools
|
|
- Estimate profitability after gas costs
|
|
- Filter opportunities based on configured thresholds
|
|
|
|
### 3. Uniswap Pricing
|
|
Handles all Uniswap V3 pricing calculations.
|
|
|
|
Key responsibilities:
|
|
- Convert between sqrtPriceX96 and ticks
|
|
- Calculate price impact of swaps
|
|
- Work with liquidity values
|
|
- Implement Uniswap V3 mathematical formulas
|
|
|
|
### 4. Transaction Executor
|
|
Responsible for executing profitable arbitrage transactions.
|
|
|
|
Key responsibilities:
|
|
- Construct arbitrage transactions
|
|
- Optimize gas usage
|
|
- Submit transactions to flashbots or similar services
|
|
- Handle transaction confirmation and errors
|
|
|
|
## Data Flow
|
|
|
|
1. Arbitrum Monitor detects new blocks and transactions
|
|
2. Potential swap transactions are sent to Market Scanner
|
|
3. Market Scanner analyzes swaps and identifies opportunities
|
|
4. Profitable opportunities are sent to Transaction Executor
|
|
5. Transaction Executor constructs and submits arbitrage transactions
|
|
|
|
## Configuration
|
|
|
|
The bot is configured through config/config.yaml which allows customization of:
|
|
- Arbitrum RPC endpoints
|
|
- Polling intervals
|
|
- Profit thresholds
|
|
- Gas price multipliers
|
|
- Logging settings |