Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankieIsLost committed Jul 24, 2023
1 parent 8a06337 commit a9c3e21
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
23 changes: 17 additions & 6 deletions crates/strategies/mev-share-uni-arb/src/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use anyhow::Result;
use artemis_core::types::Strategy;

use ethers::signers::Signer;
use matchmaker::types::{BundleRequest, BundleTx};

use ethers::providers::Middleware;
use ethers::types::{Address, H256};
use ethers::types::{H160, U256};
use mev_share::rpc::{BundleItem, Inclusion, SendBundleRequest};
use tracing::info;

use crate::types::V2V3PoolRecord;
Expand Down Expand Up @@ -110,7 +110,11 @@ impl<M: Middleware + 'static, S: Signer + 'static> Strategy<Event, Action>

impl<M: Middleware + 'static, S: Signer + 'static> MevShareUniArb<M, S> {
/// Generate a series of bundles of varying sizes to submit to the matchmaker.
pub async fn generate_bundles(&self, v3_address: H160, tx_hash: H256) -> Vec<BundleRequest> {
pub async fn generate_bundles(
&self,
v3_address: H160,
tx_hash: H256,
) -> Vec<SendBundleRequest> {
let mut bundles = Vec::new();
let v2_info = self.pool_map.get(&v3_address).unwrap();

Expand Down Expand Up @@ -184,14 +188,21 @@ impl<M: Middleware + 'static, S: Signer + 'static> MevShareUniArb<M, S> {
let signature = self.tx_signer.sign_transaction(&arb_tx).await.unwrap();
let bytes = arb_tx.rlp_signed(&signature);
let txs = vec![
BundleTx::TxHash { hash: tx_hash },
BundleTx::Tx {
BundleItem::Hash { hash: tx_hash },
BundleItem::Tx {
tx: bytes,
can_revert: false,
},
];
// bundle should be valid for next block
let bundle = BundleRequest::make_simple(block_num.add(1), txs);
let bundle = SendBundleRequest {
bundle_body: txs,
inclusion: Inclusion {
block: block_num.add(1),
// set a large validity window to ensure builder gets a chance to include bundle.
max_block: Some(block_num.add(30)),
},
..Default::default()
};
info!("submitting bundle: {:?}", bundle);
bundles.push(bundle);
}
Expand Down
5 changes: 2 additions & 3 deletions crates/strategies/mev-share-uni-arb/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use artemis_core::executors::mev_share_executor::Bundles;
use ethers::types::H160;

use mev_share::sse;
use mev_share::{rpc::SendBundleRequest, sse};

/// Core Event enum for the current strategy.
#[derive(Debug, Clone)]
Expand All @@ -12,7 +11,7 @@ pub enum Event {
/// Core Action enum for the current strategy.
#[derive(Debug, Clone)]
pub enum Action {
SubmitBundles(Bundles),
SubmitBundles(Vec<SendBundleRequest>),
}

#[derive(Debug, serde::Deserialize)]
Expand Down
4 changes: 2 additions & 2 deletions examples/mev-share-arb/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use ethers::{
prelude::MiddlewareBuilder,
providers::{Provider, Ws},
signers::{LocalWallet, Signer},
types::{Address, Chain},
types::Address,
};
use mev_share_uni_arb::{
strategy::MevShareUniArb,
Expand Down Expand Up @@ -80,7 +80,7 @@ async fn main() -> Result<()> {
engine.add_strategy(Box::new(strategy));

// Set up executor.
let mev_share_executor = Box::new(MevshareExecutor::new(fb_signer, Chain::Mainnet));
let mev_share_executor = Box::new(MevshareExecutor::new(fb_signer));
let mev_share_executor = ExecutorMap::new(mev_share_executor, |action| match action {
Action::SubmitBundles(bundles) => Some(bundles),
});
Expand Down

0 comments on commit a9c3e21

Please sign in to comment.