diff --git a/src/domain/solver/dex/mod.rs b/src/domain/solver/dex/mod.rs index 3e4af6b..d686ffe 100644 --- a/src/domain/solver/dex/mod.rs +++ b/src/domain/solver/dex/mod.rs @@ -43,6 +43,10 @@ pub struct Dex { /// Amount of gas that gets added to each swap to tweak the cost coverage of /// the solver. gas_offset: eth::Gas, + + /// Whether to internalize the solution interactions using the Settlement + /// contract buffer. + internalize_interactions: bool, } /// The amount of time we aim the solver to finish before the final deadline is @@ -67,6 +71,7 @@ impl Dex { fills: Fills::new(config.smallest_partial_fill), rate_limiter, gas_offset: config.gas_offset, + internalize_interactions: config.internalize_interactions, } } @@ -202,6 +207,10 @@ impl Dex { // Maybe some liquidity appeared that enables a bigger fill. self.fills.increase_next_try(order.uid); - Some(solution.with_buffers_internalizations(tokens)) + if self.internalize_interactions { + Some(solution.with_buffers_internalizations(tokens)) + } else { + Some(solution) + } } } diff --git a/src/infra/config/dex/file.rs b/src/infra/config/dex/file.rs index 4ef0c6d..b7d2533 100644 --- a/src/infra/config/dex/file.rs +++ b/src/infra/config/dex/file.rs @@ -71,6 +71,11 @@ struct Config { /// This is useful for caching requests on an egress proxy. #[serde(with = "humantime_serde", default)] current_block_poll_interval: Option, + + /// Whether to internalize the solution interactions using the Settlement + /// contract buffers. + #[serde(default = "default_internalize_interactions")] + internalize_interactions: bool, } fn default_relative_slippage() -> BigDecimal { @@ -103,6 +108,10 @@ fn default_gas_offset() -> eth::U256 { 106_391.into() } +fn default_internalize_interactions() -> bool { + true +} + /// Loads the base solver configuration from a TOML file. /// /// # Panics @@ -167,6 +176,7 @@ pub async fn load(path: &Path) -> (super::Config, T) { .unwrap(), gas_offset: eth::Gas(config.gas_offset), block_stream, + internalize_interactions: config.internalize_interactions, }; (config, dex) } diff --git a/src/infra/config/dex/mod.rs b/src/infra/config/dex/mod.rs index 6056c12..8cc1fe1 100644 --- a/src/infra/config/dex/mod.rs +++ b/src/infra/config/dex/mod.rs @@ -26,4 +26,5 @@ pub struct Config { pub rate_limiting_strategy: rate_limit::Strategy, pub gas_offset: eth::Gas, pub block_stream: Option, + pub internalize_interactions: bool, }