diff --git a/crates/price-estimation/src/lib.rs b/crates/price-estimation/src/lib.rs index 38ecf0c10a..b95b920ad3 100644 --- a/crates/price-estimation/src/lib.rs +++ b/crates/price-estimation/src/lib.rs @@ -203,6 +203,9 @@ pub struct Estimate { /// Whether the quoting solver supports fast-path (out-of-competition) /// execution for this order. pub supports_fast_path: bool, + /// Solver-assigned solution id when the underlying quote response + /// carried one. Threaded end-to-end into `QuoteResponse.solution_id`. + pub solution_id: Option, /// Data associated with this estimation. #[debug(ignore)] pub execution: QuoteExecution, diff --git a/crates/price-estimation/src/native/mod.rs b/crates/price-estimation/src/native/mod.rs index 0e7bdcf07e..490496955f 100644 --- a/crates/price-estimation/src/native/mod.rs +++ b/crates/price-estimation/src/native/mod.rs @@ -157,6 +157,7 @@ mod tests { solver: Address::repeat_byte(1), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }) } diff --git a/crates/price-estimation/src/sanitized.rs b/crates/price-estimation/src/sanitized.rs index 227533d466..bd96ee53a9 100644 --- a/crates/price-estimation/src/sanitized.rs +++ b/crates/price-estimation/src/sanitized.rs @@ -126,6 +126,7 @@ impl SanitizedPriceEstimator { solver: Default::default(), verified: true, supports_fast_path: false, + solution_id: None, execution: Default::default(), }; tracing::debug!(?query, ?estimation, "generate trivial price estimation"); @@ -141,6 +142,7 @@ impl SanitizedPriceEstimator { solver: Default::default(), verified: true, supports_fast_path: false, + solution_id: None, execution: Default::default(), }; tracing::debug!(?query, ?estimation, "generate trivial unwrap estimation"); @@ -156,6 +158,7 @@ impl SanitizedPriceEstimator { solver: Default::default(), verified: true, supports_fast_path: false, + solution_id: None, execution: Default::default(), }; tracing::debug!(?query, ?estimation, "generate trivial wrap estimation"); @@ -224,6 +227,7 @@ mod tests { solver: Default::default(), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), ), @@ -250,6 +254,7 @@ mod tests { solver: Default::default(), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), ), @@ -293,6 +298,7 @@ mod tests { solver: Default::default(), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), ), @@ -316,6 +322,7 @@ mod tests { solver: Default::default(), verified: true, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), ), @@ -338,6 +345,7 @@ mod tests { solver: Default::default(), verified: true, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), ), @@ -361,6 +369,7 @@ mod tests { solver: Default::default(), verified: true, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), ), @@ -384,6 +393,7 @@ mod tests { solver: Default::default(), verified: true, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), ), @@ -457,6 +467,7 @@ mod tests { solver: Default::default(), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }) } @@ -474,6 +485,7 @@ mod tests { solver: Default::default(), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }) } @@ -491,6 +503,7 @@ mod tests { solver: Default::default(), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }) } @@ -508,6 +521,7 @@ mod tests { solver: Default::default(), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }) } @@ -555,6 +569,7 @@ mod tests { solver: Default::default(), verified: true, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), ), @@ -576,6 +591,7 @@ mod tests { solver: Default::default(), verified: true, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), ), @@ -602,6 +618,7 @@ mod tests { solver: Default::default(), verified: true, supports_fast_path: false, + solution_id: None, execution: Default::default(), }) } @@ -619,6 +636,7 @@ mod tests { solver: Default::default(), verified: true, supports_fast_path: false, + solution_id: None, execution: Default::default(), }) } diff --git a/crates/price-estimation/src/trade_finding/external.rs b/crates/price-estimation/src/trade_finding/external.rs index f160177f21..df9a3eaa7b 100644 --- a/crates/price-estimation/src/trade_finding/external.rs +++ b/crates/price-estimation/src/trade_finding/external.rs @@ -184,6 +184,7 @@ impl From for LegacyTrade { solver: quote.solver, tx_origin: quote.tx_origin, supports_fast_path: quote.supports_fast_path, + solution_id: quote.solution_id, } } } @@ -215,6 +216,7 @@ impl From for Trade { tx_origin: quote.tx_origin, jit_orders: quote.jit_orders, supports_fast_path: quote.supports_fast_path, + solution_id: quote.solution_id, } } } @@ -363,6 +365,7 @@ impl TradeFinding for ExternalTradeFinder { gas_estimate, solver: trade.solver(), supports_fast_path: trade.supports_fast_path(), + solution_id: trade.solution_id(), execution: QuoteExecution { interactions: map_interactions_data(trade.interactions()), pre_interactions: map_interactions_data(trade.pre_interactions()), @@ -402,7 +405,12 @@ pub mod dto { pub amount: U256, pub kind: OrderKind, pub deadline: chrono::DateTime, - #[serde(default, skip_serializing_if = "std::ops::Not::not")] + // Renamed to match the driver's `enableFastPath` field name. + #[serde( + rename = "enableFastPath", + default, + skip_serializing_if = "std::ops::Not::not" + )] pub fast_path: bool, #[serde(skip_serializing_if = "Option::is_none")] pub auction_id: Option, @@ -429,6 +437,11 @@ pub mod dto { pub tx_origin: Option
, #[serde(default)] pub supports_fast_path: bool, + /// Solver-assigned solution id for this quote. Threaded through to + /// `QuoteResponse.solution_id` and, ultimately, into + /// `proposed_solutions.id` when a fast-path quote is persisted. + #[serde(default)] + pub solution_id: Option, } #[serde_as] @@ -448,6 +461,11 @@ pub mod dto { pub jit_orders: Vec, #[serde(default)] pub supports_fast_path: bool, + /// Solver-assigned solution id for this quote. Threaded through to + /// `QuoteResponse.solution_id` and, ultimately, into + /// `proposed_solutions.id` when a fast-path quote is persisted. + #[serde(default)] + pub solution_id: Option, } #[serde_as] diff --git a/crates/price-estimation/src/trade_finding/mod.rs b/crates/price-estimation/src/trade_finding/mod.rs index f71d43e761..8635da693b 100644 --- a/crates/price-estimation/src/trade_finding/mod.rs +++ b/crates/price-estimation/src/trade_finding/mod.rs @@ -37,6 +37,9 @@ pub struct Quote { pub solver: Address, /// Whether the quoting solver supports fast-path execution. pub supports_fast_path: bool, + /// Solver-assigned solution id, when the underlying quote response + /// carries one. + pub solution_id: Option, #[debug(ignore)] pub execution: QuoteExecution, } @@ -90,6 +93,13 @@ impl TradeKind { } } + pub fn solution_id(&self) -> Option { + match self { + TradeKind::Legacy(trade) => trade.solution_id, + TradeKind::Regular(trade) => trade.solution_id, + } + } + pub fn simulation_solver_address(&self) -> Address { self.tx_origin().unwrap_or(self.solver()) } @@ -148,6 +158,9 @@ pub struct LegacyTrade { pub tx_origin: Option
, /// Whether the quoting solver supports fast-path execution. pub supports_fast_path: bool, + /// Solver-assigned solution id for this trade, if the response carried + /// one. + pub solution_id: Option, } /// A trade with JIT orders. @@ -169,6 +182,9 @@ pub struct Trade { pub jit_orders: Vec, /// Whether the quoting solver supports fast-path execution. pub supports_fast_path: bool, + /// Solver-assigned solution id for this trade, if the response carried + /// one. + pub solution_id: Option, } impl Trade { diff --git a/crates/price-estimation/src/trade_finding/trade_estimator.rs b/crates/price-estimation/src/trade_finding/trade_estimator.rs index bee8cb9f2a..73a211e036 100644 --- a/crates/price-estimation/src/trade_finding/trade_estimator.rs +++ b/crates/price-estimation/src/trade_finding/trade_estimator.rs @@ -90,6 +90,7 @@ impl Inner { solver: quote.solver, verified: false, supports_fast_path: quote.supports_fast_path, + solution_id: quote.solution_id, execution: quote.execution, }) } diff --git a/crates/price-estimation/src/trade_verifier.rs b/crates/price-estimation/src/trade_verifier.rs index 2a81c3f2bf..d4e2995e8a 100644 --- a/crates/price-estimation/src/trade_verifier.rs +++ b/crates/price-estimation/src/trade_verifier.rs @@ -130,6 +130,7 @@ impl TradeVerifier { solver: trade.solver(), verified: false, supports_fast_path: trade.supports_fast_path(), + solution_id: trade.solution_id(), execution: QuoteExecution { interactions: map_interactions_data(trade.interactions()), pre_interactions: map_interactions_data(trade.pre_interactions()), @@ -837,6 +838,7 @@ fn ensure_quote_accuracy( solver: trade.solver(), verified: true, supports_fast_path: trade.supports_fast_path(), + solution_id: trade.solution_id(), execution: QuoteExecution { interactions: map_interactions_data(trade.interactions()), pre_interactions: map_interactions_data(trade.pre_interactions()), diff --git a/crates/shared/src/order_quoting.rs b/crates/shared/src/order_quoting.rs index 9ab3ffd32b..e759851b3a 100644 --- a/crates/shared/src/order_quoting.rs +++ b/crates/shared/src/order_quoting.rs @@ -261,6 +261,10 @@ pub struct QuoteResponse { pub verified: bool, pub supports_fast_path: bool, pub metadata: QuoteMetadata, + /// Solver-assigned solution id, when the underlying solver quote + /// response carries one. Populated into `proposed_solutions.id` when + /// the quote is persisted as fast-path competition data. + pub solution_id: Option, } impl QuoteCompetition { @@ -929,6 +933,7 @@ fn assemble_quote_data( jit_orders: estimate.execution.jit_orders, } .into(), + solution_id: estimate.solution_id, } }; @@ -1131,6 +1136,7 @@ mod tests { solver: Address::repeat_byte(1), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }, [], @@ -1176,6 +1182,7 @@ mod tests { verified: false, supports_fast_path: false, metadata: Default::default(), + solution_id: None, }, [], QuoteCompetitionMetadata { @@ -1291,6 +1298,7 @@ mod tests { solver: Address::repeat_byte(1), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }, [], @@ -1336,6 +1344,7 @@ mod tests { verified: false, supports_fast_path: false, metadata: Default::default(), + solution_id: None, }, [], QuoteCompetitionMetadata { @@ -1446,6 +1455,7 @@ mod tests { solver: Address::repeat_byte(1), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }, [], @@ -1491,6 +1501,7 @@ mod tests { verified: false, supports_fast_path: false, metadata: Default::default(), + solution_id: None, }, [], QuoteCompetitionMetadata { @@ -1584,6 +1595,7 @@ mod tests { solver: Address::repeat_byte(1), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }, [], @@ -1662,6 +1674,7 @@ mod tests { solver: Address::repeat_byte(1), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }, [], @@ -2150,6 +2163,7 @@ mod tests { solver: Address::repeat_byte(7), verified: true, supports_fast_path: false, + solution_id: None, execution: Default::default(), }; @@ -2208,6 +2222,7 @@ mod tests { solver: Address::repeat_byte(7), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }; @@ -2313,6 +2328,7 @@ mod tests { solver: Address::repeat_byte(1), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), Ok(price_estimation::Estimate { @@ -2321,6 +2337,7 @@ mod tests { solver: Address::repeat_byte(2), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), ]) @@ -2369,6 +2386,7 @@ mod tests { solver: Address::repeat_byte(1), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), // zero gas - must be dropped silently @@ -2378,6 +2396,7 @@ mod tests { solver: Address::repeat_byte(2), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), // zero out_amount - must be dropped silently @@ -2387,6 +2406,7 @@ mod tests { solver: Address::repeat_byte(3), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), }), ]) @@ -2474,6 +2494,7 @@ mod tests { solver: Address::repeat_byte(1), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), })]) .boxed() @@ -2523,6 +2544,7 @@ mod tests { solver: Address::repeat_byte(1), verified: false, supports_fast_path: false, + solution_id: None, execution: Default::default(), } }