How coltonc3/mev-bots works
Main Components
• Bot Orchestrator: The entry point is the main.py module, which likely coordinates the activities of the bot.
• Mempool Monitor: Represented by mempool.py, which likely listens to pending transactions or blockchain events.
• Arbitrage Calculation Engine: Modules like calculate.py and swaps.py indicate the logic for analyzing and calculating arbitrage opportunities.
• State Updater: update_reserves.py and query_contract_info.py are used to fetch or update on-chain data (pool reserves, contract states, etc.).
• Transaction Creator: create_tx.py and route.py are in charge of crafting and sending the transactions.
• Messaging/Utility: messages.py might be handling logging, notifications, or other communication-related functionalities.
• Configuration & External Contracts: contracts.json stores contract addresses and parameters required for interacting with the DEXes.
• Dependencies: The requirements.txt outlines external libraries that the project depends on (likely including blockchain interaction, networking, and maybe cryptography frameworks).
Relationships and Data Flow
• The bot starts with main.py as the central controller.
• mempool.py feeds live transaction data into main.py or directly into the arbitrage logic.
• When new opportunities or conditions are detected, calculate.py (and swaps.py) perform the heavy lifting of identifying profitable opportunities.
• For current contract states or DEX pool reserves, update_reserves.py and query_contract_info.py gather real-time data from the blockchain, referring to the contracts in contracts.json.
• Once an opportunity is confirmed, create_tx.py builds the transaction bundle or order, and route.py is used to send/sign the bundle as per the Skip protocol integration.
• messages.py may be used across these modules for effective logging or inter-module communication.
Architectural Patterns and Design Principles
• Modular Design: The separation of concerns is clear—the code is organized into distinct modules handling specific tasks such as monitoring, calculation, transaction creation, and state update.
• Pipeline Flow: Data flows from blockchain monitoring (mempool), through analytical processing (calculation and swaps), to transaction creation and execution.
• External Integration: The bot integrates with external blockchain services and APIs (for DEX pools and the Skip protocol) to perform its functions.
• Configurability: External JSON configuration (contracts.json) allows for easy updates as contract addresses or parameters change.
Technologies and Frameworks
• Python is the primary language.
• Likely web3 or similar libraries for blockchain interactions.
• The Skip protocol is a core component of the external execution layer.