From 4035acc82dd22fa571cb1ea5c2822347d1a85b7c Mon Sep 17 00:00:00 2001 From: mmaurello <93129175+mmaurello@users.noreply.github.com> Date: Tue, 7 Nov 2023 12:25:08 +0100 Subject: [PATCH] USDC Polkadot Asset Hub - Moonbeam integration (#160) * -wip- USDC Polkadot Asset Hub - Moonbeam integration * USDC between Polkadot Asset Hub and Moonbeam and use vDOT as fee token in vDOT transfers * remove comment * remove unnecessary changes * add changeset --- .changeset/light-ghosts-change.md | 6 +++++ packages/config/src/assets.ts | 6 +++++ packages/config/src/chains.ts | 23 ++++++++++++++----- .../config/src/configs/bifrostPolkadot.ts | 8 +++---- packages/config/src/configs/moonbeam.ts | 16 +++++++++++++ .../config/src/configs/polkadotAssetHub.ts | 21 ++++++++++++++++- 6 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 .changeset/light-ghosts-change.md diff --git a/.changeset/light-ghosts-change.md b/.changeset/light-ghosts-change.md new file mode 100644 index 00000000..3fb2849c --- /dev/null +++ b/.changeset/light-ghosts-change.md @@ -0,0 +1,6 @@ +--- +'@moonbeam-network/xcm-config': patch +'@moonbeam-network/xcm-sdk': patch +--- + +USDC asset hub integration and vDOT paying for fees diff --git a/packages/config/src/assets.ts b/packages/config/src/assets.ts index 90a4f4e8..3876cfce 100644 --- a/packages/config/src/assets.ts +++ b/packages/config/src/assets.ts @@ -220,6 +220,11 @@ export const unit = new Asset({ originSymbol: 'Unit', }); +export const usdc = new Asset({ + key: 'usdc', + originSymbol: 'USDC', +}); + export const usdcwh = new Asset({ key: 'usdcwh', originSymbol: 'USDC.Wh', @@ -334,6 +339,7 @@ export const assetsList: Asset[] = [ tt1, tur, unit, + usdc, usdcwh, usdt, usdtwh, diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index ed5a007b..60294898 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -49,6 +49,7 @@ import { tt1, tur, unit, + usdc, usdcwh, usdt, usdtwh, @@ -860,6 +861,11 @@ export const moonbeam = new EvmParachain({ asset: ring, id: '125699734534028342599692732320197985871', }, + { + asset: usdc, + id: '0xFFfffffF7D2B0B761Af01Ca8e25242976ac0aD7D', + metadataId: '166377000701797186346254371275954761085', // registered XC20 id for ERC20 tokens + }, { asset: usdcwh, id: '0x931715FEE2d06333043d11F658C8CE934aC61D0c', @@ -877,17 +883,17 @@ export const moonbeam = new EvmParachain({ { asset: vdot, id: '0xFFFfffFf15e1b7E3dF971DD813Bc394deB899aBf', - metadataId: 0, // no metadata for ERC20 tokens + metadataId: '29085784439601774464560083082574142143', // registered XC20 id for ERC20 tokens }, { asset: vfil, id: '0xFffffFffCd0aD0EA6576B7b285295c85E94cf4c1', - metadataId: 0, // no metadata for ERC20 tokens + metadataId: '272547899416482196831721420898811311297', // registered XC20 id for ERC20 tokens }, { asset: vglmr, id: '0xFfFfFFff99dABE1a8De0EA22bAa6FD48fdE96F6c', - metadataId: 0, // no metadata for ERC20 tokens + metadataId: '204507659831918931608354793288110796652', // registered XC20 id for ERC20 tokens }, { asset: wbtc, @@ -1002,17 +1008,17 @@ export const moonriver = new EvmParachain({ { asset: vbnc, id: '0xFFffffff3646A00f78caDf8883c5A2791BfCDdc4', - metadataId: 0, + metadataId: '72145018963825376852137222787619937732', }, { asset: vksm, id: '0xFFffffFFC6DEec7Fc8B11A2C8ddE9a59F8c62EFe', - metadataId: 0, + metadataId: '264344629840762281112027368930249420542', }, { asset: vmovr, id: '0xfFfffFfF98e37bF6a393504b5aDC5B53B4D0ba11', - metadataId: 0, + metadataId: '203223821023327994093278529517083736593', }, ], ecosystem: Ecosystem.Kusama, @@ -1197,6 +1203,11 @@ export const polkadotAssetHub = new Parachain({ // NOTE: no meta for native token metadataId: 9999999, }, + { + asset: usdc, + id: 1337, + palletInstance: 50, + }, ], ecosystem: Ecosystem.Polkadot, genesisHash: 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/config/src/configs/moonbeam.ts b/packages/config/src/configs/moonbeam.ts index 9ef5f85c..0e550fbc 100644 --- a/packages/config/src/configs/moonbeam.ts +++ b/packages/config/src/configs/moonbeam.ts @@ -19,6 +19,7 @@ import { para, pha, ring, + usdc, usdcwh, usdt, usdtwh, @@ -380,6 +381,21 @@ export const moonbeamConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), }, }), + new AssetConfig({ + asset: usdc, + balance: BalanceBuilder().evm().erc20(), + contract: ContractBuilder().Xtokens().transfer(), + destination: polkadotAssetHub, + destinationFee: { + amount: 0.7, + asset: usdc, + balance: BalanceBuilder().substrate().assets().account(), + }, + fee: { + asset: glmr, + balance: BalanceBuilder().substrate().system().account(), + }, + }), new AssetConfig({ asset: hdx, balance: BalanceBuilder().substrate().assets().account(), diff --git a/packages/config/src/configs/polkadotAssetHub.ts b/packages/config/src/configs/polkadotAssetHub.ts index bb459261..7e90b192 100644 --- a/packages/config/src/configs/polkadotAssetHub.ts +++ b/packages/config/src/configs/polkadotAssetHub.ts @@ -4,7 +4,7 @@ import { ExtrinsicBuilder, FeeBuilder, } from '@moonbeam-network/xcm-builder'; -import { dot, usdt } from '../assets'; +import { dot, usdc, usdt } from '../assets'; import { moonbeam, polkadotAssetHub } from '../chains'; import { AssetConfig } from '../types/AssetConfig'; import { ChainConfig } from '../types/ChainConfig'; @@ -30,6 +30,25 @@ export const polkadotAssetHubConfig = new ChainConfig({ }, min: AssetMinBuilder().assets().asset(), }), + new AssetConfig({ + asset: usdc, + balance: BalanceBuilder().substrate().assets().account(), + destination: moonbeam, + destinationFee: { + amount: 0.02, + asset: usdc, + balance: BalanceBuilder().substrate().assets().account(), + }, + extrinsic: ExtrinsicBuilder() + .polkadotXcm() + .limitedReserveTransferAssets() + .X2(), + fee: { + asset: dot, + balance: BalanceBuilder().substrate().system().account(), + }, + min: AssetMinBuilder().assets().asset(), + }), ], chain: polkadotAssetHub, });