From 92a276d7746bcce2879ccd8d0704ed2e791d9b95 Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Sat, 20 Apr 2024 02:26:14 +0100 Subject: [PATCH] wow --- mantis/node/src/mantis/solve.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mantis/node/src/mantis/solve.rs b/mantis/node/src/mantis/solve.rs index bd87f1b..2eb830c 100644 --- a/mantis/node/src/mantis/solve.rs +++ b/mantis/node/src/mantis/solve.rs @@ -129,7 +129,15 @@ pub struct PairSolution { /// 2. iterate over router and amounts to find good routing `cow`s /// 3. return cow optimal price with cross chain (virtual) order. pub fn find_cows(all_orders: &[OrderItem]) -> Vec { - let all_orders = all_orders.into_iter().group_by(|x| x.pair()); + // need to tune price of posing order vs solving it (sure need to peek only big orders higher than gas, but not more than max gas) + // so basically need to enumerate taking part of order + use rand::prelude::SliceRandom; + let mut all_orders = all_orders.to_vec(); + all_orders.shuffle(&mut rand::thread_rng()); + let all_orders: Vec = all_orders.into_iter().take(20).collect(); + + let mut all_orders = all_orders.into_iter().group_by(|x| x.pair()); + let mut cows_per_pair = vec![]; for (ab, orders) in all_orders.into_iter() { let orders = orders.collect::>(); @@ -174,7 +182,6 @@ pub fn find_cows(all_orders: &[OrderItem]) -> Vec { cows_per_pair.push(pair_solution); } } - use rand::prelude::SliceRandom; cows_per_pair.shuffle(&mut rand::thread_rng()); cows_per_pair