Skip to content

Commit

Permalink
Merge branch 'main' into update-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaurello authored Jan 29, 2024
2 parents 26b9117 + 7532704 commit 71e148c
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 17 deletions.
5 changes: 0 additions & 5 deletions .changeset/wet-flies-play.md

This file was deleted.

4 changes: 2 additions & 2 deletions examples/sdk-simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions packages/config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions packages/config/src/configs/kusama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions packages/config/src/configs/kusamaAssetHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const kusamaAssetHubConfig = new ChainConfig({
fee: {
asset: ksm,
balance: BalanceBuilder().substrate().system().account(),
xcmDeliveryFeeAmount: 0.00115,
},
min: AssetMinBuilder().assets().asset(),
}),
Expand All @@ -46,6 +47,7 @@ export const kusamaAssetHubConfig = new ChainConfig({
fee: {
asset: ksm,
balance: BalanceBuilder().substrate().system().account(),
xcmDeliveryFeeAmount: 0.00115,
},
min: AssetMinBuilder().assets().asset(),
}),
Expand Down
1 change: 1 addition & 0 deletions packages/config/src/types/AssetConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface DestinationFeeConfig extends FeeAssetConfig {
export interface FeeAssetConfig {
asset: Asset;
balance: BalanceConfigBuilder;
xcmDeliveryFeeAmount?: number;
}

export class AssetConfig {
Expand Down
9 changes: 9 additions & 0 deletions packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
Expand Down
25 changes: 23 additions & 2 deletions packages/sdk/src/getTransferData/getSourceData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -121,6 +121,7 @@ export async function getSourceData({
decimals: zeroFeeAmount.decimals,
evmSigner,
extrinsic,
feeConfig: config.fee,
polkadot,
sourceAddress,
});
Expand Down Expand Up @@ -181,6 +182,7 @@ export interface GetFeeParams {
decimals: number;
evmSigner?: EvmSigner;
extrinsic?: ExtrinsicConfig;
feeConfig?: FeeAssetConfig;
polkadot: PolkadotService;
sourceAddress: string;
}
Expand All @@ -191,6 +193,7 @@ export async function getFee({
decimals,
evmSigner,
extrinsic,
feeConfig,
polkadot,
sourceAddress,
}: GetFeeParams): Promise<bigint> {
Expand All @@ -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');
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 71e148c

Please sign in to comment.