1234567891011121314151617use frame_support::{18 parameter_types,19 traits::{Contains, Everything},20};21use frame_system::EnsureSigned;22use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key};23use sp_runtime::traits::Convert;24use xcm::latest::{Weight, Junction::*, Junctions::*, MultiLocation};25use xcm_executor::XcmExecutor;26use sp_std::{vec, vec::Vec};27use pallet_foreign_assets::{CurrencyId, NativeCurrency};28use crate::{29 Runtime, RuntimeEvent, RelayChainBlockNumberProvider,30 runtime_common::config::{31 xcm::{32 SelfLocation, Weigher, XcmExecutorConfig, UniversalLocation,33 xcm_assets::{CurrencyIdConvert},34 },35 pallets::TreasuryAccountId,36 substrate::{MaxLocks, MaxReserves},37 },38};3940use up_common::{41 types::{AccountId, Balance},42 constants::*,43};444546pub type Amount = i128;4748parameter_types! {49 pub const MinVestedTransfer: Balance = 10 * UNIQUE;50 pub const MaxVestingSchedules: u32 = 28;5152 pub const BaseXcmWeight: Weight = Weight::from_parts(100_000_000, 1000); 53 pub const MaxAssetsForTransfer: usize = 2;54}5556parameter_type_with_key! {57 pub ParachainMinFee: |_location: MultiLocation| -> Option<u128> {58 Some(100_000_000_000)59 };60}6162parameter_type_with_key! {63 pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance {64 match currency_id {65 CurrencyId::NativeAssetId(symbol) => match symbol {66 NativeCurrency::Here => 0,67 NativeCurrency::Parent=> 0,68 },69 _ => 100_00070 }71 };72}7374pub fn get_all_module_accounts() -> Vec<AccountId> {75 vec![TreasuryAccountId::get()]76}7778pub struct DustRemovalWhitelist;79impl Contains<AccountId> for DustRemovalWhitelist {80 fn contains(a: &AccountId) -> bool {81 get_all_module_accounts().contains(a)82 }83}8485pub struct AccountIdToMultiLocation;86impl Convert<AccountId, MultiLocation> for AccountIdToMultiLocation {87 fn convert(account: AccountId) -> MultiLocation {88 X1(AccountId32 {89 network: None,90 id: account.into(),91 })92 .into()93 }94}9596pub struct CurrencyHooks;97impl orml_traits::currency::MutationHooks<AccountId, CurrencyId, Balance> for CurrencyHooks {98 type OnDust = orml_tokens::TransferDust<Runtime, TreasuryAccountId>;99 type OnSlash = ();100 type PreTransfer = ();101 type PostTransfer = ();102 type PreDeposit = ();103 type PostDeposit = ();104 type OnNewTokenAccount = ();105 type OnKilledTokenAccount = ();106}107108impl orml_vesting::Config for Runtime {109 type RuntimeEvent = RuntimeEvent;110 type Currency = pallet_balances::Pallet<Runtime>;111 type MinVestedTransfer = MinVestedTransfer;112 type VestedTransferOrigin = EnsureSigned<AccountId>;113 type WeightInfo = ();114 type MaxVestingSchedules = MaxVestingSchedules;115 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;116}117118impl orml_tokens::Config for Runtime {119 type RuntimeEvent = RuntimeEvent;120 type Balance = Balance;121 type Amount = Amount;122 type CurrencyId = CurrencyId;123 type WeightInfo = ();124 type ExistentialDeposits = ExistentialDeposits;125 type CurrencyHooks = CurrencyHooks;126 type MaxLocks = MaxLocks;127 type MaxReserves = MaxReserves;128 129 type DustRemovalWhitelist = DustRemovalWhitelist;130 131 type ReserveIdentifier = ();132}133134impl orml_xtokens::Config for Runtime {135 type RuntimeEvent = RuntimeEvent;136 type Balance = Balance;137 type CurrencyId = CurrencyId;138 type CurrencyIdConvert = CurrencyIdConvert;139 type AccountIdToMultiLocation = AccountIdToMultiLocation;140 type SelfLocation = SelfLocation;141 type XcmExecutor = XcmExecutor<XcmExecutorConfig<Self>>;142 type Weigher = Weigher;143 type BaseXcmWeight = BaseXcmWeight;144 type MaxAssetsForTransfer = MaxAssetsForTransfer;145 type MinXcmFee = ParachainMinFee;146 type MultiLocationsFilter = Everything;147 type ReserveProvider = AbsoluteReserveProvider;148 type UniversalLocation = UniversalLocation;149}