Skip to content

Commit

Permalink
USDC Polkadot Asset Hub - Moonbeam integration (#160)
Browse files Browse the repository at this point in the history
* -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
  • Loading branch information
mmaurello authored Nov 7, 2023
1 parent 55ca5f7 commit 4035acc
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .changeset/light-ghosts-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@moonbeam-network/xcm-config': patch
'@moonbeam-network/xcm-sdk': patch
---

USDC asset hub integration and vDOT paying for fees
6 changes: 6 additions & 0 deletions packages/config/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -334,6 +339,7 @@ export const assetsList: Asset[] = [
tt1,
tur,
unit,
usdc,
usdcwh,
usdt,
usdtwh,
Expand Down
23 changes: 17 additions & 6 deletions packages/config/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
tt1,
tur,
unit,
usdc,
usdcwh,
usdt,
usdtwh,
Expand Down Expand Up @@ -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',
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions packages/config/src/configs/bifrostPolkadot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
16 changes: 16 additions & 0 deletions packages/config/src/configs/moonbeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
para,
pha,
ring,
usdc,
usdcwh,
usdt,
usdtwh,
Expand Down Expand Up @@ -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(),
Expand Down
21 changes: 20 additions & 1 deletion packages/config/src/configs/polkadotAssetHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
});

0 comments on commit 4035acc

Please sign in to comment.