Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EASY] Use optional values in autopilot only #2898

Merged
merged 2 commits into from
Aug 15, 2024
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
2 changes: 1 addition & 1 deletion crates/autopilot/src/boundary/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn to_domain(
amount: order.data.buy_amount.into(),
},
protocol_fees,
created: Some(u32::try_from(order.metadata.creation_date.timestamp()).unwrap_or(u32::MIN)),
created: u32::try_from(order.metadata.creation_date.timestamp()).unwrap_or(u32::MIN),
valid_to: order.data.valid_to,
side: order.data.kind.into(),
receiver: order.data.receiver.map(Into::into),
Expand Down
2 changes: 1 addition & 1 deletion crates/autopilot/src/domain/auction/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct Order {
pub protocol_fees: Vec<fee::Policy>,
pub side: Side,
pub class: Class,
pub created: Option<u32>,
pub created: u32,
pub valid_to: u32,
pub receiver: Option<eth::Address>,
pub owner: eth::Address,
Expand Down
4 changes: 2 additions & 2 deletions crates/autopilot/src/domain/fee/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,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: Option<H160>,
pub solver: H160,
}

impl From<domain::Quote> for Quote {
Expand All @@ -294,7 +294,7 @@ impl From<domain::Quote> for Quote {
sell_amount: value.sell_amount.into(),
buy_amount: value.buy_amount.into(),
fee: value.fee.into(),
solver: Some(value.solver.into()),
solver: value.solver.into(),
}
}
}
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: Some(quote.solver.into()),
solver: quote.solver.into(),
}
},
},
Expand Down
16 changes: 8 additions & 8 deletions crates/autopilot/src/infra/persistence/dto/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct Order {
#[serde_as(as = "HexOrDecimalU256")]
pub buy_amount: U256,
pub protocol_fees: Vec<FeePolicy>,
pub created: u32,
pub created: Option<u32>,
pub valid_to: u32,
pub kind: boundary::OrderKind,
pub receiver: Option<H160>,
Expand Down Expand Up @@ -50,7 +50,7 @@ pub fn from_domain(order: domain::Order) -> Order {
sell_amount: order.sell.amount.into(),
buy_amount: order.buy.amount.into(),
protocol_fees: order.protocol_fees.into_iter().map(Into::into).collect(),
created: order.created.unwrap_or(u32::MIN),
created: Some(order.created),
valid_to: order.valid_to,
kind: order.side.into(),
receiver: order.receiver.map(Into::into),
Expand Down Expand Up @@ -84,7 +84,7 @@ pub fn to_domain(order: Order) -> domain::Order {
amount: order.buy_amount.into(),
},
protocol_fees: order.protocol_fees.into_iter().map(Into::into).collect(),
created: Some(order.created),
created: order.created.unwrap_or(u32::MIN),
valid_to: order.valid_to,
side: order.kind.into(),
receiver: order.receiver.map(Into::into),
Expand Down Expand Up @@ -293,7 +293,7 @@ pub struct Quote {
pub buy_amount: U256,
#[serde_as(as = "HexOrDecimalU256")]
pub fee: U256,
pub solver: H160,
pub solver: Option<H160>,
}

impl Quote {
Expand All @@ -303,7 +303,7 @@ impl Quote {
sell_amount: self.sell_amount.into(),
buy_amount: self.buy_amount.into(),
fee: self.fee.into(),
solver: self.solver.into(),
solver: self.solver.unwrap_or_default().into(),
}
}
}
Expand All @@ -314,7 +314,7 @@ impl From<domain::Quote> for Quote {
sell_amount: quote.sell_amount.0,
buy_amount: quote.buy_amount.0,
fee: quote.fee.0,
solver: quote.solver.0,
solver: Some(quote.solver.0),
}
}
}
Expand All @@ -340,7 +340,7 @@ impl From<domain::fee::Policy> for FeePolicy {
sell_amount: quote.sell_amount,
buy_amount: quote.buy_amount,
fee: quote.fee,
solver: quote.solver.unwrap_or_default(),
solver: Some(quote.solver),
},
},
domain::fee::Policy::Volume { factor } => Self::Volume {
Expand Down Expand Up @@ -371,7 +371,7 @@ impl From<FeePolicy> for domain::fee::Policy {
sell_amount: quote.sell_amount,
buy_amount: quote.buy_amount,
fee: quote.fee,
solver: Some(quote.solver),
solver: quote.solver.unwrap_or_default(),
},
},
FeePolicy::Volume { factor } => Self::Volume {
Expand Down
8 changes: 4 additions & 4 deletions crates/driver/src/infra/api/routes/solve/dto/auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Auction {
.map(|order| competition::Order {
uid: order.uid.into(),
receiver: order.receiver.map(Into::into),
created: order.created.unwrap_or(u32::MIN).into(),
created: order.created.into(),
valid_to: order.valid_to.into(),
buy: eth::Asset {
amount: order.buy_amount.into(),
Expand Down Expand Up @@ -238,7 +238,7 @@ struct Order {
#[serde_as(as = "serialize::U256")]
buy_amount: eth::U256,
protocol_fees: Vec<FeePolicy>,
created: Option<u32>,
created: u32,
valid_to: u32,
kind: Kind,
receiver: Option<eth::H160>,
Expand Down Expand Up @@ -339,7 +339,7 @@ pub struct Quote {
pub buy_amount: eth::U256,
#[serde_as(as = "serialize::U256")]
pub fee: eth::U256,
pub solver: Option<eth::H160>,
pub solver: eth::H160,
}

impl Quote {
Expand All @@ -357,7 +357,7 @@ impl Quote {
amount: self.fee.into(),
token: sell_token.into(),
},
solver: self.solver.unwrap_or_default().into(),
solver: self.solver.into(),
}
}
}
Loading