Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PoolAssetsExchanger to asset hubs #539

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
24 changes: 23 additions & 1 deletion system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,28 @@ pub type PoolFungiblesTransactor = FungiblesAdapter<
pub type AssetTransactors =
(FungibleTransactor, FungiblesTransactor, ForeignFungiblesTransactor, PoolFungiblesTransactor);

/// Asset converter for pool assets.
/// Used to convert one asset to another, when there is a pool available between the two.
/// This type thus allows paying delivery fees with any asset as long as there is a pool between said
/// asset and the asset required for fee payment.
pub type PoolAssetsExchanger = SingleAssetExchangeAdapter<
AssetConversion,
NativeAndAssets,
(
TrustBackedAssetsAsLocation<TrustBackedAssetsPalletLocation, Balance, xcm::v4::Location>,
ForeignAssetsConvertedConcreteId,
// `ForeignAssetsConvertedConcreteId` excludes the relay token, so we add it back here.
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
MatchedConvertedConcreteId<
xcm::v4::Location,
Balance,
Equals<ParentLocation>,
WithLatestLocationConverter<xcm::v4::Location>,
TryConvertInto,
>,
),
AccountId,
>;

/// 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`.
///
Expand Down Expand Up @@ -378,7 +400,7 @@ impl xcm_executor::Config for XcmConfig {
type PalletInstancesInfo = AllPalletsWithSystem;
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
type AssetLocker = ();
type AssetExchanger = ();
type AssetExchanger = PoolAssetsExchanger;
type FeeManager = XcmFeeManagerFromComponents<
WaivedLocations,
SendXcmFeeToAccount<Self::AssetTransactor, RelayTreasuryPalletAccount>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,28 @@ pub type PoolFungiblesTransactor = FungiblesAdapter<
pub type AssetTransactors =
(FungibleTransactor, FungiblesTransactor, ForeignFungiblesTransactor, PoolFungiblesTransactor);

/// Asset converter for pool assets.
/// Used to convert one asset to another, when there is a pool available between the two.
/// This type thus allows paying delivery fees with any asset as long as there is a pool between said
/// asset and the asset required for fee payment.
pub type PoolAssetsExchanger = SingleAssetExchangeAdapter<
AssetConversion,
NativeAndAssets,
(
TrustBackedAssetsAsLocation<TrustBackedAssetsPalletLocation, Balance, xcm::v4::Location>,
ForeignAssetsConvertedConcreteId,
// `ForeignAssetsConvertedConcreteId` excludes the relay token, so we add it back here.
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
MatchedConvertedConcreteId<
xcm::v4::Location,
Balance,
Equals<ParentLocation>,
WithLatestLocationConverter<xcm::v4::Location>,
TryConvertInto,
>,
),
AccountId,
>;

/// 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`.
///
Expand Down Expand Up @@ -443,7 +465,7 @@ impl xcm_executor::Config for XcmConfig {
type PalletInstancesInfo = AllPalletsWithSystem;
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
type AssetLocker = ();
type AssetExchanger = ();
type AssetExchanger = PoolAssetsExchanger;
type FeeManager = XcmFeeManagerFromComponents<
WaivedLocations,
SendXcmFeeToAccount<Self::AssetTransactor, RelayTreasuryPalletAccount>,
Expand Down
Loading