From 7e356c4eb78cfec724e1929a589485bf47f1851a Mon Sep 17 00:00:00 2001 From: mmaurello <93129175+mmaurello@users.noreply.github.com> Date: Tue, 30 Jan 2024 03:36:08 +1300 Subject: [PATCH 1/2] Add Kusama and Kusama Asset Hub max xcm delivery fees (#198) * add manually max Xcm Delivery fees for Kusama and Kusama Asset Hub * add changeset --- .changeset/eight-parrots-cheer.md | 6 +++++ packages/config/src/configs/kusama.ts | 5 ++++ packages/config/src/configs/kusamaAssetHub.ts | 2 ++ packages/config/src/types/AssetConfig.ts | 1 + .../sdk/src/getTransferData/getSourceData.ts | 25 +++++++++++++++++-- 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 .changeset/eight-parrots-cheer.md diff --git a/.changeset/eight-parrots-cheer.md b/.changeset/eight-parrots-cheer.md new file mode 100644 index 00000000..bac7e9ad --- /dev/null +++ b/.changeset/eight-parrots-cheer.md @@ -0,0 +1,6 @@ +--- +'@moonbeam-network/xcm-config': patch +'@moonbeam-network/xcm-sdk': patch +--- + +Xcm Delivery fees for Kusama and Kusama Asset Hub diff --git a/packages/config/src/configs/kusama.ts b/packages/config/src/configs/kusama.ts index 00b7dd24..9f8f6dc2 100644 --- a/packages/config/src/configs/kusama.ts +++ b/packages/config/src/configs/kusama.ts @@ -23,6 +23,11 @@ export const kusamaConfig = new ChainConfig({ .xcmPallet() .limitedReserveTransferAssets(0) .here(), + fee: { + asset: ksm, + balance: BalanceBuilder().substrate().system().account(), + xcmDeliveryFeeAmount: 0.0015, + }, }), ], chain: kusama, diff --git a/packages/config/src/configs/kusamaAssetHub.ts b/packages/config/src/configs/kusamaAssetHub.ts index f7c9ea99..e0ff6a0f 100644 --- a/packages/config/src/configs/kusamaAssetHub.ts +++ b/packages/config/src/configs/kusamaAssetHub.ts @@ -27,6 +27,7 @@ export const kusamaAssetHubConfig = new ChainConfig({ fee: { asset: ksm, balance: BalanceBuilder().substrate().system().account(), + xcmDeliveryFeeAmount: 0.00115, }, min: AssetMinBuilder().assets().asset(), }), @@ -46,6 +47,7 @@ export const kusamaAssetHubConfig = new ChainConfig({ fee: { asset: ksm, balance: BalanceBuilder().substrate().system().account(), + xcmDeliveryFeeAmount: 0.00115, }, min: AssetMinBuilder().assets().asset(), }), diff --git a/packages/config/src/types/AssetConfig.ts b/packages/config/src/types/AssetConfig.ts index ed4e1cf8..2d6ddb29 100644 --- a/packages/config/src/types/AssetConfig.ts +++ b/packages/config/src/types/AssetConfig.ts @@ -25,6 +25,7 @@ export interface DestinationFeeConfig extends FeeAssetConfig { export interface FeeAssetConfig { asset: Asset; balance: BalanceConfigBuilder; + xcmDeliveryFeeAmount?: number; } export class AssetConfig { diff --git a/packages/sdk/src/getTransferData/getSourceData.ts b/packages/sdk/src/getTransferData/getSourceData.ts index 7abb32ff..c5b2ff6b 100644 --- a/packages/sdk/src/getTransferData/getSourceData.ts +++ b/packages/sdk/src/getTransferData/getSourceData.ts @@ -6,7 +6,7 @@ import { } from '@moonbeam-network/xcm-builder'; import { FeeAssetConfig, TransferConfig } from '@moonbeam-network/xcm-config'; import { AssetAmount } from '@moonbeam-network/xcm-types'; -import { convertDecimals } from '@moonbeam-network/xcm-utils'; +import { convertDecimals, toBigInt } from '@moonbeam-network/xcm-utils'; import Big from 'big.js'; import { TransferContractInterface, createContract } from '../contract'; import { PolkadotService } from '../polkadot'; @@ -121,6 +121,7 @@ export async function getSourceData({ decimals: zeroFeeAmount.decimals, evmSigner, extrinsic, + feeConfig: config.fee, polkadot, sourceAddress, }); @@ -181,6 +182,7 @@ export interface GetFeeParams { decimals: number; evmSigner?: EvmSigner; extrinsic?: ExtrinsicConfig; + feeConfig?: FeeAssetConfig; polkadot: PolkadotService; sourceAddress: string; } @@ -191,6 +193,7 @@ export async function getFee({ decimals, evmSigner, extrinsic, + feeConfig, polkadot, sourceAddress, }: GetFeeParams): Promise { @@ -203,7 +206,16 @@ export async function getFee({ } if (extrinsic) { - return getExtrinsicFee(balance, extrinsic, polkadot, sourceAddress); + const extrinsicFee = await getExtrinsicFee( + balance, + extrinsic, + polkadot, + sourceAddress, + ); + + const xcmDeliveryFee = getXcmDeliveryFee(decimals, feeConfig); + + return extrinsicFee + xcmDeliveryFee; } throw new Error('Either contract or extrinsic must be provided'); @@ -246,6 +258,15 @@ export async function getExtrinsicFee( } } +function getXcmDeliveryFee( + decimals: number, + feeConfig?: FeeAssetConfig, +): bigint { + return feeConfig?.xcmDeliveryFeeAmount + ? toBigInt(feeConfig.xcmDeliveryFeeAmount, decimals) + : 0n; +} + export interface GetMaxParams { balanceAmount: AssetAmount; existentialDeposit: AssetAmount; From 75327045eb55cf0e61f8db61f9f0f68b96dcdc94 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 03:37:35 +1300 Subject: [PATCH 2/2] Version Packages (#197) Co-authored-by: github-actions[bot] --- .changeset/eight-parrots-cheer.md | 6 ------ .changeset/wet-flies-play.md | 5 ----- examples/sdk-simple/package.json | 4 ++-- package-lock.json | 10 +++++----- packages/config/CHANGELOG.md | 8 ++++++++ packages/config/package.json | 2 +- packages/sdk/CHANGELOG.md | 9 +++++++++ packages/sdk/package.json | 4 ++-- 8 files changed, 27 insertions(+), 21 deletions(-) delete mode 100644 .changeset/eight-parrots-cheer.md delete mode 100644 .changeset/wet-flies-play.md diff --git a/.changeset/eight-parrots-cheer.md b/.changeset/eight-parrots-cheer.md deleted file mode 100644 index bac7e9ad..00000000 --- a/.changeset/eight-parrots-cheer.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@moonbeam-network/xcm-config': patch -'@moonbeam-network/xcm-sdk': patch ---- - -Xcm Delivery fees for Kusama and Kusama Asset Hub diff --git a/.changeset/wet-flies-play.md b/.changeset/wet-flies-play.md deleted file mode 100644 index a3d442c9..00000000 --- a/.changeset/wet-flies-play.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@moonbeam-network/xcm-config': patch ---- - -Change endpoints for Khala and Pendulum diff --git a/examples/sdk-simple/package.json b/examples/sdk-simple/package.json index 09eacc38..36b7809d 100644 --- a/examples/sdk-simple/package.json +++ b/examples/sdk-simple/package.json @@ -12,8 +12,8 @@ "author": "", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-config": "1.3.24", - "@moonbeam-network/xcm-sdk": "1.4.20", + "@moonbeam-network/xcm-config": "1.3.25", + "@moonbeam-network/xcm-sdk": "1.4.21", "@moonbeam-network/xcm-utils": "1.0.4" }, "devDependencies": { diff --git a/package-lock.json b/package-lock.json index 662bd67e..6c9206b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,8 +50,8 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-config": "1.3.24", - "@moonbeam-network/xcm-sdk": "1.4.20", + "@moonbeam-network/xcm-config": "1.3.25", + "@moonbeam-network/xcm-sdk": "1.4.21", "@moonbeam-network/xcm-utils": "1.0.4" }, "devDependencies": { @@ -17076,7 +17076,7 @@ }, "packages/config": { "name": "@moonbeam-network/xcm-config", - "version": "1.3.24", + "version": "1.3.25", "license": "MIT", "dependencies": { "@moonbeam-network/xcm-builder": "1.0.12", @@ -17090,11 +17090,11 @@ }, "packages/sdk": { "name": "@moonbeam-network/xcm-sdk", - "version": "1.4.20", + "version": "1.4.21", "license": "MIT", "dependencies": { "@moonbeam-network/xcm-builder": "1.0.12", - "@moonbeam-network/xcm-config": "1.3.24", + "@moonbeam-network/xcm-config": "1.3.25", "@moonbeam-network/xcm-types": "1.0.3", "@moonbeam-network/xcm-utils": "1.0.4", "big.js": "^6.2.1" diff --git a/packages/config/CHANGELOG.md b/packages/config/CHANGELOG.md index c9269a82..e67771e1 100644 --- a/packages/config/CHANGELOG.md +++ b/packages/config/CHANGELOG.md @@ -1,5 +1,13 @@ # @moonbeam-network/xcm-config +## 1.3.25 + +### Patch Changes + +- [#198](https://github.com/moonbeam-foundation/xcm-sdk/pull/198) [`7e356c4`](https://github.com/moonbeam-foundation/xcm-sdk/commit/7e356c4eb78cfec724e1929a589485bf47f1851a) Thanks [@mmaurello](https://github.com/mmaurello)! - Xcm Delivery fees for Kusama and Kusama Asset Hub + +- [#196](https://github.com/moonbeam-foundation/xcm-sdk/pull/196) [`ce63c3e`](https://github.com/moonbeam-foundation/xcm-sdk/commit/ce63c3ec0d15b496103965a17a5d29099b355357) Thanks [@mmaurello](https://github.com/mmaurello)! - Change endpoints for Khala and Pendulum + ## 1.3.24 ### Patch Changes diff --git a/packages/config/package.json b/packages/config/package.json index 7018f85e..5eb9dc06 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-config", - "version": "1.3.24", + "version": "1.3.25", "description": "All necessary configuration to transfer assets from Moonbeam, Moonriver, Moonbase to other parachains and back", "scripts": { "build": "tsup", diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 700c61a1..a09a6479 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,14 @@ # @moonbeam-network/xcm-sdk +## 1.4.21 + +### Patch Changes + +- [#198](https://github.com/moonbeam-foundation/xcm-sdk/pull/198) [`7e356c4`](https://github.com/moonbeam-foundation/xcm-sdk/commit/7e356c4eb78cfec724e1929a589485bf47f1851a) Thanks [@mmaurello](https://github.com/mmaurello)! - Xcm Delivery fees for Kusama and Kusama Asset Hub + +- Updated dependencies [[`7e356c4`](https://github.com/moonbeam-foundation/xcm-sdk/commit/7e356c4eb78cfec724e1929a589485bf47f1851a), [`ce63c3e`](https://github.com/moonbeam-foundation/xcm-sdk/commit/ce63c3ec0d15b496103965a17a5d29099b355357)]: + - @moonbeam-network/xcm-config@1.3.25 + ## 1.4.20 ### Patch Changes diff --git a/packages/sdk/package.json b/packages/sdk/package.json index fd8d9b3f..ce96ed7b 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-sdk", - "version": "1.4.20", + "version": "1.4.21", "description": "The Moonbeam XCM SDK enables developers to easily deposit and withdraw assets to Moonbeam/Moonriver from the relay chain and other parachains in the Polkadot/Kusama ecosystem", "scripts": { "build": "tsup", @@ -52,7 +52,7 @@ "main": "./build/index.cjs", "dependencies": { "@moonbeam-network/xcm-builder": "1.0.12", - "@moonbeam-network/xcm-config": "1.3.24", + "@moonbeam-network/xcm-config": "1.3.25", "@moonbeam-network/xcm-types": "1.0.3", "@moonbeam-network/xcm-utils": "1.0.4", "big.js": "^6.2.1"