Skip to content

Commit

Permalink
external-api: add get_quote_amount helper
Browse files Browse the repository at this point in the history
  • Loading branch information
sehyunc committed Dec 16, 2024
1 parent e26c7a6 commit 4e1e32d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions external-api/src/http/external_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4e1e32d

Please sign in to comment.