Skip to content
Open
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
13 changes: 4 additions & 9 deletions crates/driver/src/domain/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ impl Order {
solver::Liquidity::Skip => Default::default(),
};

let auction = self
.single_order_auction(eth, tokens, solver.quote_using_limit_orders())
.await?;
let auction = self.single_order_auction(eth, tokens).await?;
let auction = competition
.risk_detector
.filter_unsupported_orders_in_auction(auction)
Expand Down Expand Up @@ -193,7 +191,6 @@ impl Order {
&self,
eth: &Ethereum,
tokens: &infra::tokens::Fetcher,
quote_using_limit_orders: bool,
) -> Result<competition::Auction, Error> {
let tokens = tokens.get(&[self.buy().token, self.sell().token]).await;

Expand All @@ -213,11 +210,9 @@ impl Order {
buy: self.buy(),
sell: self.sell(),
side: self.side,
kind: if quote_using_limit_orders {
competition::order::Kind::Limit
} else {
competition::order::Kind::Market
},
// Quotes always use limit orders so that the engine
// determines the fee (see `Order::solver_determines_fee`).
kind: competition::order::Kind::Limit,
pre_interactions: Default::default(),
post_interactions: Default::default(),
sell_token_balance: competition::order::SellTokenBalance::Erc20,
Expand Down
1 change: 0 additions & 1 deletion crates/driver/src/infra/config/file/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ pub async fn load(chain: Chain, path: &Path) -> infra::Config {
},
request_headers: solver_config.request_headers,
fee_handler: solver_config.fee_handler,
quote_using_limit_orders: solver_config.quote_using_limit_orders,
fast_path_enabled: solver_config.fast_path_enabled,
merge_solutions: match solver_config.merge_solutions {
true => SolutionMerging::Allowed {
Expand Down
4 changes: 0 additions & 4 deletions crates/driver/src/infra/config/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,6 @@ struct SolverConfig {
#[serde(default)]
fee_handler: FeeHandler,

/// Use limit orders for quoting
#[serde(default)]
quote_using_limit_orders: bool,

/// Whether this solver supports fast-path (out-of-competition) execution.
#[serde(default)]
fast_path_enabled: bool,
Expand Down
9 changes: 0 additions & 9 deletions crates/driver/src/infra/solver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ pub struct Config {
pub request_headers: HashMap<String, String>,
/// Determines whether the `solver` or the `driver` handles the fees
pub fee_handler: FeeHandler,
/// Use limit orders for quoting
/// TODO: Remove once all solvers are moved to use limit orders for quoting
pub quote_using_limit_orders: bool,
/// Whether this solver supports fast-path (out-of-competition) execution.
pub fast_path_enabled: bool,
pub merge_solutions: SolutionMerging,
Expand Down Expand Up @@ -320,11 +317,6 @@ impl Solver {
self.config.timeouts
}

/// Use limit orders for quoting instead of market orders
pub fn quote_using_limit_orders(&self) -> bool {
self.config.quote_using_limit_orders
}

/// Whether this solver supports fast-path (out-of-competition) execution.
pub fn fast_path_enabled(&self) -> bool {
self.config.fast_path_enabled
Expand Down Expand Up @@ -601,7 +593,6 @@ mod tests {
},
request_headers: Default::default(),
fee_handler: FeeHandler::Driver,
quote_using_limit_orders: false,
fast_path_enabled: false,
merge_solutions: SolutionMerging::Forbidden,
s3: None,
Expand Down
31 changes: 15 additions & 16 deletions crates/driver/src/tests/cases/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,25 @@ fn extract_buy_amount(response_body: &str, sell_amount: eth::U256) -> eth::U256
sell_amount * price_low / price_high
}

/// Run a matrix of tests for all meaningful combinations of order kind and
/// side, verifying that they get quoted successfully.
/// Run a matrix of tests for all meaningful order sides, verifying that they
/// get quoted successfully. Quotes always use limit orders, so there is no
/// order-kind dimension.
#[tokio::test]
#[ignore]
async fn matrix() {
for side in [order::Side::Buy, order::Side::Sell] {
for kind in [order::Kind::Market, order::Kind::Limit] {
let test = tests::setup()
.name(format!("{side:?} {kind:?}"))
.pool(ab_pool())
.order(ab_order().side(side).kind(kind))
.solution(ab_solution())
.quote()
.done()
.await;

let quote = test.quote().await;

quote.ok().amount().interactions();
}
let test = tests::setup()
.name(format!("{side:?}"))
.pool(ab_pool())
.order(ab_order().side(side))
.solution(ab_solution())
.quote()
.done()
.await;

let quote = test.quote().await;

quote.ok().amount().interactions();
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/driver/src/tests/setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl Default for Order {
partial: Default::default(),
created: u32::MIN,
valid_to: u32::MAX,
kind: order::Kind::Market,
kind: order::Kind::Limit,
solver_fee: Default::default(),
name: Default::default(),
surplus_factor: DEFAULT_SURPLUS_FACTOR.ether().into_wei(),
Expand Down
1 change: 0 additions & 1 deletion crates/driver/src/tests/setup/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ impl Solver {
},
"partiallyFillable": matches!(quote.order.partial, Partial::Yes { .. }),
"class": match quote.order.kind {
_ if config.quote => "market",
order::Kind::Market => "market",
order::Kind::Limit => "limit",
},
Expand Down
11 changes: 1 addition & 10 deletions crates/e2e/src/setup/colocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,14 @@ pub fn start_driver(
contracts: &Contracts,
solvers: Vec<SolverEngine>,
liquidity: LiquidityProvider,
quote_using_limit_orders: bool,
) -> JoinHandle<()> {
start_driver_with_config_override(
contracts,
solvers,
liquidity,
quote_using_limit_orders,
None,
)
start_driver_with_config_override(contracts, solvers, liquidity, None)
}

pub fn start_driver_with_config_override(
contracts: &Contracts,
solvers: Vec<SolverEngine>,
liquidity: LiquidityProvider,
quote_using_limit_orders: bool,
config_override: Option<&str>,
) -> JoinHandle<()> {
let base_tokens: HashSet<_> = solvers
Expand Down Expand Up @@ -181,7 +173,6 @@ endpoint = "{endpoint}"
relative-slippage = "0.1"
account = "{account}"
merge-solutions = {merge_solutions}
quote-using-limit-orders = {quote_using_limit_orders}
enable-simulation-bad-token-detection = true
enable-metrics-bad-order-detection = true
http-time-buffer = "100ms"
Expand Down
2 changes: 0 additions & 2 deletions crates/e2e/src/setup/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ impl<'a> Services<'a> {
.await,
],
colocation::LiquidityProvider::UniswapV2,
false,
);

let test_quoter = ExternalSolver::new("test_quoter", "http://localhost:11088/test_solver");
Expand Down Expand Up @@ -406,7 +405,6 @@ impl<'a> Services<'a> {
self.contracts,
solvers,
colocation::LiquidityProvider::UniswapV2,
false,
);

self.start_autopilot(Some(Duration::from_secs(11)), autopilot_config)
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/autopilot_leader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ async fn dual_autopilot_only_leader_produces_auctions(web3: Web3) {
.await,
],
colocation::LiquidityProvider::UniswapV2,
false,
);

let services = Services::new(&onchain).await;
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ async fn onchain_settlement_without_liquidity(web3: Web3) {
.await,
],
colocation::LiquidityProvider::UniswapV2,
false,
);
let services = Services::new(&onchain).await;
services
Expand Down
5 changes: 3 additions & 2 deletions crates/e2e/tests/e2e/ethflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ async fn eth_flow_indexing_after_refund(web3: Web3) {
let services = Services::new(&onchain).await;
services.start_protocol(solver).await;

// Create an order that only exists to be cancelled.
// Create an order that only exists to be cancelled. It still needs a
// realistic amount: solvers don't quote dust that can't cover the gas fee.
let valid_to = timestamp_of_current_block_in_seconds(&web3.provider)
.await
.unwrap()
Expand All @@ -554,7 +555,7 @@ async fn eth_flow_indexing_after_refund(web3: Web3) {
&test_submit_quote(
&services,
&(EthFlowTradeIntent {
sell_amount: alloy::primitives::U256::from(42),
sell_amount: 1u64.eth(),
buy_token: *dai.address(),
receiver: Address::repeat_byte(42),
})
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/jit_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ async fn single_limit_order_test(web3: Web3) {
},
],
colocation::LiquidityProvider::UniswapV2,
false,
);

// We start the quoter as the baseline solver, and the mock solver as the
Expand Down
3 changes: 0 additions & 3 deletions crates/e2e/tests/e2e/limit_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@ async fn two_limit_orders_multiple_winners_test(web3: Web3) {
.await,
],
colocation::LiquidityProvider::UniswapV2,
false,
);

let services = Services::new(&onchain).await;
Expand Down Expand Up @@ -746,7 +745,6 @@ async fn too_many_limit_orders_test(web3: Web3) {
.await,
],
colocation::LiquidityProvider::UniswapV2,
false,
);

services
Expand Down Expand Up @@ -849,7 +847,6 @@ async fn limit_does_not_apply_to_in_market_orders_test(web3: Web3) {
.await,
],
colocation::LiquidityProvider::UniswapV2,
false,
);

services
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ async fn zero_ex_liquidity(web3: Web3) {
colocation::LiquidityProvider::ZeroEx {
api_port: zeroex_api_port,
},
false,
);

services
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/liquidity_source_notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ async fn liquidity_source_notification(web3: Web3) {
},
],
colocation::LiquidityProvider::UniswapV2,
false,
Some(&format!(
r#"
[liquidity-sources-notifier]
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/order_cancellation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ async fn order_cancellation(web3: Web3) {
.await,
],
colocation::LiquidityProvider::UniswapV2,
false,
);
services
.start_autopilot(
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/parallel_settlement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ async fn test_parallel_settlement_submission(web3: Web3) {
onchain.contracts(),
vec![solver_engine],
colocation::LiquidityProvider::UniswapV2,
false,
);

// Wait for the driver to become available.
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/place_order_with_quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ async fn fallback_native_price_estimator(web3: Web3) {
.await,
],
colocation::LiquidityProvider::UniswapV2,
false,
);

let (manual_shutdown, control) = ShutdownController::new_manual_shutdown();
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/pool_indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ max-pools-to-initialize = 10
onchain.contracts(),
vec![baseline_solver],
colocation::LiquidityProvider::UniswapV2,
false,
Some(&config_override),
);

Expand Down
4 changes: 0 additions & 4 deletions crates/e2e/tests/e2e/quoting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ async fn quote_timeout(web3: Web3) {
},
],
colocation::LiquidityProvider::UniswapV2,
false,
);

/// The default quote timeout used when the user does not override it.
Expand Down Expand Up @@ -530,7 +529,6 @@ async fn quote_custom_solver_errors(web3: Web3) {
},
],
colocation::LiquidityProvider::UniswapV2,
false,
);

services
Expand Down Expand Up @@ -656,7 +654,6 @@ async fn native_price_custom_solver_errors(web3: Web3) {
},
],
colocation::LiquidityProvider::UniswapV2,
false,
);

services
Expand Down Expand Up @@ -770,7 +767,6 @@ async fn quote_custom_solver_errors_prioritized(web3: Web3) {
},
],
colocation::LiquidityProvider::UniswapV2,
false,
);

services
Expand Down
4 changes: 0 additions & 4 deletions crates/e2e/tests/e2e/solver_competition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ async fn solver_competition(web3: Web3) {
.await,
],
colocation::LiquidityProvider::UniswapV2,
false,
);

let services = Services::new(&onchain).await;
Expand Down Expand Up @@ -279,7 +278,6 @@ async fn wrong_solution_submission_address(web3: Web3) {
.await,
],
colocation::LiquidityProvider::UniswapV2,
false,
);

let services = Services::new(&onchain).await;
Expand Down Expand Up @@ -446,7 +444,6 @@ async fn store_filtered_solutions(web3: Web3) {
},
],
colocation::LiquidityProvider::UniswapV2,
false,
);

// We start the quoter as the baseline solver, and the mock solver as the
Expand Down Expand Up @@ -734,7 +731,6 @@ async fn cannot_replace_order_bid_on_by_non_winning_solution(web3: Web3) {
},
],
colocation::LiquidityProvider::UniswapV2,
false,
);

let config = Configuration::test_no_drivers();
Expand Down
8 changes: 5 additions & 3 deletions crates/solvers/src/domain/dex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ impl Swap {
simulator: &infra::dex::Simulator,
gas_offset: eth::Gas,
) -> Option<solution::Solution> {
let gas = if order.class == order::Class::Limit {
// Only simulate gas for limit orders (whose fee depends on it) in
// proper auctions, i.e. when the auction has a sell token price. For
// quotes and market orders we use the gas indicated by the DEX to save
// time.
let gas = if order.class == order::Class::Limit && sell_token.is_some() {
match simulator.gas(order.owner(), &self).await {
Ok(value) => value,
Err(infra::dex::simulator::Error::SettlementContractIsOwner) => self.gas,
Expand All @@ -126,8 +130,6 @@ impl Swap {
}
}
} else {
// We are fine with just using heuristic gas for market orders,
// since it doesn't really play a role in the final solution.
self.gas
};

Expand Down
Loading
Loading