1use ethers::types::{Address, H256, U64, U256};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct Bundle {
6 pub txs: Vec<String>,
7 pub block_number: Option<U64>,
8 pub min_timestamp: Option<u64>,
9 pub max_timestamp: Option<u64>,
10 pub reverting_tx_hashes: Option<Vec<H256>>,
11 pub replacement_uuid: Option<String>,
12}
13
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct BundleStats {
16 pub is_high_priority: bool,
17 pub is_mev: bool,
18 pub eligible_after: Option<U64>,
19 pub eligible_until: Option<U64>,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct SendBundleResponse {
24 pub bundle_hash: H256,
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct BundleReceipt {
29 pub bundle_hash: H256,
30 pub timestamp: U64,
31 pub block_number: U64,
32 pub transactions: Vec<H256>,
33 pub state_block_number: U64,
34 pub status: String,
35 pub mev_reward: Option<U256>,
36 pub logs: Vec<String>,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
40pub struct UserStats {
41 pub is_high_priority: bool,
42 pub all_time_mev_reward: U256,
43 pub all_time_gas_spent: U256,
44 pub all_time_bundles_received: U64,
45 pub all_time_valid_bundles_received: U64,
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct SimulateBundleRequest {
50 pub bundle: Bundle,
51 pub state_block_number: Option<U64>,
52 pub parent_block: Option<U64>,
53 pub block_number: Option<U64>,
54 pub timestamp: Option<u64>,
55 pub gas_limit: Option<U64>,
56 pub base_fee: Option<U256>,
57 pub timeout: Option<u64>,
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct SimulateBundleResponse {
62 pub success: bool,
63 pub error: Option<String>,
64 pub state_block_number: U64,
65 pub gas_used: U64,
66 pub mev_reward: Option<U256>,
67 pub logs: Vec<String>,
68 pub coinbase_diff: U256,
69 pub eth_sent_to_coinbase: U256,
70 pub gas_fees: U256,
71}
72
73#[derive(Debug, Clone, Serialize, Deserialize)]
74pub struct RelayStatus {
75 pub status: String,
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
79pub struct BundlePriceResponse {
80 pub percentage: Option<f64>,
81 pub number: Option<U64>,
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
85pub struct CancelBundlesRequest {
86 pub bundle_hashes: Vec<H256>,
87}
88
89#[derive(Debug, Clone, Serialize, Deserialize)]
90pub struct CancelBundlesResponse {
91 pub success: bool,
92 pub message: String,
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
96pub struct GasPriceResponse {
97 pub last_block_gas_price: u64,
98 pub safe_low_gas_price: u64,
99 pub standard_gas_price: u64,
100 pub fast_gas_price: u64,
101 pub fastest_gas_price: u64,
102 pub block_number: U64,
103}
104
105#[derive(Debug, Clone, Serialize, Deserialize)]
106pub struct BlockResponse {
107 pub block_number: U64,
108 pub miner: Address,
109 pub base_fee_per_gas: U256,
110 pub gas_used: U256,
111 pub gas_limit: U256,
112 pub timestamp: u64,
113 pub bundles: Vec<BundleReceipt>,
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
117pub struct UserStatus {
118 pub is_high_priority: bool,
119 pub reputation: Option<f64>,
120 pub blacklisted: bool,
121 pub max_gas_price: Option<U256>,
122}
123
124#[derive(Debug, Clone, Serialize, Deserialize)]
125pub struct RelayInfo {
126 pub name: String,
127 pub version: String,
128 pub supported_apis: Vec<String>,
129 pub network: String,
130 pub chain_id: u64,
131 pub builder: Option<String>,
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
135pub struct BundleByHashResponse {
136 pub bundle: Bundle,
137 pub receipt: Option<BundleReceipt>,
138}
139
140#[derive(Debug)]
141pub enum FlashbotsError {
142 HttpError(String),
143 JsonError(String),
144 ApiError(String),
145 ValidationError(String),
146 Timeout,
147 InvalidResponse(String),
148 EthersError(String),
149 Error(String),
150}
151
152impl From<ethers::providers::ProviderError> for FlashbotsError {
153 fn from(err: ethers::providers::ProviderError) -> Self {
154 FlashbotsError::EthersError(err.to_string())
155 }
156}
157
158pub type FlashbotsResult<T> = std::result::Result<T, FlashbotsError>;