flashbots 0.1.0

A Flashbots API client for Rust
Documentation
//! A Flashbots API client for Rust.
//!
//! ## Structure
//!
//! The crate is segmented by Flashbots components:
//!
//! - [Flashbots Auction](crate::auction)
//! - [Flashbots Protect](crate::protect)
//! - [Flashbots Blocks](crate::blocks)
//!
//! Additionally, a set of helpers for simulating bundles and transactions can be found in the [simulation](crate::simulation) module.
//!
//! ## Examples
//!
//! ### Flashbots Auction
//!
//! ### Flashbots Protect
//!
//! ### Flashbots Blocks
//!
//! ## Ethers Middleware
//!
//! For an [`ethers`](ethers) middleware leveraging this crate, refer to [`ethers-flashbots`](ethers-flashbots).

/// Core types.
pub mod types {
    pub type BlockNumber = ethers_core::types::U64;
}

/// Simulation types and helpers.
pub mod simulation {
    use crate::types::BlockNumber;

    pub struct SimulationParameters {
        state_block_number: BlockNumber,
        timestamp: usize,
    }

    pub enum SimulationError {
        MaxFeePerGasTooLow,
    }
}

/// Flashbots Auction
pub mod auction {
    use crate::types::BlockNumber;
    use ethers_core::types::Bytes;
    use ethers_core::types::TxHash;
    use uuid::Uuid;

    pub struct Bundle {
        transactions: Vec<Bytes>,
        block_number: BlockNumber,
        min_timestamp: Option<usize>,
        max_timestamp: Option<usize>,
        reverting_tx_hashes: Vec<TxHash>,
        replacement_uuid: Option<Uuid>,
    }

    pub struct CachedBundle {
        bundle_id: Uuid,
        transactions: Vec<Bytes>,
    }

    pub mod stats {
        pub struct User {}
        pub struct Bundle {}
    }
}

/// Flashbots Protect
pub mod protect {
    use crate::simulation::SimulationError;
    use crate::types::BlockNumber;
    use ethers_core::types::Transaction;
    use ethers_core::types::TxHash;

    pub struct Preferences {
        fast: bool,
    }

    pub struct PrivateTransaction<T> {
        transaction: T,
        max_block_number: BlockNumber,
        preferences: Preferences,
    }

    pub enum Status {
        Pending,
        Included,
        Failed,
        Cancelled,
        Unknown,
    }

    pub struct TransactionStatus {
        status: Status,
        hash: TxHash,
        max_block_number: BlockNumber,
        transaction: Transaction,
        fast_mode: bool,
        seen_in_mempool: bool,
        simulation_error: SimulationError,
    }
}

/// Flashbots Blocks
pub mod blocks {
    use crate::types::BlockNumber;
    use ethers_core::types::{Address, TxHash, U256};

    pub struct Transaction {
        transaction_hash: TxHash,
        tx_index: U256,
        bundle_index: U256,
        block_number: BlockNumber,
        eoa_address: Address,
        to_address: Address,
        gas_used: U256,
        gas_price: U256,
        fee_recipient_eth_diff: U256,
        eth_sent_to_fee_recipient: U256,
    }

    pub struct Block {
        block_number: BlockNumber,
        fee_recipient: Address,
        fee_recipient_eth_diff: U256,
        eth_sent_to_fee_recipient: U256,
        gas_used: U256,
        gas_price: U256,
        transactions: Vec<Transaction>,
    }
}

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        let result = 2 + 2;
        assert_eq!(result, 4);
    }
}