Skip to content
Closed
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
35 changes: 35 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ proc-macro2 = "1.0.103"
alloy-sol-macro-input = "1.4.1"
alloy-sol-macro-expander = "1.4.1"
jsonrpc-core = "18.0.0"
serde-ext = { path = "crates/serde-ext" }
simulator = { path = "crates/simulator" }

[workspace.lints]
clippy.cast_possible_wrap = "deny"
4 changes: 2 additions & 2 deletions crates/autopilot/src/boundary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ pub mod events;
pub mod order;

/// Builds a web3 client based on the ethrpc args config.
pub fn web3_client(ethrpc: &Url, ethrpc_args: &shared::ethrpc::Arguments) -> Web3 {
shared::ethrpc::web3(ethrpc_args, ethrpc, "base")
pub fn web3_client(ethrpc: &Url, ethrpc_args: &shared::web3::Arguments) -> Web3 {
shared::web3::web3(ethrpc_args, ethrpc, "base")
}

pub struct SolvableOrders {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
sol_types::SolEvent,
},
contracts::alloy::CoWSwapEthFlow::CoWSwapEthFlow,
shared::{ethrpc::Web3, event_handling::AlloyEventRetrieving},
shared::{event_handling::AlloyEventRetrieving, web3::Web3},
};

pub struct EthFlowRefundRetriever {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {
sol_types::SolEvent,
},
contracts::alloy::CoWSwapOnchainOrders,
shared::{ethrpc::Web3, event_handling::AlloyEventRetrieving},
shared::{event_handling::AlloyEventRetrieving, web3::Web3},
};

// Note: we use a custom implementation of `EventRetrieving` rather than using
Expand Down
5 changes: 1 addition & 4 deletions crates/autopilot/src/infra/blockchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ pub struct Rpc {
impl Rpc {
/// Instantiate an RPC client to an Ethereum (or Ethereum-compatible) node
/// at the specifed URL.
pub async fn new(
url: &url::Url,
ethrpc_args: &shared::ethrpc::Arguments,
) -> Result<Self, Error> {
pub async fn new(url: &url::Url, ethrpc_args: &shared::web3::Arguments) -> Result<Self, Error> {
let web3 = boundary::web3_client(url, ethrpc_args);
let chain = Chain::try_from(web3.provider.get_chain_id().await?)
.map_err(|_| Error::UnsupportedChain)?;
Expand Down
12 changes: 6 additions & 6 deletions crates/autopilot/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl Liveness {

/// Creates Web3 transport based on the given config.
#[instrument(skip_all)]
async fn ethrpc(url: &Url, ethrpc_args: &shared::ethrpc::Arguments) -> infra::blockchain::Rpc {
async fn ethrpc(url: &Url, ethrpc_args: &shared::web3::Arguments) -> infra::blockchain::Rpc {
infra::blockchain::Rpc::new(url, ethrpc_args)
.await
.expect("connect ethereum RPC")
Expand All @@ -102,7 +102,7 @@ async fn ethrpc(url: &Url, ethrpc_args: &shared::ethrpc::Arguments) -> infra::bl
async fn unbuffered_ethrpc(url: &Url) -> infra::blockchain::Rpc {
ethrpc(
url,
&shared::ethrpc::Arguments {
&shared::web3::Arguments {
ethrpc_max_batch_size: 0,
ethrpc_max_concurrent_requests: 0,
ethrpc_batch_delay: Default::default(),
Expand Down Expand Up @@ -179,12 +179,12 @@ pub async fn run(args: Arguments, shutdown_controller: ShutdownController) {
crate::database::run_database_metrics_work(db_write.clone());

let http_factory = HttpClientFactory::new(&args.http_client);
let web3 = shared::ethrpc::web3(&args.shared.ethrpc, &args.shared.node_url, "base");
let web3 = shared::web3::web3(&args.shared.ethrpc, &args.shared.node_url, "base");
let simulation_web3 = args
.shared
.simulation_node_url
.as_ref()
.map(|node_url| shared::ethrpc::web3(&args.shared.ethrpc, node_url, "simulation"));
.map(|node_url| shared::web3::web3(&args.shared.ethrpc, node_url, "simulation"));

let chain_id = web3
.provider
Expand Down Expand Up @@ -323,7 +323,7 @@ pub async fn run(args: Arguments, shutdown_controller: ShutdownController) {
let trace_call_detector = args.tracing_node_url.as_ref().map(|tracing_node_url| {
CachingDetector::new(
Box::new(TraceCallDetector::new(
shared::ethrpc::web3(&args.shared.ethrpc, tracing_node_url, "trace"),
shared::web3::web3(&args.shared.ethrpc, tracing_node_url, "trace"),
*eth.contracts().settlement().address(),
finder,
)),
Expand Down Expand Up @@ -736,7 +736,7 @@ async fn shadow_mode(args: Arguments) -> ! {
.into_iter()
.collect();

let web3 = shared::ethrpc::web3(&args.shared.ethrpc, &args.shared.node_url, "base");
let web3 = shared::web3::web3(&args.shared.ethrpc, &args.shared.node_url, "base");
let weth = WETH9::Instance::deployed(&web3.provider)
.await
.expect("couldn't find deployed WETH contract");
Expand Down
18 changes: 0 additions & 18 deletions crates/autopilot/src/util/bytes.rs

This file was deleted.

4 changes: 0 additions & 4 deletions crates/autopilot/src/util/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use url::Url;

mod bytes;

pub use self::bytes::Bytes;

/// Joins a path with a URL, ensuring that there is only one slash between them.
/// It doesn't matter if the URL ends with a slash or the path starts with one.
pub fn join(url: &Url, mut path: &str) -> Url {
Expand Down
2 changes: 2 additions & 0 deletions crates/driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ prometheus = { workspace = true }
prometheus-metric-storage = { workspace = true }
rand = { workspace = true }
reqwest = { workspace = true }
simulator = { workspace = true }
s3 = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde-ext = { workspace = true }
serde_json = { workspace = true }
serde_with = { workspace = true }
solvers-dto = { path = "../solvers-dto" }
Expand Down
6 changes: 2 additions & 4 deletions crates/driver/src/boundary/liquidity/balancer/v2/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use {
crate::{
boundary,
domain::{
eth,
liquidity::{self, balancer},
},
domain::liquidity::{self, balancer},
infra::{self, blockchain::Ethereum},
},
anyhow::{Context, Result},
Expand All @@ -18,6 +15,7 @@ use {
},
ethrpc::block_stream::{BlockRetrieving, CurrentBlockWatcher},
shared::{
domain::eth,
http_solver::model::TokenAmount,
sources::balancer_v2::{
BalancerPoolFetcher,
Expand Down
6 changes: 2 additions & 4 deletions crates/driver/src/boundary/liquidity/balancer/v2/stable.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use {
crate::{
boundary::Result,
domain::{
eth,
liquidity::{self, balancer},
},
domain::liquidity::{self, balancer},
},
shared::domain::eth,
solver::liquidity::{StablePoolOrder, balancer_v2},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use {
crate::{
boundary::Result,
domain::{
eth,
liquidity::{self, balancer},
},
domain::liquidity::{self, balancer},
},
shared::sources::balancer_v2::pool_fetching::WeightedPoolVersion,
shared::{domain::eth, sources::balancer_v2::pool_fetching::WeightedPoolVersion},
solver::liquidity::{WeightedProductOrder, balancer_v2},
};

Expand Down
3 changes: 2 additions & 1 deletion crates/driver/src/boundary/liquidity/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
crate::{
domain::{eth, liquidity},
domain::liquidity,
infra::{self, blockchain::Ethereum},
},
anyhow::Result,
Expand All @@ -9,6 +9,7 @@ use {
model::TokenPair,
shared::{
baseline_solver::BaseTokens,
domain::eth,
http_client::HttpClientFactory,
recent_block_cache::{self, CacheConfig},
},
Expand Down
6 changes: 2 additions & 4 deletions crates/driver/src/boundary/liquidity/uniswap/v2.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
use {
crate::{
boundary::{self, Result},
domain::{
eth,
liquidity::{self, uniswap},
},
domain::liquidity::{self, uniswap},
infra::{self, blockchain::Ethereum},
},
alloy::primitives::Address,
async_trait::async_trait,
contracts::alloy::IUniswapLikeRouter,
ethrpc::{Web3, block_stream::CurrentBlockWatcher},
shared::{
domain::eth,
http_solver::model::TokenAmount,
sources::uniswap_v2::{
pair_provider::PairProvider,
Expand Down
12 changes: 5 additions & 7 deletions crates/driver/src/boundary/liquidity/uniswap/v3.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
use {
crate::{
boundary::{self, Result},
domain::{
eth,
liquidity::{
self,
uniswap::v3::{Fee, Liquidity, LiquidityNet, Pool, SqrtPrice, Tick},
},
domain::liquidity::{
self,
uniswap::v3::{Fee, Liquidity, LiquidityNet, Pool, SqrtPrice, Tick},
},
infra::{self, blockchain::Ethereum},
},
anyhow::Context,
ethrpc::block_stream::BlockRetrieving,
shared::{
domain::eth,
http_solver::model::TokenAmount,
interaction::Interaction,
maintenance::ServiceMaintenance,
Expand Down Expand Up @@ -93,7 +91,7 @@ pub fn to_interaction(
eth::Interaction {
target: encoded.0,
value: encoded.1.into(),
call_data: crate::util::Bytes(encoded.2.0.to_vec()),
call_data: encoded.2,
}
}

Expand Down
33 changes: 11 additions & 22 deletions crates/driver/src/boundary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,18 @@ pub use {
anyhow::{Error, Result},
contracts,
model::order::OrderData,
shared::ethrpc::Web3,
shared::web3::Web3,
};

/// Builds a web3 client that buffers requests and sends them in a
/// batch call.
pub fn buffered_web3_client(
ethrpc: &Url,
max_batch_size: usize,
max_concurrent_requests: usize,
) -> Web3 {
web3_client(ethrpc, max_batch_size, max_concurrent_requests)
}

/// Builds a web3 client that sends requests one by one.
pub fn unbuffered_web3_client(ethrpc: &Url) -> Web3 {
web3_client(ethrpc, 0, 0)
}

fn web3_client(ethrpc: &Url, max_batch_size: usize, max_concurrent_requests: usize) -> Web3 {
let ethrpc_args = shared::ethrpc::Arguments {
ethrpc_max_batch_size: max_batch_size,
ethrpc_max_concurrent_requests: max_concurrent_requests,
ethrpc_batch_delay: Default::default(),
};
shared::ethrpc::web3(&ethrpc_args, ethrpc, "base")
pub fn unbuffered_web3(ethrpc: &Url) -> Web3 {
shared::web3::web3(
&shared::web3::Arguments {
ethrpc_max_batch_size: 0,
ethrpc_max_concurrent_requests: 0,
ethrpc_batch_delay: Default::default(),
},
ethrpc,
"base",
)
}
Loading
Loading