Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate mev share dependencies #39

Merged
merged 9 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
338 changes: 143 additions & 195 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ members = [

default-members = ["bin/artemis", "bin/cli"]

[workspace.dependencies]
## eth
ethers = { version = "2", features = ["ws", "rustls"]}
ethers-signers = "2.0"


[profile.release]
panic = 'abort'

Expand Down
7 changes: 4 additions & 3 deletions crates/artemis-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ edition = "2021"
[dependencies]

## eth
ethers = { version = "2", features = ["ws", "rustls"]}
ethers.workspace = true
opensea-stream = { git = "https://github.com/FrankieIsLost/opensea-stream-rs"}
mev-share = "0.1.1"
matchmaker = { path = "../../crates/clients/matchmaker" }
mev-share = "0.1.4"
ethers-flashbots = { git = "https://github.com/FrankieIsLost/ethers-flashbots", features = ["rustls"] }

## async
Expand All @@ -20,8 +19,10 @@ futures = "0.3"
reqwest = { version = "0.11.14", default-features = false, features = ["rustls-tls"] }
tokio = { version = "1.18", features = ["full"] }
tokio-stream = { version = "0.1", features = ['sync'] }
jsonrpsee = { version = "0.18", features = ["client", "async-client"] }

## misc
anyhow = "1.0.70"
thiserror = "1.0.40"
tracing = "0.1.37"
tower = "0.4.13"
39 changes: 25 additions & 14 deletions crates/artemis-core/src/executors/mev_share_executor.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,46 @@
use crate::types::Executor;
use anyhow::Result;
use async_trait::async_trait;
use ethers::{signers::Signer, types::Chain};
use ethers::signers::Signer;
use futures::{stream, StreamExt};
use matchmaker::{client::Client, types::BundleRequest};
use jsonrpsee::http_client::{
transport::{self},
HttpClientBuilder,
};
use mev_share::rpc::{FlashbotsSignerLayer, MevApiClient, SendBundleRequest};

use tracing::{error, info};

/// An executor that sends bundles to the MEV-share Matchmaker.
pub struct MevshareExecutor<S> {
matchmaker_client: Client<S>,
pub struct MevshareExecutor {
mev_share_client: Box<dyn MevApiClient + Send + Sync>,
}

/// List of bundles to send to the Matchmaker.
pub type Bundles = Vec<BundleRequest>;

impl<S: Signer + Clone + 'static> MevshareExecutor<S> {
pub fn new(signer: S, chain: Chain) -> Self {
impl MevshareExecutor {
pub fn new(signer: impl Signer + Clone + 'static) -> Self {
// Set up flashbots-style auth middleware
let http = HttpClientBuilder::default()
.set_middleware(
tower::ServiceBuilder::new()
.map_err(transport::Error::Http)
.layer(FlashbotsSignerLayer::new(signer)),
)
.build("https://relay.flashbots.net:443")
.expect("failed to build HTTP client");
Self {
matchmaker_client: Client::new(signer, chain),
mev_share_client: Box::new(http),
}
}
}

#[async_trait]
impl<S: Signer + Clone + 'static> Executor<Bundles> for MevshareExecutor<S> {
impl Executor<Vec<SendBundleRequest>> for MevshareExecutor {
/// Send bundles to the matchmaker.
async fn execute(&self, action: Bundles) -> Result<()> {
async fn execute(&self, action: Vec<SendBundleRequest>) -> Result<()> {
let bodies = stream::iter(action)
.map(|bundle| {
let client = &self.matchmaker_client;
async move { client.send_bundle(&bundle).await }
let client = &self.mev_share_client;
async move { client.send_bundle(bundle).await }
})
.buffer_unordered(5);

Expand Down
22 changes: 0 additions & 22 deletions crates/clients/matchmaker/Cargo.toml

This file was deleted.

64 changes: 0 additions & 64 deletions crates/clients/matchmaker/README.md

This file was deleted.

54 changes: 0 additions & 54 deletions crates/clients/matchmaker/src/client.rs

This file was deleted.

150 changes: 0 additions & 150 deletions crates/clients/matchmaker/src/flashbots_signer.rs

This file was deleted.

Loading
Loading