Artemis Framework

repository·main·Indexed 25 days ago

https://github.com/paradigmxyz/artemis

A 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.

Tokens
19.8K
Snippets
49
Records
107
Agent score
83%

What's inside Artemis

  1. Overview of MEV Share Uniswap V2 / V3 Arbitrage Strategy

    main
    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.
  2. Overview of the Artemis MEV Framework

    main

    Artemis 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:

    1. Collectors: Ingest external events (e.g., pending transactions, new blocks, marketplace orders) and convert them into an internal event representation.
    2. Strategies: Contain the core logic for identifying MEV opportunities. They consume events and produce actions (e.g., detecting cross-exchange arbitrage from marketplace orders).
    3. Executors: Process actions to execute them in specific domains, such as submitting transactions or posting off-chain orders.
  3. Integrate Chainbound with Artemis

    main

    The chainbound-artemis crate 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 mempool and new_blocks data.
    • 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_KEY via environment variables.

  4. Use the OpenSea V2 client to fulfill listings

    main

    The opensea-v2 crate provides Rust bindings for the Opensea V2 API, specifically supporting the fulfill_listing endpoint. This endpoint is used for taker strategies to retrieve the necessary arguments to fulfill orders onchain.

    To use it, instantiate an OpenSeaV2Client using an OpenSeaApiConfig containing your API key, then call fulfill_listing with a FulfillListingRequest containing 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);
  5. Deploy the Artemis Sudo x Seaport Arbitrage contract

    main

    To reduce reliance on the huffc compiler, you can use the precompiled SudoOpenseaArbCompiled library. 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;
  6. Install chainbound-artemis

    main

    Add the following dependencies to your Cargo.toml to use the Chainbound integration. Note that artemis-core and chainbound-artemis are 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"