Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions crates/autopilot/src/domain/fee/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use {
boundary::{self},
domain::{self, eth},
},
alloy::primitives::Address,
app_data::Validator,
derive_more::Into,
primitive_types::{H160, U256},
Expand Down Expand Up @@ -185,7 +186,7 @@ impl ProtocolFees {
sell_amount: quote.sell_amount.into(),
buy_amount: quote.buy_amount.into(),
fee: quote.fee.into(),
solver: quote.solver.into(),
solver: quote.solver,
},
}
}
Expand All @@ -209,7 +210,7 @@ impl ProtocolFees {
sell_amount: order.data.sell_amount.into(),
buy_amount: U256::zero().into(),
fee: order.data.fee_amount.into(),
solver: H160::zero().into(),
solver: Address::ZERO,
});

let partner_fee =
Expand Down Expand Up @@ -333,7 +334,7 @@ pub struct Quote {
pub buy_amount: U256,
/// The amount that needs to be paid, denominated in the sell token.
pub fee: U256,
pub solver: H160,
pub solver: Address,
}

impl Quote {
Expand All @@ -342,7 +343,7 @@ impl Quote {
sell_amount: value.sell_amount.into(),
buy_amount: value.buy_amount.into(),
fee: value.fee.into(),
solver: value.solver.into(),
solver: value.solver,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/autopilot/src/domain/quote/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use {
super::OrderUid,
crate::{boundary::Amounts, domain::eth},
alloy::primitives::Address,
};

#[derive(Clone, Debug, PartialEq)]
Expand All @@ -9,7 +10,7 @@ pub struct Quote {
pub sell_amount: eth::SellTokenAmount,
pub buy_amount: eth::TokenAmount,
pub fee: eth::SellTokenAmount,
pub solver: eth::Address,
pub solver: Address,
}

impl From<&Quote> for Amounts {
Expand Down
2 changes: 1 addition & 1 deletion crates/autopilot/src/infra/persistence/dto/fee_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub fn try_into_domain(
sell_amount: quote.sell_amount.into(),
buy_amount: quote.buy_amount.into(),
fee: quote.fee.into(),
solver: quote.solver.into(),
solver: quote.solver,
}
},
},
Expand Down
37 changes: 19 additions & 18 deletions crates/autopilot/src/infra/persistence/dto/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use {
boundary::{self},
domain::{self, OrderUid, eth, fee::FeeFactor},
},
alloy::primitives::Address,
app_data::AppDataHash,
ethrpc::alloy::conversions::{IntoAlloy, IntoLegacy},
number::serialization::HexOrDecimalU256,
Expand Down Expand Up @@ -289,9 +290,9 @@ impl FeePolicy {
factor: factor.into(),
max_volume_factor: max_volume_factor.into(),
quote: Quote {
sell_amount: quote.sell_amount,
buy_amount: quote.buy_amount,
fee: quote.fee,
sell_amount: quote.sell_amount.into_alloy(),
buy_amount: quote.buy_amount.into_alloy(),
fee: quote.fee.into_alloy(),
solver: quote.solver,
},
},
Expand All @@ -318,9 +319,9 @@ impl FeePolicy {
factor: FeeFactor::try_from(factor).unwrap(),
max_volume_factor: FeeFactor::try_from(max_volume_factor).unwrap(),
quote: domain::fee::Quote {
sell_amount: quote.sell_amount,
buy_amount: quote.buy_amount,
fee: quote.fee,
sell_amount: quote.sell_amount.into_legacy(),
buy_amount: quote.buy_amount.into_legacy(),
fee: quote.fee.into_legacy(),
solver: quote.solver,
},
},
Expand All @@ -336,31 +337,31 @@ impl FeePolicy {
#[serde(rename_all = "camelCase")]
pub struct Quote {
#[serde_as(as = "HexOrDecimalU256")]
pub sell_amount: U256,
pub sell_amount: alloy::primitives::U256,
#[serde_as(as = "HexOrDecimalU256")]
pub buy_amount: U256,
pub buy_amount: alloy::primitives::U256,
#[serde_as(as = "HexOrDecimalU256")]
pub fee: U256,
pub solver: H160,
pub fee: alloy::primitives::U256,
pub solver: Address,
}

impl Quote {
fn from_domain(quote: domain::Quote) -> Self {
Quote {
sell_amount: quote.sell_amount.0,
buy_amount: quote.buy_amount.0,
fee: quote.fee.0,
solver: quote.solver.0,
sell_amount: quote.sell_amount.0.into_alloy(),
buy_amount: quote.buy_amount.0.into_alloy(),
fee: quote.fee.0.into_alloy(),
solver: quote.solver,
}
}

pub fn to_domain(&self, order_uid: OrderUid) -> domain::Quote {
domain::Quote {
order_uid,
sell_amount: self.sell_amount.into(),
buy_amount: self.buy_amount.into(),
fee: self.fee.into(),
solver: self.solver.into(),
sell_amount: self.sell_amount.into_legacy().into(),
buy_amount: self.buy_amount.into_legacy().into(),
fee: self.fee.into_legacy().into(),
solver: self.solver,
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions crates/autopilot/src/infra/persistence/dto/quote.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use {
crate::{
boundary,
domain::{self, eth},
domain::{self},
},
alloy::primitives::Address,
bigdecimal::{
FromPrimitive,
num_traits::{CheckedDiv, CheckedMul},
Expand Down Expand Up @@ -33,7 +34,7 @@ pub fn into_domain(quote: boundary::database::orders::Quote) -> Result<domain::Q
.ok_or(QuoteError::U256Overflow)?
.into(),
fee: fee.into(),
solver: eth::H160::from(quote.solver.0).into(),
solver: Address::new(quote.solver.0),
})
}

Expand Down
Loading