From f87cb0c1530ddf34f3ac2f688cf762068614ed8d Mon Sep 17 00:00:00 2001 From: MartinquaXD Date: Sat, 10 Feb 2024 23:33:35 +0100 Subject: [PATCH] Prioritize newer orders in auction --- crates/autopilot/src/solvable_orders.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/autopilot/src/solvable_orders.rs b/crates/autopilot/src/solvable_orders.rs index aaa86b6dfb..9fea4942b6 100644 --- a/crates/autopilot/src/solvable_orders.rs +++ b/crates/autopilot/src/solvable_orders.rs @@ -329,6 +329,8 @@ async fn filter_invalid_signature_orders( /// Removes orders that can't possibly be settled because there isn't enough /// balance. fn orders_with_balance(mut orders: Vec, balances: &Balances) -> Vec { + // Prefer newer orders over older ones. + orders.sort_by_key(|order| std::cmp::Reverse(order.metadata.creation_date)); orders.retain(|order| { let balance = match balances.get(&Query::from_order(order)) { None => return false,