Skip to content

Commit

Permalink
Merge branch 'main' into feature/storing-call-data-in-quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrug committed Dec 11, 2024
2 parents 373f891 + 665e401 commit c61f4bc
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 46 deletions.
6 changes: 0 additions & 6 deletions crates/autopilot/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,6 @@ pub struct Arguments {
#[clap(long, env, use_value_delimiter = true)]
pub fee_policies: Vec<FeePolicy>,

/// Enables multiple fees
#[clap(long, env, action = clap::ArgAction::Set, default_value = "false")]
pub enable_multiple_fees: bool,

/// Maximum partner fee allow. If the partner fee specified is greater than
/// this maximum, the partner fee will be capped
#[clap(long, env, default_value = "0.01")]
Expand Down Expand Up @@ -269,7 +265,6 @@ impl std::fmt::Display for Arguments {
shadow,
solve_deadline,
fee_policies,
enable_multiple_fees,
fee_policy_max_partner_fee,
order_events_cleanup_interval,
order_events_cleanup_threshold,
Expand Down Expand Up @@ -326,7 +321,6 @@ impl std::fmt::Display for Arguments {
display_option(f, "shadow", shadow)?;
writeln!(f, "solve_deadline: {:?}", solve_deadline)?;
writeln!(f, "fee_policies: {:?}", fee_policies)?;
writeln!(f, "enable_multiple_fees: {:?}", enable_multiple_fees)?;
writeln!(
f,
"fee_policy_max_partner_fee: {:?}",
Expand Down
35 changes: 2 additions & 33 deletions crates/autopilot/src/domain/fee/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use {
},
app_data::Validator,
derive_more::Into,
itertools::Itertools,
primitive_types::{H160, U256},
prometheus::core::Number,
std::{collections::HashSet, str::FromStr},
Expand Down Expand Up @@ -57,14 +56,12 @@ pub type ProtocolFeeExemptAddresses = HashSet<H160>;
pub struct ProtocolFees {
fee_policies: Vec<ProtocolFee>,
max_partner_fee: FeeFactor,
enable_protocol_fees: bool,
}

impl ProtocolFees {
pub fn new(
fee_policies: &[arguments::FeePolicy],
fee_policy_max_partner_fee: FeeFactor,
enable_protocol_fees: bool,
) -> Self {
Self {
fee_policies: fee_policies
Expand All @@ -73,7 +70,6 @@ impl ProtocolFees {
.map(ProtocolFee::from)
.collect(),
max_partner_fee: fee_policy_max_partner_fee,
enable_protocol_fees,
}
}

Expand Down Expand Up @@ -132,37 +128,10 @@ impl ProtocolFees {
fee: quote.fee.into(),
};

if self.enable_protocol_fees {
self.apply_multiple_policies(order, quote, order_, quote_, partner_fee)
} else {
self.apply_single_policy(order, quote, order_, quote_, partner_fee)
}
}

fn apply_single_policy(
&self,
order: boundary::Order,
quote: domain::Quote,
order_: boundary::Amounts,
quote_: boundary::Amounts,
partner_fees: Vec<Policy>,
) -> domain::Order {
if let Some(partner_fee) = partner_fees.first() {
return boundary::order::to_domain(order, vec![*partner_fee], Some(quote));
}
let protocol_fees = self
.fee_policies
.iter()
.find_map(|fee_policy| {
Self::protocol_fee_into_policy(&order, &order_, &quote_, fee_policy)
})
.and_then(|policy| Self::variant_fee_apply(&order, &quote, policy))
.into_iter()
.collect_vec();
boundary::order::to_domain(order, protocol_fees, Some(quote))
self.apply_policies(order, quote, order_, quote_, partner_fee)
}

fn apply_multiple_policies(
fn apply_policies(
&self,
order: boundary::Order,
quote: domain::Quote,
Expand Down
6 changes: 1 addition & 5 deletions crates/autopilot/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,7 @@ pub async fn run(args: Arguments) {
args.limit_order_price_factor
.try_into()
.expect("limit order price factor can't be converted to BigDecimal"),
domain::ProtocolFees::new(
&args.fee_policies,
args.fee_policy_max_partner_fee,
args.enable_multiple_fees,
),
domain::ProtocolFees::new(&args.fee_policies, args.fee_policy_max_partner_fee),
cow_amm_registry.clone(),
args.run_loop_native_price_timeout,
);
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/limit_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,6 @@ async fn no_liquidity_limit_order(web3: Web3) {
ExtraServiceArgs {
autopilot: vec![
protocol_fees_config,
"--enable-multiple-fees=true".to_string(),
format!("--unsupported-tokens={:#x}", unsupported.address()),
],
..Default::default()
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/protocol_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ async fn combined_protocol_fees(web3: Web3) {
let autopilot_config = vec![
ProtocolFeesConfig(vec![limit_surplus_policy, market_price_improvement_policy]).to_string(),
"--fee-policy-max-partner-fee=0.02".to_string(),
"--enable-multiple-fees=true".to_string(),
];
let services = Services::new(&onchain).await;
services
Expand Down

0 comments on commit c61f4bc

Please sign in to comment.