diff --git a/crates/autopilot/src/domain/fee/mod.rs b/crates/autopilot/src/domain/fee/mod.rs index aaf5361008..84b5766aca 100644 --- a/crates/autopilot/src/domain/fee/mod.rs +++ b/crates/autopilot/src/domain/fee/mod.rs @@ -50,6 +50,7 @@ impl ProtocolFee { if boundary::is_order_outside_market_price( &order.data.sell_amount, &order.data.buy_amount, + &order.data.fee_amount, "e.buy_amount, "e.sell_amount, "e.fee, diff --git a/crates/shared/src/order_validation.rs b/crates/shared/src/order_validation.rs index dc3bd71196..2313996646 100644 --- a/crates/shared/src/order_validation.rs +++ b/crates/shared/src/order_validation.rs @@ -743,6 +743,7 @@ impl OrderValidating for OrderValidator { if is_order_outside_market_price( "e_parameters.sell_amount, "e_parameters.buy_amount, + "e_parameters.fee_amount, "e.sell_amount, "e.buy_amount, "e.fee_amount, @@ -980,11 +981,12 @@ async fn get_or_create_quote( pub fn is_order_outside_market_price( sell_amount: &U256, buy_amount: &U256, + fee_amount: &U256, quote_sell_amount: &U256, quote_buy_amount: &U256, quote_fee_amount: &U256, ) -> bool { - sell_amount.full_mul(*quote_buy_amount) + (sell_amount + fee_amount).full_mul(*quote_buy_amount) < (quote_sell_amount + quote_fee_amount).full_mul(*buy_amount) } @@ -2427,6 +2429,7 @@ mod tests { assert!(!is_order_outside_market_price( &"100".into(), &"100".into(), + &"0".into(), "e.sell_amount, "e.buy_amount, "e.fee_amount, @@ -2435,6 +2438,7 @@ mod tests { assert!(!is_order_outside_market_price( &"100".into(), &"90".into(), + &"0".into(), "e.sell_amount, "e.buy_amount, "e.fee_amount, @@ -2443,6 +2447,7 @@ mod tests { assert!(is_order_outside_market_price( &"100".into(), &"1000".into(), + &"0".into(), "e.sell_amount, "e.buy_amount, "e.fee_amount,