From c7e17048dda96e7e4bf399047b68ebc4bc239f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Fri, 27 Oct 2023 00:01:01 +0200 Subject: [PATCH] Currencies: ED consistent between tokens and assets (#1596) --- runtime/altair/src/lib.rs | 17 +++----- runtime/centrifuge/src/lib.rs | 17 +++----- runtime/common/src/lib.rs | 22 ++++++++++ runtime/development/src/lib.rs | 12 ++---- .../integration-tests/src/evm/precompile.rs | 9 +++- .../pallet/development/test_net.rs | 9 ++++ .../liquidity_pools/add_allow_upgrade.rs | 3 ++ .../liquidity_pools/foreign_investments.rs | 43 ++++++++----------- .../tests/liquidity_pools/setup.rs | 6 ++- .../tests/liquidity_pools/transfers.rs | 24 ++++++++--- .../pallet/development/tests/mod.rs | 6 +-- runtime/integration-tests/src/utils/mod.rs | 5 +++ 12 files changed, 101 insertions(+), 72 deletions(-) diff --git a/runtime/altair/src/lib.rs b/runtime/altair/src/lib.rs index 56f7f23c7c..89b674f1b0 100644 --- a/runtime/altair/src/lib.rs +++ b/runtime/altair/src/lib.rs @@ -58,7 +58,7 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, EnsureSigned, }; -use orml_traits::{currency::MutationHooks, parameter_type_with_key}; +use orml_traits::currency::MutationHooks; use pallet_anchors::AnchorData; pub use pallet_balances::Call as BalancesCall; use pallet_collective::{EnsureMember, EnsureProportionMoreThan}; @@ -74,11 +74,13 @@ pub use pallet_timestamp::Call as TimestampCall; pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment}; use pallet_transaction_payment_rpc_runtime_api::{FeeDetails, RuntimeDispatchInfo}; use polkadot_runtime_common::{prod_or_fast, BlockHashCount, SlowAdjustingFeeUpdate}; -pub use runtime_common::*; use runtime_common::{ account_conversion::AccountConverter, + asset_registry, fees::{DealWithFees, WeightToFee}, + production_or_benchmark, xcm::AccountIdToMultiLocation, + xcm_transactor, CurrencyED, }; use scale_info::TypeInfo; use sp_api::impl_runtime_apis; @@ -1107,15 +1109,6 @@ impl pallet_restricted_tokens::Config for Runtime { type WeightInfo = weights::pallet_restricted_tokens::WeightInfo; } -parameter_type_with_key! { - pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance { - match currency_id { - CurrencyId::Native => ExistentialDeposit::get(), - _ => 0, - } - }; -} - parameter_types! { pub TreasuryAccount: AccountId = TreasuryPalletId::get().into_account_truncating(); } @@ -1138,7 +1131,7 @@ impl orml_tokens::Config for Runtime { type CurrencyHooks = CurrencyHooks; type CurrencyId = CurrencyId; type DustRemovalWhitelist = frame_support::traits::Nothing; - type ExistentialDeposits = ExistentialDeposits; + type ExistentialDeposits = CurrencyED; type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; diff --git a/runtime/centrifuge/src/lib.rs b/runtime/centrifuge/src/lib.rs index 0e2e963733..a2501bb907 100644 --- a/runtime/centrifuge/src/lib.rs +++ b/runtime/centrifuge/src/lib.rs @@ -59,7 +59,7 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, EnsureSigned, }; -use orml_traits::{currency::MutationHooks, parameter_type_with_key}; +use orml_traits::currency::MutationHooks; use pallet_anchors::AnchorData; pub use pallet_balances::Call as BalancesCall; use pallet_collective::{EnsureMember, EnsureProportionAtLeast, EnsureProportionMoreThan}; @@ -78,7 +78,9 @@ pub use pallet_timestamp::Call as TimestampCall; pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment}; use pallet_transaction_payment_rpc_runtime_api::{FeeDetails, RuntimeDispatchInfo}; use polkadot_runtime_common::{prod_or_fast, BlockHashCount, SlowAdjustingFeeUpdate}; -use runtime_common::{account_conversion::AccountConverter, xcm::AccountIdToMultiLocation}; +use runtime_common::{ + account_conversion::AccountConverter, xcm::AccountIdToMultiLocation, CurrencyED, +}; use scale_info::TypeInfo; use sp_api::impl_runtime_apis; use sp_core::{OpaqueMetadata, H160, H256, U256}; @@ -378,15 +380,6 @@ parameter_types! { pub TreasuryAccount: AccountId = TreasuryPalletId::get().into_account_truncating(); } -parameter_type_with_key! { - pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance { - match currency_id { - CurrencyId::Native => ExistentialDeposit::get(), - _ => 0, - } - }; -} - pub struct CurrencyHooks(sp_std::marker::PhantomData); impl MutationHooks for CurrencyHooks { type OnDust = orml_tokens::TransferDust; @@ -405,7 +398,7 @@ impl orml_tokens::Config for Runtime { type CurrencyHooks = CurrencyHooks; type CurrencyId = CurrencyId; type DustRemovalWhitelist = frame_support::traits::Nothing; - type ExistentialDeposits = ExistentialDeposits; + type ExistentialDeposits = CurrencyED; type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index a931aea44b..8e47762d35 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -26,6 +26,12 @@ pub mod migrations; pub mod oracle; pub mod xcm; +use cfg_primitives::Balance; +use cfg_types::tokens::CurrencyId; +use orml_traits::GetByKey; +use sp_runtime::traits::Get; +use sp_std::marker::PhantomData; + #[macro_export] macro_rules! production_or_benchmark { ($production:expr, $benchmark:expr) => {{ @@ -37,6 +43,22 @@ macro_rules! production_or_benchmark { }}; } +pub struct CurrencyED(PhantomData); +impl GetByKey for CurrencyED +where + T: pallet_balances::Config + + orml_asset_registry::Config, +{ + fn get(currency_id: &CurrencyId) -> Balance { + match currency_id { + CurrencyId::Native => T::ExistentialDeposit::get(), + currency_id => orml_asset_registry::Pallet::::metadata(currency_id) + .map(|metadata| metadata.existential_deposit) + .unwrap_or_default(), + } + } +} + pub mod xcm_fees { use cfg_primitives::{constants::currency_decimals, types::Balance}; use frame_support::weights::constants::{ExtrinsicBaseWeight, WEIGHT_REF_TIME_PER_SECOND}; diff --git a/runtime/development/src/lib.rs b/runtime/development/src/lib.rs index fcfa0bcef9..9f7e6db94e 100644 --- a/runtime/development/src/lib.rs +++ b/runtime/development/src/lib.rs @@ -68,7 +68,7 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, EnsureSigned, }; -use orml_traits::{currency::MutationHooks, parameter_type_with_key}; +use orml_traits::currency::MutationHooks; use pallet_anchors::AnchorData; pub use pallet_balances::Call as BalancesCall; use pallet_collective::EnsureMember; @@ -92,6 +92,7 @@ use runtime_common::{ account_conversion::AccountConverter, fees::{DealWithFees, WeightToFee}, xcm::AccountIdToMultiLocation, + CurrencyED, }; use scale_info::TypeInfo; use sp_api::impl_runtime_apis; @@ -1498,13 +1499,6 @@ impl pallet_restricted_tokens::Config for Runtime { type WeightInfo = weights::pallet_restricted_tokens::WeightInfo; } -parameter_type_with_key! { - pub ExistentialDeposits: |_currency_id: CurrencyId| -> Balance { - // every currency has a zero existential deposit - 0 - }; -} - parameter_types! { pub TreasuryAccount: AccountId = TreasuryPalletId::get().into_account_truncating(); } @@ -1527,7 +1521,7 @@ impl orml_tokens::Config for Runtime { type CurrencyHooks = CurrencyHooks; type CurrencyId = CurrencyId; type DustRemovalWhitelist = frame_support::traits::Nothing; - type ExistentialDeposits = ExistentialDeposits; + type ExistentialDeposits = CurrencyED; type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; diff --git a/runtime/integration-tests/src/evm/precompile.rs b/runtime/integration-tests/src/evm/precompile.rs index 9a58b61e3d..e43a8de2fa 100644 --- a/runtime/integration-tests/src/evm/precompile.rs +++ b/runtime/integration-tests/src/evm/precompile.rs @@ -48,6 +48,8 @@ use crate::{ }, }; +const ED: Balance = 1_234; + #[tokio::test] async fn axelar_precompile_execute() { let mut env = env::test_env_default(Handle::current()); @@ -90,7 +92,7 @@ async fn axelar_precompile_execute() { decimals: 18, name: "Test".into(), symbol: "TST".into(), - existential_deposit: 1_000_000, + existential_deposit: ED, location: Some(VersionedMultiLocation::V3(MultiLocation::here())), additional: CustomMetadata { transferability: Default::default(), @@ -114,6 +116,9 @@ async fn axelar_precompile_execute() { 1_000_000_000_000 * 10u128.saturating_pow(18), ) .unwrap(); + + orml_tokens::Pallet::::deposit(currency_id, &derived_receiver_account, ED) + .unwrap(); }) .unwrap(); @@ -227,7 +232,7 @@ async fn axelar_precompile_execute() { let derived_receiver_balance = orml_tokens::Pallet::::free_balance(currency_id, &derived_receiver_account); - assert_eq!(derived_receiver_balance, transfer_amount) + assert_eq!(derived_receiver_balance, transfer_amount + ED) }) .unwrap(); } diff --git a/runtime/integration-tests/src/liquidity_pools/pallet/development/test_net.rs b/runtime/integration-tests/src/liquidity_pools/pallet/development/test_net.rs index d270d8ba78..44c278dd94 100644 --- a/runtime/integration-tests/src/liquidity_pools/pallet/development/test_net.rs +++ b/runtime/integration-tests/src/liquidity_pools/pallet/development/test_net.rs @@ -23,6 +23,9 @@ use sp_runtime::traits::AccountIdConversion; use xcm_emulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain}; use super::setup::{cfg, ExtBuilder, ALICE, BOB, PARA_ID_MOONBEAM}; +use crate::utils::{ + AUSD_CURRENCY_ID, AUSD_ED, GLMR_CURRENCY_ID, GLMR_ED, USDT_CURRENCY_ID, USDT_ED, +}; decl_test_relay_chain! { pub struct RelayChain { @@ -114,6 +117,12 @@ pub fn para_ext(parachain_id: u32) -> sp_io::TestExternalities { .balances(vec![ (AccountId::from(ALICE), CurrencyId::Native, cfg(10_000)), (AccountId::from(BOB), CurrencyId::Native, cfg(10_000)), + (AccountId::from(ALICE), AUSD_CURRENCY_ID, AUSD_ED), + (AccountId::from(BOB), AUSD_CURRENCY_ID, AUSD_ED), + (AccountId::from(ALICE), USDT_CURRENCY_ID, USDT_ED), + (AccountId::from(BOB), USDT_CURRENCY_ID, USDT_ED), + (AccountId::from(ALICE), GLMR_CURRENCY_ID, GLMR_ED), + (AccountId::from(BOB), GLMR_CURRENCY_ID, GLMR_ED), ]) .parachain_id(parachain_id) .build() diff --git a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/add_allow_upgrade.rs b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/add_allow_upgrade.rs index b6938b01f6..176e0a6167 100644 --- a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/add_allow_upgrade.rs +++ b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/add_allow_upgrade.rs @@ -364,6 +364,7 @@ fn add_currency_should_fail() { "TEST".into(), 12, false, + 1_000_000, None, CrossChainTransferability::LiquidityPools, ), @@ -500,6 +501,7 @@ fn allow_pool_should_fail() { "TEST".into(), 12, true, + 1_000_000, None, Default::default(), ), @@ -629,6 +631,7 @@ fn allow_pool_should_fail() { "AUSD".into(), 12, true, + 1_000_000, None, Default::default() ), diff --git a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/foreign_investments.rs b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/foreign_investments.rs index cc7e38409d..e1d30ab9d6 100644 --- a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/foreign_investments.rs +++ b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/foreign_investments.rs @@ -37,7 +37,7 @@ use cfg_types::{ pools::TrancheMetadata, tokens::{ CrossChainTransferability, CurrencyId, CurrencyId::ForeignAsset, CustomMetadata, - ForeignAssetId, + ForeignAssetId, TrancheCurrency, }, }; use development_runtime::{ @@ -89,7 +89,7 @@ use crate::{ }, }, }, - utils::AUSD_CURRENCY_ID, + utils::{AUSD_CURRENCY_ID, AUSD_ED}, }; mod same_currencies { @@ -103,7 +103,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let amount = 100_000_000; + let amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -151,7 +151,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let invest_amount: u128 = 100_000_000; + let invest_amount: u128 = 10 * dollar(12); let decrease_amount = invest_amount / 3; let final_amount = invest_amount - decrease_amount; let investor: AccountId = @@ -233,7 +233,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let invest_amount = 100_000_000; + let invest_amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -330,7 +330,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let amount = 100_000_000; + let amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -482,7 +482,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let invest_amount = 100_000_000; + let invest_amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -740,7 +740,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let amount = 100_000_000; + let amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -793,7 +793,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let redeem_amount = 100_000_000; + let redeem_amount = 10 * dollar(12); let decrease_amount = redeem_amount / 3; let final_amount = redeem_amount - decrease_amount; let investor: AccountId = @@ -906,7 +906,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let redeem_amount = 100_000_000; + let redeem_amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -1002,7 +1002,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let amount = 100_000_000; + let amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -1156,7 +1156,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let redeem_amount = 100_000_000; + let redeem_amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -1380,7 +1380,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let invest_amount: u128 = 100_000_000; + let invest_amount: u128 = 10 * dollar(12); let decrease_amount = invest_amount + 1; let investor: AccountId = AccountConverter::< DevelopmentRuntime, @@ -1422,7 +1422,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let redeem_amount: u128 = 100_000_000; + let redeem_amount: u128 = 10 * dollar(12); let decrease_amount = redeem_amount + 1; let investor: AccountId = AccountConverter::< DevelopmentRuntime, @@ -1465,7 +1465,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let amount: u128 = 100_000_000; + let amount: u128 = 10 * dollar(12); let investor: AccountId = AccountConverter::< DevelopmentRuntime, LocationToAccountId, @@ -1501,7 +1501,7 @@ mod same_currencies { tranche_id: default_tranche_id(pool_id), investor: investor.clone().into(), currency: general_currency_index(currency_id), - amount: 1, + amount: AUSD_ED, }; assert_noop!( LiquidityPools::submit(DEFAULT_DOMAIN_ADDRESS_MOONBEAM, increase_msg), @@ -1533,7 +1533,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let amount: u128 = 100_000_000; + let amount: u128 = 10 * dollar(12); let investor: AccountId = AccountConverter::< DevelopmentRuntime, LocationToAccountId, @@ -1636,7 +1636,7 @@ mod same_currencies { tranche_id: default_tranche_id(pool_id), investor: investor.clone().into(), currency: general_currency_index(foreign_currency), - amount: 1, + amount: AUSD_ED, }; assert_noop!( LiquidityPools::submit(DEFAULT_DOMAIN_ADDRESS_MOONBEAM, increase_msg), @@ -2739,10 +2739,6 @@ mod mismatching_currencies { redeem_amount: invest_amount_pool_denominated / 2, } ); - dbg!(System::events()); - dbg!(min_fulfillment_amount(foreign_currency)); - dbg!(invest_amount_pool_denominated / 8); - dbg!(min_fulfillment_amount(pool_currency)); assert!(System::events().iter().any(|e| { e.event @@ -3362,9 +3358,6 @@ mod mismatching_currencies { ); let swap_amount = invest_amount_foreign_denominated + invest_amount_foreign_denominated / 8; - dbg!(System::events()); - dbg!(swap_amount); - dbg!(MinFulfillmentAmountNative::get()); assert!(System::events().iter().any(|e| { e.event == pallet_order_book::Event::::OrderUpdated { diff --git a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/setup.rs b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/setup.rs index bc26be806d..fa58883d88 100644 --- a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/setup.rs +++ b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/setup.rs @@ -70,7 +70,7 @@ use crate::{ setup::{dollar, ALICE, BOB, PARA_ID_MOONBEAM}, tests::register_ausd, }, - utils::{AUSD_CURRENCY_ID, GLMR_CURRENCY_ID, MOONBEAM_EVM_CHAIN_ID}, + utils::{AUSD_CURRENCY_ID, GLMR_CURRENCY_ID, GLMR_ED, MOONBEAM_EVM_CHAIN_ID}, }; // 10 GLMR (18 decimals) pub const DEFAULT_BALANCE_GLMR: Balance = 10_000_000_000_000_000_000; @@ -159,6 +159,7 @@ pub fn setup_pre_requirements() { "GLMR".into(), 18, false, + GLMR_ED, Some(VersionedMultiLocation::V3( get_default_moonbeam_native_token_location() )), @@ -303,6 +304,7 @@ pub fn asset_metadata( symbol: Vec, decimals: u32, is_pool_currency: bool, + existential_deposit: Balance, location: Option, transferability: CrossChainTransferability, ) -> AssetMetadata { @@ -311,7 +313,7 @@ pub fn asset_metadata( symbol, decimals, location, - existential_deposit: 1_000_000, + existential_deposit, additional: CustomMetadata { transferability, mintable: false, diff --git a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/transfers.rs b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/transfers.rs index a4c9080b78..8b7998bb82 100644 --- a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/transfers.rs +++ b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/transfers.rs @@ -52,7 +52,7 @@ use xcm_emulator::TestExt; use crate::{ liquidity_pools::pallet::development::{ - setup::{dollar, ALICE, BOB}, + setup::{dollar, ALICE, BOB, CHARLIE}, test_net::{Development, Moonbeam, RelayChain, TestNet}, tests::liquidity_pools::setup::{ asset_metadata, create_ausd_pool, create_currency_pool, @@ -63,7 +63,7 @@ use crate::{ DEFAULT_POOL_ID, }, }, - utils::{AUSD_CURRENCY_ID, MOONBEAM_EVM_CHAIN_ID}, + utils::{AUSD_CURRENCY_ID, AUSD_ED, MOONBEAM_EVM_CHAIN_ID}, }; #[test] @@ -73,13 +73,17 @@ fn transfer_non_tranche_tokens_from_local() { // Register GLMR and fund BOB setup_pre_requirements(); - let initial_balance = 100_000_000; + let initial_balance = 2 * AUSD_ED; let amount = initial_balance / 2; let dest_address = DEFAULT_DOMAIN_ADDRESS_MOONBEAM; let currency_id = AUSD_CURRENCY_ID; - let source_account = BOB; + let source_account = CHARLIE; // Mint sufficient balance + assert_eq!( + OrmlTokens::free_balance(currency_id, &source_account.into()), + 0 + ); assert_ok!(OrmlTokens::mint_into( currency_id, &source_account.into(), @@ -188,15 +192,21 @@ fn transfer_non_tranche_tokens_to_local() { amount, }; - assert!(OrmlTokens::total_issuance(currency_id).is_zero()); + assert_eq!(OrmlTokens::total_issuance(currency_id), AUSD_ED * 2); // Finally, verify that we can now transfer the tranche to the destination // address assert_ok!(LiquidityPools::submit(DEFAULT_DOMAIN_ADDRESS_MOONBEAM, msg)); // Verify that the correct amount was minted - assert_eq!(OrmlTokens::total_issuance(currency_id), amount); - assert_eq!(OrmlTokens::free_balance(currency_id, &receiver), amount); + assert_eq!( + OrmlTokens::total_issuance(currency_id), + amount + AUSD_ED * 2 + ); + assert_eq!( + OrmlTokens::free_balance(currency_id, &receiver), + amount + AUSD_ED + ); // Verify empty transfers throw assert_noop!( diff --git a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/mod.rs b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/mod.rs index 7ac3eef92a..b39c5ccc28 100644 --- a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/mod.rs +++ b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/mod.rs @@ -10,7 +10,7 @@ use xcm::{ VersionedMultiLocation, }; -use crate::utils::{AUSD_CURRENCY_ID, USDT_CURRENCY_ID}; +use crate::utils::{AUSD_CURRENCY_ID, AUSD_ED, USDT_CURRENCY_ID, USDT_ED}; mod liquidity_pools; mod routers; @@ -23,7 +23,7 @@ pub fn register_ausd() { decimals: 12, name: "Acala Dollar".into(), symbol: "AUSD".into(), - existential_deposit: 1_000_000_000, + existential_deposit: AUSD_ED, location: Some(VersionedMultiLocation::V3(MultiLocation::new( 1, X2( @@ -54,7 +54,7 @@ fn register_usdt() { decimals: 6, name: "Tether USDT".into(), symbol: "USDT".into(), - existential_deposit: 10_000, + existential_deposit: USDT_ED, location: Some(VersionedMultiLocation::V3(MultiLocation::new( 1, X3(Parachain(1000), PalletInstance(50), GeneralIndex(1984)), diff --git a/runtime/integration-tests/src/utils/mod.rs b/runtime/integration-tests/src/utils/mod.rs index 686713f73b..b1bb563505 100644 --- a/runtime/integration-tests/src/utils/mod.rs +++ b/runtime/integration-tests/src/utils/mod.rs @@ -10,6 +10,7 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. +use cfg_primitives::Balance; use cfg_types::tokens::CurrencyId; pub mod accounts; @@ -37,3 +38,7 @@ pub const AUSD_CURRENCY_ID: CurrencyId = CurrencyId::ForeignAsset(3); pub const USDT_CURRENCY_ID: CurrencyId = CurrencyId::ForeignAsset(1); /// The EVM Chain id of Moonbeam pub const MOONBEAM_EVM_CHAIN_ID: u64 = 1284; + +pub const GLMR_ED: Balance = 1_000_000; +pub const AUSD_ED: Balance = 1_000_000_000; +pub const USDT_ED: Balance = 10_000;