Skip to content
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
10 changes: 7 additions & 3 deletions crates/driver/src/domain/competition/pre_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct Utilities {
liquidity_fetcher: infra::liquidity::Fetcher,
tokens: tokens::Fetcher,
balance_fetcher: Arc<dyn BalanceFetching>,
cow_amm_cache: cow_amm::Cache,
cow_amm_cache: Option<cow_amm::Cache>,
}

impl std::fmt::Debug for Utilities {
Expand Down Expand Up @@ -390,12 +390,16 @@ impl Utilities {
}

async fn cow_amm_orders(self: Arc<Self>, auction: Arc<Auction>) -> Arc<Vec<Order>> {
let Some(ref cow_amm_cache) = self.cow_amm_cache else {
// CoW AMMs are not configured, return empty vec
return Default::default();
};

let _timer = metrics::get().processing_stage_timer("cow_amm_orders");
let _timer2 =
observe::metrics::metrics().on_auction_overhead_start("driver", "cow_amm_orders");

let cow_amms = self
.cow_amm_cache
let cow_amms = cow_amm_cache
.get_or_create_amms(&auction.surplus_capturing_jit_order_owners)
.await;

Expand Down
10 changes: 7 additions & 3 deletions crates/driver/src/domain/cow_amm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ pub struct Cache {
}

impl Cache {
pub fn new(web3: DynProvider, factory_mapping: HashMap<Address, Address>) -> Self {
pub fn new(web3: DynProvider, factory_mapping: HashMap<Address, Address>) -> Option<Self> {
if factory_mapping.is_empty() {
return None;
}

let helper_by_factory = factory_mapping
.into_iter()
.map(|(factory, helper)| {
Expand All @@ -34,11 +38,11 @@ impl Cache {
)
})
.collect();
Self {
Some(Self {
inner: RwLock::new(HashMap::new()),
web3: web3.clone(),
helper_by_factory,
}
})
}

/// Gets or creates AMM instances for the given surplus capturing JIT order
Expand Down
Loading