alloy_provider/ext/mev/
mod.rs

1mod with_auth;
2
3pub use self::with_auth::{sign_flashbots_payload, MevBuilder};
4use crate::Provider;
5use alloy_network::Network;
6use alloy_rpc_types_mev::{EthBundleHash, EthSendBundle};
7
8/// The HTTP header used for Flashbots signature authentication.
9pub const FLASHBOTS_SIGNATURE_HEADER: &str = "x-flashbots-signature";
10
11/// This module provides support for interacting with non-standard MEV-related RPC endpoints.
12#[cfg_attr(target_family = "wasm", async_trait::async_trait(?Send))]
13#[cfg_attr(not(target_family = "wasm"), async_trait::async_trait)]
14pub trait MevApi<N>: Send + Sync {
15    /// Sends a MEV bundle using the `eth_sendBundle` RPC method.
16    /// Returns the resulting bundle hash on success.
17    fn send_bundle(
18        &self,
19        bundle: EthSendBundle,
20    ) -> MevBuilder<(EthSendBundle,), Option<EthBundleHash>>;
21}
22
23#[cfg_attr(target_family = "wasm", async_trait::async_trait(?Send))]
24#[cfg_attr(not(target_family = "wasm"), async_trait::async_trait)]
25impl<N, P> MevApi<N> for P
26where
27    N: Network,
28    P: Provider<N>,
29{
30    fn send_bundle(
31        &self,
32        bundle: EthSendBundle,
33    ) -> MevBuilder<(EthSendBundle,), Option<EthBundleHash>> {
34        MevBuilder::new_rpc(self.client().request("eth_sendBundle", (bundle,)))
35    }
36}