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

Apply XcmPaymentApi fees in transactions to Moonbeam / Moonriver / Moonbase-Alpha #351

Merged
merged 17 commits into from
Sep 24, 2024

Conversation

mmaurello
Copy link
Contributor

@mmaurello mmaurello commented Sep 18, 2024

Description

  • Implement fees form xcmPaymentApi Apply queryXcmWeight to get weight and queryWeightToAssetFee to get the fee with that weight.
  • Configure XCM instructions executed in Moonbeam / Moonriver / Moonbase Alpha to calculate the fees
  • Apply configuration to all routes going to "MoonChains". Fees from MoonChains remain as they are
  • Remove assetTypeUnitsPerSecond as it is being removed in Moonbeam's RT3200, and it is only used for Moonbeam Chains

Considerations

  • As V3 is coming soon and few chains have implemented the xcmPaymentApi, this is only applied with MoonChains in mind. It will be more generic in V3.
  • In the same line, PalletInstances are being applied directly for MoonChains, even though palletInstance exist in the Asset config. Technically, the palletInstance should be related to the chain and not the asset. This will be addressed properly in V3.
  • The function getNativeAssetId returns the Multilocation of the native asset in MoonChains. In V3, we will have to configure the multilocation of the assets whose reserve chain is the one in the configuration, since there is no way of querying it from the Polkadot service.
  • Even though some XCM routes are using XCM V3, we are doing the calculations with V4 always, since the result is the same. However, you can see in the FeeBuilder.utils.ts file that it is programmed with a switch in mind for the V3 (or earlier) format of the instructions. This could be removed but I prefer to leave it like this for the moment in case we have to switch quickly to V3 for a specific route.
  • SetTopic instruction is only executed for specific chains / pallets. But we are always considering it in the calculations to be on the safe side, and it doesn't increase the fees too much

Checklist

  • If this requires a documentation change, I have created a PR that updates the mkdocs/docs directory
  • If this requires it, I have updated the Readme
  • If necessary, I have updated the examples
  • I have verified if I need to create/update unit tests
  • I have verified if I need to create/update acceptance tests
  • If necessary, I have run acceptance tests on this branch in CI

Copy link

changeset-bot bot commented Sep 18, 2024

🦋 Changeset detected

Latest commit: 2b96c57

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@moonbeam-network/xcm-builder Minor
@moonbeam-network/xcm-config Minor
@moonbeam-network/xcm-types Minor
@moonbeam-network/xcm-sdk Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mmaurello mmaurello marked this pull request as draft September 18, 2024 17:08
@mmaurello mmaurello changed the title [WIP] Apply XcmPaymentApi fees in transactions to Moonbeam [WIP] Apply XcmPaymentApi fees in transactions to Moonbeam / Moonriver / Moonbase-Alpha Sep 20, 2024
@mmaurello mmaurello marked this pull request as ready for review September 23, 2024 09:57
@mmaurello mmaurello changed the title [WIP] Apply XcmPaymentApi fees in transactions to Moonbeam / Moonriver / Moonbase-Alpha Apply XcmPaymentApi fees in transactions to Moonbeam / Moonriver / Moonbase-Alpha Sep 23, 2024
packages/builder/src/fee/FeeBuilder.utils.ts Show resolved Hide resolved
packages/builder/src/fee/FeeBuilder.utils.ts Outdated Show resolved Hide resolved
packages/builder/src/fee/FeeBuilder.utils.ts Outdated Show resolved Hide resolved
packages/builder/src/fee/FeeBuilder.utils.ts Outdated Show resolved Hide resolved
@mmaurello mmaurello merged commit 2a7ed04 into main Sep 24, 2024
8 checks passed
@mmaurello mmaurello deleted the mjm/xcm-payment-api-moonbeam branch September 24, 2024 14:31
@github-actions github-actions bot mentioned this pull request Sep 24, 2024
@mmaurello mmaurello mentioned this pull request Sep 24, 2024
6 tasks
mmaurello added a commit that referenced this pull request Oct 2, 2024
* Apply XcmPaymentApi fees in transactions to Moonbeam / Moonriver / Moonbase-Alpha (#351)

* -wip- initial commit and initial configs

* -wip- extract common code

* -wip- fix some types

* -wip- TODOs and refactoring

* -wip- group all in a single function

* -wip- apply to all Acala and Hydration routes

* -wip- apply to manta routes

* apply xcmv4 and solution for registered asset id for ERC20s

* sort assets, handle different palletInstances and apply to several configs

* remove unused property

* remove logs

* remove deleted routes from snapshots

* apply new configuration to Kusama chains

* add changeset

* remove assetTypeUnitsPerSecond function since it is not used now

* remove assetTypeUnitsPerSecond function since it is not used now

* apply PR reviews

* Version Packages (#352)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* update snapshots

* add asset ordering param to ibtc and kbtc

* fix linting and spell checking

* add changeset for xcm-utils (#353)

* Version Packages (#355)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* fix linting and spell checking

* fix linting error

* move palletInstance validation

* fix TEER configuration in Integritee (#356)

* Version Packages (#357)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* change native asset checking and builder interface

* fix error

* Fix Asset Hub memecoings asset ordering in fee calculation (#359)

* Version Packages (#360)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* fix lint

* change property name

* rename properties

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

2 participants