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 9786b325..d231e56a 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 bf215874..d8d773fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,8 +51,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": { @@ -17058,7 +17058,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", @@ -17072,11 +17072,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/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/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 719a8b31..2ab16496 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" 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;