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 4b70eb7 commit 4c68e5c
Showing 1 changed file with 42 additions and 39 deletions.
81 changes: 42 additions & 39 deletions crates/driver/src/tests/cases/protocol_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,29 +193,29 @@ async fn volume_protocol_fee_sell_order() {
#[ignore]
async fn price_improvement_fee_buy_out_of_market_order() {
let quote_sell_amount = 50000000000000000000u128;
let quote_buy_amount = 45000000000000000000u128;
let quote_buy_amount = 35000000000000000000u128;
let fee: eth::U256 = 10000000000000000000u128.into();
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,
},
};
let order_sell_amount = 50000000000000000000u128.into();
let order_buy_amount = 40000000000000000000u128.into();
let test_case = TestCase {
order_side: order::Side::Buy,
fee_policy,
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: 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(),
order_sell_amount,
solver_fee: Some(fee),
quote_sell_amount: order_sell_amount,
quote_buy_amount: order_buy_amount,
executed: order_buy_amount,
executed_sell_amount: 59285714285714285714u128.into(),
executed_buy_amount: order_buy_amount,
};

protocol_fee_test_case(test_case).await;
Expand All @@ -225,29 +225,29 @@ async fn price_improvement_fee_buy_out_of_market_order() {
#[ignore]
async fn price_improvement_fee_sell_out_of_market_order() {
let quote_sell_amount = 50000000000000000000u128;
let quote_buy_amount = 45000000000000000000u128;
let quote_buy_amount = 35000000000000000000u128;
let fee: eth::U256 = 10000000000000000000u128.into();
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,
},
};
let order_sell_amount = 50000000000000000000u128;
let order_buy_amount = 40000000000000000000u128;
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: 40000000000000000000u128.into(),
// executed sell amount should match order sell amount
solver_fee: Some(fee),
quote_sell_amount: 50000000000000000000u128.into(),
quote_buy_amount: order_buy_amount.into(),
executed: order_buy_amount.into(),
executed_sell_amount: order_sell_amount.into(),
executed_buy_amount: 44558823529411764706u128.into(),
executed_buy_amount: 34583333333333333333u128.into(),
};

protocol_fee_test_case(test_case).await;
Expand All @@ -257,28 +257,29 @@ async fn price_improvement_fee_sell_out_of_market_order() {
#[ignore]
async fn price_improvement_fee_buy_in_market_order() {
let quote_sell_amount = 50000000000000000000u128;
let quote_buy_amount = 45000000000000000000u128;
let quote_buy_amount = 40000000000000000000u128;
let fee = 10000000000000000000u128.into();
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: 20000000000000000000u128.into(),
fee,
},
};
let order_sell_amount = 50000000000000000000u128.into();
let order_buy_amount = 35000000000000000000u128.into();
let test_case = TestCase {
order_side: order::Side::Buy,
fee_policy,
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: quote_buy_amount.into(),
executed_sell_amount: 60000000000000000000u128.into(),
// executed buy amount should match order buy amount
executed_buy_amount: quote_buy_amount.into(),
order_sell_amount,
solver_fee: Some(fee),
quote_sell_amount: order_sell_amount,
quote_buy_amount: order_buy_amount,
executed: order_buy_amount,
executed_sell_amount: 51250000000000000000u128.into(),
executed_buy_amount: order_buy_amount,
};

protocol_fee_test_case(test_case).await;
Expand All @@ -288,29 +289,31 @@ async fn price_improvement_fee_buy_in_market_order() {
#[ignore]
async fn price_improvement_fee_sell_in_market_order() {
let quote_sell_amount = 50000000000000000000u128;
let quote_buy_amount = 45000000000000000000u128;
let quote_buy_amount = 40000000000000000000u128;
let fee = 10000000000000000000u128.into();
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: 20000000000000000000u128.into(),
fee,
},
};
let order_sell_amount = 50000000000000000000u128;
let order_buy_amount = 35000000000000000000u128;
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(),
solver_fee: Some(fee),
quote_sell_amount: order_sell_amount.into(),
quote_buy_amount: order_buy_amount.into(),
// order_buy_amount + fee * factor
executed: 40000000000000000000u128.into(),
// executed sell amount should match order sell amount
executed_sell_amount: order_sell_amount.into(),
executed_buy_amount: 38571428571428571429u128.into(),
executed_buy_amount: 34166666666666666666u128.into(),
};

protocol_fee_test_case(test_case).await;
Expand Down

0 comments on commit 4c68e5c

Please sign in to comment.