Sequencer is working (minimal parsing)

This commit is contained in:
Krypto Kajun
2025-09-14 06:21:10 -05:00
parent 7dd5b5b692
commit 518758790a
59 changed files with 10539 additions and 471 deletions

View File

@@ -1,20 +1,27 @@
# Monitoring System Documentation
This document explains how the MEV bot monitors the Arbitrum sequencer for potential swap transactions.
This document explains how the MEV bot monitors the Arbitrum sequencer for potential swap transactions by reading L2 messages and parsing them to find opportunities.
## Overview
The monitoring system connects to an Arbitrum RPC endpoint and continuously monitors for new blocks and transactions. It identifies potential swap transactions and forwards them to the market scanner for analysis.
The monitoring system connects to Arbitrum RPC and WebSocket endpoints to continuously monitor for new blocks and L2 messages. It identifies potential swap transactions from both sources and forwards them to the market pipeline for analysis.
## Components
### ArbitrumMonitor
The main monitoring component that handles:
- Connecting to the arbitrum sequencer and parsing feed and filtering pool swaps and/or router swaps and the like (slight look into the future (very slight, as transations are processed every 250ms))
- Connecting to the Arbitrum WSS endpoint, RPC as redundant backup (get actual values in realtime)
- Subscribing to new blocks filtered based on filters (for pool discovery, addresses should not be filterd) ()
- Processing transactions in new blocks
- Identifying potential swap transactions
- Connecting to the Arbitrum sequencer and parsing L2 messages to find potential swap opportunities
- Connecting to the Arbitrum WSS endpoint for real-time data, with RPC as redundant backup
- Subscribing to new blocks and L2 message feeds for comprehensive coverage
- Processing transactions with high frequency (every 250ms) for competitive advantage
- Identifying potential swap transactions from both blocks and L2 messages
### L2 Message Processing
Each L2 message is analyzed to determine if it represents a potential opportunity:
1. Check if the message contains DEX interaction data
2. Decode the message to extract swap parameters
3. Extract token addresses and amounts
4. Calculate potential price impact
### Transaction Processing
Each transaction is analyzed to determine if it's a potential swap:
@@ -27,15 +34,39 @@ Each transaction is analyzed to determine if it's a potential swap:
The monitoring system is configured through config/config.yaml:
- `arbitrum.rpc_endpoint`: The RPC endpoint to connect to
- `bot.polling_interval`: How often to check for new blocks
- `arbitrum.ws_endpoint`: The WebSocket endpoint for real-time data
- `bot.polling_interval`: How often to check for new blocks (minimum 250ms)
- `arbitrum.chain_id`: The chain ID to ensure we're on the correct network
## Implementation Details
The monitor uses the go-ethereum library to interact with the Arbitrum network. It implements efficient polling to minimize RPC calls while ensuring timely detection of new blocks.
The monitor uses the go-ethereum library to interact with the Arbitrum network. It implements efficient polling and WebSocket subscriptions to minimize latency while ensuring comprehensive coverage of opportunities.
Key features:
- Graceful error handling and reconnection
- Configurable polling intervals
- Real-time L2 message processing via WebSocket
- Graceful error handling and reconnection for both RPC and WebSocket
- Configurable polling intervals with 250ms minimum for high-frequency processing
- Transaction sender identification
- Support for both RPC and WebSocket endpoints
- Support for both RPC and WebSocket endpoints with automatic fallback
- Processing of both blocks and L2 messages for complete opportunity coverage
## L2 Message Parsing
The monitoring system specifically focuses on parsing L2 messages to identify opportunities before they are included in blocks:
### Message Identification
- Filters L2 messages for DEX-related activities
- Identifies pool swaps and router swaps from message content
- Extracts transaction parameters from message data
### Early Opportunity Detection
- Processes L2 messages with minimal delay
- Calculates potential profitability from message data
- Prioritizes high-value opportunities for immediate analysis
- Provides competitive advantage by identifying opportunities before block inclusion
### Data Integration
- Combines data from L2 messages and blocks for comprehensive analysis
- Uses message data to pre-analyze potential opportunities
- Falls back to block data when message data is unavailable
- Maintains consistency between message and block processing