diff --git a/libs/types/src/tokens.rs b/libs/types/src/tokens.rs index bebedfdd56..743a7d13c6 100644 --- a/libs/types/src/tokens.rs +++ b/libs/types/src/tokens.rs @@ -370,16 +370,16 @@ pub mod usdc { use super::*; - pub const MIN_SWAP_ORDER_AMOUNT_USDC: Balance = 10_000_000; - pub const DECIMALS_USDC: u32 = 6; - pub const EXISTENTIAL_DEPOSIT_USDC: Balance = 1000; + pub const MIN_SWAP_ORDER_AMOUNT: Balance = 10_000_000; + pub const DECIMALS: u32 = 6; + pub const EXISTENTIAL_DEPOSIT: Balance = 1000; - pub const CURRENCY_ID_DOT_NATIVE_USDC: CurrencyId = CurrencyId::ForeignAsset(6); - pub const CURRENCY_ID_LP_ETH_USDC: CurrencyId = CurrencyId::ForeignAsset(100_001); - pub const CURRENCY_ID_LP_ETH_GOERLI_USDC: CurrencyId = CurrencyId::ForeignAsset(100_001); - pub const CURRENCY_ID_LP_BASE_USDC: CurrencyId = CurrencyId::ForeignAsset(100_002); - pub const CURRENCY_ID_LP_ARB_USDC: CurrencyId = CurrencyId::ForeignAsset(100_004); - pub const CURRENCY_ID_LP_CELO_USDC: CurrencyId = CurrencyId::ForeignAsset(100_005); + pub const CURRENCY_ID_DOT_NATIVE: CurrencyId = CurrencyId::ForeignAsset(6); + pub const CURRENCY_ID_LP_ETH: CurrencyId = CurrencyId::ForeignAsset(100_001); + pub const CURRENCY_ID_LP_ETH_GOERLI: CurrencyId = CurrencyId::ForeignAsset(100_001); + pub const CURRENCY_ID_LP_BASE: CurrencyId = CurrencyId::ForeignAsset(100_002); + pub const CURRENCY_ID_LP_ARB: CurrencyId = CurrencyId::ForeignAsset(100_003); + pub const CURRENCY_ID_LP_CELO: CurrencyId = CurrencyId::ForeignAsset(100_004); pub const CHAIN_ID_ETHEREUM_MAINNET: EVMChainId = 1; pub const CHAIN_ID_ETH_GOERLI_TESTNET: EVMChainId = 5; @@ -387,15 +387,15 @@ pub mod usdc { pub const CHAIN_ID_ARBITRUM_MAINNET: EVMChainId = 42_161; pub const CHAIN_ID_CELO_MAINNET: EVMChainId = 42_220; - pub const CONTRACT_ETHEREUM_USDC: [u8; 20] = + pub const CONTRACT_ETHEREUM: [u8; 20] = hex_literal::hex!("a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"); - pub const CONTRACT_ETH_GOERLI_USDC: [u8; 20] = + pub const CONTRACT_ETH_GOERLI: [u8; 20] = hex_literal::hex!("07865c6e87b9f70255377e024ace6630c1eaa37f"); - pub const CONTRACT_BASE_USDC: [u8; 20] = + pub const CONTRACT_BASE: [u8; 20] = hex_literal::hex!("833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"); - pub const CONTRACT_ARBITRUM_USDC: [u8; 20] = + pub const CONTRACT_ARBITRUM: [u8; 20] = hex_literal::hex!("af88d065e77c8cC2239327C5EDb3A432268e5831"); - pub const CONTRACT_CELO_USDC: [u8; 20] = + pub const CONTRACT_CELO: [u8; 20] = hex_literal::hex!("37f750B7cC259A2f741AF45294f6a16572CF5cAd"); /// The metadata generator for the LP wrapped USDC currencies @@ -410,10 +410,10 @@ pub mod usdc { pool_currency: bool, ) -> AssetMetadata { AssetMetadata { - decimals: DECIMALS_USDC, + decimals: DECIMALS, name, symbol, - existential_deposit: EXISTENTIAL_DEPOSIT_USDC, + existential_deposit: EXISTENTIAL_DEPOSIT, location: Some(VersionedMultiLocation::V3(MultiLocation { parents: 0, interior: xcm::v3::Junctions::X3( diff --git a/runtime/centrifuge/src/migrations.rs b/runtime/centrifuge/src/migrations.rs index 4e5fdbc9f6..4b79901576 100644 --- a/runtime/centrifuge/src/migrations.rs +++ b/runtime/centrifuge/src/migrations.rs @@ -18,7 +18,7 @@ pub type UpgradeCentrifuge1021 = (anemoy_pool::Migration, add_wrapped_usdc_varia mod anemoy_pool { use cfg_primitives::PoolId; use cfg_traits::PoolInspect; - use cfg_types::tokens::usdc::{CURRENCY_ID_DOT_NATIVE_USDC, CURRENCY_ID_LP_ETH_USDC}; + use cfg_types::tokens::usdc::{CURRENCY_ID_DOT_NATIVE, CURRENCY_ID_LP_ETH}; #[cfg(feature = "try-runtime")] use codec::{Decode, Encode}; #[cfg(feature = "try-runtime")] @@ -44,7 +44,7 @@ mod anemoy_pool { PoolSystem::pool(ANEMOY_POOL_ID).ok_or("Could not find Anemoy Pool")?; ensure!( - pool_details.currency == CURRENCY_ID_LP_ETH_USDC, + pool_details.currency == CURRENCY_ID_LP_ETH, "anemoy_pool::Migration: pre_upgrade failing as Anemoy's currency should be LpEthUSDC" ); @@ -66,10 +66,13 @@ mod anemoy_pool { return weight; } - pallet_pool_system::Pool::::mutate(ANEMOY_POOL_ID, |details| { - let details = details.as_mut().unwrap(); - details.currency = CURRENCY_ID_DOT_NATIVE_USDC; - log::info!("anemoy_pool::Migration: currency set to USDC ✓"); + pallet_pool_system::Pool::::mutate(ANEMOY_POOL_ID, |maybe_details| { + if let Some(details) = maybe_details { + details.currency = CURRENCY_ID_DOT_NATIVE; + log::info!("anemoy_pool::Migration: currency set to USDC ✓"); + } else { + log::warn!("anemoy_pool::Migration: Pool details empty, skipping migration"); + } }); weight.saturating_add( @@ -86,7 +89,7 @@ mod anemoy_pool { PoolSystem::pool(ANEMOY_POOL_ID).ok_or("Could not find Anemoy Pool")?; // Ensure the currency set to USDC is the only mutation performed - old_pool_details.currency = CURRENCY_ID_DOT_NATIVE_USDC; + old_pool_details.currency = CURRENCY_ID_DOT_NATIVE; ensure!( old_pool_details == pool_details, "Corrupted migration: Only the currency of the Anemoy pool should have changed" @@ -100,7 +103,7 @@ mod anemoy_pool { fn verify_sanity_checks() -> (bool, Weight) { let res = crate::Tokens::balance( - CURRENCY_ID_LP_ETH_USDC, + CURRENCY_ID_LP_ETH, &>::account_for(ANEMOY_POOL_ID), ) == 0 && pallet_investments::ActiveInvestOrders::::iter_keys() .filter(|investment| investment.pool_id == ANEMOY_POOL_ID) @@ -136,9 +139,9 @@ pub mod add_wrapped_usdc_variants { use cfg_types::tokens::{ usdc::{ lp_wrapped_usdc_metadata, CHAIN_ID_ARBITRUM_MAINNET, CHAIN_ID_BASE_MAINNET, - CHAIN_ID_CELO_MAINNET, CONTRACT_ARBITRUM_USDC, CONTRACT_BASE_USDC, CONTRACT_CELO_USDC, - CURRENCY_ID_DOT_NATIVE_USDC, CURRENCY_ID_LP_ARB_USDC, CURRENCY_ID_LP_BASE_USDC, - CURRENCY_ID_LP_CELO_USDC, CURRENCY_ID_LP_ETH_USDC, MIN_SWAP_ORDER_AMOUNT_USDC, + CHAIN_ID_CELO_MAINNET, CONTRACT_ARBITRUM, CONTRACT_BASE, CONTRACT_CELO, + CURRENCY_ID_DOT_NATIVE, CURRENCY_ID_LP_ARB, CURRENCY_ID_LP_BASE, CURRENCY_ID_LP_CELO, + CURRENCY_ID_LP_ETH, MIN_SWAP_ORDER_AMOUNT, }, CurrencyId, CustomMetadata, }; @@ -182,28 +185,28 @@ pub mod add_wrapped_usdc_variants { currency_id ); pallet_order_book::TradingPair::::insert( - CURRENCY_ID_DOT_NATIVE_USDC, + CURRENCY_ID_DOT_NATIVE, currency_id, - MIN_SWAP_ORDER_AMOUNT_USDC, + MIN_SWAP_ORDER_AMOUNT, ); pallet_order_book::TradingPair::::insert( currency_id, - CURRENCY_ID_DOT_NATIVE_USDC, - MIN_SWAP_ORDER_AMOUNT_USDC, + CURRENCY_ID_DOT_NATIVE, + MIN_SWAP_ORDER_AMOUNT, ); }) .ok(); } // Add trading pair for already registered LpEthUsdc pallet_order_book::TradingPair::::insert( - CURRENCY_ID_DOT_NATIVE_USDC, - CURRENCY_ID_LP_ETH_USDC, - MIN_SWAP_ORDER_AMOUNT_USDC, + CURRENCY_ID_DOT_NATIVE, + CURRENCY_ID_LP_ETH, + MIN_SWAP_ORDER_AMOUNT, ); pallet_order_book::TradingPair::::insert( - CURRENCY_ID_LP_ETH_USDC, - CURRENCY_ID_DOT_NATIVE_USDC, - MIN_SWAP_ORDER_AMOUNT_USDC, + CURRENCY_ID_LP_ETH, + CURRENCY_ID_DOT_NATIVE, + MIN_SWAP_ORDER_AMOUNT, ); log::info!("add_wrapped_usdc_variants::Migration: on_runtime_upgrade succeeded ✓"); @@ -240,7 +243,7 @@ pub mod add_wrapped_usdc_variants { Self::get_tradeable_ids() .into_iter() .all(|wrapped_usdc_id| { - OrderBook::valid_pair(CURRENCY_ID_DOT_NATIVE_USDC, wrapped_usdc_id) + OrderBook::valid_pair(CURRENCY_ID_DOT_NATIVE, wrapped_usdc_id) }), "At least one of the wrapped USDC variants is not enabled as trading pair into DOT native USDC" ); @@ -249,7 +252,7 @@ pub mod add_wrapped_usdc_variants { Self::get_tradeable_ids() .into_iter() .all(|wrapped_usdc_id| { - OrderBook::valid_pair(wrapped_usdc_id, CURRENCY_ID_DOT_NATIVE_USDC) + OrderBook::valid_pair(wrapped_usdc_id, CURRENCY_ID_DOT_NATIVE) }), "At least one of the wrapped USDC variants is not enabled as trading pair from DOT native USDC" ); @@ -261,20 +264,16 @@ pub mod add_wrapped_usdc_variants { impl Migration { fn get_unregistered_ids() -> Vec { - vec![ - CURRENCY_ID_LP_BASE_USDC, - CURRENCY_ID_LP_ARB_USDC, - CURRENCY_ID_LP_CELO_USDC, - ] + vec![CURRENCY_ID_LP_BASE, CURRENCY_ID_LP_ARB, CURRENCY_ID_LP_CELO] } #[cfg(feature = "try-runtime")] fn get_tradeable_ids() -> Vec { vec![ - CURRENCY_ID_LP_ETH_USDC, - CURRENCY_ID_LP_BASE_USDC, - CURRENCY_ID_LP_ARB_USDC, - CURRENCY_ID_LP_CELO_USDC, + CURRENCY_ID_LP_ETH, + CURRENCY_ID_LP_BASE, + CURRENCY_ID_LP_ARB, + CURRENCY_ID_LP_CELO, ] } @@ -282,35 +281,35 @@ pub mod add_wrapped_usdc_variants { { vec![ ( - CURRENCY_ID_LP_BASE_USDC, + CURRENCY_ID_LP_BASE, lp_wrapped_usdc_metadata( "LP Base Wrapped USDC".as_bytes().to_vec(), "LpBaseUSDC".as_bytes().to_vec(), LiquidityPoolsPalletIndex::get(), CHAIN_ID_BASE_MAINNET, - CONTRACT_BASE_USDC, + CONTRACT_BASE, true, ), ), ( - CURRENCY_ID_LP_ARB_USDC, + CURRENCY_ID_LP_ARB, lp_wrapped_usdc_metadata( "LP Arbitrum Wrapped USDC".as_bytes().to_vec(), "LpArbUSDC".as_bytes().to_vec(), LiquidityPoolsPalletIndex::get(), CHAIN_ID_ARBITRUM_MAINNET, - CONTRACT_ARBITRUM_USDC, + CONTRACT_ARBITRUM, true, ), ), ( - CURRENCY_ID_LP_CELO_USDC, + CURRENCY_ID_LP_CELO, lp_wrapped_usdc_metadata( "LP Celo Wrapped USDC".as_bytes().to_vec(), "LpCeloUSDC".as_bytes().to_vec(), LiquidityPoolsPalletIndex::get(), CHAIN_ID_CELO_MAINNET, - CONTRACT_CELO_USDC, + CONTRACT_CELO, true, ), ), diff --git a/src/chain_spec.rs b/src/chain_spec.rs index 6b8b51e5ca..0363d00a64 100644 --- a/src/chain_spec.rs +++ b/src/chain_spec.rs @@ -30,8 +30,8 @@ use cfg_types::{ fee_keys::FeeKey, tokens::{ usdc::{ - lp_wrapped_usdc_metadata, CHAIN_ID_ETH_GOERLI_TESTNET, CONTRACT_ETH_GOERLI_USDC, - CURRENCY_ID_LP_ETH_GOERLI_USDC, + lp_wrapped_usdc_metadata, CHAIN_ID_ETH_GOERLI_TESTNET, CONTRACT_ETH_GOERLI, + CURRENCY_ID_LP_ETH_GOERLI, }, AssetMetadata, CrossChainTransferability, CurrencyId, CustomMetadata, }, @@ -1002,13 +1002,13 @@ fn asset_registry_assets() -> Vec<(CurrencyId, Vec)> { .encode(), ), ( - CURRENCY_ID_LP_ETH_GOERLI_USDC, + CURRENCY_ID_LP_ETH_GOERLI, lp_wrapped_usdc_metadata( "LP Ethereum Wrapped USDC".as_bytes().to_vec(), "LpEthUSDC".as_bytes().to_vec(), development_runtime::liquidity_pools::LiquidityPoolsPalletIndex::get(), CHAIN_ID_ETH_GOERLI_TESTNET, - CONTRACT_ETH_GOERLI_USDC, + CONTRACT_ETH_GOERLI, true, ) .encode(),