Skip to content

Commit

Permalink
Include jit order executed amount
Browse files Browse the repository at this point in the history
  • Loading branch information
squadgazzz committed Oct 3, 2024
1 parent b4a8ff6 commit e1c93e9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
2 changes: 2 additions & 0 deletions crates/driver/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ components:
$ref: "#/components/schemas/TokenAmount"
buyAmount:
$ref: "#/components/schemas/TokenAmount"
executedAmount:
$ref: "#/components/schemas/TokenAmount"
receiver:
$ref: "#/components/schemas/Address"
validTo:
Expand Down
4 changes: 2 additions & 2 deletions crates/driver/src/domain/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct Quote {
pub gas: Option<eth::Gas>,
/// Which `tx.origin` is required to make the quote simulation pass.
pub tx_origin: Option<eth::Address>,
pub jit_orders: Vec<order::Jit>,
pub jit_orders: Vec<solution::trade::Jit>,
}

impl Quote {
Expand Down Expand Up @@ -77,7 +77,7 @@ impl Quote {
.trades()
.iter()
.filter_map(|trade| match trade {
solution::Trade::Jit(jit) => Some(jit.order().clone()),
solution::Trade::Jit(jit) => Some(jit.clone()),
_ => None,
})
.collect(),
Expand Down
31 changes: 17 additions & 14 deletions crates/driver/src/infra/api/routes/quote/dto/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ struct JitOrder {
sell_amount: eth::U256,
#[serde_as(as = "serialize::U256")]
buy_amount: eth::U256,
#[serde_as(as = "serialize::U256")]
executed_amount: eth::U256,
receiver: eth::H160,
valid_to: u32,
#[serde_as(as = "serialize::Hex")]
Expand All @@ -90,21 +92,22 @@ struct JitOrder {
signing_scheme: SigningScheme,
}

impl From<domain::competition::order::Jit> for JitOrder {
fn from(jit: domain::competition::order::Jit) -> Self {
impl From<domain::competition::solution::trade::Jit> for JitOrder {
fn from(jit: domain::competition::solution::trade::Jit) -> Self {
Self {
sell_token: jit.sell.token.into(),
buy_token: jit.buy.token.into(),
sell_amount: jit.sell.amount.into(),
buy_amount: jit.buy.amount.into(),
receiver: jit.receiver.into(),
valid_to: jit.valid_to.into(),
app_data: jit.app_data.into(),
side: jit.side.into(),
sell_token_source: jit.sell_token_balance.into(),
buy_token_destination: jit.buy_token_balance.into(),
signature: jit.signature.data.into(),
signing_scheme: jit.signature.scheme.to_boundary_scheme(),
sell_token: jit.order().sell.token.into(),
buy_token: jit.order().buy.token.into(),
sell_amount: jit.order().sell.amount.into(),
buy_amount: jit.order().buy.amount.into(),
executed_amount: jit.executed().into(),
receiver: jit.order().receiver.into(),
valid_to: jit.order().valid_to.into(),
app_data: jit.order().app_data.into(),
side: jit.order().side.into(),
sell_token_source: jit.order().sell_token_balance.into(),
buy_token_destination: jit.order().buy_token_balance.into(),
signature: jit.order().signature.data.clone().into(),
signing_scheme: jit.order().signature.scheme.to_boundary_scheme(),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/shared/src/trade_finding/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ mod dto {
pub sell_amount: U256,
#[serde_as(as = "HexOrDecimalU256")]
pub buy_amount: U256,
#[serde_as(as = "HexOrDecimalU256")]
pub executed_amount: U256,
pub receiver: H160,
pub valid_to: u32,
#[serde_as(as = "BytesHex")]
Expand Down

0 comments on commit e1c93e9

Please sign in to comment.