How zacholme7/basebuster works
Main Components
a. Smart Contracts Layer:
• Located in the contracts directory.
• Contains Solidity contracts (using Foundry, indicated by foundry.toml and various solidity libraries like openzeppelin-contracts, aave-v3-core, etc.).
• This layer is responsible for on-chain operations, potentially including execution of arbitrage, flash loans, or settlement operations.
b. Core Arbiter Engine (Rust Application):
• The primary entry is in src/main.rs.
• Modules responsible for arbitrage signal processing, estimation, and simulation (e.g., estimator.rs, simulator.rs, quoter.rs, swap.rs, gas_station.rs, tx_sender.rs).
• Calculation modules (src/calculation folder) specific to different protocols (uniswap.rs, balancer.rs, curve.rs, etc.) suggesting that the bot calculates potential profit opportunities using protocol-specific logic.
• The state_db component (src/state_db) for storing and retrieving blockchain or market state information.
c. Data and Utility Layers:
• Graph, event logging (src/graph.rs, src/events.rs, src/tracing.rs) modules for monitoring and debugging.
• Caching (src/cache.rs) and a database layer (src/history_db.rs) to maintain historical data that may inform arbitrage decisions.
• ABI decoding/access from the src/abi folder and bytecode handling from src/bytecode.rs to interact with deployed contracts on the blockchain.
d. Testing and Simulation:
• Extensive tests and helper modules (under src/tests and src/tests/helpers) to validate the bot’s strategies and ensure reliability.
Configure the Relationships and Interactions
a. Off-chain Components (Rust Code):
• The main application orchestrates data fetching (from blockchains, state_db, etc.), processes market data through calculation modules, and simulates arbitrage strategies.
• It then communicates with the smart contracts deployed on-chain (located in contracts/) via transaction sending and possibly event listening (hinted by modules like tx_sender.rs and stream.rs).
b. On-chain Components (Smart Contracts):
• The contracts layer should be represented with its relationships to the Rust engine; pointing out that when an arbitrage opportunity is detected, the off-chain system can invoke on-chain contracts to execute a trade.
c. Inter-module Communications:
• How the Rust modules link with each other: for instance, how the gas_station module is linked to tx_sender to compute the required gas fees before executing a transaction.
• Directional flows between the calculation modules (protocol-specific calculations) feeding into the quoter module, which in turn informs the decision to execute a swap.
Important Architectural Patterns and Technologies
• Modular Design: The Rust source is separated into clear modules (calculation, state_db, simulation, etc.), implementing separation of concerns.
• Testing First: The extensive test suite ensures reliability before any execution in a live blockchain environment.
• Hybrid Architecture: Combining off-chain computation (Rust backend) with on-chain smart contracts.
• Build/Deployment Automation: Presence of CI/CD workflows in the contracts directory (see .github/workflows) indicates automated testing/deployment practices for on-chain components.
• Use of popular blockchain libraries: openzeppelin-contracts, forge-std, etc.