Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
69ca6c1
Move common eth domain types to separate crate
m-sz Mar 12, 2026
c87657c
tombi format
m-sz Mar 12, 2026
fd4a8d6
Split up acess_list and token_amount
m-sz Mar 12, 2026
d2687f8
fix doc-test
m-sz Mar 12, 2026
b3253a5
Merge branch 'main' into eth-domain-types
m-sz Mar 12, 2026
43510bf
fmt
m-sz Mar 12, 2026
8ba638c
Fully qualify ops
m-sz Mar 13, 2026
6bd3879
Merge branch 'main' into eth-domain-types
m-sz Mar 13, 2026
c89ea6a
Move autopilot specific, non fundamental types back
m-sz Mar 13, 2026
ef5c1af
Remove WethAddress in favour of WrappedNativeToken
m-sz Mar 13, 2026
225f55c
Hide internals of {Contact,Token}Address
m-sz Mar 13, 2026
050a35a
Add Deref to WrappedNativeToken
m-sz Mar 13, 2026
607683e
Migrate driver to eth-domain-types
m-sz Mar 12, 2026
8bb68a1
Hide internals of {Contact,Token}Address
m-sz Mar 13, 2026
59cc93a
Remove driver/src/domain/eth
m-sz Mar 13, 2026
f995199
Add domain/blockchain and flashloan files for driver
m-sz Mar 13, 2026
5e277c5
fmt + doc test fix
m-sz Mar 13, 2026
1d90ff6
Factor out code-fetching to separate crate
m-sz Mar 13, 2026
37bc9f7
Simulator
m-sz Mar 13, 2026
eb1c81f
De-duplicate settlement_encoding
m-sz Mar 17, 2026
9f8994b
Merge branch 'main' into simulator-crate
m-sz Mar 17, 2026
43ea033
Removed debug tracing calls
m-sz Mar 17, 2026
da7aeaf
Small fix
m-sz Mar 17, 2026
612fd75
TOML fmt
m-sz Mar 17, 2026
a922bb7
Remove unused files
m-sz Mar 17, 2026
07da382
Fix copy-and-paste error
m-sz Mar 17, 2026
a050340
Remove interactions from Query
m-sz Mar 18, 2026
d57160e
Merge branch 'main' into simulator-crate
m-sz Mar 18, 2026
3e127b0
Update crates/simulator/src/swap_simulator.rs
m-sz Mar 19, 2026
ec6fc0f
Add docs
m-sz Mar 19, 2026
adb1970
Merge branch 'main' into simulator-crate
m-sz Mar 19, 2026
fd07b5b
Merge branch 'main' into simulator-crate
m-sz Mar 19, 2026
0973507
Add correct solver for trade_verification
m-sz Mar 19, 2026
f61af42
Add debug logs
m-sz Mar 19, 2026
2fa8a08
Simulation endpoint
m-sz Mar 17, 2026
e8bb53e
Clippy + tombi
m-sz Mar 18, 2026
6eefd09
in/out amount logic
m-sz Mar 18, 2026
66b2d03
Fix settlement target for wrapper calls
m-sz Mar 19, 2026
cc93e3c
Error code for when feature is not enabled
m-sz Mar 19, 2026
c0759c2
Revert "Add debug logs"
m-sz Mar 19, 2026
5510e0a
Revert contracts changes
m-sz Mar 19, 2026
15675ae
Merge branch 'simulator-crate' into simulation-endpoint
m-sz Mar 19, 2026
eb4d0a6
Revert contracts changes
m-sz Mar 19, 2026
532ef29
Revert contracts changes 2
m-sz Mar 19, 2026
37f3650
Merge branch 'simulator-crate' into simulation-endpoint
m-sz Mar 19, 2026
03c6ecb
Merge branch 'main' into simulation-endpoint
m-sz Mar 20, 2026
0c604e5
Add state overrides to order simulation
m-sz Mar 20, 2026
a746694
Add order simulation files which I forgot to add before
m-sz Mar 20, 2026
c49cac7
ditto
m-sz Mar 20, 2026
3c034ec
Merge branch 'main' into simulation-endpoint
m-sz Mar 20, 2026
8c5d109
Remove e2e test module
m-sz Mar 20, 2026
cfb72f0
clippy
m-sz Mar 20, 2026
3a65bae
fmt
m-sz Mar 20, 2026
c458cbf
Order simulation E2E test
m-sz Mar 20, 2026
b1f0ab5
Fix e2e test balance overrides config
m-sz Mar 20, 2026
5dde228
lint + add missing file
m-sz Mar 20, 2026
7ae0fe6
Remove e2e test debug logs
m-sz Mar 20, 2026
1d68536
Remove leftover comment
m-sz Mar 20, 2026
b652c16
Addressed comments
m-sz Mar 20, 2026
fb18d06
Make simulation gas limit config option a U256
m-sz Mar 20, 2026
e93ddca
Merge branch 'main' into simulation-endpoint
m-sz Mar 20, 2026
3948d51
Add order simulation TestDefault config
m-sz Mar 20, 2026
7760789
OpenAPI spec
m-sz Mar 20, 2026
9278131
Merge branch 'main' into simulation-endpoint
m-sz Mar 20, 2026
ec7cd91
Fix OpenAPI spec
m-sz Mar 20, 2026
9ce5309
Merge branch 'main' into simulation-endpoint
m-sz Mar 30, 2026
2a66f8d
Merge branch 'main' into simulation-endpoint
m-sz Mar 31, 2026
d6ebe8f
Update crates/orderbook/src/order_simulator.rs
m-sz Mar 31, 2026
f12c0b5
Merge branch 'main' into simulation-endpoint
m-sz Mar 31, 2026
61eb2ca
Doc fix
m-sz Mar 31, 2026
37adc8d
Pass through EncodedSwap in the post processing methods
m-sz Mar 31, 2026
ff1a373
Fix HTTP error codes and update OpenApi spec
m-sz Mar 31, 2026
057a7ed
Change private to public link related to wrapper doc
m-sz Mar 31, 2026
28943f7
Rename in/out amount/token of Query to sell and buy
m-sz Mar 31, 2026
88972d4
Add missing docs, introduce control over how trade is encoded
m-sz Mar 31, 2026
1551f37
Add doc for the simulate_order method
m-sz Mar 31, 2026
c6193d6
Clippy
m-sz Mar 31, 2026
401d44d
Merge branch 'main' into simulation-endpoint
m-sz Mar 31, 2026
0068069
unwrap() -> expect() on wrapper encoding
m-sz Mar 31, 2026
b7a4f9f
Tx gas simulation
m-sz Mar 31, 2026
b4f5cd9
Gas estimation impl
m-sz Mar 31, 2026
b9d7702
Factor out state overrides
m-sz Mar 31, 2026
5bb45e6
E2E test plan
m-sz Apr 2, 2026
c06dcdb
tx gas estimation E2E test case
m-sz Apr 7, 2026
e7ace5c
Merge branch 'main' into tx-gas-simulation
m-sz Apr 7, 2026
939f0db
Merge branch 'main' into tx-gas-simulation
m-sz Apr 28, 2026
b3e5317
Merge branch 'main' into tx-gas-simulation
m-sz Apr 28, 2026
5ca9623
fmt + clippy
m-sz Apr 28, 2026
93b8112
Cleanup and fix test startup
m-sz Apr 29, 2026
d462c30
Use original owner for calculating solution
m-sz Apr 30, 2026
57e20bc
WIP correct tx gas estimation for solver
m-sz May 4, 2026
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
2 changes: 2 additions & 0 deletions Cargo.lock

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

13 changes: 8 additions & 5 deletions crates/driver/src/domain/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use {
util,
},
chrono::Utc,
eth_domain_types as eth,
eth_domain_types::{self as eth, Address},
std::collections::{HashMap, HashSet},
};

Expand Down Expand Up @@ -118,6 +118,9 @@ pub struct Order {
pub amount: order::TargetAmount,
pub side: order::Side,
pub deadline: chrono::DateTime<chrono::Utc>,
pub owner: Address,
pub pre_interactions: Vec<domain::Interaction>,
pub post_interactions: Vec<domain::Interaction>,
}

impl Order {
Expand Down Expand Up @@ -177,7 +180,7 @@ impl Order {
competition::Auction::new(
None,
vec![competition::Order {
uid: Default::default(),
uid: competition::order::Uid::from_parts(eth::B256::ZERO, self.owner, u32::MAX),
receiver: None,
created: u32::try_from(Utc::now().timestamp())
.unwrap_or(u32::MIN)
Expand All @@ -193,14 +196,14 @@ impl Order {
},
app_data: Default::default(),
partial: competition::order::Partial::No,
pre_interactions: Default::default(),
post_interactions: Default::default(),
pre_interactions: self.pre_interactions.clone(),
post_interactions: self.post_interactions.clone(),
sell_token_balance: competition::order::SellTokenBalance::Erc20,
buy_token_balance: competition::order::BuyTokenBalance::Erc20,
signature: competition::order::Signature {
scheme: competition::order::signature::Scheme::Eip1271,
data: Default::default(),
signer: Default::default(),
signer: self.owner,
},
protocol_fees: Default::default(),
quote: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion crates/driver/src/infra/api/routes/quote/dto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ mod order;
mod quote;

pub use {
order::{Error as OrderError, Order},
order::{Error as OrderError, Order, PostOrder},
quote::Quote,
};
73 changes: 72 additions & 1 deletion crates/driver/src/infra/api/routes/quote/dto/order.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
use {
crate::domain::{competition, quote},
crate::domain::{self, competition, quote},
eth_domain_types as eth,
serde::Deserialize,
serde_with::serde_as,
};

impl Order {
pub fn into_domain(self) -> quote::Order {
self.into_domain_with_interactions(
Default::default(),
Default::default(),
Default::default(),
)
}

pub fn into_domain_with_interactions(
self,
owner: eth::Address,
pre_interactions: Vec<domain::Interaction>,
post_interactions: Vec<domain::Interaction>,
) -> quote::Order {
quote::Order {
tokens: quote::Tokens::new(self.sell_token.into(), self.buy_token.into()),
amount: self.amount.into(),
Expand All @@ -15,6 +28,9 @@ impl Order {
Kind::Buy => competition::order::Side::Buy,
},
deadline: self.deadline,
owner,
pre_interactions,
post_interactions,
}
}
}
Expand All @@ -38,6 +54,61 @@ enum Kind {
Buy,
}

/// Order body for the POST /quote endpoint, which additionally allows
/// specifying pre/post interactions.
#[serde_as]
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PostOrder {
#[serde(flatten)]
pub order: Order,
#[serde(default)]
pub from: eth::Address,
#[serde(default)]
pub interactions: Interactions,
}

impl PostOrder {
pub fn into_domain(self) -> quote::Order {
self.order.into_domain_with_interactions(
self.from,
self.interactions.pre.into_iter().map(Into::into).collect(),
self.interactions.post.into_iter().map(Into::into).collect(),
)
}
}

#[serde_as]
#[derive(Debug, Default, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Interactions {
#[serde(default)]
pub pre: Vec<Interaction>,
#[serde(default)]
pub post: Vec<Interaction>,
}

#[serde_as]
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Interaction {
pub target: eth::Address,
#[serde_as(as = "serde_ext::U256")]
pub value: eth::U256,
#[serde_as(as = "serde_ext::Hex")]
pub call_data: Vec<u8>,
}

impl From<Interaction> for domain::Interaction {
fn from(i: Interaction) -> Self {
Self {
target: i.target,
value: i.value.into(),
call_data: i.call_data.into(),
}
}
}

#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("received an order with identical buy and sell tokens")]
Expand Down
21 changes: 18 additions & 3 deletions crates/driver/src/infra/api/routes/quote/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,30 @@ mod dto;
pub use dto::OrderError;

pub(in crate::infra::api) fn quote(router: axum::Router<State>) -> axum::Router<State> {
router.route("/quote", axum::routing::get(route))
router
.route("/quote", axum::routing::get(get))
.route("/quote", axum::routing::post(post))
}

async fn route(
async fn get(
state: axum::extract::State<State>,
LoggingQuery(order): LoggingQuery<dto::Order>,
) -> Result<axum::Json<dto::Quote>, (axum::http::StatusCode, axum::Json<Error>)> {
execute(state, order.into_domain()).await
}

async fn post(
state: axum::extract::State<State>,
axum::Json(order): axum::Json<dto::PostOrder>,
) -> Result<axum::Json<dto::Quote>, (axum::http::StatusCode, axum::Json<Error>)> {
execute(state, order.into_domain()).await
}

async fn execute(
state: axum::extract::State<State>,
order: crate::domain::quote::Order,
) -> Result<axum::Json<dto::Quote>, (axum::http::StatusCode, axum::Json<Error>)> {
let handle_request = async {
let order = order.into_domain();
observe::quoting(&order);
let quote = order
.quote(
Expand Down
35 changes: 35 additions & 0 deletions crates/e2e/src/setup/colocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,41 @@ uni-v3-node-url = "http://localhost:8545"
}
}

pub async fn start_baseline_solver_with_gas_simulation(
name: String,
account: TestAccount,
weth: Address,
base_tokens: Vec<Address>,
max_hops: usize,
merge_solutions: bool,
settlement: Address,
) -> SolverEngine {
let encoded_base_tokens = encode_base_tokens(base_tokens.clone());
let config_file = config_tmp_file(format!(
r#"
weth = "{weth:?}"
base-tokens = [{encoded_base_tokens}]
max-hops = {max_hops}
max-partial-attempts = 5
native-token-price-estimation-amount = "100000000000000000"
uni-v3-node-url = "http://localhost:8545"
gas-simulation-node-url = "http://localhost:8545"
gas-simulation-settlement = "{settlement:?}"
"#,
));
let endpoint = start_solver(config_file, "baseline".to_string()).await;
SolverEngine {
name,
endpoint,
account,
base_tokens,
merge_solutions,
haircut_bps: 0,
submission_keys: vec![],
forwarder_contract: None,
}
}

async fn start_solver(config_file: TempPath, solver_name: String) -> Url {
let args = vec![
"solvers".to_string(),
Expand Down
Loading
Loading