diff --git a/external-api/src/http/external_match.rs b/external-api/src/http/external_match.rs index 75c02501..eae19382 100644 --- a/external-api/src/http/external_match.rs +++ b/external-api/src/http/external_match.rs @@ -185,6 +185,20 @@ impl ExternalOrder { let div = FixedPoint::floor_div_int(min_fill, price) + Scalar::one(); scalar_to_u128(&div) } + + /// Get the quote amount of the order implied by the external order + /// + /// The price here is expected to be decimal corrected; i.e. multiplied by + /// the decimal diff for the two tokens + pub fn get_quote_amount(&self, price: FixedPoint) -> Amount { + if self.quote_amount != 0 { + return self.quote_amount; + } + + let base_amount_scalar = Scalar::from(self.base_amount); + let implied_quote_amount = price * base_amount_scalar; + scalar_to_u128(&implied_quote_amount.floor()) + } } /// An atomic match settlement bundle, sent to the client so that they may