Skip to content

[XCM]XcmPaymentApi::query_delivery_fees() allow querying fee using custom asset#7179

Closed
programskillforverification wants to merge 4 commits intoparitytech:masterfrom
programskillforverification:custom-asset-for-query_delivery_fees
Closed

[XCM]XcmPaymentApi::query_delivery_fees() allow querying fee using custom asset#7179
programskillforverification wants to merge 4 commits intoparitytech:masterfrom
programskillforverification:custom-asset-for-query_delivery_fees

Conversation

@programskillforverification
Copy link
Copy Markdown
Contributor

@programskillforverification programskillforverification commented Jan 15, 2025

Description

close #7061

@programskillforverification programskillforverification changed the title init [XCM]XcmPaymentApi::query_delivery_fees() allow querying fee using custom asset Jan 15, 2025
XcmPaymentApiError::Unroutable
})?;

// fees.into_inner().iter().for_each(|asset| {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acatangiu how can I convert fee to new asset corresponding custom_asset without introduce new dependency?

Copy link
Copy Markdown
Contributor

@acatangiu acatangiu Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

I think add a new is better

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Runtime APIs are versioned so there's no problem with changing the signature.
You just need to specify the version, leave the old signature and point to the new one.
Example:

Screenshot 2025-01-17 at 10 50 36

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

assets_common causes cyclic package dependency. So directly use pallet-asset-conversion::quote_price_tokens_for_exact_tokens()?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XcmPaymentApi::query_delivery_fees() should allow querying fee using custom asset

3 participants