From 2f844ef7132e069dc251170f9c0ed49d420723a1 Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 13 Mar 2024 17:23:37 +0000 Subject: [PATCH] Capped surplus partially fillable tests --- .../driver/src/tests/cases/protocol_fees.rs | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/crates/driver/src/tests/cases/protocol_fees.rs b/crates/driver/src/tests/cases/protocol_fees.rs index 5322508f50..b46daa1f9d 100644 --- a/crates/driver/src/tests/cases/protocol_fees.rs +++ b/crates/driver/src/tests/cases/protocol_fees.rs @@ -265,7 +265,6 @@ async fn surplus_protocol_fee_buy_order_capped() { }, }, }; - protocol_fee_test_case(test_case).await; } @@ -299,6 +298,66 @@ async fn surplus_protocol_fee_sell_order_capped() { protocol_fee_test_case(test_case).await; } +#[tokio::test] +#[ignore] +async fn surplus_protocol_fee_partial_buy_order_capped() { + let fee_policy = Policy::Surplus { + factor: 0.5, + // low enough so we get capped by volume fee + max_volume_factor: 0.2, + }; + let test_case = TestCase { + fee_policy, + order: Order { + sell_amount: 50.ether().into_wei(), + buy_amount: 40.ether().into_wei(), + side: order::Side::Buy, + }, + execution: Execution { + // Fee is capped at 20% of solver proposed sell volume + solver: Amounts { + sell: 25.ether().into_wei(), + buy: 28.ether().into_wei(), + }, + driver: Amounts { + sell: 30.ether().into_wei(), + buy: 28.ether().into_wei(), + }, + }, + }; + protocol_fee_test_case(test_case).await; +} + +#[tokio::test] +#[ignore] +async fn surplus_protocol_fee_partial_sell_order_capped() { + let fee_policy = Policy::Surplus { + factor: 0.5, + // log enough so we get capped by volume fee + max_volume_factor: 0.1, + }; + let test_case = TestCase { + fee_policy, + order: Order { + sell_amount: 50.ether().into_wei(), + buy_amount: 40.ether().into_wei(), + side: order::Side::Sell, + }, + execution: Execution { + // Fee is capped at 10% of solver proposed buy volume + solver: Amounts { + sell: 25.ether().into_wei(), + buy: 26.ether().into_wei(), + }, + driver: Amounts { + sell: 25.ether().into_wei(), + buy: "23.4".ether().into_wei(), + }, + }, + }; + protocol_fee_test_case(test_case).await; +} + #[tokio::test] #[ignore] async fn volume_protocol_fee_buy_order() {