Artemis Framework
repository·main·Indexed 25 days ago
https://github.com/paradigmxyz/artemisA modular Rust framework for building high-performance MEV bots using an event-driven pipeline architecture. It includes components such as artemis-core, the chainbound-artemis integration for Fiber Collector and Echo Executor, and an OpenSea V2 client for fulfilling listings. The repository also contains MEV strategies, such as Uniswap V2/V3 arbitrage on MEV Share, and associated Solidity contracts.
What's inside Artemis
- This strategy implements probabilistic Uniswap V2 / V3 arbitrage on MEV Share. It works by listening to a stream of MEV-Share events and filtering for trades that interact with a V3 pool. Upon finding a relevant transaction, the strategy submits a series of backruns of varying sizes to attempt to capture profitable arbitrage opportunities.
Overview of the Artemis MEV Framework
mainArtemis is a modular and fast Rust framework for writing MEV (Maximal Extractable Value) bots. It operates as an event processing pipeline consisting of three primary components:
- Collectors: Ingest external events (e.g., pending transactions, new blocks, marketplace orders) and convert them into an internal event representation.
- Strategies: Contain the core logic for identifying MEV opportunities. They consume events and produce actions (e.g., detecting cross-exchange arbitrage from marketplace orders).
- Executors: Process actions to execute them in specific domains, such as submitting transactions or posting off-chain orders.
Overview of Opensea Sudo Arb Strategy
mainTheopensea-sudo-arbstrategy implements atomic, cross-market NFT arbitrage between Seaport and Sudoswap. It monitors Seaport sell orders and calculates if they can be fulfilled atomically by selling the NFT into a Sudoswap pool for a profit.Integrate Chainbound with Artemis
mainThe
chainbound-artemiscrate provides access to Chainbound's MEV tools within the Artemis framework. It implements two main components following standard Artemis traits:- Fiber Collector: A low-latency stream for Ethereum providing
mempoolandnew_blocksdata. - Echo Executor: A feature-rich RPC endpoint used to propagate MEV bundles to block builders.
To use these components, you must provide a
CHAINBOUND_API_KEYvia environment variables.- Fiber Collector: A low-latency stream for Ethereum providing
Use the OpenSea V2 client to fulfill listings
mainThe
opensea-v2crate provides Rust bindings for the Opensea V2 API, specifically supporting thefulfill_listingendpoint. This endpoint is used for taker strategies to retrieve the necessary arguments to fulfill orders onchain.To use it, instantiate an
OpenSeaV2Clientusing anOpenSeaApiConfigcontaining your API key, then callfulfill_listingwith aFulfillListingRequestcontaining the listing details and the fulfiller's address.let client = OpenSeaV2Client::new(OpenSeaApiConfig { api_key }); let req = FulfillListingRequest { listing: Listing { hash: H256::from_str( "0xce83ef67f520d74d081aa4da9588ee6743d3aa64caff98a7dddf214e10469929", ) .unwrap(), chain: Chain::Mainnet, protocol_version: ProtocolVersion::V1_4, }, fulfiller: Fulfiller { address: H160::from_str("0xD77F375A33b1109e82f3C46A30537F1E019708eB").unwrap(), }, }; let resp = client.fulfill_listing(req).await; println!("{:?}", resp);Build and test the opensea-v2 crate
mainUse the following Cargo commands to verify and build the
opensea-v2crate:- Check for errors:
cargo check - Run tests:
cargo test - Build the project:
cargo build [--release]
cargo check cargo test cargo build [--release]- Check for errors:
Build and Test the MEV Share Uniswap V2 / V3 Arbitrage Strategy
mainTo ensure the strategy is working correctly, you can run both Solidity and Rust tests.
Solidity Tests
Running Solidity tests requires an Alchemy or Infura key provided via the
ETH_MAINNET_HTTPenvironment variable.Rust Tests
Run the standard Rust test suite using
cargo test.Install Forge Standard Library
mainInstall
forge-stdusing the Forge CLI to use its helper contracts and libraries with Foundry.forge install foundry-rs/forge-stdDeploy the Artemis Sudo x Seaport Arbitrage contract
mainTo reduce reliance on the
huffccompiler, you can use the precompiledSudoOpenseaArbCompiledlibrary. You can either deploy the contract directly (where the caller becomes the owner) or access the initialization code as a constant.// deploys the contract where the caller is the owner. address deployment = SudoOpenseaArbCompiled.deploy(); // returns the initialization code. bytes memory initcode = SudoOpenseaArbCompiled.initcode;Install chainbound-artemis
mainAdd the following dependencies to your
Cargo.tomlto use the Chainbound integration. Note thatartemis-coreandchainbound-artemisare pulled directly from the Artemis repository.[dependencies] artemis-core = { git = "https://github.com/paradigmxyz/artemis.git" } chainbound-artemis = { git = "https://github.com/paradigmxyz/artemis.git" } # Required dependencies for the example implementation ethers = { version = "2", features = ["ws", "rustls"] } tokio = { version = "1.18", features = ["full"] } anyhow = "1.0.70"[dependencies] artemis-core = { git = "https://github.com/paradigmxyz/artemis.git" } chainbound-artemis = { git = "https://github.com/paradigmxyz/artemis.git" } # the following dependencies are also used in this example ethers = { version = "2", features = ["ws", "rustls"] } tokio = { version = "1.18", features = ["full"] } anyhow = "1.0.70"Regenerate Rust bindings for MEV Share Uniswap V2 / V3 Arbitrage contracts
mainIf you modify the Solidity contracts and need to update the Rust bindings used by the strategy, use the
forge bindcommand with the specified path and crate name.forge bind --bindings-path ./bindings --root ./contracts --crate-name bindingsSetup and Build Artemis
mainTo build and test Artemis, ensure you have Anvil installed.
Follow these steps to clone the repository and run the test suite:
git clone https://github.com/paradigmxyz/artemis cd artemis cargo test --all