Skip to content

Commit

Permalink
Adjusted values
Browse files Browse the repository at this point in the history
  • Loading branch information
squadgazzz committed Mar 5, 2024
1 parent 9b3a0ee commit dd233e2
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions crates/driver/src/tests/cases/protocol_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ async fn volume_protocol_fee_sell_order() {
#[tokio::test]
#[ignore]
async fn price_improvement_fee_buy_out_market_order() {
let quote_sell_amount = 21000000000000000000u128;
let quote_buy_amount = 18000000000000000000u128;
let quote_sell_amount = 50000000000000000000u128;
let quote_buy_amount = 45000000000000000000u128;
let fee_policy = FeePolicy::PriceImprovement {
factor: 0.5,
// high enough so we don't get capped by volume fee
Expand All @@ -204,18 +204,18 @@ async fn price_improvement_fee_buy_out_market_order() {
fee: 1000000000000000000u128.into(),
},
};
let executed_buy = 17143028023069342830u128;
let test_case = TestCase {
order_side: order::Side::Buy,
fee_policy,
order_sell_amount: 20000000000000000000u128.into(),
order_sell_amount: 50000000000000000000u128.into(),
solver_fee: Some(10000000000000000000u128.into()),
quote_sell_amount: quote_sell_amount.into(),
quote_buy_amount: quote_buy_amount.into(),
executed: executed_buy.into(),
executed_sell_amount: 20476294902986820618u128.into(),
// executed buy amount should match order buy amount
executed_buy_amount: executed_buy.into(),
executed: quote_buy_amount.into(),
// sell amount + quote fee * factor
executed_sell_amount: 50500000000000000000u128.into(),
// executed buy amount should match quote buy amount
executed_buy_amount: quote_buy_amount.into(),
};

protocol_fee_test_case(test_case).await;
Expand All @@ -224,8 +224,8 @@ async fn price_improvement_fee_buy_out_market_order() {
#[tokio::test]
#[ignore]
async fn price_improvement_fee_sell_out_market_order() {
let quote_sell_amount = 21000000000000000000u128;
let quote_buy_amount = 18000000000000000000u128;
let quote_sell_amount = 50000000000000000000u128;
let quote_buy_amount = 45000000000000000000u128;
let fee_policy = FeePolicy::PriceImprovement {
factor: 0.5,
// high enough so we don't get capped by volume fee
Expand All @@ -236,18 +236,18 @@ async fn price_improvement_fee_sell_out_market_order() {
fee: 1000000000000000000u128.into(),
},
};
let order_sell_amount = 20000000000000000000u128;
let order_sell_amount = 50000000000000000000u128;
let test_case = TestCase {
order_side: order::Side::Sell,
fee_policy,
order_sell_amount: order_sell_amount.into(),
solver_fee: Some(10000000000000000000u128.into()),
quote_sell_amount: quote_sell_amount.into(),
quote_buy_amount: quote_buy_amount.into(),
executed: 10000000000000000000u128.into(),
executed: 40000000000000000000u128.into(),
// executed sell amount should match order sell amount
executed_sell_amount: order_sell_amount.into(),
executed_buy_amount: 16753332193352853234u128.into(),
executed_buy_amount: 44558823529411764706u128.into(),
};

protocol_fee_test_case(test_case).await;
Expand All @@ -256,30 +256,29 @@ async fn price_improvement_fee_sell_out_market_order() {
#[tokio::test]
#[ignore]
async fn price_improvement_fee_buy_in_market_order() {
let quote_sell_amount = 17000000000000000000u128;
let quote_buy_amount = 10000000000000000000u128;
let quote_sell_amount = 50000000000000000000u128;
let quote_buy_amount = 45000000000000000000u128;
let fee_policy = FeePolicy::PriceImprovement {
factor: 0.5,
// high enough so we don't get capped by volume fee
max_volume_factor: 1.0,
quote: PriceImprovementQuote {
sell_amount: quote_sell_amount.into(),
buy_amount: quote_buy_amount.into(),
fee: 1000000000000000000u128.into(),
fee: 20000000000000000000u128.into(),
},
};
let executed_buy_amount = 11764354070151352996u128;
let test_case = TestCase {
order_side: order::Side::Buy,
fee_policy,
order_sell_amount: 20000000000000000000u128.into(),
order_sell_amount: 50000000000000000000u128.into(),
solver_fee: Some(10000000000000000000u128.into()),
quote_sell_amount: quote_sell_amount.into(),
quote_buy_amount: quote_buy_amount.into(),
executed: executed_buy_amount.into(),
executed_sell_amount: 20587918663136217696u128.into(),
executed: quote_buy_amount.into(),
executed_sell_amount: 60000000000000000000u128.into(),
// executed buy amount should match order buy amount
executed_buy_amount: executed_buy_amount.into(),
executed_buy_amount: quote_buy_amount.into(),
};

protocol_fee_test_case(test_case).await;
Expand All @@ -288,30 +287,30 @@ async fn price_improvement_fee_buy_in_market_order() {
#[tokio::test]
#[ignore]
async fn price_improvement_fee_sell_in_market_order() {
let quote_sell_amount = 9000000000000000000u128;
let quote_buy_amount = 25000000000000000000u128;
let quote_sell_amount = 50000000000000000000u128;
let quote_buy_amount = 45000000000000000000u128;
let fee_policy = FeePolicy::PriceImprovement {
factor: 0.5,
// high enough so we don't get capped by volume fee
max_volume_factor: 1.0,
quote: PriceImprovementQuote {
sell_amount: quote_sell_amount.into(),
buy_amount: quote_buy_amount.into(),
fee: 1000000000000000000u128.into(),
fee: 20000000000000000000u128.into(),
},
};
let order_sell_amount = 10000000000000000000u128;
let order_sell_amount = 50000000000000000000u128;
let test_case = TestCase {
order_side: order::Side::Sell,
fee_policy,
order_sell_amount: order_sell_amount.into(),
solver_fee: Some(5000000000000000000u128.into()),
solver_fee: Some(10000000000000000000u128.into()),
quote_sell_amount: quote_sell_amount.into(),
quote_buy_amount: quote_buy_amount.into(),
executed: 5000000000000000000u128.into(),
executed: 40000000000000000000u128.into(),
// executed sell amount should match order sell amount
executed_sell_amount: order_sell_amount.into(),
executed_buy_amount: 26388750430470970935u128.into(),
executed_buy_amount: 38571428571428571429u128.into(),
};

protocol_fee_test_case(test_case).await;
Expand Down

0 comments on commit dd233e2

Please sign in to comment.