Skip to content

Commit

Permalink
USDT Moonbeam integration (#24)
Browse files Browse the repository at this point in the history
* enable USDT back from Moonriver to Statemine
  • Loading branch information
mmaurello authored Sep 27, 2022
1 parent 406ba7e commit 23580e0
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 81 deletions.
38 changes: 0 additions & 38 deletions packages/config/src/config/moonbase/assets/astr.ts

This file was deleted.

26 changes: 2 additions & 24 deletions packages/config/src/config/moonbase/assets/dev.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { AssetSymbol, ChainKey } from '../../../constants';
import {
PolkadotXcmExtrinsicSuccessEvent,
XTokensExtrinsicSuccessEvent,
} from '../../../extrinsic';
import { getMoonAssetId, getPalletInstance } from '../../config.utils';
import { XTokensExtrinsicSuccessEvent } from '../../../extrinsic';
import { getMoonAssetId } from '../../config.utils';
import {
assets,
balance,
Expand All @@ -15,28 +12,14 @@ import {
import { MoonbaseXcmConfig } from '../moonbase.interfaces';

const asset = assets[AssetSymbol.DEV];
const astar = chains[ChainKey.AstarAlphanet];
const clover = chains[ChainKey.CloverAlphanet];

const astarDevId = getMoonAssetId(astar);
const cloverDevId = getMoonAssetId(clover);

export const DEV: MoonbaseXcmConfig = {
asset,
origin: moonbase,
deposit: {
[astar.key]: {
origin: astar,
balance: balance.assets(astarDevId),
sourceFeeBalance: balance.system(),
extrinsic: extrinsic
.polkadotXcm()
.limitedReserveWithdrawAssets()
.successEvent(PolkadotXcmExtrinsicSuccessEvent.Attempted)
.origin(astar)
.V1()
.X2(getPalletInstance(astar)),
},
[clover.key]: {
origin: clover,
balance: balance.assets(cloverDevId),
Expand All @@ -52,11 +35,6 @@ export const DEV: MoonbaseXcmConfig = {
},
},
withdraw: {
[astar.key]: withdraw.xTokens({
balance: balance.assets(astarDevId),
destination: astar,
feePerWeight: 50_000,
}),
[clover.key]: withdraw.xTokens({
balance: balance.assets(cloverDevId),
destination: clover,
Expand Down
6 changes: 0 additions & 6 deletions packages/config/src/config/moonbase/moonbase.assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { AssetsMap } from '../config.interfaces';
import { MoonbaseAssets } from './moonbase.interfaces';

export const MOONBASE_ASSETS = <const>[
AssetSymbol.ASTR,
AssetSymbol.BSX,
AssetSymbol.CLV,
AssetSymbol.CRU,
Expand All @@ -18,11 +17,6 @@ export const MOONBASE_ASSETS = <const>[
];

export const MOONBASE_ASSETS_MAP: AssetsMap<MoonbaseAssets> = {
[AssetSymbol.ASTR]: {
id: '16797826370226091782818345603793389938',
erc20Id: '0xffffffff0ca324c842330521525e7de111f38972',
originSymbol: AssetSymbol.ASTR,
},
[AssetSymbol.BSX]: {
id: '102433417954722588084020852587557555194',
erc20Id: '0xffffffff4d0ff56d0097bbd14920eac488540bfa',
Expand Down
10 changes: 0 additions & 10 deletions packages/config/src/config/moonbase/moonbase.chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { MoonbaseChains } from './moonbase.interfaces';

export const MOONBASE_CHAINS = <const>[
ChainKey.AlphanetRelay,
ChainKey.AstarAlphanet,
ChainKey.BasiliskAlphanet,
ChainKey.CloverAlphanet,
ChainKey.CrustShadowAlphanet,
Expand All @@ -23,15 +22,6 @@ export const MOONBASE_CHAINS_MAP: ChainsMap<MoonbaseChains> = {
weight: 1_000_000_000,
parachainId: 0,
},
[ChainKey.AstarAlphanet]: {
key: ChainKey.AstarAlphanet,
name: 'Astar Alphanet',
ws: 'wss://alphanet.astar.network/',
weight: 1_000_000_000,
parachainId: 2007,
palletInstance: 3,
moonAssetId: 100,
},
[ChainKey.BasiliskAlphanet]: {
key: ChainKey.BasiliskAlphanet,
name: 'Basilisk Alphanet',
Expand Down
2 changes: 0 additions & 2 deletions packages/config/src/config/moonbase/moonbase.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { AssetSymbol } from '../../constants';
import { MoonbaseXcmConfigs } from './moonbase.interfaces';

import { ASTR } from './assets/astr';
import { BSX } from './assets/bsx';
import { CLV } from './assets/clv';
import { CRU } from './assets/cru';
Expand All @@ -15,7 +14,6 @@ import { TT1 } from './assets/tt1';
import { UNIT } from './assets/unit';

export const MOONBASE_CONFIGS: MoonbaseXcmConfigs = {
[AssetSymbol.ASTR]: ASTR,
[AssetSymbol.BSX]: BSX,
[AssetSymbol.CLV]: CLV,
[AssetSymbol.CRU]: CRU,
Expand Down
30 changes: 30 additions & 0 deletions packages/config/src/config/moonbeam/assets/usdt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { AssetSymbol, ChainKey } from '../../../constants';
import { PolkadotXcmExtrinsicSuccessEvent } from '../../../extrinsic';
import { getOriginAssetId, getPalletInstance } from '../../config.utils';
import { assets, balance, chains, extrinsic } from '../moonbeam.common';
import { MoonbeamXcmConfig } from '../moonbeam.interfaces';

const asset = assets[AssetSymbol.USDT];
const origin = chains[ChainKey.Statemint];
const originAssetId = getOriginAssetId(asset);

export const USDT: MoonbeamXcmConfig = {
asset,
origin,
deposit: {
[origin.key]: {
origin,
balance: balance.assets(originAssetId),
sourceFeeBalance: balance.system(),
sourceMinBalance: balance.min(originAssetId),
extrinsic: extrinsic
.polkadotXcm()
.limitedReserveTransferAssets()
.successEvent(PolkadotXcmExtrinsicSuccessEvent.Attempted)
.origin(origin)
.V1()
.X2(getPalletInstance(origin), originAssetId),
},
},
withdraw: {},
};
7 changes: 7 additions & 0 deletions packages/config/src/config/moonbeam/moonbeam.assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const MOONBEAM_ASSETS = <const>[
AssetSymbol.INTR,
AssetSymbol.PARA,
AssetSymbol.PHA,
AssetSymbol.USDT,
];

export const MOONBEAM_ASSETS_MAP: AssetsMap<MoonbeamAssets> = {
Expand Down Expand Up @@ -61,4 +62,10 @@ export const MOONBEAM_ASSETS_MAP: AssetsMap<MoonbeamAssets> = {
erc20Id: '0xffffffff63d24ecc8eb8a7b5d0803e900f7b6ced',
originSymbol: AssetSymbol.PHA,
},
[AssetSymbol.USDT]: {
id: '311091173110107856861649819128533077277',
erc20Id: '0xffffffffea09fb06d082fd1275cd48b191cbcd1d',
originSymbol: AssetSymbol.USDT,
originAssetId: 1984,
},
};
9 changes: 9 additions & 0 deletions packages/config/src/config/moonbeam/moonbeam.chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const MOONBEAM_CHAINS = <const>[
ChainKey.Parallel,
ChainKey.Phala,
ChainKey.Polkadot,
ChainKey.Statemint,
];

export const MOONBEAM_CHAINS_MAP: ChainsMap<MoonbeamChains> = {
Expand Down Expand Up @@ -59,4 +60,12 @@ export const MOONBEAM_CHAINS_MAP: ChainsMap<MoonbeamChains> = {
weight: 1_000_000_000,
parachainId: 0,
},
[ChainKey.Statemint]: {
key: ChainKey.Statemint,
name: 'Statemint',
ws: 'wss://statemint-rpc.polkadot.io',
weight: 1_000_000_000,
parachainId: 1000,
palletInstance: 50,
},
};
2 changes: 2 additions & 0 deletions packages/config/src/config/moonbeam/moonbeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { IBTC } from './assets/ibtc';
import { INTR } from './assets/intr';
import { PARA } from './assets/para';
import { PHA } from './assets/pha';
import { USDT } from './assets/usdt';

export const MOONBEAM_CONFIGS: MoonbeamXcmConfigs = {
[AssetSymbol.ACA]: ACA,
Expand All @@ -21,4 +22,5 @@ export const MOONBEAM_CONFIGS: MoonbeamXcmConfigs = {
[AssetSymbol.INTR]: INTR,
[AssetSymbol.PARA]: PARA,
[AssetSymbol.PHA]: PHA,
[AssetSymbol.USDT]: USDT,
};
2 changes: 1 addition & 1 deletion packages/config/src/constants/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export enum ChainKey {
Acala = 'Acala',
AlphanetRelay = 'AlphanetRelay',
Astar = 'Astar',
AstarAlphanet = 'AstarAlphanet',
BasiliskAlphanet = 'BasiliskAlphanet',
Bifrost = 'Bifrost',
Calamari = 'Calamari',
Expand All @@ -65,4 +64,5 @@ export enum ChainKey {
Shiden = 'Shiden',
Statemine = 'Statemine',
StatemineAlphanet = 'StatemineAlphanet',
Statemint = 'Statemint',
}

0 comments on commit 23580e0

Please sign in to comment.