Skip to content

Commit

Permalink
Better tests values
Browse files Browse the repository at this point in the history
  • Loading branch information
squadgazzz committed Mar 14, 2024
1 parent d685908 commit 38469a3
Showing 1 changed file with 70 additions and 70 deletions.
140 changes: 70 additions & 70 deletions crates/driver/src/tests/cases/protocol_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,19 @@ async fn surplus_protocol_fee_partial_buy_order_not_capped() {
fee_policy,
order: Order {
sell_amount: 50.ether().into_wei(),
buy_amount: 40.ether().into_wei(),
buy_amount: 50.ether().into_wei(),
side: order::Side::Buy,
},
execution: Execution {
// 6 ETH surplus in sell token (after network fee), half of which is kept by the
// 10 ETH surplus in sell token (after network fee), half of which is kept by the
// protocol
solver: Amounts {
sell: 29.ether().into_wei(),
buy: 28.ether().into_wei(),
sell: 10.ether().into_wei(),
buy: 20.ether().into_wei(),
},
driver: Amounts {
sell: 32.ether().into_wei(),
buy: 28.ether().into_wei(),
sell: 15.ether().into_wei(),
buy: 20.ether().into_wei(),
},
},
};
Expand All @@ -205,18 +205,18 @@ async fn surplus_protocol_fee_partial_sell_order_not_capped() {
fee_policy,
order: Order {
sell_amount: 50.ether().into_wei(),
buy_amount: 40.ether().into_wei(),
buy_amount: 50.ether().into_wei(),
side: order::Side::Sell,
},
execution: Execution {
// 6 ETH surplus, half of which gets captured by the protocol
// 10 ETH surplus, half of which gets captured by the protocol
solver: Amounts {
sell: 25.ether().into_wei(),
buy: 26.ether().into_wei(),
sell: 20.ether().into_wei(),
buy: 30.ether().into_wei(),
},
driver: Amounts {
sell: 25.ether().into_wei(),
buy: 23.ether().into_wei(),
sell: 20.ether().into_wei(),
buy: 25.ether().into_wei(),
},
},
};
Expand Down Expand Up @@ -295,18 +295,18 @@ async fn surplus_protocol_fee_partial_buy_order_capped() {
fee_policy,
order: Order {
sell_amount: 50.ether().into_wei(),
buy_amount: 40.ether().into_wei(),
buy_amount: 50.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(),
sell: 10.ether().into_wei(),
buy: 20.ether().into_wei(),
},
driver: Amounts {
sell: 30.ether().into_wei(),
buy: 28.ether().into_wei(),
sell: 12.ether().into_wei(),
buy: 20.ether().into_wei(),
},
},
};
Expand All @@ -325,18 +325,18 @@ async fn surplus_protocol_fee_partial_sell_order_capped() {
fee_policy,
order: Order {
sell_amount: 50.ether().into_wei(),
buy_amount: 40.ether().into_wei(),
buy_amount: 50.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(),
sell: 20.ether().into_wei(),
buy: 30.ether().into_wei(),
},
driver: Amounts {
sell: 25.ether().into_wei(),
buy: "23.4".ether().into_wei(),
sell: 20.ether().into_wei(),
buy: 27.ether().into_wei(),
},
},
};
Expand Down Expand Up @@ -403,18 +403,18 @@ async fn volume_protocol_fee_partial_buy_order() {
fee_policy,
order: Order {
sell_amount: 50.ether().into_wei(),
buy_amount: 40.ether().into_wei(),
buy_amount: 50.ether().into_wei(),
side: order::Side::Buy,
},
execution: Execution {
// Half of the solver proposed sell volume is kept by the protocol
solver: Amounts {
sell: 20.ether().into_wei(),
buy: 28.ether().into_wei(),
sell: 10.ether().into_wei(),
buy: 20.ether().into_wei(),
},
driver: Amounts {
sell: 30.ether().into_wei(),
buy: 28.ether().into_wei(),
sell: 15.ether().into_wei(),
buy: 20.ether().into_wei(),
},
},
};
Expand All @@ -429,17 +429,17 @@ async fn volume_protocol_fee_partial_sell_order() {
fee_policy,
order: Order {
sell_amount: 50.ether().into_wei(),
buy_amount: 40.ether().into_wei(),
buy_amount: 50.ether().into_wei(),
side: order::Side::Sell,
},
execution: Execution {
// 10% of the solver proposed buy value is kept by the protocol
solver: Amounts {
sell: 25.ether().into_wei(),
sell: 20.ether().into_wei(),
buy: 30.ether().into_wei(),
},
driver: Amounts {
sell: 25.ether().into_wei(),
sell: 20.ether().into_wei(),
buy: 27.ether().into_wei(),
},
},
Expand Down Expand Up @@ -743,7 +743,7 @@ async fn price_improvement_fee_partial_buy_in_market_order_not_capped() {
// high enough so we don't get capped by volume fee
max_volume_factor: 1.0,
quote: Quote {
sell: 49.ether().into_wei(),
sell: 39.ether().into_wei(),
buy: 40.ether().into_wei(),
network_fee: 1.ether().into_wei(),
},
Expand All @@ -752,18 +752,18 @@ async fn price_improvement_fee_partial_buy_in_market_order_not_capped() {
fee_policy,
order: Order {
// Demanding to sell more than quoted (in-market)
sell_amount: 60.ether().into_wei(),
sell_amount: 50.ether().into_wei(),
buy_amount: 40.ether().into_wei(),
side: order::Side::Buy,
},
execution: Execution {
// Sell 5 ETH less than quoted, half of which is kept by the protocol
// Sell 10 ETH less than quoted, half of which is kept by the protocol
solver: Amounts {
sell: 20.ether().into_wei(),
sell: 10.ether().into_wei(),
buy: 20.ether().into_wei(),
},
driver: Amounts {
sell: "22.5".ether().into_wei(),
sell: 15.ether().into_wei(),
buy: 20.ether().into_wei(),
},
},
Expand Down Expand Up @@ -793,14 +793,14 @@ async fn price_improvement_fee_partial_sell_in_market_order_not_capped() {
side: order::Side::Sell,
},
execution: Execution {
// Receive 5 ETH more than quoted, half of which gets captured by the protocol
// Receive 10 ETH more than quoted, half of which gets captured by the protocol
solver: Amounts {
sell: 25.ether().into_wei(),
sell: 20.ether().into_wei(),
buy: 30.ether().into_wei(),
},
driver: Amounts {
sell: 25.ether().into_wei(),
buy: "27.5".ether().into_wei(),
sell: 20.ether().into_wei(),
buy: 25.ether().into_wei(),
},
},
};
Expand All @@ -816,7 +816,7 @@ async fn price_improvement_fee_partial_buy_out_of_market_order_not_capped() {
max_volume_factor: 1.0,
quote: Quote {
sell: 59.ether().into_wei(),
buy: 40.ether().into_wei(),
buy: 50.ether().into_wei(),
network_fee: 1.ether().into_wei(),
},
};
Expand All @@ -825,17 +825,17 @@ async fn price_improvement_fee_partial_buy_out_of_market_order_not_capped() {
order: Order {
// Demanding to sell less than quoted (out-market)
sell_amount: 50.ether().into_wei(),
buy_amount: 40.ether().into_wei(),
buy_amount: 50.ether().into_wei(),
side: order::Side::Buy,
},
execution: Execution {
// Sell 5 ETH less than requested, half of which is kept by the protocol
// Sell 10 ETH less than requested, half of which is kept by the protocol
solver: Amounts {
sell: 20.ether().into_wei(),
sell: 10.ether().into_wei(),
buy: 20.ether().into_wei(),
},
driver: Amounts {
sell: "22.5".ether().into_wei(),
sell: 15.ether().into_wei(),
buy: 20.ether().into_wei(),
},
},
Expand Down Expand Up @@ -865,14 +865,14 @@ async fn price_improvement_fee_partial_sell_out_of_market_order_not_capped() {
side: order::Side::Sell,
},
execution: Execution {
// Receive 5 ETH more than quoted, half of which gets captured by the protocol
// Receive 10 ETH more than quoted, half of which gets captured by the protocol
solver: Amounts {
sell: 25.ether().into_wei(),
sell: 20.ether().into_wei(),
buy: 30.ether().into_wei(),
},
driver: Amounts {
sell: 25.ether().into_wei(),
buy: "27.5".ether().into_wei(),
sell: 20.ether().into_wei(),
buy: 25.ether().into_wei(),
},
},
};
Expand All @@ -885,10 +885,10 @@ async fn price_improvement_fee_partial_buy_in_market_order_capped() {
let fee_policy = Policy::PriceImprovement {
factor: 0.5,
// low enough so we get capped by volume fee
max_volume_factor: 0.05,
max_volume_factor: 0.1,
quote: Quote {
sell: 49.ether().into_wei(),
buy: 40.ether().into_wei(),
buy: 50.ether().into_wei(),
network_fee: 1.ether().into_wei(),
},
};
Expand All @@ -897,17 +897,17 @@ async fn price_improvement_fee_partial_buy_in_market_order_capped() {
order: Order {
// Demanding to sell more than quoted (in-market)
sell_amount: 60.ether().into_wei(),
buy_amount: 40.ether().into_wei(),
buy_amount: 50.ether().into_wei(),
side: order::Side::Buy,
},
execution: Execution {
// Fee is capped at 5% of solver proposed sell volume
// Fee is capped at 10% of solver proposed sell volume
solver: Amounts {
sell: 20.ether().into_wei(),
sell: 10.ether().into_wei(),
buy: 20.ether().into_wei(),
},
driver: Amounts {
sell: 21.ether().into_wei(),
sell: 11.ether().into_wei(),
buy: 20.ether().into_wei(),
},
},
Expand All @@ -921,7 +921,7 @@ async fn price_improvement_fee_partial_sell_in_market_order_capped() {
let fee_policy = Policy::PriceImprovement {
factor: 0.5,
// low enough so we get capped by volume fee
max_volume_factor: 0.05,
max_volume_factor: 0.1,
quote: Quote {
sell: 49.ether().into_wei(),
buy: 50.ether().into_wei(),
Expand All @@ -937,14 +937,14 @@ async fn price_improvement_fee_partial_sell_in_market_order_capped() {
side: order::Side::Sell,
},
execution: Execution {
// Fee is capped at 5% of solver proposed buy volume
// Fee is capped at 10% of solver proposed buy volume
solver: Amounts {
sell: 25.ether().into_wei(),
sell: 20.ether().into_wei(),
buy: 30.ether().into_wei(),
},
driver: Amounts {
sell: 25.ether().into_wei(),
buy: "28.5".ether().into_wei(),
sell: 20.ether().into_wei(),
buy: 27.ether().into_wei(),
},
},
};
Expand All @@ -957,10 +957,10 @@ async fn price_improvement_fee_partial_buy_out_of_market_order_capped() {
let fee_policy = Policy::PriceImprovement {
factor: 0.5,
// low enough so we get capped by volume fee
max_volume_factor: 0.05,
max_volume_factor: 0.1,
quote: Quote {
sell: 59.ether().into_wei(),
buy: 40.ether().into_wei(),
buy: 50.ether().into_wei(),
network_fee: 1.ether().into_wei(),
},
};
Expand All @@ -969,17 +969,17 @@ async fn price_improvement_fee_partial_buy_out_of_market_order_capped() {
order: Order {
// Demanding to sell less than quoted (out-market)
sell_amount: 50.ether().into_wei(),
buy_amount: 40.ether().into_wei(),
buy_amount: 50.ether().into_wei(),
side: order::Side::Buy,
},
execution: Execution {
// Fee is capped at 5% of solver proposed sell volume
// Fee is capped at 10% of solver proposed sell volume
solver: Amounts {
sell: 20.ether().into_wei(),
sell: 10.ether().into_wei(),
buy: 20.ether().into_wei(),
},
driver: Amounts {
sell: 21.ether().into_wei(),
sell: 11.ether().into_wei(),
buy: 20.ether().into_wei(),
},
},
Expand All @@ -993,7 +993,7 @@ async fn price_improvement_fee_partial_sell_out_of_market_order_capped() {
let fee_policy = Policy::PriceImprovement {
factor: 0.5,
// low enough so we get capped by volume fee
max_volume_factor: 0.05,
max_volume_factor: 0.1,
quote: Quote {
sell: 49.ether().into_wei(),
buy: 40.ether().into_wei(),
Expand All @@ -1009,14 +1009,14 @@ async fn price_improvement_fee_partial_sell_out_of_market_order_capped() {
side: order::Side::Sell,
},
execution: Execution {
// Fee is capped at 5% of solver proposed buy volume
// Fee is capped at 10% of solver proposed buy volume
solver: Amounts {
sell: 25.ether().into_wei(),
sell: 20.ether().into_wei(),
buy: 30.ether().into_wei(),
},
driver: Amounts {
sell: 25.ether().into_wei(),
buy: "28.5".ether().into_wei(),
sell: 20.ether().into_wei(),
buy: 27.ether().into_wei(),
},
},
};
Expand Down

0 comments on commit 38469a3

Please sign in to comment.