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

Fix WeightToFee function in MangataAdapter #111

Merged
merged 8 commits into from
Dec 5, 2023
Merged

Conversation

imstar15
Copy link
Member

According Mangata code

https://github.com/mangata-finance/mangata-node/blob/24d4304b982c02ed162f2ff5d94faa907520b3fd/runtime/mangata-rococo/src/constants.rs#L49

If we use MGR for xcmp fee, We should use the following code to calculate the fee by weight.

const UNIT = new BN("1000000000000000000");
// ExtrinsicBaseWeight benchmark value: 114756 nano seconds
const extrinsicBaseWeight = WEIGHT_REF_TIME_PER_NANOS.mul(new BN(114756));
const feePerSecond = WEIGHT_REF_TIME_PER_SECOND.mul(
  UNIT.div(extrinsicBaseWeight),
);
const refTimeFee = weight.refTime
  .mul(feePerSecond)
  .div(WEIGHT_REF_TIME_PER_SECOND);
const proofSizeFee = weight.proofSize
  .mul(feePerSecond)
  .div(WEIGHT_PROOF_SIZE_PER_MB);
return refTimeFee.add(proofSizeFee);

Copy link

changeset-bot bot commented Nov 30, 2023

⚠️ No Changeset found

Latest commit: 23c6406

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@imstar15 imstar15 requested review from chrisli30 and v9n November 30, 2023 18:48
chrisli30
chrisli30 previously approved these changes Dec 1, 2023
Copy link
Member

@chrisli30 chrisli30 left a comment

Choose a reason for hiding this comment

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

The code looks generally good to me.

packages/adapter/src/chains/mangata.ts Outdated Show resolved Hide resolved
@imstar15 imstar15 requested a review from chrisli30 December 4, 2023 13:19
@imstar15 imstar15 marked this pull request as ready for review December 4, 2023 13:19
@imstar15 imstar15 changed the title [WIP]Fix WeightToFee function in MangataAdapter Fix WeightToFee function in MangataAdapter Dec 4, 2023
Copy link
Member

@chrisli30 chrisli30 left a comment

Choose a reason for hiding this comment

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

Let me find a better name for the x2Params since it’s not accurate enough.

packages/adapter/src/chains/oak.ts Outdated Show resolved Hide resolved
Copy link
Member

@chrisli30 chrisli30 left a comment

Choose a reason for hiding this comment

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

Let’s revert the line break changes. Please see what is the value of your eslint max-len

chrisli30
chrisli30 previously approved these changes Dec 5, 2023
}

// Function to construct the 'location' object based on the parameters.
function constructLocation(parachainId: number, palletInstance?: number): Location {
let interior = palletInstance ? { X2: [{ Parachain: parachainId }, { PalletInstance: palletInstance }] } : { X1: { Parachain: parachainId } };
function constructLocation(parachainId: number, x2Params?: any): Location {
Copy link
Member

Choose a reason for hiding this comment

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

Let’s rename the x2Params to interior.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@imstar15 imstar15 force-pushed the fix-mangata-weight-to-fee branch from 4e0e133 to 23c6406 Compare December 5, 2023 03:27
Copy link
Member

@chrisli30 chrisli30 left a comment

Choose a reason for hiding this comment

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

Okay, the changes look good 🆗

@imstar15 imstar15 merged commit 1c93e9c into dev Dec 5, 2023
2 checks passed
@imstar15 imstar15 deleted the fix-mangata-weight-to-fee branch December 5, 2023 07:09
chrisli30 added a commit that referenced this pull request Dec 28, 2023
* Merge dev_bakup to dev branch (#108)

* Add a past time test for dynamic dispatch task (#103)

* Add a past time test for dynamic dispatch task

* Specific errors were thrown during testing

* Fix past time test with time slot

* Auto compound interfaces (#99)

* Fix adapter

* Auto compound interfaces

* Remove eslint-disable-next-line import/no-extraneous-dependencies

* Update @polkadot/typegen, "@polkadot/types  version to ^10.9.1

* Remove ChainData; Add instructionNetworkType to XcmConfig

* Add tests for auto-compound

* Listen events

* Return after the reject or resolve statement

* Revert "Return after the reject or resolve statement"

This reverts commit a5fe124.

* Change ensureBalance to hasEnoughFreeBalance

* Rename test case names

* If the delegation does not exist, getAutoCompoundingDelegationPercentage return undefined

* Add description for Compound tests

---------

Co-authored-by: imstar15 <imstar15@qq.com>

* Return different instruction numbers based on the transactType (#110)

* Renamed chainData to chainConfig in adapters

* Added moment library root to fix test/sdk/sdk.test.ts dependency missing problem

* Updated to getChainConfig() in test/sdk/sdk.test.ts

* Added a temporary fix for MoonbeamAdapter fetchAndUpdateConfigs

* Defined build order in package.json to make sure config builds first

* Remove from git add from package.json

* Upgraded yarn to use the workspace feature

* Added root:true to make sure .eslintrc.json works as the root path

* Added custom errors to adapter package

* Updated dependency of adapter to config@^1.0.0

* Updated the dependencies among our packages

* Added isEthereum to all chains in the config package

* Added util functions to adapter

* Fix WeightToFee function in MangataAdapter (#111)

* Fix WeightToFee function in MangataAdapter

* Caculate unit by decimals

* Change chainData to chainConfig

* Fix mangata crossChainTransfer function

* Rename x2Params to interior

* Format code with .prettierrc

* Fixed Github Actions caused by the new yarn berry version (#112)

* Try to fix yarn@2 issue caused in Actions

* Fix a typo in Release Action

* Try to fix dependency missing issue in Actions

* Run yarn install with yarn berry version in local environment

* Turn off installConfig.immutable in .yarnrc.yml in github Actions

* Turn off installConfig.immutable in .yarnrc.yml in github Actions

* Added continue-on-error: true to changeset Pull Release in Action

* Remove testing trigger branch from .github/workflows/release.yml

* Updated Github Actions using yarn berry version

* Optimize typescript files based on eslint suggestions

* docs(changeset): Updated dependencies among @oak-network/packages to refer to the latest code instead of fixed version

* Reverted package reference strategy back to workspace:^1.0.0 (#114)

* Reverted package reference strategy back to workspace:^1.0.0

* docs(changeset): Reverted package reference strategy back to workspace:^1.0.0

* Fix publish dev version to NPM Github Actions (#116)

* Added ls command to print out the current path in Action

* Make sure postbuild script run

* Clean up github actions

* RELEASING: Releasing 5 package(s) (#115)

Releases:
  @oak-network/api-augment@2.1.1
  @oak-network/adapter@0.1.6
  @oak-network/config@1.0.1
  @oak-network/types@2.1.1
  @oak-network/sdk@0.1.6

[skip ci]

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

* RELEASING: Releasing 5 package(s) (#117)

Releases:
  @oak-network/api-augment@2.1.1
  @oak-network/adapter@0.1.6
  @oak-network/config@1.0.1
  @oak-network/types@2.1.1
  @oak-network/sdk@0.1.6

[skip ci]

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

* Update script/package-setup.js (#118)

* docs(changeset): SDK and adapter upgrades with automationPrice support

* Update package-setup.js

* RELEASING: Releasing 2 package(s) (#119)

Releases:
  @oak-network/adapter@0.2.0
  @oak-network/sdk@0.2.0

[skip ci]

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

* Export utils constants and errors from adapters (#120)

* Export utils constants and errors from adapters

* docs(changeset): Export utils constants and errors from adapters

* Set the release action to trigger only on main branch

* Revert "Set the release action to trigger only on main branch"

This reverts commit 67900f5.

* RELEASING: Releasing 1 package(s) (#121)

Releases:
  @oak-network/adapter@0.2.1

[skip ci]

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

* Add scheduleAs to task params (#122)

* Add scheduleAs to task params

* docs(changeset): Add scheduleAs to task params

* The scheduleAs parameter should be pass into schedule task function

* RELEASING: Releasing 1 package(s) (#123)

Releases:
  @oak-network/sdk@0.2.1

[skip ci]

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

* Change oakAdapter account derivation (#125)

* Change oakAdapter account derivation

* docs(changeset): Change oakAdapter account derivation

* RELEASING: Releasing 2 package(s) (#127)

Releases:
  @oak-network/adapter@0.2.2
  @oak-network/sdk@0.2.2

[skip ci]

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

* Rename xtokens to xTokens in astarAdapter (#126)

* Rename xtokens to xTokens in astarAdapter

* docs(changeset): Rename xtokens to xTokens in astarAdapter

* RELEASING: Releasing 1 package(s) (#128)

Releases:
  @oak-network/adapter@0.2.3

[skip ci]

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

* Added currencyId to tokens of Turing chains (#129)

* docs(changeset): Export utils constants and errors from adapters

* Added currencyId to tokens of Turing chains

* docs(changeset): Added currency Id to the tokens registered on Turing chains

* Revert "docs(changeset): Export utils constants and errors from adapters"

This reverts commit d89c5fd.

* RELEASING: Releasing 1 package(s) (#131)

Releases:
  @oak-network/config@1.0.2

[skip ci]

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

* Fix a problem where currencyId is not set on Turing chains (#132)

* Fix a problem where currencyId is not set on Turing chains

* docs(changeset): Fix a problem where currencyId is not set on Turing chains

* RELEASING: Releasing 1 package(s) (#133)

Releases:
  @oak-network/config@1.0.3

[skip ci]

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

---------

Co-authored-by: imstar15 <imstar15@qq.com>
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