diff --git a/libs/mocks/src/investment.rs b/libs/mocks/src/investment.rs index b42052c74b..546e8a79d6 100644 --- a/libs/mocks/src/investment.rs +++ b/libs/mocks/src/investment.rs @@ -30,12 +30,6 @@ pub mod pallet { register_call!(move |(a, b, c)| f(a, b, c)); } - pub fn mock_accepted_payment_currency( - f: impl Fn(T::InvestmentId, T::CurrencyId) -> bool + 'static, - ) { - register_call!(move |(a, b)| f(a, b)); - } - pub fn mock_investment( f: impl Fn(&T::AccountId, T::InvestmentId) -> Result + 'static, ) { @@ -48,12 +42,6 @@ pub mod pallet { register_call!(move |(a, b, c)| f(a, b, c)); } - pub fn mock_accepted_payout_currency( - f: impl Fn(T::InvestmentId, T::CurrencyId) -> bool + 'static, - ) { - register_call!(move |(a, b)| f(a, b)); - } - pub fn mock_redemption( f: impl Fn(&T::AccountId, T::InvestmentId) -> Result + 'static, @@ -101,10 +89,6 @@ pub mod pallet { execute_call!((a, b, c)) } - fn accepted_payment_currency(a: Self::InvestmentId, b: Self::CurrencyId) -> bool { - execute_call!((a, b)) - } - fn investment( a: &T::AccountId, b: Self::InvestmentId, @@ -120,10 +104,6 @@ pub mod pallet { execute_call!((a, b, c)) } - fn accepted_payout_currency(a: Self::InvestmentId, b: Self::CurrencyId) -> bool { - execute_call!((a, b)) - } - fn redemption( a: &T::AccountId, b: Self::InvestmentId, diff --git a/libs/mocks/src/token_swaps.rs b/libs/mocks/src/token_swaps.rs index 230e7c9ce7..a035198914 100644 --- a/libs/mocks/src/token_swaps.rs +++ b/libs/mocks/src/token_swaps.rs @@ -52,12 +52,6 @@ pub mod pallet { register_call!(f); } - pub fn mock_valid_pair( - f: impl Fn(T::CurrencyId, T::CurrencyId) -> DispatchResult + 'static, - ) { - register_call!(move |(a, b)| f(a, b)); - } - pub fn mock_get_order_details( f: impl Fn(T::OrderId) -> Option> + 'static, @@ -81,13 +75,6 @@ pub mod pallet { ) { register_call!(move |(a, b, c)| f(a, b, c)) } - - #[cfg(feature = "runtime-benchmarks")] - pub fn mock_add_trading_pair( - f: impl Fn(T::CurrencyId, T::CurrencyId, T::BalanceOut) -> DispatchResult + 'static, - ) { - register_call!(move |(a, b, c)| f(a, b, c)) - } } impl TokenSwaps for Pallet { @@ -119,10 +106,6 @@ pub mod pallet { execute_call!(a) } - fn valid_pair(a: Self::CurrencyId, b: Self::CurrencyId) -> bool { - execute_call!((a, b)) - } - fn get_order_details( a: Self::OrderId, ) -> Option> { @@ -140,14 +123,5 @@ pub mod pallet { fn fill_order(a: T::AccountId, b: Self::OrderId, c: Self::BalanceOut) -> DispatchResult { execute_call!((a, b, c)) } - - #[cfg(feature = "runtime-benchmarks")] - fn add_trading_pair( - a: Self::CurrencyId, - b: Self::CurrencyId, - c: Self::BalanceOut, - ) -> DispatchResult { - execute_call!((a, b, c)) - } } } diff --git a/libs/traits/src/investments.rs b/libs/traits/src/investments.rs index 2f03c7fa4e..7cbe2c2b28 100644 --- a/libs/traits/src/investments.rs +++ b/libs/traits/src/investments.rs @@ -42,12 +42,6 @@ pub trait Investment { amount: Self::Amount, ) -> Result<(), Self::Error>; - /// Checks whether a currency can be used for buying the given investment. - fn accepted_payment_currency( - investment_id: Self::InvestmentId, - currency: Self::CurrencyId, - ) -> bool; - /// Returns, if possible, the currently unprocessed investment amount (in /// pool currency) of who into the given investment class. /// @@ -70,13 +64,6 @@ pub trait Investment { amount: Self::TrancheAmount, ) -> Result<(), Self::Error>; - /// Checks whether a currency is accepted as a payout for the given - /// investment. - fn accepted_payout_currency( - investment_id: Self::InvestmentId, - currency: Self::CurrencyId, - ) -> bool; - /// Returns, if possible, the currently unprocessed redemption amount (in /// tranche tokens) of who into the given investment class. /// @@ -329,17 +316,4 @@ pub trait ForeignInvestment { who: &AccountId, investment_id: Self::InvestmentId, ) -> Result; - - /// Checks whether a currency can be used for buying the given investment. - fn accepted_payment_currency( - investment_id: Self::InvestmentId, - currency: Self::CurrencyId, - ) -> bool; - - /// Checks whether a currency is accepted as a payout for the given - /// investment. - fn accepted_payout_currency( - investment_id: Self::InvestmentId, - currency: Self::CurrencyId, - ) -> bool; } diff --git a/libs/traits/src/swaps.rs b/libs/traits/src/swaps.rs index 1ec7906d34..32aa2c7b19 100644 --- a/libs/traits/src/swaps.rs +++ b/libs/traits/src/swaps.rs @@ -83,11 +83,6 @@ pub trait TokenSwaps { amount: Self::BalanceOut, ) -> DispatchResult; - /// A sanity check that can be used for validating that a trading pair - /// is supported. Will also be checked when placing an order but might be - /// cheaper. - fn valid_pair(currency_in: Self::CurrencyId, currency_out: Self::CurrencyId) -> bool; - /// Cancel an already active order. fn cancel_order(order: Self::OrderId) -> DispatchResult; @@ -103,14 +98,6 @@ pub trait TokenSwaps { currency_out: Self::CurrencyId, amount_out: Self::BalanceOut, ) -> Result; - - #[cfg(feature = "runtime-benchmarks")] - /// Adds a valid trading pair. - fn add_trading_pair( - currency_in: Self::CurrencyId, - currency_out: Self::CurrencyId, - min_order: Self::BalanceOut, - ) -> DispatchResult; } /// A representation of a currency swap in process. @@ -172,9 +159,6 @@ pub trait Swaps { from_currency: Self::CurrencyId, ) -> Result; - /// Check that validates that if swapping pair is supported. - fn valid_pair(currency_in: Self::CurrencyId, currency_out: Self::CurrencyId) -> bool; - /// Makes a conversion between 2 currencies using the market ratio between /// them // TODO: Should be removed after #1723 diff --git a/pallets/foreign-investments/src/impls.rs b/pallets/foreign-investments/src/impls.rs index bf24ede27a..af92f86b0e 100644 --- a/pallets/foreign-investments/src/impls.rs +++ b/pallets/foreign-investments/src/impls.rs @@ -1,9 +1,9 @@ //! Trait implementations. Higher level file. use cfg_traits::{ - investments::{ForeignInvestment, Investment, InvestmentCollector, TrancheCurrency}, + investments::{ForeignInvestment, Investment, InvestmentCollector}, swaps::{SwapState, Swaps}, - PoolInspect, StatusNotificationHook, + StatusNotificationHook, }; use cfg_types::investments::CollectedAmount; use frame_support::pallet_prelude::*; @@ -203,26 +203,6 @@ impl ForeignInvestment for Pallet { ) -> Result { T::Investment::redemption(who, investment_id) } - - fn accepted_payment_currency(investment_id: T::InvestmentId, currency: T::CurrencyId) -> bool { - if T::Investment::accepted_payment_currency(investment_id, currency) { - true - } else { - T::PoolInspect::currency_for(investment_id.of_pool()) - .map(|pool_currency| T::Swaps::valid_pair(pool_currency, currency)) - .unwrap_or(false) - } - } - - fn accepted_payout_currency(investment_id: T::InvestmentId, currency: T::CurrencyId) -> bool { - if T::Investment::accepted_payout_currency(investment_id, currency) { - true - } else { - T::PoolInspect::currency_for(investment_id.of_pool()) - .map(|pool_currency| T::Swaps::valid_pair(currency, pool_currency)) - .unwrap_or(false) - } - } } pub struct FulfilledSwapHook(PhantomData); diff --git a/pallets/investments/src/lib.rs b/pallets/investments/src/lib.rs index fb84dbc51e..ed7c5027eb 100644 --- a/pallets/investments/src/lib.rs +++ b/pallets/investments/src/lib.rs @@ -1097,15 +1097,6 @@ impl Investment for Pallet { Pallet::::do_update_investment(who.clone(), investment_id, amount) } - fn accepted_payment_currency( - investment_id: Self::InvestmentId, - currency: Self::CurrencyId, - ) -> bool { - T::Accountant::info(investment_id) - .map(|info| info.payment_currency == currency) - .unwrap_or(false) - } - fn investment( who: &T::AccountId, investment_id: Self::InvestmentId, @@ -1122,15 +1113,6 @@ impl Investment for Pallet { Pallet::::do_update_redemption(who.clone(), investment_id, amount) } - fn accepted_payout_currency( - investment_id: Self::InvestmentId, - currency: Self::CurrencyId, - ) -> bool { - T::Accountant::info(investment_id) - .map(|info| info.payment_currency == currency) - .unwrap_or(false) - } - fn redemption( who: &T::AccountId, investment_id: Self::InvestmentId, diff --git a/pallets/liquidity-pools/src/inbound.rs b/pallets/liquidity-pools/src/inbound.rs index 4a321cb050..573bce07c1 100644 --- a/pallets/liquidity-pools/src/inbound.rs +++ b/pallets/liquidity-pools/src/inbound.rs @@ -102,7 +102,7 @@ where amount: ::Balance, ) -> DispatchResult { let invest_id: T::TrancheCurrency = Self::derive_invest_id(pool_id, tranche_id)?; - let payment_currency = Self::try_get_payment_currency(invest_id.clone(), currency_index)?; + let payment_currency = Self::try_get_currency_id(currency_index)?; // Mint additional amount of payment currency T::Tokens::mint_into(payment_currency, &investor, amount)?; @@ -134,10 +134,7 @@ where amount: ::Balance, ) -> DispatchResult { let invest_id: T::TrancheCurrency = Self::derive_invest_id(pool_id, tranche_id)?; - // NOTE: Even though we can assume this currency to have been used as payment, - // the trading pair needs to be registered for the opposite direction as hin - // case a swap from pool to foreign results from updating the `InvestState` - let payout_currency = Self::try_get_payout_currency(invest_id.clone(), currency_index)?; + let payout_currency = Self::try_get_currency_id(currency_index)?; T::ForeignInvestment::decrease_foreign_investment( &investor, @@ -187,7 +184,7 @@ where sending_domain: DomainAddress, ) -> DispatchResult { let invest_id: T::TrancheCurrency = Self::derive_invest_id(pool_id, tranche_id)?; - let payout_currency = Self::try_get_payout_currency(invest_id.clone(), currency_index)?; + let payout_currency = Self::try_get_currency_id(currency_index)?; // Transfer tranche tokens from `DomainLocator` account of // origination domain @@ -227,7 +224,7 @@ where ) -> DispatchResult { let invest_id: T::TrancheCurrency = Self::derive_invest_id(pool_id, tranche_id)?; let currency_u128 = currency_index.index; - let payout_currency = Self::try_get_payout_currency(invest_id.clone(), currency_index)?; + let payout_currency = Self::try_get_currency_id(currency_index)?; T::ForeignInvestment::decrease_foreign_redemption( &investor, @@ -304,7 +301,7 @@ where currency_index: GeneralCurrencyIndexOf, ) -> DispatchResult { let invest_id: T::TrancheCurrency = Self::derive_invest_id(pool_id, tranche_id)?; - let payment_currency = Self::try_get_payment_currency(invest_id.clone(), currency_index)?; + let payment_currency = Self::try_get_currency_id(currency_index)?; // NOTE: Dispatch of `ExecutedCollectInvest` is handled by // `ExecutedCollectInvestHook` @@ -331,7 +328,7 @@ where currency_index: GeneralCurrencyIndexOf, ) -> DispatchResult { let invest_id: T::TrancheCurrency = Self::derive_invest_id(pool_id, tranche_id)?; - let payout_currency = Self::try_get_payout_currency(invest_id.clone(), currency_index)?; + let payout_currency = Self::try_get_currency_id(currency_index)?; T::ForeignInvestment::collect_foreign_redemption(&investor, invest_id, payout_currency)?; diff --git a/pallets/liquidity-pools/src/lib.rs b/pallets/liquidity-pools/src/lib.rs index f5ec048378..3bb86a93a8 100644 --- a/pallets/liquidity-pools/src/lib.rs +++ b/pallets/liquidity-pools/src/lib.rs @@ -316,8 +316,6 @@ pub mod pallet { /// The asset is not a [LiquidityPoolsWrappedToken] and thus cannot be /// transferred via liquidity pools. AssetNotLiquidityPoolsWrappedToken, - /// The given asset does not match the currency of the pool. - AssetNotPoolCurrency, /// A pool could not be found. PoolNotFound, /// A tranche could not be found. @@ -328,30 +326,18 @@ pub mod pallet { /// This can occur if `TrancheNotFound` or if effectively /// the price for this tranche has not yet been set. MissingTranchePrice, - /// Router not set for a given domain. - MissingRouter, /// Transfer amount must be non-zero. InvalidTransferAmount, /// Senders balance is insufficient for transfer amount BalanceTooLow, /// A transfer to a non-whitelisted destination was attempted. UnauthorizedTransfer, - /// Failed to build Ethereum_Xcm call. - FailedToBuildEthereumXcmCall, - /// The origin of an incoming message is not in the allow-list. - InvalidIncomingMessageOrigin, /// Failed to decode an incoming message. InvalidIncomingMessage, /// The destination domain is invalid. InvalidDomain, /// The validity is in the past. InvalidTrancheInvestorValidity, - /// The derived currency from the provided GeneralCurrencyIndex is not - /// accepted as payment for the given pool. - InvalidPaymentCurrency, - /// The derived currency from the provided GeneralCurrencyIndex is not - /// accepted as payout for the given pool. - InvalidPayoutCurrency, /// The currency is not allowed to be transferred via LiquidityPools. InvalidTransferCurrency, /// The account derived from the [Domain] and [DomainAddress] has not @@ -721,7 +707,6 @@ pub mod pallet { pub fn allow_investment_currency( origin: OriginFor, pool_id: T::PoolId, - tranche_id: T::TrancheId, currency_id: CurrencyIdOf, ) -> DispatchResult { // TODO(future): In the future, should be permissioned by trait which @@ -738,8 +723,7 @@ pub mod pallet { Error::::NotPoolAdmin ); - let (currency, chain_id) = - Self::validate_investment_currency(pool_id, tranche_id, currency_id)?; + let (currency, chain_id) = Self::validate_investment_currency(currency_id)?; T::OutboundQueue::submit( who, @@ -829,7 +813,6 @@ pub mod pallet { pub fn disallow_investment_currency( origin: OriginFor, pool_id: T::PoolId, - tranche_id: T::TrancheId, currency_id: CurrencyIdOf, ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -843,8 +826,7 @@ pub mod pallet { Error::::NotPoolAdmin ); - let (currency, chain_id) = - Self::validate_investment_currency(pool_id, tranche_id, currency_id)?; + let (currency, chain_id) = Self::validate_investment_currency(currency_id)?; T::OutboundQueue::submit( who, @@ -945,62 +927,11 @@ pub mod pallet { Ok(TrancheCurrency::generate(pool_id, tranche_id)) } - /// Ensures that currency id can be derived from the - /// GeneralCurrencyIndex and that the former is an accepted payment - /// currency for the given investment id. - pub fn try_get_payment_currency( - invest_id: ::TrancheCurrency, - currency_index: GeneralCurrencyIndexOf, - ) -> Result, DispatchError> { - // retrieve currency id from general index - let currency = Self::try_get_currency_id(currency_index)?; - - ensure!( - T::ForeignInvestment::accepted_payment_currency(invest_id, currency), - Error::::InvalidPaymentCurrency - ); - - Ok(currency) - } - - /// Ensures that currency id can be derived from the - /// GeneralCurrencyIndex and that the former is an accepted payout - /// currency for the given investment id. - pub fn try_get_payout_currency( - invest_id: ::TrancheCurrency, - currency_index: GeneralCurrencyIndexOf, - ) -> Result, DispatchError> { - let currency = Self::try_get_currency_id(currency_index)?; - - ensure!( - T::ForeignInvestment::accepted_payout_currency(invest_id, currency), - Error::::InvalidPaymentCurrency - ); - - Ok(currency) - } - /// Performs multiple checks for the provided currency and returns its /// general index and the EVM chain ID associated with it. pub fn validate_investment_currency( - pool_id: T::PoolId, - tranche_id: T::TrancheId, currency_id: CurrencyIdOf, ) -> Result<(u128, EVMChainId), DispatchError> { - // Ensure currency is allowed as payment and payout currency for pool - let invest_id = Self::derive_invest_id(pool_id, tranche_id)?; - // Required for increasing and collecting investments - ensure!( - T::ForeignInvestment::accepted_payment_currency(invest_id.clone(), currency_id), - Error::::InvalidPaymentCurrency - ); - // Required for decreasing investments as well as increasing, decreasing and - // collecting redemptions - ensure!( - T::ForeignInvestment::accepted_payout_currency(invest_id, currency_id), - Error::::InvalidPayoutCurrency - ); - // Ensure the currency is enabled as pool_currency let metadata = T::AssetRegistry::metadata(¤cy_id).ok_or(Error::::AssetNotFound)?; diff --git a/pallets/order-book/src/benchmarking.rs b/pallets/order-book/src/benchmarking.rs index c37983756c..1cb72b2b07 100644 --- a/pallets/order-book/src/benchmarking.rs +++ b/pallets/order-book/src/benchmarking.rs @@ -113,16 +113,6 @@ where min_fulfillment + T::BalanceOut::from(5u32) * zeros } - pub fn add_trading_pair() { - Pallet::::add_trading_pair( - RawOrigin::Root.into(), - CURRENCY_IN.into(), - CURRENCY_OUT.into(), - Zero::zero(), - ) - .unwrap(); - } - pub fn place_order(account_out: &T::AccountId) -> T::OrderIdNonce { as TokenSwaps>::place_order( account_out.clone(), @@ -159,7 +149,6 @@ mod benchmarks { init_mocks(); let (account_out, _) = Helper::::setup(); - Helper::::add_trading_pair(); #[extrinsic_call] place_order( @@ -179,7 +168,6 @@ mod benchmarks { init_mocks(); let (account_out, _) = Helper::::setup(); - Helper::::add_trading_pair(); let order_id = Helper::::place_order(&account_out); let amount = Helper::::amount_out() - 1u32.into(); @@ -200,7 +188,6 @@ mod benchmarks { init_mocks(); let (account_out, _) = Helper::::setup(); - Helper::::add_trading_pair(); let order_id = Helper::::place_order(&account_out); #[extrinsic_call] @@ -215,7 +202,6 @@ mod benchmarks { init_mocks(); let (account_out, account_in) = Helper::::setup(); - Helper::::add_trading_pair(); let order_id = Helper::::place_order(&account_out); let amount = Helper::::amount_out(); @@ -227,33 +213,6 @@ mod benchmarks { Ok(()) } - #[benchmark] - fn add_trading_pair() -> Result<(), BenchmarkError> { - #[cfg(test)] - init_mocks(); - - #[extrinsic_call] - add_trading_pair( - RawOrigin::Root, - CURRENCY_IN.into(), - CURRENCY_OUT.into(), - 1u32.into(), - ); - - Ok(()) - } - - #[benchmark] - fn rm_trading_pair() -> Result<(), BenchmarkError> { - #[cfg(test)] - init_mocks(); - - #[extrinsic_call] - rm_trading_pair(RawOrigin::Root, CURRENCY_IN.into(), CURRENCY_OUT.into()); - - Ok(()) - } - #[benchmark] fn set_market_feeder() -> Result<(), BenchmarkError> { #[cfg(test)] diff --git a/pallets/order-book/src/lib.rs b/pallets/order-book/src/lib.rs index 87d091cb1c..997cacbfc7 100644 --- a/pallets/order-book/src/lib.rs +++ b/pallets/order-book/src/lib.rs @@ -255,23 +255,6 @@ pub mod pallet { #[pallet::storage] pub type OrderIdNonceStore = StorageValue<_, T::OrderIdNonce, ValueQuery>; - /// Storage of valid order pairs. - /// Stores: - /// - key1 -> CurrencyIn - /// - key2 -> CurrencyOut - /// - /// Stores the minimum `amount_out` of `currency_out` - #[pallet::storage] - pub type TradingPair = StorageDoubleMap< - _, - Twox64Concat, - T::CurrencyId, - Twox64Concat, - T::CurrencyId, - T::BalanceOut, - ResultQuery::InvalidTradingPair>, - >; - /// Stores the market feeder id used to set with market conversion ratios #[pallet::storage] pub type MarketFeederId = @@ -317,17 +300,6 @@ pub mod pallet { currency_out: T::CurrencyId, ratio: T::Ratio, }, - /// Event emitted when a valid trading pair is added. - TradingPairAdded { - currency_in: T::CurrencyId, - currency_out: T::CurrencyId, - min_order: T::BalanceOut, - }, - /// Event emitted when a valid trading pair is removed. - TradingPairRemoved { - currency_in: T::CurrencyId, - currency_out: T::CurrencyId, - }, /// Event emitted when a valid trading pair is removed. FeederChanged { feeder_id: T::FeederId }, } @@ -340,15 +312,9 @@ pub mod pallet { SameCurrencyIds, /// Error when an account cannot reserve or transfer the amount. BelowMinFulfillmentAmount, - /// Error when an order amount is too small - BelowMinOrderAmount, /// Error when an order is placed with a currency that is not in the /// `AssetRegistry`. InvalidCurrencyId, - /// Error when a trade is using an invalid trading pair. - /// Currently can happen when there is not a minimum order size - /// defined for the trading pair. - InvalidTradingPair, /// Error when an operation is attempted on an order id that is not in /// storage. OrderNotFound, @@ -384,7 +350,6 @@ pub mod pallet { currency_out, amount_out, ratio, - TradingPair::::get(¤cy_in, ¤cy_out)?, Self::min_fulfillment_amount(currency_out)?, )?; @@ -412,7 +377,6 @@ pub mod pallet { order.clone(), amount_out, ratio, - TradingPair::::get(&order.currency_in, &order.currency_out)?, Self::min_fulfillment_amount(order.currency_out)?, ) } @@ -448,58 +412,9 @@ pub mod pallet { Self::fulfill_order_with_amount(order, amount_out, account_id) } - /// Adds a valid trading pair. - #[pallet::call_index(4)] - #[pallet::weight(T::Weights::add_trading_pair())] - pub fn add_trading_pair( - origin: OriginFor, - currency_in: T::CurrencyId, - currency_out: T::CurrencyId, - min_order: T::BalanceOut, - ) -> DispatchResult { - T::AdminOrigin::ensure_origin(origin)?; - - // We do not check, we just overwrite as this is an admin action. - TradingPair::::insert(currency_in, currency_out, min_order); - - Self::deposit_event(Event::::TradingPairAdded { - currency_in, - currency_out, - min_order, - }); - - Ok(()) - } - - /// Removes a valid trading pair - // - // NOTE: We do not need to remove existing order as - // fulfilling orders is not checking for a valid trading pair. - // Existing orders will just fade out by by being canceled - // or fulfilled. - #[pallet::call_index(5)] - #[pallet::weight(T::Weights::rm_trading_pair())] - pub fn rm_trading_pair( - origin: OriginFor, - currency_in: T::CurrencyId, - currency_out: T::CurrencyId, - ) -> DispatchResult { - T::AdminOrigin::ensure_origin(origin)?; - - // We do not check, we just remove as this is an admin action. - TradingPair::::remove(currency_in, currency_out); - - Self::deposit_event(Event::::TradingPairRemoved { - currency_in, - currency_out, - }); - - Ok(()) - } - /// Set the market feeder for set market ratios. /// The origin must be the admin origin. - #[pallet::call_index(6)] + #[pallet::call_index(4)] #[pallet::weight(T::Weights::set_market_feeder())] pub fn set_market_feeder(origin: OriginFor, feeder_id: T::FeederId) -> DispatchResult { T::AdminOrigin::ensure_origin(origin)?; @@ -519,7 +434,6 @@ pub mod pallet { currency_out: T::CurrencyId, amount_out: T::BalanceOut, ratio: OrderRatio, - min_amount_out: T::BalanceOut, min_fulfillment_amount_out: T::BalanceOut, ) -> Result { let order_id = OrderIdNonceStore::::try_mutate(|n| { @@ -527,7 +441,10 @@ pub mod pallet { Ok::<_, DispatchError>(*n) })?; - Self::validate_amount(amount_out, min_fulfillment_amount_out, min_amount_out)?; + ensure!( + amount_out >= min_fulfillment_amount_out, + Error::::BelowMinFulfillmentAmount + ); ensure!(currency_in != currency_out, Error::::SameCurrencyIds); @@ -564,10 +481,12 @@ pub mod pallet { mut order: Order, amount_out: T::BalanceOut, ratio: OrderRatio, - min_amount_out: T::BalanceOut, min_fulfillment_amount_out: T::BalanceOut, ) -> DispatchResult { - Self::validate_amount(amount_out, min_fulfillment_amount_out, min_amount_out)?; + ensure!( + amount_out >= min_fulfillment_amount_out, + Error::::BelowMinFulfillmentAmount + ); match amount_out.cmp(&order.amount_out) { Ordering::Greater => { @@ -749,24 +668,6 @@ pub mod pallet { Ok(convert_balance_decimals(from_decimals, to_decimals, amount_in.into())?.into()) } - fn validate_amount( - amount_out: T::BalanceOut, - min_fulfillment_amount_out: T::BalanceOut, - min_order_amount: T::BalanceOut, - ) -> DispatchResult { - ensure!( - amount_out >= min_fulfillment_amount_out, - Error::::BelowMinFulfillmentAmount - ); - - ensure!( - amount_out >= min_order_amount, - Error::::BelowMinOrderAmount - ); - - Ok(()) - } - pub fn min_fulfillment_amount( currency: T::CurrencyId, ) -> Result { @@ -795,7 +696,6 @@ pub mod pallet { amount_out, ratio, T::BalanceOut::zero(), - T::BalanceOut::zero(), ) } @@ -827,13 +727,7 @@ pub mod pallet { ) -> DispatchResult { let order = Orders::::get(order_id)?; - Self::inner_update_order( - order, - amount_out, - ratio, - T::BalanceOut::zero(), - T::BalanceOut::zero(), - ) + Self::inner_update_order(order, amount_out, ratio, T::BalanceOut::zero()) } fn get_order_details( @@ -861,10 +755,6 @@ pub mod pallet { Self::fulfill_order_with_amount(order, buy_amount, account) } - fn valid_pair(currency_in: Self::CurrencyId, currency_out: Self::CurrencyId) -> bool { - TradingPair::::get(currency_in, currency_out).is_ok() - } - fn convert_by_market( currency_in: Self::CurrencyId, currency_out: Self::CurrencyId, @@ -878,20 +768,6 @@ pub mod pallet { let ratio = Self::market_ratio(currency_out, currency_in)?; Self::convert_with_ratio(currency_out, currency_in, ratio, amount_out) } - - #[cfg(feature = "runtime-benchmarks")] - fn add_trading_pair( - currency_in: T::CurrencyId, - currency_out: T::CurrencyId, - min_order: T::BalanceOut, - ) -> DispatchResult { - Self::add_trading_pair( - frame_support::dispatch::RawOrigin::Root.into(), - currency_in, - currency_out, - min_order, - ) - } } #[cfg(feature = "runtime-benchmarks")] diff --git a/pallets/order-book/src/mock.rs b/pallets/order-book/src/mock.rs index 3bf1b22182..9e445cad14 100644 --- a/pallets/order-book/src/mock.rs +++ b/pallets/order-book/src/mock.rs @@ -236,17 +236,6 @@ impl order_book::Config for Runtime { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut e = new_test_ext_no_pair(); - - e.execute_with(|| { - order_book::TradingPair::::insert(CURRENCY_B, CURRENCY_A, token_a(5)); - order_book::TradingPair::::insert(CURRENCY_A, CURRENCY_B, token_b(5)); - }); - - e -} - -pub fn new_test_ext_no_pair() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::default() .build_storage::() .unwrap(); diff --git a/pallets/order-book/src/tests.rs b/pallets/order-book/src/tests.rs index d71890f73a..b4fb0b4cc4 100644 --- a/pallets/order-book/src/tests.rs +++ b/pallets/order-book/src/tests.rs @@ -12,7 +12,7 @@ use cfg_traits::swaps::{OrderInfo, OrderRatio, Swap, SwapState, TokenSwaps}; use frame_support::{ - assert_err, assert_noop, assert_ok, + assert_err, assert_ok, traits::fungibles::{Inspect, InspectHold}, }; use sp_runtime::{DispatchError, FixedPointNumber}; @@ -91,75 +91,6 @@ mod util { } } -mod min_amount { - use super::*; - #[test] - fn adding_trading_pair_works() { - new_test_ext_no_pair().execute_with(|| { - assert_ok!(OrderBook::add_trading_pair( - RuntimeOrigin::root(), - CURRENCY_B, - CURRENCY_A, - token_a(100), - )); - assert_eq!( - TradingPair::::get(CURRENCY_B, CURRENCY_A).unwrap(), - token_a(100), - ); - assert!(OrderBook::valid_pair(CURRENCY_B, CURRENCY_A)); - }) - } - - #[test] - fn adding_trading_pair_fails() { - new_test_ext_no_pair().execute_with(|| { - assert_noop!( - OrderBook::add_trading_pair( - RuntimeOrigin::signed(FROM), - CURRENCY_B, - CURRENCY_A, - token_a(100), - ), - DispatchError::BadOrigin - ); - assert_noop!( - TradingPair::::get(CURRENCY_B, CURRENCY_A), - Error::::InvalidTradingPair - ); - assert!(!OrderBook::valid_pair(CURRENCY_B, CURRENCY_A)); - }) - } - - #[test] - fn removing_trading_pair_works() { - new_test_ext_no_pair().execute_with(|| { - assert_ok!(OrderBook::rm_trading_pair( - RuntimeOrigin::root(), - CURRENCY_B, - CURRENCY_A, - )); - assert_noop!( - TradingPair::::get(CURRENCY_B, CURRENCY_A), - Error::::InvalidTradingPair - ); - }) - } - - #[test] - fn removing_trading_pair_fails() { - new_test_ext().execute_with(|| { - assert_noop!( - OrderBook::rm_trading_pair(RuntimeOrigin::signed(FROM), CURRENCY_B, CURRENCY_A), - DispatchError::BadOrigin - ); - assert_eq!( - TradingPair::::get(CURRENCY_B, CURRENCY_A).unwrap(), - token_a(5) - ); - }) - } -} - #[test] fn create_order_works() { new_test_ext().execute_with(|| { @@ -213,47 +144,6 @@ fn create_order_without_required_min_fulfillment_amount() { }) } -#[test] -fn create_order_without_required_min_amount() { - new_test_ext().execute_with(|| { - assert_err!( - OrderBook::place_order( - RuntimeOrigin::signed(FROM), - CURRENCY_B, - CURRENCY_A, - token_a(3), - OrderRatio::Custom(DEFAULT_RATIO) - ), - Error::::BelowMinOrderAmount, - ); - - // The trait method version does not have min order amount check - assert_ok!(>::place_order( - FROM, - CURRENCY_B, - CURRENCY_A, - token_a(3), - OrderRatio::Custom(DEFAULT_RATIO) - )); - }); -} - -#[test] -fn create_order_requires_pair_with_defined_min() { - new_test_ext().execute_with(|| { - assert_err!( - OrderBook::place_order( - RuntimeOrigin::signed(FROM), - CURRENCY_B, - CURRENCY_X, - token_a(10), - OrderRatio::Custom(DEFAULT_RATIO), - ), - Error::::InvalidTradingPair - ); - }) -} - #[test] fn update_order_works() { new_test_ext().execute_with(|| { @@ -340,31 +230,6 @@ fn update_order_without_required_min_fulfillment_amount() { }) } -#[test] -fn update_order_without_required_min_amount() { - new_test_ext().execute_with(|| { - let order_id = util::create_default_order(token_a(10)); - - assert_err!( - OrderBook::update_order( - RuntimeOrigin::signed(FROM), - order_id, - token_a(3), - OrderRatio::Custom((1, 2).into()), - ), - Error::::BelowMinOrderAmount, - ); - - // The trait method version for updating order does not have min order amount - // check - assert_ok!(>::update_order( - order_id, - token_a(3), - OrderRatio::Custom((1, 2).into()) - )); - }) -} - #[test] fn update_order_without_placing_account() { new_test_ext().execute_with(|| { diff --git a/pallets/order-book/src/weights.rs b/pallets/order-book/src/weights.rs index f647d3cf1f..1323bb7df2 100644 --- a/pallets/order-book/src/weights.rs +++ b/pallets/order-book/src/weights.rs @@ -17,8 +17,6 @@ pub trait WeightInfo { fn update_order() -> Weight; fn cancel_order() -> Weight; fn fill_order() -> Weight; - fn add_trading_pair() -> Weight; - fn rm_trading_pair() -> Weight; fn set_market_feeder() -> Weight; } @@ -39,14 +37,6 @@ impl WeightInfo for () { Weight::zero() } - fn add_trading_pair() -> Weight { - Weight::zero() - } - - fn rm_trading_pair() -> Weight { - Weight::zero() - } - fn set_market_feeder() -> Weight { Weight::zero() } diff --git a/pallets/swaps/src/lib.rs b/pallets/swaps/src/lib.rs index 5dca9c9e81..d8002151e7 100644 --- a/pallets/swaps/src/lib.rs +++ b/pallets/swaps/src/lib.rs @@ -283,10 +283,6 @@ pub mod pallet { .unwrap_or_default()) } - fn valid_pair(currency_in: Self::CurrencyId, currency_out: Self::CurrencyId) -> bool { - T::OrderBook::valid_pair(currency_in, currency_out) - } - fn convert_by_market( currency_in: Self::CurrencyId, currency_out: Self::CurrencyId, diff --git a/pallets/token-mux/src/benchmarking.rs b/pallets/token-mux/src/benchmarking.rs index 893abb2845..8eb749ffae 100644 --- a/pallets/token-mux/src/benchmarking.rs +++ b/pallets/token-mux/src/benchmarking.rs @@ -38,7 +38,6 @@ fn init_mocks() { use crate::{mock::MockTokenSwaps, tests::ORDER_ID}; MockTokenSwaps::mock_place_order(|_, _, _, _, _| Ok(ORDER_ID)); - MockTokenSwaps::mock_add_trading_pair(|_, _, _| Ok(())); MockTokenSwaps::mock_get_order_details(|_| None); } #[cfg(test)] @@ -124,11 +123,6 @@ where .unwrap(); } - fn add_trading_pair(currency_out: CurrencyId, currency_in: CurrencyId) { - T::OrderBook::add_trading_pair(currency_in.into(), currency_out.into(), Zero::zero()) - .unwrap(); - } - fn place_order( currency_out: CurrencyId, currency_in: CurrencyId, @@ -162,8 +156,6 @@ where /// Registers currencies, registers trading pair and sets up account. pub fn swap_setup() -> T::AccountId { Self::setup_currencies(); - Self::add_trading_pair(FOREIGN_CURRENCY, LOCAL_CURRENCY); - Self::add_trading_pair(LOCAL_CURRENCY, FOREIGN_CURRENCY); Self::setup_account() } } diff --git a/runtime/altair/src/weights/pallet_order_book.rs b/runtime/altair/src/weights/pallet_order_book.rs index 17ece775fb..f5746a38d9 100644 --- a/runtime/altair/src/weights/pallet_order_book.rs +++ b/runtime/altair/src/weights/pallet_order_book.rs @@ -120,28 +120,6 @@ impl pallet_order_book::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(9)) } - /// Storage: OrderBook TradingPair (r:0 w:1) - /// Proof: OrderBook TradingPair (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - fn add_trading_pair() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 13_605_000 picoseconds. - Weight::from_parts(14_127_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: OrderBook TradingPair (r:0 w:1) - /// Proof: OrderBook TradingPair (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - fn rm_trading_pair() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 14_937_000 picoseconds. - Weight::from_parts(15_349_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(1)) - } fn set_market_feeder() -> Weight { // Pending to be generated Weight::zero() diff --git a/runtime/centrifuge/src/migrations.rs b/runtime/centrifuge/src/migrations.rs index b50374d875..1d42f68632 100644 --- a/runtime/centrifuge/src/migrations.rs +++ b/runtime/centrifuge/src/migrations.rs @@ -63,41 +63,12 @@ pub type UpgradeCentrifuge1025 = ( PoolCurrencyAnemoy, LocalCurrencyIdUsdc, >, - // Register trading pairs one by one - runtime_common::migrations::local_currency::add_bidirectional_trading_pair::Migration< - super::Runtime, - UsdcDot, - LocalCurrencyIdUsdc, - MinOrderAmount, - >, - runtime_common::migrations::local_currency::add_bidirectional_trading_pair::Migration< - super::Runtime, - UsdcEth, - LocalCurrencyIdUsdc, - MinOrderAmount, - >, - runtime_common::migrations::local_currency::add_bidirectional_trading_pair::Migration< - super::Runtime, - UsdcBase, - LocalCurrencyIdUsdc, - MinOrderAmount, - >, - runtime_common::migrations::local_currency::add_bidirectional_trading_pair::Migration< - super::Runtime, - UsdcArb, - LocalCurrencyIdUsdc, - MinOrderAmount, - >, - runtime_common::migrations::local_currency::add_bidirectional_trading_pair::Migration< - super::Runtime, - UsdcCelo, - LocalCurrencyIdUsdc, - MinOrderAmount, - >, // Removes unused migration pallet runtime_common::migrations::nuke::KillPallet, // Sets account codes for all precompiles runtime_common::migrations::precompile_account_codes::Migration, + // Bumps storage version from 0 to 1 + runtime_common::migrations::nuke::ResetPallet, ); // Copyright 2021 Centrifuge Foundation (centrifuge.io). diff --git a/runtime/centrifuge/src/weights/pallet_order_book.rs b/runtime/centrifuge/src/weights/pallet_order_book.rs index 637bc10cab..febbfa10b2 100644 --- a/runtime/centrifuge/src/weights/pallet_order_book.rs +++ b/runtime/centrifuge/src/weights/pallet_order_book.rs @@ -120,28 +120,6 @@ impl pallet_order_book::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(9)) } - /// Storage: OrderBook TradingPair (r:0 w:1) - /// Proof: OrderBook TradingPair (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - fn add_trading_pair() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 13_175_000 picoseconds. - Weight::from_parts(13_796_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: OrderBook TradingPair (r:0 w:1) - /// Proof: OrderBook TradingPair (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - fn rm_trading_pair() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 14_727_000 picoseconds. - Weight::from_parts(15_068_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(1)) - } fn set_market_feeder() -> Weight { // Pending to be generated Weight::zero() diff --git a/runtime/common/src/migrations/local_currency.rs b/runtime/common/src/migrations/local_currency.rs index d3f3ee222f..26907eebeb 100644 --- a/runtime/common/src/migrations/local_currency.rs +++ b/runtime/common/src/migrations/local_currency.rs @@ -385,99 +385,3 @@ pub mod migrate_pool_currency { } } } - -pub mod add_bidirectional_trading_pair { - use cfg_primitives::Balance; - #[cfg(feature = "try-runtime")] - use cfg_traits::swaps::TokenSwaps; - use frame_support::dispatch::RawOrigin; - #[cfg(feature = "try-runtime")] - use sp_std::vec::Vec; - - use super::*; - - const LOG_PREFIX: &str = "AddBidirectionalTradingPair"; - - pub struct Migration( - sp_std::marker::PhantomData<(T, CurrencyOne, CurrencyTwo, MinOrderAmount)>, - ); - - impl OnRuntimeUpgrade - for Migration - where - T: pallet_order_book::Config< - CurrencyId = CurrencyId, - BalanceIn = Balance, - BalanceOut = Balance, - >, - CurrencyOne: Get, - CurrencyTwo: Get, - MinOrderAmount: Get, - { - fn on_runtime_upgrade() -> Weight { - pallet_order_book::Pallet::::add_trading_pair( - RawOrigin::Root.into(), - CurrencyTwo::get(), - CurrencyOne::get(), - MinOrderAmount::get(), - ) - .map_err(|e| { - log::info!( - "{LOG_PREFIX} Failed to add trading pair from {:?} to {:?} due to error {:?}", - CurrencyTwo::get(), - CurrencyOne::get(), - e - ); - }) - .ok(); - pallet_order_book::Pallet::::add_trading_pair( - RawOrigin::Root.into(), - CurrencyOne::get(), - CurrencyTwo::get(), - MinOrderAmount::get(), - ) - .map_err(|e| { - log::info!( - "{LOG_PREFIX} Failed to add trading pair from {:?} to {:?} due to error {:?}", - CurrencyOne::get(), - CurrencyTwo::get(), - e - ); - }) - .ok(); - - log::info!("{LOG_PREFIX} UPGRADE: Finished"); - T::DbWeight::get().writes(2) - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, DispatchError> { - assert!(!pallet_order_book::Pallet::::valid_pair( - CurrencyTwo::get(), - CurrencyOne::get() - )); - assert!(!pallet_order_book::Pallet::::valid_pair( - CurrencyOne::get(), - CurrencyTwo::get() - )); - log::info!("{LOG_PREFIX} PRE UPGRADE: Finished"); - - Ok(vec![]) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(_: Vec) -> Result<(), DispatchError> { - assert!(pallet_order_book::Pallet::::valid_pair( - CurrencyTwo::get(), - CurrencyOne::get() - )); - assert!(pallet_order_book::Pallet::::valid_pair( - CurrencyOne::get(), - CurrencyTwo::get() - )); - log::info!("{LOG_PREFIX} POST UPGRADE: Finished"); - - Ok(()) - } - } -} diff --git a/runtime/development/src/weights/pallet_order_book.rs b/runtime/development/src/weights/pallet_order_book.rs index 1b9de3e7ec..6fa4ddb383 100644 --- a/runtime/development/src/weights/pallet_order_book.rs +++ b/runtime/development/src/weights/pallet_order_book.rs @@ -120,28 +120,6 @@ impl pallet_order_book::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(9)) } - /// Storage: OrderBook TradingPair (r:0 w:1) - /// Proof: OrderBook TradingPair (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - fn add_trading_pair() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 13_405_000 picoseconds. - Weight::from_parts(13_857_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: OrderBook TradingPair (r:0 w:1) - /// Proof: OrderBook TradingPair (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - fn rm_trading_pair() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 14_507_000 picoseconds. - Weight::from_parts(15_168_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(1)) - } fn set_market_feeder() -> Weight { // Pending to be generated Weight::zero() diff --git a/runtime/integration-tests/src/generic/cases/liquidity_pools.rs b/runtime/integration-tests/src/generic/cases/liquidity_pools.rs index 8c1f25fadb..34fae9b269 100644 --- a/runtime/integration-tests/src/generic/cases/liquidity_pools.rs +++ b/runtime/integration-tests/src/generic/cases/liquidity_pools.rs @@ -3,7 +3,7 @@ use cfg_primitives::{ TrancheId, }; use cfg_traits::{ - investments::{ForeignInvestment, Investment, OrderManager, TrancheCurrency}, + investments::{Investment, OrderManager, TrancheCurrency}, liquidity_pools::{Codec, InboundQueue, OutboundQueue}, IdentityCurrencyConversion, Permissions, PoolInspect, PoolMutate, Seconds, }; @@ -832,49 +832,12 @@ mod development { ); if enable_foreign_to_pool_pair { - assert!( - !pallet_foreign_investments::Pallet::::accepted_payment_currency( - default_investment_id::(), - foreign_currency - ) - ); - assert_ok!(pallet_order_book::Pallet::::add_trading_pair( - ::RuntimeOrigin::root(), - pool_currency, - foreign_currency, - 1 - )); - assert!( - pallet_foreign_investments::Pallet::::accepted_payment_currency( - default_investment_id::(), - foreign_currency - ) - ); crate::generic::utils::oracle::feed_from_root::( OracleKey::ConversionRatio(foreign_currency, pool_currency), Ratio::one(), ); } if enable_pool_to_foreign_pair { - assert!( - !pallet_foreign_investments::Pallet::::accepted_payout_currency( - default_investment_id::(), - foreign_currency - ) - ); - - assert_ok!(pallet_order_book::Pallet::::add_trading_pair( - ::RuntimeOrigin::root(), - foreign_currency, - pool_currency, - 1 - )); - assert!( - pallet_foreign_investments::Pallet::::accepted_payout_currency( - default_investment_id::(), - foreign_currency - ) - ); crate::generic::utils::oracle::feed_from_root::( OracleKey::ConversionRatio(pool_currency, foreign_currency), Ratio::one(), @@ -1383,7 +1346,6 @@ mod development { pallet_liquidity_pools::Pallet::::allow_investment_currency( RawOrigin::Signed(Keyring::Bob.into()).into(), pool_id, - default_tranche_id::(pool_id), currency_id, ) ); @@ -1392,7 +1354,6 @@ mod development { pallet_liquidity_pools::Pallet::::allow_investment_currency( RawOrigin::Signed(Keyring::Charlie.into()).into(), pool_id, - default_tranche_id::(pool_id), currency_id, ), pallet_liquidity_pools::Error::::NotPoolAdmin @@ -1423,8 +1384,6 @@ mod development { pallet_liquidity_pools::Pallet::::allow_investment_currency( RawOrigin::Signed(Keyring::Bob.into()).into(), pool_id, - // Tranche id is arbitrary in this case as pool does not exist - [0u8; 16], currency_id, ), pallet_liquidity_pools::Error::::NotPoolAdmin @@ -1450,38 +1409,8 @@ mod development { // Create pool create_currency_pool::(pool_id, currency_id, 10_000 * decimals(12)); - // Should fail if asset is not payment currency - assert_noop!( - pallet_liquidity_pools::Pallet::::allow_investment_currency( - RawOrigin::Signed(Keyring::Bob.into()).into(), - pool_id, - default_tranche_id::(pool_id), - ausd_currency_id, - ), - pallet_liquidity_pools::Error::::InvalidPaymentCurrency - ); - - // Allow as payment but not payout currency - assert_ok!(pallet_order_book::Pallet::::add_trading_pair( - ::RuntimeOrigin::root(), - currency_id, - ausd_currency_id, - Default::default() - )); - - // Should fail if asset is not payout currency enable_liquidity_pool_transferability::(ausd_currency_id); - assert_noop!( - pallet_liquidity_pools::Pallet::::allow_investment_currency( - RawOrigin::Signed(Keyring::Bob.into()).into(), - pool_id, - default_tranche_id::(pool_id), - ausd_currency_id, - ), - pallet_liquidity_pools::Error::::InvalidPayoutCurrency - ); - // Should fail if currency is not liquidityPools transferable assert_ok!(orml_asset_registry::Pallet::::update_asset( ::RuntimeOrigin::root(), @@ -1503,7 +1432,6 @@ mod development { pallet_liquidity_pools::Pallet::::allow_investment_currency( RawOrigin::Signed(Keyring::Bob.into()).into(), pool_id, - default_tranche_id::(pool_id), currency_id, ), pallet_liquidity_pools::Error::::AssetNotLiquidityPoolsTransferable @@ -1530,7 +1458,6 @@ mod development { pallet_liquidity_pools::Pallet::::allow_investment_currency( RawOrigin::Signed(Keyring::Bob.into()).into(), pool_id, - default_tranche_id::(pool_id), currency_id, ), pallet_liquidity_pools::Error::::AssetNotLiquidityPoolsWrappedToken @@ -1556,7 +1483,6 @@ mod development { pallet_liquidity_pools::Pallet::::allow_investment_currency( RawOrigin::Signed(Keyring::Bob.into()).into(), pool_id, - default_tranche_id::(pool_id), currency_id, ), pallet_liquidity_pools::Error::::AssetNotLiquidityPoolsWrappedToken @@ -1613,7 +1539,6 @@ mod development { pallet_liquidity_pools::Pallet::::disallow_investment_currency( RawOrigin::Signed(Keyring::Bob.into()).into(), pool_id, - default_tranche_id::(pool_id), currency_id, ) ); @@ -1622,7 +1547,6 @@ mod development { pallet_liquidity_pools::Pallet::::disallow_investment_currency( RawOrigin::Signed(Keyring::Charlie.into()).into(), pool_id, - default_tranche_id::(pool_id), currency_id, ), pallet_liquidity_pools::Error::::NotPoolAdmin @@ -1653,8 +1577,6 @@ mod development { pallet_liquidity_pools::Pallet::::disallow_investment_currency( RawOrigin::Signed(Keyring::Bob.into()).into(), pool_id, - // Tranche id is arbitrary in this case as pool does not exist - [0u8; 16], currency_id, ), pallet_liquidity_pools::Error::::NotPoolAdmin @@ -1680,38 +1602,8 @@ mod development { // Create pool create_currency_pool::(pool_id, currency_id, 10_000 * decimals(12)); - // Should fail if asset is not payment currency - assert_noop!( - pallet_liquidity_pools::Pallet::::disallow_investment_currency( - RawOrigin::Signed(Keyring::Bob.into()).into(), - pool_id, - default_tranche_id::(pool_id), - ausd_currency_id, - ), - pallet_liquidity_pools::Error::::InvalidPaymentCurrency - ); - - // Allow as payment but not payout currency - assert_ok!(pallet_order_book::Pallet::::add_trading_pair( - ::RuntimeOrigin::root(), - currency_id, - ausd_currency_id, - Default::default() - )); - - // Should fail if asset is not payout currency enable_liquidity_pool_transferability::(ausd_currency_id); - assert_noop!( - pallet_liquidity_pools::Pallet::::disallow_investment_currency( - RawOrigin::Signed(Keyring::Bob.into()).into(), - pool_id, - default_tranche_id::(pool_id), - ausd_currency_id, - ), - pallet_liquidity_pools::Error::::InvalidPayoutCurrency - ); - // Should fail if currency is not liquidityPools transferable assert_ok!(orml_asset_registry::Pallet::::update_asset( ::RuntimeOrigin::root(), @@ -1733,7 +1625,6 @@ mod development { pallet_liquidity_pools::Pallet::::disallow_investment_currency( RawOrigin::Signed(Keyring::Bob.into()).into(), pool_id, - default_tranche_id::(pool_id), currency_id, ), pallet_liquidity_pools::Error::::AssetNotLiquidityPoolsTransferable @@ -1760,7 +1651,6 @@ mod development { pallet_liquidity_pools::Pallet::::disallow_investment_currency( RawOrigin::Signed(Keyring::Bob.into()).into(), pool_id, - default_tranche_id::(pool_id), currency_id, ), pallet_liquidity_pools::Error::::AssetNotLiquidityPoolsWrappedToken @@ -1786,7 +1676,6 @@ mod development { pallet_liquidity_pools::Pallet::::disallow_investment_currency( RawOrigin::Signed(Keyring::Bob.into()).into(), pool_id, - default_tranche_id::(pool_id), currency_id, ), pallet_liquidity_pools::Error::::AssetNotLiquidityPoolsWrappedToken