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, NetworkId};25use xcm_builder::LocationInverter;26use xcm_executor::XcmExecutor;27use sp_std::{vec, vec::Vec};28use pallet_foreign_assets::{CurrencyId, NativeCurrency};29use crate::{30 Runtime, RuntimeEvent, RelayChainBlockNumberProvider,31 runtime_common::config::{32 xcm::{33 SelfLocation, Weigher, XcmConfig, Ancestry,34 xcm_assets::{CurrencyIdConvert},35 },36 pallets::TreasuryAccountId,37 substrate::{MaxLocks, MaxReserves},38 },39};4041use up_common::{42 types::{AccountId, Balance},43 constants::*,44};454647pub type Amount = i128;4849parameter_types! {50 pub const MinVestedTransfer: Balance = 10 * UNIQUE;51 pub const MaxVestingSchedules: u32 = 28;5253 pub const BaseXcmWeight: Weight = 100_000_000; 54 pub const MaxAssetsForTransfer: usize = 2;55}5657parameter_type_with_key! {58 pub ParachainMinFee: |_location: MultiLocation| -> Option<u128> {59 Some(100_000_000_000)60 };61}6263parameter_type_with_key! {64 pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance {65 match currency_id {66 CurrencyId::NativeAssetId(symbol) => match symbol {67 NativeCurrency::Here => 0,68 NativeCurrency::Parent=> 0,69 },70 _ => 100_00071 }72 };73}7475pub fn get_all_module_accounts() -> Vec<AccountId> {76 vec![TreasuryAccountId::get()]77}7879pub struct DustRemovalWhitelist;80impl Contains<AccountId> for DustRemovalWhitelist {81 fn contains(a: &AccountId) -> bool {82 get_all_module_accounts().contains(a)83 }84}8586pub struct AccountIdToMultiLocation;87impl Convert<AccountId, MultiLocation> for AccountIdToMultiLocation {88 fn convert(account: AccountId) -> MultiLocation {89 X1(AccountId32 {90 network: NetworkId::Any,91 id: account.into(),92 })93 .into()94 }95}9697pub struct CurrencyHooks;98impl orml_traits::currency::MutationHooks<AccountId, CurrencyId, Balance> for CurrencyHooks {99 type OnDust = orml_tokens::TransferDust<Runtime, TreasuryAccountId>;100 type OnSlash = ();101 type PreTransfer = ();102 type PostTransfer = ();103 type PreDeposit = ();104 type PostDeposit = ();105 type OnNewTokenAccount = ();106 type OnKilledTokenAccount = ();107}108109impl orml_vesting::Config for Runtime {110 type RuntimeEvent = RuntimeEvent;111 type Currency = pallet_balances::Pallet<Runtime>;112 type MinVestedTransfer = MinVestedTransfer;113 type VestedTransferOrigin = EnsureSigned<AccountId>;114 type WeightInfo = ();115 type MaxVestingSchedules = MaxVestingSchedules;116 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;117}118119impl orml_tokens::Config for Runtime {120 type RuntimeEvent = RuntimeEvent;121 type Balance = Balance;122 type Amount = Amount;123 type CurrencyId = CurrencyId;124 type WeightInfo = ();125 type ExistentialDeposits = ExistentialDeposits;126 type CurrencyHooks = CurrencyHooks;127 type MaxLocks = MaxLocks;128 type MaxReserves = MaxReserves;129 130 type DustRemovalWhitelist = DustRemovalWhitelist;131 132 type ReserveIdentifier = ();133}134135impl orml_xtokens::Config for Runtime {136 type RuntimeEvent = RuntimeEvent;137 type Balance = Balance;138 type CurrencyId = CurrencyId;139 type CurrencyIdConvert = CurrencyIdConvert;140 type AccountIdToMultiLocation = AccountIdToMultiLocation;141 type SelfLocation = SelfLocation;142 type XcmExecutor = XcmExecutor<XcmConfig<Self>>;143 type Weigher = Weigher;144 type BaseXcmWeight = BaseXcmWeight;145 type LocationInverter = LocationInverter<Ancestry>;146 type MaxAssetsForTransfer = MaxAssetsForTransfer;147 type MinXcmFee = ParachainMinFee;148 type MultiLocationsFilter = Everything;149 type ReserveProvider = AbsoluteReserveProvider;150}