diff --git a/pallets/order-book/src/lib.rs b/pallets/order-book/src/lib.rs index 047a9959e4..e296dbf8b8 100644 --- a/pallets/order-book/src/lib.rs +++ b/pallets/order-book/src/lib.rs @@ -644,8 +644,13 @@ pub mod pallet { ) -> Result { let feeder = MarketFeederId::::get()?; - T::RatioProvider::get(&feeder, &(currency_from, currency_to))? - .ok_or(Error::::MarketRatioNotFound.into()) + if currency_to < currency_from { + T::RatioProvider::get(&feeder, &(currency_to, currency_from))? + .map(|ratio| ratio.reciprocal().unwrap_or(Zero::zero())) + } else { + T::RatioProvider::get(&feeder, &(currency_from, currency_to))? + } + .ok_or(Error::::MarketRatioNotFound.into()) } /// `ratio` is the value you multiply `amount_from` to obtain