Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DOT and USDT to chains #21

Merged
merged 8 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions packages/xcm-cfg/src/builders/pallets/xcmPallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import {
XcmVersion,
ExtrinsicConfigBuilder,
ExtrinsicConfig,
Parents,
} from '@moonbeam-network/xcm-builder';
import { toAssets, toBeneficiary, toDest } from './xcmPallet.utils';
import { getExtrinsicAccount } from '../ExtrinsicBuilder.utils';

const pallet = 'xcmPallet';

const limitedReserveTransferAssets = () => {
const limitedReserveTransferAssets = (parent: Parents) => {
const func = 'limitedReserveTransferAssets';
return {
here: (): ExtrinsicConfigBuilder => ({
Expand All @@ -22,7 +23,31 @@ const limitedReserveTransferAssets = () => {
return [
toDest(version, destination),
toBeneficiary(version, account),
toAssets(version, amount),
toAssets(version, parent, 'Here', amount),
0,
'Unlimited',
];
},
}),
}),
};
};

const limitedTeleportAssets = (parent: Parents) => {
const func = 'limitedTeleportAssets';
return {
here: (): ExtrinsicConfigBuilder => ({
build: ({ address, amount, destination }) =>
new ExtrinsicConfig({
module: pallet,
func,
getArgs: () => {
const version = XcmVersion.v3;
const account = getExtrinsicAccount(address);
return [
toDest(version, destination),
toBeneficiary(version, account),
toAssets(version, parent, 'Here', amount),
0,
'Unlimited',
];
Expand All @@ -35,5 +60,6 @@ const limitedReserveTransferAssets = () => {
export const xcmPallet = () => {
return {
limitedReserveTransferAssets,
limitedTeleportAssets,
};
};
13 changes: 9 additions & 4 deletions packages/xcm-cfg/src/builders/pallets/xcmPallet.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { XcmVersion } from '@moonbeam-network/xcm-builder';
import { Parents, XcmVersion } from '@moonbeam-network/xcm-builder';
import { AnyChain } from '@moonbeam-network/xcm-types';

export const toDest = (version: XcmVersion, destination: AnyChain) => {
Expand All @@ -23,14 +23,19 @@ export const toBeneficiary = (version: XcmVersion, account: any) => {
};
};

export const toAssets = (version: XcmVersion, amount: any) => {
export const toAssets = (
version: XcmVersion,
parents: Parents,
interior: any,
amount: any
) => {
return {
[version]: [
{
id: {
Concrete: {
parents: 0,
interior: 'Here',
parents: parents,
interior: interior,
},
},
fun: {
Expand Down
47 changes: 47 additions & 0 deletions packages/xcm-cfg/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ export const assetHub = new Parachain({
id: 1337,
palletInstance: 50,
},
{
asset: dot,
decimals: 10,
id: 0,
},
],
ecosystem: Ecosystem.Polkadot,
genesisHash:
Expand All @@ -101,6 +106,18 @@ export const astar = new Parachain({
asset: astr,
metadataId: 0,
},
{
asset: dot,
id: '340282366920938463463374607431768211455',
metadataId: 0,
decimals: 10,
},
{
asset: usdt,
id: '4294969280',
metadataId: 0,
decimals: 6,
}
],
ecosystem: Ecosystem.Polkadot,
genesisHash:
Expand Down Expand Up @@ -130,6 +147,12 @@ export const bifrost = new Parachain({
metadataId: { Token2: 0 },
decimals: 10,
},
{
asset: usdt,
id: { Token2: 2 },
metadataId: { Token2: 2 },
decimals: 6,
},
],
ecosystem: Ecosystem.Polkadot,
genesisHash:
Expand Down Expand Up @@ -310,6 +333,18 @@ export const interlay = new Parachain({
id: { Token: intr.originSymbol },
metadataId: 0,
},
{
asset: dot,
decimals: 10,
id: { Token: dot.originSymbol },
metadataId: 0,
},
{
asset: usdt,
decimals: 6,
id: { ForeignAsset: 2 },
metadataId: 0,
},
],
ecosystem: Ecosystem.Polkadot,
genesisHash:
Expand Down Expand Up @@ -363,6 +398,18 @@ export const moonbeam = new EvmParachain({
metadataId: 0,
decimals: 18,
},
{
asset: dot,
id: '42259045809535163221576417993425387648',
metadataId: 0,
decimals: 10,
},
{
asset: usdt,
id: '311091173110107856861649819128533077277',
metadataId: 0,
decimals: 6,
},
],
ecosystem: Ecosystem.Polkadot,
genesisHash:
Expand Down
50 changes: 48 additions & 2 deletions packages/xcm-cfg/src/configs/assethub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import {
BalanceBuilder,
ExtrinsicBuilder,
} from '@moonbeam-network/xcm-builder';
import { AssetConfig, ChainConfig } from '@moonbeam-network/xcm-config';
import {
AssetConfig,
ChainConfig,
polkadot,
} from '@moonbeam-network/xcm-config';

import { dot, usdc, usdt } from '../assets';
import { assetHub, hydraDX } from '../chains';
import { ExtrinsicBuilderV2 } from '../builders';

const toHydraDX: AssetConfig[] = [
new AssetConfig({
Expand Down Expand Up @@ -47,9 +52,50 @@ const toHydraDX: AssetConfig[] = [
},
min: AssetMinBuilder().assets().asset(),
}),
new AssetConfig({
asset: dot,
balance: BalanceBuilder().substrate().system().account(),
destination: hydraDX,
destinationFee: {
amount: 0.02,
asset: dot,
balance: BalanceBuilder().substrate().system().account(),
},
extrinsic: ExtrinsicBuilder()
.polkadotXcm()
.limitedReserveTransferAssets()
.X1(),
fee: {
asset: dot,
balance: BalanceBuilder().substrate().system().account(),
},
min: AssetMinBuilder().assets().asset(),
}),
];

const toPolkadot: AssetConfig[] = [
new AssetConfig({
asset: dot,
balance: BalanceBuilder().substrate().system().account(),
destination: polkadot,
destinationFee: {
amount: 0.02,
asset: dot,
balance: BalanceBuilder().substrate().system().account(),
},
extrinsic: ExtrinsicBuilderV2()
.polkadotXcm()
.limitedTeleportAssets(1)
.here(),
fee: {
asset: dot,
balance: BalanceBuilder().substrate().system().account(),
},
min: AssetMinBuilder().assets().asset(),
}),
];

export const assetHubConfig = new ChainConfig({
assets: [...toHydraDX],
assets: [...toHydraDX, ...toPolkadot],
chain: assetHub,
});
32 changes: 31 additions & 1 deletion packages/xcm-cfg/src/configs/astar.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BalanceBuilder } from '@moonbeam-network/xcm-builder';
import { AssetConfig, ChainConfig } from '@moonbeam-network/xcm-config';

import { astr } from '../assets';
import { astr, dot, hdx, usdt } from '../assets';
import { astar, hydraDX } from '../chains';
import { ExtrinsicBuilderV2 } from '../builders';

Expand All @@ -20,6 +20,36 @@ const toHydraDX: AssetConfig[] = [
.reserveTransferAssets()
.here(),
}),
new AssetConfig({
asset: dot,
balance: BalanceBuilder().substrate().assets().account(),
destination: hydraDX,
destinationFee: {
amount: 0.6,
asset: hdx,
balance: BalanceBuilder().substrate().tokens().accounts(),
},
fee: {
asset: astr,
balance: BalanceBuilder().substrate().system().account(),
},
extrinsic: ExtrinsicBuilderV2().xTokens().transfer()
}),
new AssetConfig({
asset: usdt,
balance: BalanceBuilder().substrate().assets().account(),
destination: hydraDX,
destinationFee: {
amount: 0.6,
asset: hdx,
balance: BalanceBuilder().substrate().tokens().accounts(),
},
fee: {
asset: astr,
balance: BalanceBuilder().substrate().system().account(),
},
extrinsic: ExtrinsicBuilderV2().xTokens().transfer()
}),
];

export const astarConfig = new ChainConfig({
Expand Down
17 changes: 16 additions & 1 deletion packages/xcm-cfg/src/configs/bifrost.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BalanceBuilder } from '@moonbeam-network/xcm-builder';
import { AssetConfig, ChainConfig, polkadot } from '@moonbeam-network/xcm-config';

import { bnc, vdot, dot } from '../assets';
import { bnc, vdot, dot, usdt, hdx } from '../assets';
import { bifrost, hydraDX } from '../chains';
import { ExtrinsicBuilderV2 } from '../builders';

Expand Down Expand Up @@ -47,6 +47,21 @@ const toHydraDX: AssetConfig[] = [
balance: BalanceBuilder().substrate().system().account(),
},
}),
new AssetConfig({
asset: usdt,
balance: BalanceBuilder().substrate().tokens().accounts(),
destination: hydraDX,
destinationFee: {
amount: 0.0013,
asset: hdx,
balance: BalanceBuilder().substrate().tokens().accounts(),
},
extrinsic: ExtrinsicBuilderV2().xTokens().transfer(),
fee: {
asset: bnc,
balance: BalanceBuilder().substrate().system().account(),
}
}),
];

const toPolkadot: AssetConfig[] = [
Expand Down
Loading
Loading