[XCM]XcmPaymentApi::query_delivery_fees() allow querying fee using custom asset#7179
Conversation
polkadot/xcm/pallet-xcm/src/lib.rs
Outdated
| XcmPaymentApiError::Unroutable | ||
| })?; | ||
|
|
||
| // fees.into_inner().iter().for_each(|asset| { |
There was a problem hiding this comment.
@acatangiu how can I convert fee to new asset corresponding custom_asset without introduce new dependency?
There was a problem hiding this comment.
you don't change pallet_xcm::query_delivery_fees() - it provides delivery fee as X DOT
you change xcm_runtime_apis::fees::XcmPaymentApi implementation fn query_delivery_fees(dest, msg, asset_id) to convert X DOT to Y custom_asset using assets_common::PoolAdapter::::quote_price_tokens_for_exact_tokens()
There was a problem hiding this comment.
You also need to change the XcmPaymentApi to take custom asset_id for delivery fees.
You can either change existing fn query_delivery_fees() - which would be a API breaking change - or you can add a new function..
RuntimeAPIs are versioned so it's not a big deal to break them, but not sure which one's better. @franciscoaguirre thoughts?
There was a problem hiding this comment.
You also need to change the
XcmPaymentApito take customasset_idfor delivery fees.You can either change existing fn query_delivery_fees() - which would be a API breaking change - or you can add a new function..
RuntimeAPIs are versioned so it's not a big deal to break them, but not sure which one's better. @franciscoaguirre thoughts?
I think add a new is better
There was a problem hiding this comment.
you don't change
pallet_xcm::query_delivery_fees()- it provides delivery fee as X DOTyou change
xcm_runtime_apis::fees::XcmPaymentApiimplementation fn query_delivery_fees(dest, msg, asset_id) to convertX DOTto Ycustom_assetusing assets_common::PoolAdapter::::quote_price_tokens_for_exact_tokens()
assets_common causes cyclic package dependency. So directly use pallet-asset-conversion::quote_price_tokens_for_exact_tokens()?
There was a problem hiding this comment.
I think returning the delivery fees in the required asset (DOT, for example) is as far as this pallet-xcm helper is going to get.
This pallet doesn't assume the runtime it's running on has pallet-asset-conversion, or any pallet.
So we should call assets_common::PoolAdapter::::quote_price_tokens_for_exact_tokens() on the runtimes we want to swap, so asset-hub-westend.
The implementation in asset-hub-westend would call this pallet-xcm helper to get the fee in DOT and then call the asset conversion function to convert it into the custom asset that was passed in

Description
close #7061