From 88ee77b3cdc246b0ee623d98bd7c9dae3b217e41 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 7 Nov 2024 09:30:41 +0000 Subject: [PATCH] Tmp --- .../src/price_estimation/trade_verifier.rs | 31 +++---------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/crates/shared/src/price_estimation/trade_verifier.rs b/crates/shared/src/price_estimation/trade_verifier.rs index 849c3f1bb1..83d45b62ea 100644 --- a/crates/shared/src/price_estimation/trade_verifier.rs +++ b/crates/shared/src/price_estimation/trade_verifier.rs @@ -696,40 +696,19 @@ fn ensure_quote_accuracy( u256_to_big_rational(&sell_amount), u256_to_big_rational(&buy_amount), ); - - // Calculate the expected token losses that should be covered by JIT orders. - let (expected_sell_token_lost, expected_buy_token_lost) = match trade { - TradeKind::Regular(trade) if !trade.jit_orders.is_empty() => { - let jit_orders_net_token_changes = trade.jit_orders_net_token_changes()?; - let jit_orders_sell_token_changes = jit_orders_net_token_changes - .get(&query.sell_token) - .context("missing jit orders sell token executed amount")?; - let jit_orders_buy_token_changes = - jit_orders_net_token_changes - .get(&query.buy_token) - .context("missing jit orders buy token executed amount")?; - - let expected_sell_token_lost = -&sell_amount - jit_orders_sell_token_changes; - let expected_buy_token_lost = &buy_amount - jit_orders_buy_token_changes; - (expected_sell_token_lost, expected_buy_token_lost) - } - _ => (BigRational::zero(), BigRational::zero()), - }; + let sell_token_lost_limit = inaccuracy_limit * &sell_amount; + let buy_token_lost_limit = inaccuracy_limit * &buy_amount; let sell_token_lost = summary .tokens_lost .get(&query.sell_token) - .context("summary sell token is missing")? - - expected_sell_token_lost; - let sell_token_lost_limit = inaccuracy_limit * &sell_amount; + .context("summary sell token is missing")?; let buy_token_lost = summary .tokens_lost .get(&query.buy_token) - .context("summary buy token is missing")? - - expected_buy_token_lost; - let buy_token_lost_limit = inaccuracy_limit * &buy_amount; + .context("summary buy token is missing")?; - if sell_token_lost >= sell_token_lost_limit || buy_token_lost >= buy_token_lost_limit { + if *sell_token_lost >= sell_token_lost_limit || *buy_token_lost >= buy_token_lost_limit { return Err(Error::TooInaccurate); }