-
Notifications
You must be signed in to change notification settings - Fork 380
Pay XCM execution with local and foreign assets #2854
base: master
Are you sure you want to change the base?
Changes from 9 commits
c322b41
a303989
2e11c16
6a7b39c
b1e4532
470903b
7b334af
76a3c1a
a155a90
a33ce58
9b1be53
9548d4b
4839910
bd91d47
308abf0
f59d16a
88c4e31
94aef1d
081517f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ use assets_common::{ | |
matching::{ | ||
FromSiblingParachain, IsForeignConcreteAsset, StartsWith, StartsWithExplicitGlobalConsensus, | ||
}, | ||
AssetIdForTrustBackedAssetsConvert, | ||
}; | ||
use frame_support::{ | ||
match_types, parameter_types, | ||
|
@@ -46,6 +47,7 @@ use xcm_builder::{ | |
}; | ||
use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; | ||
|
||
use assets_common::local_and_foreign_assets::LocalAndForeignAssets; | ||
#[cfg(feature = "runtime-benchmarks")] | ||
use {cumulus_primitives_core::ParaId, sp_core::Get}; | ||
|
||
|
@@ -125,6 +127,17 @@ pub type ForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConverte | |
Balance, | ||
>; | ||
|
||
/// `AssetId/Balance` converter for pay by swap | ||
pub type LocalAndForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConvertedConcreteId< | ||
( | ||
// Ignore asset which starts explicitly with our `GlobalConsensus(NetworkId)`, means: | ||
// - foreign assets from our consensus should be: `MultiLocation {parents: 1, X*(Parachain(xyz), ..)} | ||
// - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` wont be accepted here | ||
StartsWithExplicitGlobalConsensus<UniversalLocationNetworkId>, | ||
), | ||
Balance, | ||
>; | ||
|
||
/// Means for transacting foreign assets from different global consensus. | ||
pub type ForeignFungiblesTransactor = FungiblesAdapter< | ||
// Use this fungibles implementation: | ||
|
@@ -469,12 +482,19 @@ impl xcm_executor::Config for XcmConfig { | |
>; | ||
type Trader = ( | ||
UsingComponents<WeightToFee, WestendLocation, AccountId, Balances, ToStakingPot<Runtime>>, | ||
cumulus_primitives_utility::TakeFirstAssetTrader< | ||
AccountId, | ||
AssetFeeAsExistentialDepositMultiplierFeeCharger, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understand is, that we can use the same One important thing is that the |
||
TrustBackedAssetsConvertedConcreteId, | ||
Assets, | ||
cumulus_primitives_utility::SwapFirstAssetTrader< | ||
PatricioNapoli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Runtime, | ||
LocationToAccountId, | ||
pallet_asset_conversion::Pallet<Runtime>, | ||
WeightToFee, | ||
LocalAndForeignAssetsConvertedConcreteId, | ||
LocalAndForeignAssets< | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also
it took me a while to find a issue with this missing overridden implementations b8f86cf and I am afraid that there could be possible other hidden bugs (maybe not), |
||
Assets, | ||
AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation>, | ||
ForeignAssets, | ||
>, | ||
cumulus_primitives_utility::XcmFeesTo32ByteAccount< | ||
// Revenue could also be Foreign Fungible? Maybe with multi-asset treasury..? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, although Treasury here is just a normal |
||
FungiblesTransactor, | ||
AccountId, | ||
XcmAssetFeesReceiver, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this is good way and if it covers everything: Local and Foreign... it is kind of hacky.
what was wrong with two
SwapFirstAssetTrader
instance configured withAssets
andForeignAssets
with reused verified converters?xcm uses everywhere tuple implementation, e.g. check AssetTransactors, it is much clear approach,
maybe in future we would like to add another pallet_assets instance, then what?
LocalAndForeignAndWhateverAssetsConvertedConcreteId + LocalAndForeignAndWhateverAssets
?I guess easier/nicer is to add another
SwapFirstAssetTrader
like we do for AssetTransactors - we just add new instance:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree. I think a lot of the problem originates in the
SignedExtension
for fee payment. TheLocalOrForeign
struct basically serves as the router, to figure out which instance of the Assets pallet the input refers to. But I don't think we need to do that here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try using two SwapFirstAssetTrader instances for now and if and when LocalAndForeignAssets gets conformance tests, we can switch to that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, I would not switch back to
LocalAndForeignAssets
here :),as Joe said
LocalAndForeignAssets
is ok/needed forSignedExtension
, but here is much clear to have multipleSwapFirstAssetTrader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the
Assets
one, how do I fulfill the bound inSwapFirstAssetTrader
that is:MultiLocation: From<ConcreteAssets::AssetId> + Into<T::MultiAssetId>
Here's the constraint
The question is explicitly, what would be the right
MatchedConvertedConcreteId
(asset matcher) type to pass in here? Or else, what would the right bound be inSwapFirstAssetTrader
for using the regular Asset's ID in the swap fn?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PatricioNapoli
for
Assets
->xcm_config::TrustBackedAssetsConvertedConcreteId
for
ForeignAssets
->xcm_config::ForeignAssetsConvertedConcreteId
and for that constraint, I tried it (does not compile because of XcmContext), but something like this should work:
#2955
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkontur
Does not currently compile for the Local assets trader, using
TrustBackedAssetsConvertedConcreteId
error is:
latest changes are pushed