Skip to content

Commit

Permalink
Prioritize newer orders in auction (#2397)
Browse files Browse the repository at this point in the history
# Description
When we build the auction in the autopilot we filter out orders that are
unlikely to be filled to shrink the auction to a more manageable size.
One step is to filter out fill-or-kill orders where the owner doesn't
have enough sell_token for all of the open orders. The new logic sorts
orders by `creation_timestamp` (desc) to first use the user's existing
balance on recent orders rather than old ones.

Fixes: #1997
  • Loading branch information
MartinquaXD authored Feb 12, 2024
1 parent c0fb701 commit 11ec759
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/autopilot/src/solvable_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Order>, balances: &Balances) -> Vec<Order> {
// 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,
Expand Down

0 comments on commit 11ec759

Please sign in to comment.