From 4763a1af051688d730c842a25f3eade72fa02e4e Mon Sep 17 00:00:00 2001 From: Mario J Maurello Date: Wed, 25 Oct 2023 16:41:38 +0200 Subject: [PATCH 1/2] Change paying token for vDOT transfers and adapt decimals query in destination chain --- packages/config/src/chains.ts | 2 +- .../config/src/configs/bifrostPolkadot.ts | 8 ++++---- .../src/getTransferData/getDestinationData.ts | 19 +++++++++++++++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index cdcf7a37..6c719bc5 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -219,7 +219,7 @@ export const bifrostPolkadot = new Parachain({ name: 'Bifrost', parachainId: 2030, ss58Format: 6, - ws: 'wss://hk.p.bifrost-rpc.liebi.com/ws', + ws: 'wss://eu.bifrost-polkadot-rpc.liebi.com/ws', }); export const calamari = new Parachain({ diff --git a/packages/config/src/configs/bifrostPolkadot.ts b/packages/config/src/configs/bifrostPolkadot.ts index f7542e73..f6d24020 100644 --- a/packages/config/src/configs/bifrostPolkadot.ts +++ b/packages/config/src/configs/bifrostPolkadot.ts @@ -59,11 +59,11 @@ export const bifrostPolkadotConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.2, - asset: bnc, - balance: BalanceBuilder().substrate().system().account(), + amount: 0.01, + asset: vdot, + balance: BalanceBuilder().substrate().tokens().accounts(), }, - extrinsic: ExtrinsicBuilder().xTokens().transferMultiCurrencies(), + extrinsic: ExtrinsicBuilder().xTokens().transfer(), fee: { asset: bnc, balance: BalanceBuilder().substrate().system().account(), diff --git a/packages/sdk/src/getTransferData/getDestinationData.ts b/packages/sdk/src/getTransferData/getDestinationData.ts index 1f59fd0b..ed56e1cc 100644 --- a/packages/sdk/src/getTransferData/getDestinationData.ts +++ b/packages/sdk/src/getTransferData/getDestinationData.ts @@ -46,7 +46,12 @@ export async function getDestinationData({ const balanceAmount = zeroAmount.copyWith({ amount: balance }); const { existentialDeposit } = polkadot; - const feeAmount = await getFee({ config: transferConfig, polkadot }); + const feeAmount = await getFee({ + address: destinationAddress, + config: transferConfig, + evmSigner, + polkadot, + }); const minAmount = zeroAmount.copyWith({ amount: min }); return { @@ -59,16 +64,26 @@ export async function getDestinationData({ } export interface GetFeeParams { + address: string; config: TransferConfig; + evmSigner?: EvmSigner; polkadot: PolkadotService; } export async function getFee({ + address, config, + evmSigner, polkadot, }: GetFeeParams): Promise { const { amount, asset } = config.source.config.destinationFee; - const decimals = await polkadot.getAssetDecimals(asset); + const decimals = await getDecimals({ + address, + asset, + config: config.destination.config, + evmSigner, + polkadot, + }); const zeroAmount = AssetAmount.fromAsset(asset, { amount: 0n, decimals, From 44e8fefa0950edecb83674cfed8fc84a872b908c Mon Sep 17 00:00:00 2001 From: Mario J Maurello Date: Wed, 25 Oct 2023 16:46:13 +0200 Subject: [PATCH 2/2] add changeset --- .changeset/orange-trainers-teach.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/orange-trainers-teach.md diff --git a/.changeset/orange-trainers-teach.md b/.changeset/orange-trainers-teach.md new file mode 100644 index 00000000..338e6d80 --- /dev/null +++ b/.changeset/orange-trainers-teach.md @@ -0,0 +1,6 @@ +--- +'@moonbeam-network/xcm-config': patch +'@moonbeam-network/xcm-sdk': patch +--- + +Change how we get decimals from assets in destination and change vDOT transfers paying asset