Skip to content

Commit

Permalink
adds more bundle types
Browse files Browse the repository at this point in the history
- adds the SignetCallBundle types and all of the response types
  • Loading branch information
dylanlott committed Jan 7, 2025
1 parent bff62db commit d9a02b6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
39 changes: 38 additions & 1 deletion src/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use alloy::rpc::types::mev::EthSendBundle;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;

use alloy::rpc::types::mev::{EthCallBundle, EthCallBundleResponse, EthSendBundle};
use alloy_primitives::{Address, B256, U256};

use crate::SignedOrder;

Expand All @@ -15,3 +18,37 @@ pub struct SignetEthBundle {
/// TODO: Link to docs
pub host_fills: Option<SignedOrder>,
}

/// Response for `signet_sendBundle`
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SignetEthBundleResponse {
/// The bundle hash of the sent bundle.
///
/// This is calculated as keccak256(tx_hashes) where tx_hashes are the concatenated transaction hashes.
pub bundle_hash: B256,
}

/// Bundle of transactions for `signet_callBundle`
///
/// TODO: Link to docs.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SignetCallBundle {
/// The bundle of transactions to simulate. Same structure as a Flashbots [EthCallBundle] bundle.
/// see <https://github.com/alloy-rs/alloy/blob/main/crates/rpc-types-mev/src/eth_calls.rs#L13-L33>
#[serde(flatten)]
pub bundle: EthCallBundle,
/// Host fills to be applied to the bundle for simulation. The mapping corresponds
/// to asset => user => amount.
pub host_fills: BTreeMap<Address, BTreeMap<Address, U256>>,
}

/// Response for `signet_callBundle`
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SignetCallBundleResponse {
/// The flattened "vanilla" response which comes from `eth_callBundle`
#[serde(flatten)]
pub response: EthCallBundleResponse,
}
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ mod orders;
pub use orders::{AggregateOrders, SignedOrder};

mod bundle;
pub use bundle::SignetEthBundle;
pub use bundle::{
SignetCallBundle, SignetCallBundleResponse, SignetEthBundle, SignetEthBundleResponse,
};

mod req;
pub use req::SignRequest;
Expand Down

0 comments on commit d9a02b6

Please # to comment.