git.delta.rocks / unique-network / refs/commits / d59d4711fcdc

difftreelog

Assets transactor

Ilja Khabarov2022-08-19parent: #538e923.patch.diff
in: master

2 files changed

modifiedruntime/common/config/xcm.rsdiffbeforeafterboth
before · runtime/common/config/xcm.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{18	traits::{19		tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Get, Everything,20	},21	weights::{Weight, WeightToFeePolynomial, WeightToFee},22	parameter_types, match_types,23};24use frame_system::EnsureRoot;25use sp_runtime::{26	traits::{Saturating, CheckedConversion, Zero},27	SaturatedConversion,28};29use pallet_xcm::XcmPassthrough;30use polkadot_parachain::primitives::Sibling;31use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};32use xcm::latest::{33	AssetId::{Concrete},34	Fungibility::Fungible as XcmFungible,35	MultiAsset, Error as XcmError,36};37use xcm_executor::traits::{MatchesFungible, WeightTrader};38use xcm_builder::{39	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin,40	FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser, RelayChainAsNative,41	SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,42	SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, ParentIsPreset,43};44use xcm_executor::{Config, XcmExecutor, Assets};45use sp_std::marker::PhantomData;46use crate::{47	Runtime, Call, Event, Origin, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, XcmpQueue,48};49use up_common::{50	types::{AccountId, Balance},51	constants::*,52};5354parameter_types! {55	pub const RelayLocation: MultiLocation = MultiLocation::parent();56	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;57	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();58	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();59}6061/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used62/// when determining ownership of accounts for asset transacting and when attempting to use XCM63/// `Transact` in order to determine the dispatch Origin.64pub type LocationToAccountId = (65	// The parent (Relay-chain) origin converts to the default `AccountId`.66	ParentIsPreset<AccountId>,67	// Sibling parachain origins convert to AccountId via the `ParaId::into`.68	SiblingParachainConvertsVia<Sibling, AccountId>,69	// Straight up local `AccountId32` origins just alias directly to `AccountId`.70	AccountId32Aliases<RelayNetwork, AccountId>,71);7273pub struct OnlySelfCurrency;74impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {75	fn matches_fungible(a: &MultiAsset) -> Option<B> {76		match (&a.id, &a.fun) {77			(Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),78			_ => None,79		}80	}81}8283/// Means for transacting assets on this chain.84pub type LocalAssetTransactor = CurrencyAdapter<85	// Use this currency:86	Balances,87	// Use this currency when it is a fungible asset matching the given location or name:88	OnlySelfCurrency,89	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:90	LocationToAccountId,91	// Our chain's account ID type (we can't get away without mentioning it explicitly):92	AccountId,93	// We don't track any teleports.94	(),95>;9697/// No local origins on this chain are allowed to dispatch XCM sends/executions.98pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);99100/// The means for routing XCM messages which are not for local execution into the right message101/// queues.102pub type XcmRouter = (103	// Two routers - use UMP to communicate with the relay chain:104	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,105	// ..and XCMP to communicate with the sibling chains.106	XcmpQueue,107);108109/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,110/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can111/// biases the kind of local `Origin` it will become.112pub type XcmOriginToTransactDispatchOrigin = (113	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location114	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for115	// foreign chains who want to have a local sovereign account on this chain which they control.116	SovereignSignedViaLocation<LocationToAccountId, Origin>,117	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when118	// recognised.119	RelayChainAsNative<RelayOrigin, Origin>,120	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when121	// recognised.122	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,123	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a124	// transaction from the Root origin.125	ParentAsSuperuser<Origin>,126	// Native signed account converter; this just converts an `AccountId32` origin into a normal127	// `Origin::Signed` origin of the same 32-byte value.128	SignedAccountId32AsNative<RelayNetwork, Origin>,129	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.130	XcmPassthrough<Origin>,131);132133parameter_types! {134	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.135	pub UnitWeightCost: Weight = 1_000_000;136	// 1200 UNIQUEs buy 1 second of weight.137	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);138	pub const MaxInstructions: u32 = 100;139}140141match_types! {142	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {143		MultiLocation { parents: 1, interior: Here } |144		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }145	};146}147148pub type Barrier = (149	TakeWeightCredit,150	AllowTopLevelPaidExecutionFrom<Everything>,151	// ^^^ Parent & its unit plurality gets free execution152);153154pub struct UsingOnlySelfCurrencyComponents<155	WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,156	AssetId: Get<MultiLocation>,157	AccountId,158	Currency: CurrencyT<AccountId>,159	OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,160>(161	Weight,162	Currency::Balance,163	PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,164);165impl<166		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,167		AssetId: Get<MultiLocation>,168		AccountId,169		Currency: CurrencyT<AccountId>,170		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,171	> WeightTrader172	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>173{174	fn new() -> Self {175		Self(0, Zero::zero(), PhantomData)176	}177178	fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {179		let amount = WeightToFee::weight_to_fee(&weight);180		let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;181182		// location to this parachain through relay chain183		let option1: xcm::v1::AssetId = Concrete(MultiLocation {184			parents: 1,185			interior: X1(Parachain(ParachainInfo::parachain_id().into())),186		});187		// direct location188		let option2: xcm::v1::AssetId = Concrete(MultiLocation {189			parents: 0,190			interior: Here,191		});192193		let required = if payment.fungible.contains_key(&option1) {194			(option1, u128_amount).into()195		} else if payment.fungible.contains_key(&option2) {196			(option2, u128_amount).into()197		} else {198			(Concrete(MultiLocation::default()), u128_amount).into()199		};200201		let unused = payment202			.checked_sub(required)203			.map_err(|_| XcmError::TooExpensive)?;204		self.0 = self.0.saturating_add(weight);205		self.1 = self.1.saturating_add(amount);206		Ok(unused)207	}208209	fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {210		let weight = weight.min(self.0);211		let amount = WeightToFee::weight_to_fee(&weight);212		self.0 -= weight;213		self.1 = self.1.saturating_sub(amount);214		let amount: u128 = amount.saturated_into();215		if amount > 0 {216			Some((AssetId::get(), amount).into())217		} else {218			None219		}220	}221}222impl<223		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,224		AssetId: Get<MultiLocation>,225		AccountId,226		Currency: CurrencyT<AccountId>,227		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,228	> Drop229	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>230{231	fn drop(&mut self) {232		OnUnbalanced::on_unbalanced(Currency::issue(self.1));233	}234}235236pub struct XcmConfig<T>(PhantomData<T>);237impl<T> Config for XcmConfig<T>238where239	T: pallet_configuration::Config,240{241	type Call = Call;242	type XcmSender = XcmRouter;243	// How to withdraw and deposit an asset.244	type AssetTransactor = LocalAssetTransactor;245	type OriginConverter = XcmOriginToTransactDispatchOrigin;246	type IsReserve = NativeAsset;247	type IsTeleporter = (); // Teleportation is disabled248	type LocationInverter = LocationInverter<Ancestry>;249	type Barrier = Barrier;250	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;251	type Trader = UsingOnlySelfCurrencyComponents<252		pallet_configuration::WeightToFee<T, Balance>,253		RelayLocation,254		AccountId,255		Balances,256		(),257	>;258	type ResponseHandler = (); // Don't handle responses for now.259	type SubscriptionService = PolkadotXcm;260261	type AssetTrap = PolkadotXcm;262	type AssetClaims = PolkadotXcm;263}264265impl pallet_xcm::Config for Runtime {266	type Event = Event;267	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;268	type XcmRouter = XcmRouter;269	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;270	type XcmExecuteFilter = Everything;271	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;272	type XcmTeleportFilter = Everything;273	type XcmReserveTransferFilter = Everything;274	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;275	type LocationInverter = LocationInverter<Ancestry>;276	type Origin = Origin;277	type Call = Call;278	const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;279	type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;280}281282impl cumulus_pallet_xcm::Config for Runtime {283	type Event = Event;284	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;285}286287impl cumulus_pallet_xcmp_queue::Config for Runtime {288	type WeightInfo = ();289	type Event = Event;290	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;291	type ChannelInfo = ParachainSystem;292	type VersionWrapper = ();293	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;294	type ControllerOrigin = EnsureRoot<AccountId>;295	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;296}297298impl cumulus_pallet_dmp_queue::Config for Runtime {299	type Event = Event;300	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;301	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;302}
after · runtime/common/config/xcm.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{18	traits::{19		Contains, tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Get, Everything,20		fungibles,21	},22	weights::{Weight, WeightToFeePolynomial, WeightToFee},23	parameter_types, match_types,24};25use frame_system::EnsureRoot;26use sp_runtime::{27	traits::{Saturating, CheckedConversion, Zero},28	SaturatedConversion,29};30use pallet_xcm::XcmPassthrough;31use polkadot_parachain::primitives::Sibling;32use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};33use xcm::latest::{34	AssetId::{Concrete},35	Fungibility::Fungible as XcmFungible,36	MultiAsset, Error as XcmError,37};38use xcm_executor::traits::{Convert as ConvertXcm, MatchesFungible, WeightTrader};39use xcm_builder::{40	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin,41	FixedWeightBounds, FungiblesAdapter, LocationInverter, NativeAsset, ParentAsSuperuser, RelayChainAsNative,42	SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,43	SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, ParentIsPreset,44};45use xcm_executor::{Config, XcmExecutor, Assets};46use pallet_foreing_assets::{47	AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, CurrencyId, NativeCurrency,48	UsingAnyCurrencyComponents, TryAsForeing, ForeignAssetId,49};50use sp_std::{borrow::Borrow, marker::PhantomData, vec, vec::Vec};51use crate::{52	Runtime, Call, Event, Origin, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, XcmpQueue53};54#[cfg(feature = "foreign-assets")]55use crate::ForeingAssets;5657use up_common::{58	types::{AccountId, Balance},59	constants::*,60};6162parameter_types! {63	pub const RelayLocation: MultiLocation = MultiLocation::parent();64	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;65	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();66	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();67}6869/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used70/// when determining ownership of accounts for asset transacting and when attempting to use XCM71/// `Transact` in order to determine the dispatch Origin.72pub type LocationToAccountId = (73	// The parent (Relay-chain) origin converts to the default `AccountId`.74	ParentIsPreset<AccountId>,75	// Sibling parachain origins convert to AccountId via the `ParaId::into`.76	SiblingParachainConvertsVia<Sibling, AccountId>,77	// Straight up local `AccountId32` origins just alias directly to `AccountId`.78	AccountId32Aliases<RelayNetwork, AccountId>,79);8081pub struct OnlySelfCurrency;82impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {83	fn matches_fungible(a: &MultiAsset) -> Option<B> {84		match (&a.id, &a.fun) {85			(Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),86			_ => None,87		}88	}89}9091/// Means for transacting assets on this chain.92pub type LocalAssetTransactor = CurrencyAdapter<93	// Use this currency:94	Balances,95	// Use this currency when it is a fungible asset matching the given location or name:96	OnlySelfCurrency,97	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:98	LocationToAccountId,99	// Our chain's account ID type (we can't get away without mentioning it explicitly):100	AccountId,101	// We don't track any teleports.102	(),103>;104105/// No local origins on this chain are allowed to dispatch XCM sends/executions.106pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);107108/// The means for routing XCM messages which are not for local execution into the right message109/// queues.110pub type XcmRouter = (111	// Two routers - use UMP to communicate with the relay chain:112	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,113	// ..and XCMP to communicate with the sibling chains.114	XcmpQueue,115);116117/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,118/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can119/// biases the kind of local `Origin` it will become.120pub type XcmOriginToTransactDispatchOrigin = (121	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location122	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for123	// foreign chains who want to have a local sovereign account on this chain which they control.124	SovereignSignedViaLocation<LocationToAccountId, Origin>,125	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when126	// recognised.127	RelayChainAsNative<RelayOrigin, Origin>,128	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when129	// recognised.130	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,131	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a132	// transaction from the Root origin.133	ParentAsSuperuser<Origin>,134	// Native signed account converter; this just converts an `AccountId32` origin into a normal135	// `Origin::Signed` origin of the same 32-byte value.136	SignedAccountId32AsNative<RelayNetwork, Origin>,137	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.138	XcmPassthrough<Origin>,139);140141parameter_types! {142	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.143	pub UnitWeightCost: Weight = 1_000_000;144	// 1200 UNIQUEs buy 1 second of weight.145	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);146	pub const MaxInstructions: u32 = 100;147}148149match_types! {150	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {151		MultiLocation { parents: 1, interior: Here } |152		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }153	};154}155156pub type Barrier = (157	TakeWeightCredit,158	AllowTopLevelPaidExecutionFrom<Everything>,159	// ^^^ Parent & its unit plurality gets free execution160);161162pub struct UsingOnlySelfCurrencyComponents<163	WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,164	AssetId: Get<MultiLocation>,165	AccountId,166	Currency: CurrencyT<AccountId>,167	OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,168>(169	Weight,170	Currency::Balance,171	PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,172);173impl<174		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,175		AssetId: Get<MultiLocation>,176		AccountId,177		Currency: CurrencyT<AccountId>,178		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,179	> WeightTrader180	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>181{182	fn new() -> Self {183		Self(0, Zero::zero(), PhantomData)184	}185186	fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {187		let amount = WeightToFee::weight_to_fee(&weight);188		let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;189190		// location to this parachain through relay chain191		let option1: xcm::v1::AssetId = Concrete(MultiLocation {192			parents: 1,193			interior: X1(Parachain(ParachainInfo::parachain_id().into())),194		});195		// direct location196		let option2: xcm::v1::AssetId = Concrete(MultiLocation {197			parents: 0,198			interior: Here,199		});200201		let required = if payment.fungible.contains_key(&option1) {202			(option1, u128_amount).into()203		} else if payment.fungible.contains_key(&option2) {204			(option2, u128_amount).into()205		} else {206			(Concrete(MultiLocation::default()), u128_amount).into()207		};208209		let unused = payment210			.checked_sub(required)211			.map_err(|_| XcmError::TooExpensive)?;212		self.0 = self.0.saturating_add(weight);213		self.1 = self.1.saturating_add(amount);214		Ok(unused)215	}216217	fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {218		let weight = weight.min(self.0);219		let amount = WeightToFee::weight_to_fee(&weight);220		self.0 -= weight;221		self.1 = self.1.saturating_sub(amount);222		let amount: u128 = amount.saturated_into();223		if amount > 0 {224			Some((AssetId::get(), amount).into())225		} else {226			None227		}228	}229}230impl<231		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,232		AssetId: Get<MultiLocation>,233		AccountId,234		Currency: CurrencyT<AccountId>,235		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,236	> Drop237	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>238{239	fn drop(&mut self) {240		OnUnbalanced::on_unbalanced(Currency::issue(self.1));241	}242}243244parameter_types! {245	pub CheckingAccount: AccountId = PolkadotXcm::check_account();246}247/// Allow checking in assets that have issuance > 0.248#[cfg(feature = "foreign-assets")]249pub struct NonZeroIssuance<AccountId, ForeingAssets>(PhantomData<(AccountId, ForeingAssets)>);250251#[cfg(feature = "foreign-assets")]252impl<AccountId, ForeingAssets> Contains<<ForeingAssets as fungibles::Inspect<AccountId>>::AssetId>253for NonZeroIssuance<AccountId, ForeingAssets>254	where255		ForeingAssets: fungibles::Inspect<AccountId>,256{257	fn contains(id: &<ForeingAssets as fungibles::Inspect<AccountId>>::AssetId) -> bool {258		!ForeingAssets::total_issuance(*id).is_zero()259	}260}261262#[cfg(feature = "foreign-assets")]263pub struct AsInnerId<AssetId, ConvertAssetId>(PhantomData<(AssetId, ConvertAssetId)>);264#[cfg(feature = "foreign-assets")]265impl<AssetId: Clone + PartialEq, ConvertAssetId: ConvertXcm<AssetId, AssetId>>266ConvertXcm<MultiLocation, AssetId> for AsInnerId<AssetId, ConvertAssetId>267	where268		AssetId: Borrow<AssetId>,269		AssetId: TryAsForeing<AssetId, ForeignAssetId>,270		AssetIds: Borrow<AssetId>,271{272	fn convert_ref(id: impl Borrow<MultiLocation>) -> Result<AssetId, ()> {273		let id = id.borrow();274275		log::trace!(276			target: "xcm::AsInnerId::Convert",277			"AsInnerId {:?}",278			id279		);280281		let parent = MultiLocation::parent();282		let here = MultiLocation::here();283		let self_location = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));284285		if *id == parent {286			return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent));287		}288289		if *id == here || *id == self_location {290			return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here));291		}292293		match XcmForeignAssetIdMapping::<Runtime>::get_currency_id(id.clone()) {294			Some(AssetIds::ForeignAssetId(foreign_asset_id)) => {295				ConvertAssetId::convert_ref(AssetIds::ForeignAssetId(foreign_asset_id))296			}297			_ => ConvertAssetId::convert_ref(AssetIds::ForeignAssetId(0)),298		}299	}300301	fn reverse_ref(what: impl Borrow<AssetId>) -> Result<MultiLocation, ()> {302		log::trace!(303			target: "xcm::AsInnerId::Reverse",304			"AsInnerId",305		);306307		let asset_id = what.borrow();308309		let parent_id =310			ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent)).unwrap();311		let here_id =312			ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here)).unwrap();313314		if asset_id.clone() == parent_id {315			return Ok(MultiLocation::parent());316		}317318		if asset_id.clone() == here_id {319			return Ok(MultiLocation::new(320				1,321				X1(Parachain(ParachainInfo::get().into())),322			));323		}324325		match <AssetId as TryAsForeing<AssetId, ForeignAssetId>>::try_as_foreing(asset_id.clone()) {326			Some(fid) => match XcmForeignAssetIdMapping::<Runtime>::get_multi_location(fid) {327				Some(location) => Ok(location),328				None => Err(()),329			},330			None => Err(()),331		}332	}333}334335/// Means for transacting assets besides the native currency on this chain.336#[cfg(feature = "foreign-assets")]337pub type FungiblesTransactor = FungiblesAdapter<338	// Use this fungibles implementation:339	ForeingAssets,340	// Use this currency when it is a fungible asset matching the given location or name:341	ConvertedConcreteAssetId<AssetIds, Balance, AsInnerId<AssetIds, JustTry>, JustTry>,342	// Convert an XCM MultiLocation into a local account id:343	LocationToAccountId,344	// Our chain's account ID type (we can't get away without mentioning it explicitly):345	AccountId,346	// We only want to allow teleports of known assets. We use non-zero issuance as an indication347	// that this asset is known.348	NonZeroIssuance<AccountId, ForeingAssets>,349	// The account to use for tracking teleports.350	CheckingAccount,351>;352353/// Means for transacting assets on this chain.354#[cfg(feature = "foreign-assets")]355pub type AssetTransactors = FungiblesTransactor;356#[cfg(not(feature = "foreign-assets"))]357pub type AssetTransactors = LocalAssetTransactor;358359pub struct XcmConfig<T>(PhantomData<T>);360impl<T> Config for XcmConfig<T>361where362	T: pallet_configuration::Config,363{364	type Call = Call;365	type XcmSender = XcmRouter;366	// How to withdraw and deposit an asset.367	type AssetTransactor = LocalAssetTransactor;368	type OriginConverter = XcmOriginToTransactDispatchOrigin;369	type IsReserve = NativeAsset;370	type IsTeleporter = (); // Teleportation is disabled371	type LocationInverter = LocationInverter<Ancestry>;372	type Barrier = Barrier;373	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;374	type Trader = UsingOnlySelfCurrencyComponents<375		pallet_configuration::WeightToFee<T, Balance>,376		RelayLocation,377		AccountId,378		Balances,379		(),380	>;381	type ResponseHandler = (); // Don't handle responses for now.382	type SubscriptionService = PolkadotXcm;383384	type AssetTrap = PolkadotXcm;385	type AssetClaims = PolkadotXcm;386}387388impl pallet_xcm::Config for Runtime {389	type Event = Event;390	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;391	type XcmRouter = XcmRouter;392	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;393	type XcmExecuteFilter = Everything;394	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;395	type XcmTeleportFilter = Everything;396	type XcmReserveTransferFilter = Everything;397	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;398	type LocationInverter = LocationInverter<Ancestry>;399	type Origin = Origin;400	type Call = Call;401	const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;402	type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;403}404405impl cumulus_pallet_xcm::Config for Runtime {406	type Event = Event;407	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;408}409410impl cumulus_pallet_xcmp_queue::Config for Runtime {411	type WeightInfo = ();412	type Event = Event;413	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;414	type ChannelInfo = ParachainSystem;415	type VersionWrapper = ();416	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;417	type ControllerOrigin = EnsureRoot<AccountId>;418	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;419}420421impl cumulus_pallet_dmp_queue::Config for Runtime {422	type Event = Event;423	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;424	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;425}426
addedruntime/opal/src/xcm_config.rsdiffbeforeafterboth
--- /dev/null
+++ b/runtime/opal/src/xcm_config.rs
@@ -0,0 +1,513 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+use cumulus_pallet_xcm;
+use frame_support::{
+	{match_types, parameter_types, weights::Weight},
+	pallet_prelude::Get,
+	traits::{Contains, Everything, fungibles},
+};
+use frame_system::EnsureRoot;
+use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key};
+use pallet_xcm::XcmPassthrough;
+use polkadot_parachain::primitives::Sibling;
+use sp_runtime::traits::{AccountIdConversion, CheckedConversion, Convert, Zero};
+use sp_std::{borrow::Borrow, marker::PhantomData, vec, vec::Vec};
+use xcm::{
+	latest::{MultiAsset, Xcm},
+	prelude::{Concrete, Fungible as XcmFungible},
+	v1::{BodyId, Junction::*, Junctions::*, MultiLocation, NetworkId},
+};
+use xcm_builder::{
+	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
+	EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, LocationInverter, ParentAsSuperuser,
+	ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
+	SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
+	ConvertedConcreteAssetId,
+};
+use xcm_executor::{
+	{Config, XcmExecutor},
+	traits::{Convert as ConvertXcm, FilterAssetLocation, JustTry, MatchesFungible, ShouldExecute},
+};
+
+use up_common::{
+	constants::{MAXIMUM_BLOCK_WEIGHT, UNIQUE},
+	types::{AccountId, Balance},
+};
+
+use crate::{
+	Balances, Call, DmpQueue, Event, ForeingAssets, Origin, ParachainInfo,
+	ParachainSystem, PolkadotXcm, Runtime, XcmpQueue,
+};
+use crate::runtime_common::config::substrate::{TreasuryModuleId, MaxLocks, MaxReserves};
+use crate::runtime_common::config::pallets::TreasuryAccountId;
+use crate::runtime_common::config::xcm::*;
+use crate::*;
+
+use pallet_foreing_assets::{
+	AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, CurrencyId, NativeCurrency,
+	UsingAnyCurrencyComponents, TryAsForeing, ForeignAssetId,
+};
+
+// Signed version of balance
+pub type Amount = i128;
+
+/*
+parameter_types! {
+	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
+	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
+}
+
+impl cumulus_pallet_parachain_system::Config for Runtime {
+	type Event = Event;
+	type SelfParaId = parachain_info::Pallet<Self>;
+	type OnSystemEvent = ();
+	type OutboundXcmpMessageSource = XcmpQueue;
+	type DmpMessageHandler = DmpQueue;
+	type ReservedDmpWeight = ReservedDmpWeight;
+	type ReservedXcmpWeight = ReservedXcmpWeight;
+	type XcmpMessageHandler = XcmpQueue;
+}
+
+impl parachain_info::Config for Runtime {}
+
+impl cumulus_pallet_aura_ext::Config for Runtime {}
+ */
+
+parameter_types! {
+	pub const RelayLocation: MultiLocation = MultiLocation::parent();
+	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;
+	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();
+	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
+	pub SelfLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));
+}
+
+/*
+/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
+/// when determining ownership of accounts for asset transacting and when attempting to use XCM
+/// `Transact` in order to determine the dispatch Origin.
+pub type LocationToAccountId = (
+	// The parent (Relay-chain) origin converts to the default `AccountId`.
+	ParentIsPreset<AccountId>,
+	// Sibling parachain origins convert to AccountId via the `ParaId::into`.
+	SiblingParachainConvertsVia<Sibling, AccountId>,
+	// Straight up local `AccountId32` origins just alias directly to `AccountId`.
+	AccountId32Aliases<RelayNetwork, AccountId>,
+);
+
+pub struct OnlySelfCurrency;
+
+impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {
+	fn matches_fungible(a: &MultiAsset) -> Option<B> {
+		match (&a.id, &a.fun) {
+			(Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),
+			_ => None,
+		}
+	}
+}
+
+/// Means for transacting assets on this chain.
+pub type LocalAssetTransactor = CurrencyAdapter<
+	// Use this currency:
+	Balances,
+	// Use this currency when it is a fungible asset matching the given location or name:
+	OnlySelfCurrency,
+	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
+	LocationToAccountId,
+	// Our chain's account ID type (we can't get away without mentioning it explicitly):
+	AccountId,
+	// We don't track any teleports.
+	(),
+>;
+
+ */
+
+/*
+parameter_types! {
+	pub CheckingAccount: AccountId = PolkadotXcm::check_account();
+}
+
+/// Allow checking in assets that have issuance > 0.
+pub struct NonZeroIssuance<AccountId, ForeingAssets>(PhantomData<(AccountId, ForeingAssets)>);
+impl<AccountId, ForeingAssets> Contains<<ForeingAssets as fungibles::Inspect<AccountId>>::AssetId>
+	for NonZeroIssuance<AccountId, ForeingAssets>
+where
+	ForeingAssets: fungibles::Inspect<AccountId>,
+{
+	fn contains(id: &<ForeingAssets as fungibles::Inspect<AccountId>>::AssetId) -> bool {
+		!ForeingAssets::total_issuance(*id).is_zero()
+	}
+}
+
+pub struct AsInnerId<AssetId, ConvertAssetId>(PhantomData<(AssetId, ConvertAssetId)>);
+impl<AssetId: Clone + PartialEq, ConvertAssetId: ConvertXcm<AssetId, AssetId>>
+	ConvertXcm<MultiLocation, AssetId> for AsInnerId<AssetId, ConvertAssetId>
+where
+	AssetId: Borrow<AssetId>,
+	AssetId: TryAsForeing<AssetId, ForeignAssetId>,
+	AssetIds: Borrow<AssetId>,
+{
+	fn convert_ref(id: impl Borrow<MultiLocation>) -> Result<AssetId, ()> {
+		let id = id.borrow();
+
+		log::trace!(
+			target: "xcm::AsInnerId::Convert",
+			"AsInnerId {:?}",
+			id
+		);
+
+		let parent = MultiLocation::parent();
+		let here = MultiLocation::here();
+		let self_location = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));
+
+		if *id == parent {
+			return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent));
+		}
+
+		if *id == here || *id == self_location {
+			return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here));
+		}
+
+		match XcmForeignAssetIdMapping::<Runtime>::get_currency_id(id.clone()) {
+			Some(AssetIds::ForeignAssetId(foreign_asset_id)) => {
+				ConvertAssetId::convert_ref(AssetIds::ForeignAssetId(foreign_asset_id))
+			}
+			_ => ConvertAssetId::convert_ref(AssetIds::ForeignAssetId(0)),
+		}
+	}
+
+	fn reverse_ref(what: impl Borrow<AssetId>) -> Result<MultiLocation, ()> {
+		log::trace!(
+			target: "xcm::AsInnerId::Reverse",
+			"AsInnerId",
+		);
+
+		let asset_id = what.borrow();
+
+		let parent_id =
+			ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent)).unwrap();
+		let here_id =
+			ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here)).unwrap();
+
+		if asset_id.clone() == parent_id {
+			return Ok(MultiLocation::parent());
+		}
+
+		if asset_id.clone() == here_id {
+			return Ok(MultiLocation::new(
+				1,
+				X1(Parachain(ParachainInfo::get().into())),
+			));
+		}
+
+		match <AssetId as TryAsForeing<AssetId, ForeignAssetId>>::try_as_foreing(asset_id.clone()) {
+			Some(fid) => match XcmForeignAssetIdMapping::<Runtime>::get_multi_location(fid) {
+				Some(location) => Ok(location),
+				None => Err(()),
+			},
+			None => Err(()),
+		}
+	}
+}
+
+/// Means for transacting assets besides the native currency on this chain.
+pub type FungiblesTransactor = FungiblesAdapter<
+	// Use this fungibles implementation:
+	ForeingAssets,
+	// Use this currency when it is a fungible asset matching the given location or name:
+	ConvertedConcreteAssetId<AssetIds, Balance, AsInnerId<AssetIds, JustTry>, JustTry>,
+	// Convert an XCM MultiLocation into a local account id:
+	LocationToAccountId,
+	// Our chain's account ID type (we can't get away without mentioning it explicitly):
+	AccountId,
+	// We only want to allow teleports of known assets. We use non-zero issuance as an indication
+	// that this asset is known.
+	NonZeroIssuance<AccountId, ForeingAssets>,
+	// The account to use for tracking teleports.
+	CheckingAccount,
+>;
+
+/// Means for transacting assets on this chain.
+pub type AssetTransactors = FungiblesTransactor;
+ */
+
+/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
+/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
+/// biases the kind of local `Origin` it will become.
+pub type XcmOriginToTransactDispatchOrigin = (
+	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location
+	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for
+	// foreign chains who want to have a local sovereign account on this chain which they control.
+	SovereignSignedViaLocation<LocationToAccountId, Origin>,
+	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
+	// recognised.
+	RelayChainAsNative<RelayOrigin, Origin>,
+	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
+	// recognised.
+	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,
+	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
+	// transaction from the Root origin.
+	ParentAsSuperuser<Origin>,
+	// Native signed account converter; this just converts an `AccountId32` origin into a normal
+	// `Origin::Signed` origin of the same 32-byte value.
+	SignedAccountId32AsNative<RelayNetwork, Origin>,
+	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.
+	XcmPassthrough<Origin>,
+);
+
+parameter_types! {
+	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.
+	pub UnitWeightCost: Weight = 1_000_000;
+	// 1200 UNIQUEs buy 1 second of weight.
+	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);
+	pub const MaxInstructions: u32 = 100;
+	pub const MaxAuthorities: u32 = 100_000;
+}
+
+match_types! {
+	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {
+		MultiLocation { parents: 1, interior: Here } |
+		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }
+	};
+}
+
+/// Execution barrier that just takes `max_weight` from `weight_credit`.
+///
+/// Useful to allow XCM execution by local chain users via extrinsics.
+/// E.g. `pallet_xcm::reserve_asset_transfer` to transfer a reserve asset
+/// out of the local chain to another one.
+pub struct AllowAllDebug;
+impl ShouldExecute for AllowAllDebug {
+	fn should_execute<Call>(
+		_origin: &MultiLocation,
+		_message: &mut Xcm<Call>,
+		max_weight: Weight,
+		weight_credit: &mut Weight,
+	) -> Result<(), ()> {
+		Ok(())
+	}
+}
+
+pub type Barrier = (
+	TakeWeightCredit,
+	AllowTopLevelPaidExecutionFrom<Everything>,
+	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,
+	// ^^^ Parent & its unit plurality gets free execution
+	AllowAllDebug,
+);
+
+pub struct AllAsset;
+impl FilterAssetLocation for AllAsset {
+	fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool {
+		true
+	}
+}
+
+/* /// CHANGEME!!!
+pub struct XcmConfig;
+impl Config for XcmConfig {
+	type Call = Call;
+	type XcmSender = XcmRouter;
+	// How to withdraw and deposit an asset.
+	type AssetTransactor = AssetTransactors;
+	type OriginConverter = XcmOriginToTransactDispatchOrigin;
+	type IsReserve = AllAsset; //NativeAsset;
+	type IsTeleporter = (); // Teleportation is disabled
+	type LocationInverter = LocationInverter<Ancestry>;
+	type Barrier = Barrier;
+	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
+	type Trader =
+		UsingAnyCurrencyComponents<LinearFee<Balance>, RelayLocation, AccountId, Balances, ()>;
+	type ResponseHandler = (); // Don't handle responses for now.
+	type SubscriptionService = PolkadotXcm;
+	type AssetTrap = PolkadotXcm;
+	type AssetClaims = PolkadotXcm;
+}
+ */
+
+/*
+/// No local origins on this chain are allowed to dispatch XCM sends/executions.
+pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);
+
+/// The means for routing XCM messages which are not for local execution into the right message
+/// queues.
+pub type XcmRouter = (
+	// Two routers - use UMP to communicate with the relay chain:
+	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,
+	// ..and XCMP to communicate with the sibling chains.
+	XcmpQueue,
+);
+ */
+
+/*
+impl pallet_xcm::Config for Runtime {
+	type Event = Event;
+	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
+	type XcmRouter = XcmRouter;
+	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
+	type XcmExecuteFilter = Everything;
+	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;
+	type XcmTeleportFilter = Everything;
+	type XcmReserveTransferFilter = Everything;
+	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
+	type LocationInverter = LocationInverter<Ancestry>;
+	type Origin = Origin;
+	type Call = Call;
+	const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
+	type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
+}
+ */
+
+/*
+impl cumulus_pallet_xcm::Config for Runtime {
+	type Event = Event;
+	type XcmExecutor = XcmExecutor<XcmConfig>;
+}
+
+impl cumulus_pallet_xcmp_queue::Config for Runtime {
+	type WeightInfo = ();
+	type Event = Event;
+	type XcmExecutor = XcmExecutor<XcmConfig>;
+	type ChannelInfo = ParachainSystem;
+	type VersionWrapper = ();
+	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
+	type ControllerOrigin = EnsureRoot<AccountId>;
+	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
+}
+
+impl cumulus_pallet_dmp_queue::Config for Runtime {
+	type Event = Event;
+	type XcmExecutor = XcmExecutor<XcmConfig>;
+	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
+}
+ */
+
+pub struct CurrencyIdConvert;
+impl Convert<AssetIds, Option<MultiLocation>> for CurrencyIdConvert {
+	fn convert(id: AssetIds) -> Option<MultiLocation> {
+		match id {
+			AssetIds::NativeAssetId(NativeCurrency::Here) => Some(MultiLocation::new(
+				1,
+				X1(Parachain(ParachainInfo::get().into())),
+			)),
+			AssetIds::NativeAssetId(NativeCurrency::Parent) => Some(MultiLocation::parent()),
+			AssetIds::ForeignAssetId(foreign_asset_id) => {
+				XcmForeignAssetIdMapping::<Runtime>::get_multi_location(foreign_asset_id)
+			}
+		}
+	}
+}
+impl Convert<MultiLocation, Option<CurrencyId>> for CurrencyIdConvert {
+	fn convert(location: MultiLocation) -> Option<CurrencyId> {
+		if location == MultiLocation::here()
+			|| location == MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())))
+		{
+			return Some(AssetIds::NativeAssetId(NativeCurrency::Here));
+		}
+
+		if location == MultiLocation::parent() {
+			return Some(AssetIds::NativeAssetId(NativeCurrency::Parent));
+		}
+
+		if let Some(currency_id) =
+			XcmForeignAssetIdMapping::<Runtime>::get_currency_id(location.clone())
+		{
+			return Some(currency_id);
+		}
+
+		None
+	}
+}
+
+pub fn get_all_module_accounts() -> Vec<AccountId> {
+	vec![TreasuryModuleId::get().into_account_truncating()]
+}
+
+pub struct DustRemovalWhitelist;
+impl Contains<AccountId> for DustRemovalWhitelist {
+	fn contains(a: &AccountId) -> bool {
+		get_all_module_accounts().contains(a)
+	}
+}
+
+parameter_type_with_key! {
+	pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance {
+		match currency_id {
+			CurrencyId::NativeAssetId(symbol) => match symbol {
+				NativeCurrency::Here => 0,
+				NativeCurrency::Parent=> 0,
+			},
+			_ => 100_000
+		}
+	};
+}
+
+impl orml_tokens::Config for Runtime {
+	type Event = Event;
+	type Balance = Balance;
+	type Amount = Amount;
+	type CurrencyId = CurrencyId;
+	type WeightInfo = ();
+	type ExistentialDeposits = ExistentialDeposits;
+	type OnDust = orml_tokens::TransferDust<Runtime, TreasuryAccountId>;
+	type MaxLocks = MaxLocks;
+	type MaxReserves = MaxReserves;
+	// TODO: Add all module accounts
+	type DustRemovalWhitelist = DustRemovalWhitelist;
+	/// The id type for named reserves.
+	type ReserveIdentifier = ();
+	type OnNewTokenAccount = ();
+	type OnKilledTokenAccount = ();
+}
+
+parameter_types! {
+	pub const BaseXcmWeight: Weight = 100_000_000; // TODO: recheck this
+	pub const MaxAssetsForTransfer: usize = 2;
+}
+
+parameter_type_with_key! {
+	pub ParachainMinFee: |_location: MultiLocation| -> Option<u128> {
+		Some(100_000_000)
+	};
+}
+
+pub struct AccountIdToMultiLocation;
+impl Convert<AccountId, MultiLocation> for AccountIdToMultiLocation {
+	fn convert(account: AccountId) -> MultiLocation {
+		X1(AccountId32 {
+			network: NetworkId::Any,
+			id: account.into(),
+		})
+		.into()
+	}
+}
+
+impl orml_xtokens::Config for Runtime {
+	type Event = Event;
+	type Balance = Balance;
+	type CurrencyId = AssetIds;
+	type CurrencyIdConvert = CurrencyIdConvert;
+	type AccountIdToMultiLocation = AccountIdToMultiLocation;
+	type SelfLocation = SelfLocation;
+	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;
+	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
+	type BaseXcmWeight = BaseXcmWeight;
+	type LocationInverter = LocationInverter<Ancestry>;
+	type MaxAssetsForTransfer = MaxAssetsForTransfer;
+	type MinXcmFee = ParachainMinFee;
+	type MultiLocationsFilter = Everything;
+	type ReserveProvider = AbsoluteReserveProvider;
+}