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

Quote with JIT orders API #3083

Merged
merged 9 commits into from
Oct 28, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Redundant amount
  • Loading branch information
squadgazzz committed Oct 25, 2024
commit 898e5e73854c9a727491b6b743f52fd90108147d
24 changes: 10 additions & 14 deletions crates/shared/src/trade_finding/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,10 @@ impl ExternalTradeFinder {
}
})?;
match quote {
dto::Quote::LegacyQuote(quote) => Ok(Trade::from(quote)),
dto::Quote::QuoteWithJitOrders(_) => {
Err(PriceEstimationError::EstimatorInternal(anyhow!(
"Quote with JIT orders is not currently supported"
)))
}
dto::Quote::Legacy(quote) => Ok(Trade::from(quote)),
dto::Quote::WithJitOrders(_) => Err(PriceEstimationError::EstimatorInternal(
anyhow!("Quote with JIT orders is not currently supported"),
)),
}
}
.boxed()
Expand Down Expand Up @@ -210,9 +208,9 @@ mod dto {
#[serde_as]
#[derive(Clone, Debug)]
pub enum Quote {
LegacyQuote(LegacyQuote),
Legacy(LegacyQuote),
#[allow(unused)]
QuoteWithJitOrders(QuoteWithJITOrders),
WithJitOrders(QuoteWithJITOrders),
}

impl<'de> Deserialize<'de> for Quote {
Expand All @@ -226,11 +224,11 @@ mod dto {
|| value.get("jitOrders").is_some()
|| value.get("preInteractions").is_some()
{
Ok(Quote::QuoteWithJitOrders(
Ok(Quote::WithJitOrders(
QuoteWithJITOrders::deserialize(value).map_err(de::Error::custom)?,
))
} else {
Ok(Quote::LegacyQuote(
Ok(Quote::Legacy(
LegacyQuote::deserialize(value).map_err(de::Error::custom)?,
))
}
Expand All @@ -254,15 +252,13 @@ mod dto {
#[serde(rename_all = "camelCase")]
#[allow(unused)]
pub struct QuoteWithJITOrders {
#[serde_as(as = "HexOrDecimalU256")]
pub amount: U256,
#[serde_as(as = "HashMap<_, HexOrDecimalU256>")]
pub clearing_prices: HashMap<H160, U256>,
pub pre_interactions: Vec<Interaction>,
pub interactions: Vec<Interaction>,
pub solver: H160,
pub gas: Option<u64>,
pub tx_origin: Option<H160>,
#[serde_as(as = "HashMap<_, HexOrDecimalU256>")]
pub clearing_prices: HashMap<H160, U256>,
pub jit_orders: Vec<JitOrder>,
}

Expand Down
Loading