diff --git a/libs/mocks/src/pools.rs b/libs/mocks/src/pools.rs index 23f6da4fa7..7d0f67e0fe 100644 --- a/libs/mocks/src/pools.rs +++ b/libs/mocks/src/pools.rs @@ -1,8 +1,7 @@ #[frame_support::pallet(dev_mode)] pub mod pallet { use cfg_traits::{ - investments::InvestmentAccountant, PoolInspect, PoolReserve, PriceValue, Seconds, - TrancheTokenPrice, + investments::InvestmentAccountant, PoolInspect, PoolReserve, Seconds, TrancheTokenPrice, }; use cfg_types::investments::InvestmentInfo; use frame_support::pallet_prelude::*; @@ -86,6 +85,12 @@ pub mod pallet { register_call!(move |(a, b, c, d)| f(a, b, c, d)); } + pub fn mock_get_price( + f: impl Fn(T::PoolId, T::TrancheId) -> Option<(T::BalanceRatio, Seconds)> + 'static, + ) { + register_call!(move |(a, b)| f(a, b)); + } + #[allow(non_snake_case)] pub fn mock_InvestmentAccountant_deposit( f: impl Fn(&T::AccountId, T::TrancheCurrency, T::Balance) -> DispatchResult + 'static, @@ -168,10 +173,7 @@ pub mod pallet { type PoolId = T::PoolId; type TrancheId = T::TrancheId; - fn get( - a: T::PoolId, - b: T::TrancheId, - ) -> Option> { + fn get_price(a: T::PoolId, b: T::TrancheId) -> Option<(T::BalanceRatio, Seconds)> { execute_call!((a, b)) } } diff --git a/libs/traits/src/lib.rs b/libs/traits/src/lib.rs index ec97102eb5..d7eb9042b0 100644 --- a/libs/traits/src/lib.rs +++ b/libs/traits/src/lib.rs @@ -96,10 +96,10 @@ pub trait TrancheTokenPrice { type BalanceRatio; type Moment; - fn get( + fn get_price( pool_id: Self::PoolId, tranche_id: Self::TrancheId, - ) -> Option>; + ) -> Option<(Self::BalanceRatio, Self::Moment)>; } /// Variants for valid Pool updates to send out as events @@ -206,31 +206,6 @@ pub trait PoolWriteOffPolicyMutate { fn worst_case_policy() -> Self::Policy; } -/// A trait that can be used to retrieve the current price for a currency -pub struct CurrencyPair { - pub base: CurrencyId, - pub quote: CurrencyId, -} - -pub struct PriceValue { - pub pair: CurrencyPair, - pub price: Rate, - pub last_updated: Moment, -} - -pub trait CurrencyPrice { - type Rate; - type Moment; - - /// Retrieve the latest price of `base` currency, denominated in the `quote` - /// currency If `quote` currency is not passed, then the default `quote` - /// currency is used (when possible) - fn get_latest( - base: CurrencyId, - quote: Option, - ) -> Option>; -} - pub trait Permissions { type Scope; type Role; diff --git a/pallets/liquidity-pools/src/contract.rs b/pallets/liquidity-pools/src/contract.rs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/pallets/liquidity-pools/src/lib.rs b/pallets/liquidity-pools/src/lib.rs index 7fe1545d71..9e450c3411 100644 --- a/pallets/liquidity-pools/src/lib.rs +++ b/pallets/liquidity-pools/src/lib.rs @@ -43,6 +43,7 @@ use core::convert::TryFrom; use cfg_traits::{ liquidity_pools::{InboundQueue, OutboundQueue}, + swaps::TokenSwaps, PreConditions, }; use cfg_types::{ @@ -60,7 +61,7 @@ use frame_support::{ use orml_traits::asset_registry::{self, Inspect as _}; pub use pallet::*; use sp_runtime::{ - traits::{AtLeast32BitUnsigned, Convert}, + traits::{AtLeast32BitUnsigned, Convert, EnsureMul}, FixedPointNumber, SaturatedConversion, }; use sp_std::{convert::TryInto, vec}; @@ -271,6 +272,13 @@ pub mod pallet { Result = DispatchResult, >; + /// Type used to retrive market ratio information about currencies + type MarketRatio: TokenSwaps< + Self::AccountId, + CurrencyId = Self::CurrencyId, + Ratio = Self::BalanceRatio, + >; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -435,12 +443,15 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin.clone())?; - // TODO(future): Once we diverge from 1-to-1 conversions for foreign and pool - // currencies, this price must be first converted into the currency_id and then - // re-denominated to 18 decimals (i.e. `Ratio` precision) - let price_value = T::TrancheTokenPrice::get(pool_id, tranche_id) + let (price, computed_at) = T::TrancheTokenPrice::get_price(pool_id, tranche_id) .ok_or(Error::::MissingTranchePrice)?; + let foreign_price = T::MarketRatio::market_ratio( + currency_id, + T::PoolInspect::currency_for(pool_id).ok_or(Error::::PoolNotFound)?, + )? + .ensure_mul(price)?; + // Check that the registered asset location matches the destination match Self::try_get_wrapped_token(¤cy_id)? { LiquidityPoolsWrappedToken::EVM { chain_id, .. } => { @@ -459,8 +470,8 @@ pub mod pallet { pool_id: pool_id.into(), tranche_id: tranche_id.into(), currency, - price: price_value.price.into_inner(), - computed_at: price_value.last_updated, + price: foreign_price.into_inner(), + computed_at, }, )?; diff --git a/pallets/liquidity-pools/src/mock.rs b/pallets/liquidity-pools/src/mock.rs index 47d8bd14a4..3d120e2e53 100644 --- a/pallets/liquidity-pools/src/mock.rs +++ b/pallets/liquidity-pools/src/mock.rs @@ -27,6 +27,7 @@ frame_support::construct_runtime!( DomainAddressToAccountId: cfg_mocks::converter::pallet::, DomainAccountToDomainAddress: cfg_mocks::converter::pallet::, TransferFilter: cfg_mocks::pre_conditions::pallet, + MarketRatio: cfg_mocks::token_swaps::pallet, Tokens: orml_tokens, LiquidityPools: pallet_liquidity_pools, } @@ -91,6 +92,14 @@ impl cfg_mocks::pre_conditions::pallet::Config for Runtime { type Result = DispatchResult; } +impl cfg_mocks::token_swaps::pallet::Config for Runtime { + type BalanceIn = Balance; + type BalanceOut = Balance; + type CurrencyId = CurrencyId; + type OrderId = (); + type Ratio = Ratio; +} + parameter_type_with_key! { pub ExistentialDeposits: |_currency_id: CurrencyId| -> Balance { Default::default() @@ -125,6 +134,7 @@ impl pallet_liquidity_pools::Config for Runtime { type DomainAddressToAccountId = DomainAddressToAccountId; type ForeignInvestment = ForeignInvestment; type GeneralCurrencyPrefix = CurrencyPrefix; + type MarketRatio = MarketRatio; type OutboundQueue = Gateway; type Permission = Permissions; type PoolId = PoolId; diff --git a/pallets/liquidity-pools/src/tests.rs b/pallets/liquidity-pools/src/tests.rs index d736b7a975..689f2cbed7 100644 --- a/pallets/liquidity-pools/src/tests.rs +++ b/pallets/liquidity-pools/src/tests.rs @@ -3,7 +3,7 @@ use cfg_traits::{liquidity_pools::InboundQueue, Millis}; use cfg_types::{ domain_address::DomainAddress, permissions::{PermissionScope, PoolRole, Role}, - tokens::{AssetMetadata, CrossChainTransferability, CurrencyId, CustomMetadata}, + tokens::{AssetMetadata, CrossChainTransferability, CurrencyId, CustomMetadata, LocalAssetId}, }; use cfg_utils::vec_to_fixed_array; use frame_support::{ @@ -13,7 +13,7 @@ use frame_support::{ PalletInfo as _, }, }; -use sp_runtime::{DispatchError, TokenError}; +use sp_runtime::{traits::Saturating, DispatchError, TokenError}; use staging_xcm::{ v4::{Junction::*, Location, NetworkId}, VersionedLocation, @@ -28,6 +28,7 @@ const CONTRACT_ACCOUNT_ID: AccountId = AccountId::new([1; 32]); const EVM_ADDRESS: DomainAddress = DomainAddress::EVM(CHAIN_ID, CONTRACT_ACCOUNT); const AMOUNT: Balance = 100; const CURRENCY_ID: CurrencyId = CurrencyId::ForeignAsset(1); +const POOL_CURRENCY_ID: CurrencyId = CurrencyId::LocalAsset(LocalAssetId(1)); const POOL_ID: PoolId = 1; const TRANCHE_ID: TrancheId = [1; 16]; const NOW: Millis = 0; @@ -35,6 +36,8 @@ const NAME: &[u8] = b"Token name"; const SYMBOL: &[u8] = b"Token symbol"; const DECIMALS: u8 = 6; const TRANCHE_CURRENCY: CurrencyId = CurrencyId::Tranche(POOL_ID, TRANCHE_ID); +const TRANCHE_TOKEN_PRICE: Ratio = Ratio::from_rational(10, 1); +const MARKET_RATIO: Ratio = Ratio::from_rational(2, 1); mod util { use super::*; @@ -118,7 +121,7 @@ mod transfer { }) } - mod erroring_out_when { + mod erroring_out { use super::*; #[test] @@ -326,7 +329,7 @@ mod transfer_tranche_tokens { }) } - mod erroring_out_when { + mod erroring_out { use super::*; #[test] @@ -461,7 +464,7 @@ mod add_pool { }) } - mod erroring_out_when { + mod erroring_out { use super::*; #[test] @@ -540,7 +543,7 @@ mod add_tranche { }) } - mod erroring_out_when { + mod erroring_out { use super::*; #[test] @@ -619,6 +622,131 @@ mod add_tranche { } } +mod update_token_price { + use super::*; + + #[test] + fn success() { + System::externalities().execute_with(|| { + Pools::mock_get_price(|_, _| Some((TRANCHE_TOKEN_PRICE, 1234))); + Pools::mock_currency_for(|_| Some(POOL_CURRENCY_ID)); + MarketRatio::mock_market_ratio(|target, origin| { + assert_eq!(target, CURRENCY_ID); + assert_eq!(origin, POOL_CURRENCY_ID); + Ok(MARKET_RATIO) + }); + AssetRegistry::mock_metadata(|_| Some(util::wrapped_transferable_metadata())); + Gateway::mock_submit(|sender, destination, msg| { + assert_eq!(sender, ALICE); + assert_eq!(destination, EVM_ADDRESS.domain()); + assert_eq!( + msg, + Message::UpdateTrancheTokenPrice { + pool_id: POOL_ID, + tranche_id: TRANCHE_ID, + currency: util::currency_index(CURRENCY_ID), + price: TRANCHE_TOKEN_PRICE + .saturating_mul(MARKET_RATIO) + .into_inner(), + computed_at: 1234 + } + ); + Ok(()) + }); + + assert_ok!(LiquidityPools::update_token_price( + RuntimeOrigin::signed(ALICE), + POOL_ID, + TRANCHE_ID, + CURRENCY_ID, + EVM_ADDRESS.domain(), + )); + }) + } + + mod erroring_out { + use super::*; + + #[test] + fn with_missing_tranche_price() { + System::externalities().execute_with(|| { + Pools::mock_get_price(|_, _| None); + + assert_noop!( + LiquidityPools::update_token_price( + RuntimeOrigin::signed(ALICE), + POOL_ID, + TRANCHE_ID, + CURRENCY_ID, + EVM_ADDRESS.domain(), + ), + Error::::MissingTranchePrice, + ); + }) + } + + #[test] + fn with_wrong_pool() { + System::externalities().execute_with(|| { + Pools::mock_get_price(|_, _| Some((TRANCHE_TOKEN_PRICE, 1234))); + Pools::mock_currency_for(|_| None); + + assert_noop!( + LiquidityPools::update_token_price( + RuntimeOrigin::signed(ALICE), + POOL_ID, + TRANCHE_ID, + CURRENCY_ID, + EVM_ADDRESS.domain(), + ), + Error::::PoolNotFound, + ); + }) + } + + #[test] + fn with_no_market_ratio() { + System::externalities().execute_with(|| { + Pools::mock_get_price(|_, _| Some((TRANCHE_TOKEN_PRICE, 1234))); + Pools::mock_currency_for(|_| Some(POOL_CURRENCY_ID)); + MarketRatio::mock_market_ratio(|_, _| Err(DispatchError::Other(""))); + + assert_noop!( + LiquidityPools::update_token_price( + RuntimeOrigin::signed(ALICE), + POOL_ID, + TRANCHE_ID, + CURRENCY_ID, + EVM_ADDRESS.domain(), + ), + DispatchError::Other("") + ); + }) + } + + #[test] + fn with_no_transferible_asset() { + System::externalities().execute_with(|| { + Pools::mock_get_price(|_, _| Some((TRANCHE_TOKEN_PRICE, 1234))); + Pools::mock_currency_for(|_| Some(POOL_CURRENCY_ID)); + MarketRatio::mock_market_ratio(|_, _| Ok(MARKET_RATIO)); + AssetRegistry::mock_metadata(|_| Some(util::default_metadata())); + + assert_noop!( + LiquidityPools::update_token_price( + RuntimeOrigin::signed(ALICE), + POOL_ID, + TRANCHE_ID, + CURRENCY_ID, + EVM_ADDRESS.domain(), + ), + Error::::AssetNotLiquidityPoolsTransferable, + ); + }) + } + } +} + #[test] fn receiving_output_message() { System::externalities().execute_with(|| { diff --git a/pallets/pool-system/src/impls.rs b/pallets/pool-system/src/impls.rs index da2a469df2..cf80f26ec8 100644 --- a/pallets/pool-system/src/impls.rs +++ b/pallets/pool-system/src/impls.rs @@ -14,7 +14,7 @@ use cfg_traits::{ changes::ChangeGuard, fee::{PoolFeeBucket, PoolFeesMutate}, investments::{InvestmentAccountant, TrancheCurrency}, - CurrencyPair, PoolUpdateGuard, PriceValue, TrancheTokenPrice, UpdateState, + PoolUpdateGuard, TrancheTokenPrice, UpdateState, }; use cfg_types::{epoch::EpochState, investments::InvestmentInfo, pools::PoolFeeInfo}; use frame_support::traits::{ @@ -62,10 +62,10 @@ impl TrancheTokenPrice for Pallet { type PoolId = T::PoolId; type TrancheId = T::TrancheId; - fn get( + fn get_price( pool_id: Self::PoolId, tranche_id: Self::TrancheId, - ) -> Option> { + ) -> Option<(T::BalanceRatio, Seconds)> { let now = T::Time::now(); let mut pool = Pool::::get(pool_id)?; @@ -84,21 +84,9 @@ impl TrancheTokenPrice for Pallet { .calculate_prices::(total_assets, now) .ok()?; - let base = pool - .tranches - .tranche_currency(TrancheLoc::Id(tranche_id))? - .into(); - let price = prices.get(tranche_index).cloned()?; - Some(PriceValue { - pair: CurrencyPair { - base, - quote: pool.currency, - }, - price, - last_updated: nav_last_updated, - }) + Some((price, nav_last_updated)) } } diff --git a/pallets/pool-system/src/mock.rs b/pallets/pool-system/src/mock.rs index da4ec270df..e4423bca61 100644 --- a/pallets/pool-system/src/mock.rs +++ b/pallets/pool-system/src/mock.rs @@ -26,8 +26,6 @@ use cfg_types::{ time::TimeProvider, tokens::{CurrencyId, CustomMetadata, TrancheCurrency}, }; -#[cfg(feature = "runtime-benchmarks")] -use frame_support::dispatch::RawOrigin; use frame_support::{ assert_ok, derive_impl, parameter_types, traits::{Contains, EnsureOriginWithArg, Hooks, PalletInfoAccess, SortedMembers}, diff --git a/pallets/pool-system/src/tests/mod.rs b/pallets/pool-system/src/tests/mod.rs index d3554142d7..7e6fbd82e9 100644 --- a/pallets/pool-system/src/tests/mod.rs +++ b/pallets/pool-system/src/tests/mod.rs @@ -624,9 +624,9 @@ fn epoch() { ::AccountId, ::CurrencyId, - >>::get(0, SeniorTrancheId::get()) + >>::get_price(0, SeniorTrancheId::get()) .unwrap() - .price, + .0, Quantity::one() ); @@ -762,9 +762,9 @@ fn epoch() { let senior_price = ::AccountId, ::CurrencyId, - >>::get(0, SeniorTrancheId::get()) + >>::get_price(0, SeniorTrancheId::get()) .unwrap() - .price; + .0; assert_eq!(pool.tranches.residual_tranche().unwrap().debt, 0); assert_eq!( pool.tranches.residual_tranche().unwrap().reserve, @@ -789,9 +789,9 @@ fn epoch() { ::AccountId, ::CurrencyId, - >>::get(0, SeniorTrancheId::get()) + >>::get_price(0, SeniorTrancheId::get()) .unwrap() - .price, + .0, Quantity::from_inner(1004126524122317386) ); }); diff --git a/runtime/altair/src/lib.rs b/runtime/altair/src/lib.rs index d8c3e488f2..61bcb317bc 100644 --- a/runtime/altair/src/lib.rs +++ b/runtime/altair/src/lib.rs @@ -110,9 +110,7 @@ use runtime_common::{ gateway, instances, instances::{CouncilCollective, TechnicalCollective, TechnicalMembership}, message_queue::{NarrowOriginToSibling, ParaIdToSibling}, - oracle::{ - Feeder, OracleConverterBridge, OracleRatioProvider, OracleRatioProviderLocalAssetExtension, - }, + oracle::{DigestedOracleRatioProvider, Feeder, OracleConverterBridge, OracleRatioProvider}, origins::gov::{ types::{ AllOfCouncil, DispatchWhitelistedOrigin, EnsureRootOr, HalfOfCouncil, PoolCreateOrigin, @@ -1759,7 +1757,7 @@ impl pallet_order_book::Config for Runtime { type NativeDecimals = NativeDecimals; type OrderIdNonce = u64; type Ratio = Ratio; - type RatioProvider = OracleRatioProviderLocalAssetExtension< + type RatioProvider = DigestedOracleRatioProvider< RuntimeOrigin, OracleRatioProvider, OrmlAssetRegistry, @@ -1807,6 +1805,7 @@ impl pallet_liquidity_pools::Config for Runtime { type DomainAddressToAccountId = AccountConverter; type ForeignInvestment = ForeignInvestments; type GeneralCurrencyPrefix = GeneralCurrencyPrefix; + type MarketRatio = OrderBook; type OutboundQueue = LiquidityPoolsGateway; type Permission = Permissions; type PoolId = PoolId; diff --git a/runtime/centrifuge/src/lib.rs b/runtime/centrifuge/src/lib.rs index e1d71fe98f..8ffd3571c9 100644 --- a/runtime/centrifuge/src/lib.rs +++ b/runtime/centrifuge/src/lib.rs @@ -112,9 +112,7 @@ use runtime_common::{ gateway, instances, instances::CouncilCollective, message_queue::{NarrowOriginToSibling, ParaIdToSibling}, - oracle::{ - Feeder, OracleConverterBridge, OracleRatioProvider, OracleRatioProviderLocalAssetExtension, - }, + oracle::{DigestedOracleRatioProvider, Feeder, OracleConverterBridge, OracleRatioProvider}, origin::EnsureAccountOrRootOr, origins::gov::types::{ AllOfCouncil, EnsureRootOr, HalfOfCouncil, ThreeFourthOfCouncil, TwoThirdOfCouncil, @@ -1838,7 +1836,7 @@ impl pallet_order_book::Config for Runtime { type NativeDecimals = NativeDecimals; type OrderIdNonce = u64; type Ratio = Ratio; - type RatioProvider = OracleRatioProviderLocalAssetExtension< + type RatioProvider = DigestedOracleRatioProvider< RuntimeOrigin, OracleRatioProvider, OrmlAssetRegistry, @@ -1887,6 +1885,7 @@ impl pallet_liquidity_pools::Config for Runtime { type DomainAddressToAccountId = AccountConverter; type ForeignInvestment = ForeignInvestments; type GeneralCurrencyPrefix = GeneralCurrencyPrefix; + type MarketRatio = OrderBook; type OutboundQueue = LiquidityPoolsGateway; type Permission = Permissions; type PoolId = PoolId; diff --git a/runtime/common/src/oracle.rs b/runtime/common/src/oracle.rs index 03941cef71..a300306aae 100644 --- a/runtime/common/src/oracle.rs +++ b/runtime/common/src/oracle.rs @@ -168,11 +168,11 @@ where /// An extension of the [OracleRatioProvider] which performs a pre-check when /// querying a feeder key value pair. -pub struct OracleRatioProviderLocalAssetExtension( +pub struct DigestedOracleRatioProvider( PhantomData<(Origin, Provider, AssetInspect)>, ); impl ValueProvider, (CurrencyId, CurrencyId)> - for OracleRatioProviderLocalAssetExtension + for DigestedOracleRatioProvider where Origin: OriginTrait, Provider: ValueProvider, (CurrencyId, CurrencyId), Value = Ratio>, @@ -195,7 +195,7 @@ where _ => Ok(false), }?; - if locally_coupled_assets { + if locally_coupled_assets || from == to { Ok(Some(Ratio::one())) } else { Provider::get(feeder, &(*from, *to)) @@ -203,7 +203,7 @@ where } #[cfg(feature = "runtime-benchmarks")] - fn set(feeder: &Feeder, (from, to): &(CurrencyId, CurrencyId), ratio: Ratio) { - Provider::set(&feeder, &(*from, *to), ratio); + fn set(feeder: &Feeder, currencies: &(CurrencyId, CurrencyId), ratio: Ratio) { + Provider::set(feeder, currencies, ratio); } } diff --git a/runtime/development/src/lib.rs b/runtime/development/src/lib.rs index cb8016acd5..83e96723b2 100644 --- a/runtime/development/src/lib.rs +++ b/runtime/development/src/lib.rs @@ -114,9 +114,7 @@ use runtime_common::{ gateway, instances, instances::{CouncilCollective, TechnicalCollective, TechnicalMembership}, message_queue::{NarrowOriginToSibling, ParaIdToSibling}, - oracle::{ - Feeder, OracleConverterBridge, OracleRatioProvider, OracleRatioProviderLocalAssetExtension, - }, + oracle::{DigestedOracleRatioProvider, Feeder, OracleConverterBridge, OracleRatioProvider}, origins::gov::{ pallet_custom_origins, types::{ @@ -1858,7 +1856,7 @@ impl pallet_order_book::Config for Runtime { type NativeDecimals = NativeDecimals; type OrderIdNonce = u64; type Ratio = Ratio; - type RatioProvider = OracleRatioProviderLocalAssetExtension< + type RatioProvider = DigestedOracleRatioProvider< RuntimeOrigin, OracleRatioProvider, OrmlAssetRegistry, @@ -1907,6 +1905,7 @@ impl pallet_liquidity_pools::Config for Runtime { type DomainAddressToAccountId = AccountConverter; type ForeignInvestment = ForeignInvestments; type GeneralCurrencyPrefix = GeneralCurrencyPrefix; + type MarketRatio = OrderBook; type OutboundQueue = LiquidityPoolsGateway; type Permission = Permissions; type PoolId = PoolId; diff --git a/runtime/integration-tests/src/cases/liquidity_pools.rs b/runtime/integration-tests/src/cases/liquidity_pools.rs index 621ff5d41a..fba101b521 100644 --- a/runtime/integration-tests/src/cases/liquidity_pools.rs +++ b/runtime/integration-tests/src/cases/liquidity_pools.rs @@ -773,38 +773,6 @@ mod add_allow_upgrade { }); } - #[test_runtimes([development])] - fn update_token_price() { - let mut env = FudgeEnv::::from_parachain_storage( - Genesis::default() - .add(genesis::balances::(cfg(1_000))) - .add(genesis::tokens::(vec![( - GLMR_CURRENCY_ID, - DEFAULT_BALANCE_GLMR, - )])) - .storage(), - ); - - setup_test(&mut env); - - env.parachain_state_mut(|| { - let currency_id = AUSD_CURRENCY_ID; - let pool_id = POOL_ID; - - enable_liquidity_pool_transferability::(currency_id); - - create_ausd_pool::(pool_id); - - assert_ok!(pallet_liquidity_pools::Pallet::::update_token_price( - RawOrigin::Signed(Keyring::Bob.into()).into(), - pool_id, - default_tranche_id::(pool_id), - currency_id, - Domain::EVM(MOONBEAM_EVM_CHAIN_ID), - )); - }); - } - #[test_runtimes([development])] fn add_currency() { let mut env = FudgeEnv::::from_parachain_storage( diff --git a/runtime/integration-tests/src/cases/lp/pool_management.rs b/runtime/integration-tests/src/cases/lp/pool_management.rs index 6950fae46b..a0e361c34d 100644 --- a/runtime/integration-tests/src/cases/lp/pool_management.rs +++ b/runtime/integration-tests/src/cases/lp/pool_management.rs @@ -10,7 +10,7 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use cfg_primitives::{Balance, PoolId, SECONDS_PER_YEAR}; +use cfg_primitives::{AccountId, Balance, PoolId, SECONDS_PER_YEAR}; use cfg_traits::{PoolMetadata, TimeAsSecs, TrancheTokenPrice}; use cfg_types::{ domain_address::{Domain, DomainAddress}, @@ -561,12 +561,13 @@ fn update_tranche_token_price() { assert_eq!(computed_evm, 0); }); - let pre_price_cfg = env.state_mut(|_evm| { - let price = as TrancheTokenPrice< - ::AccountId, - CurrencyId, - >>::get(POOL_A, pool_a_tranche_1_id::()) - .unwrap(); + let (price, last_updated) = env.state_mut(|_evm| { + let price = + as TrancheTokenPrice>::get_price( + POOL_A, + pool_a_tranche_1_id::(), + ) + .unwrap(); assert_ok!(pallet_liquidity_pools::Pallet::::update_token_price( OriginFor::::signed(Keyring::Alice.into()), @@ -596,7 +597,7 @@ fn update_tranche_token_price() { .value, ); - assert_eq!(pre_price_cfg.last_updated, computed_at_evm); - assert_eq!(price_evm, pre_price_cfg.price.into_inner()); + assert_eq!(last_updated, computed_at_evm); + assert_eq!(price.into_inner(), price_evm); }); }