diff --git a/packages/config/src/assets.ts b/packages/config/src/assets.ts index f3c01f66..f1fc28a6 100644 --- a/packages/config/src/assets.ts +++ b/packages/config/src/assets.ts @@ -205,7 +205,13 @@ export const unit = new Asset({ originSymbol: 'Unit', }); -export const usdc = new Asset({ +// TODO mjm rename? +export const usdcAH = new Asset({ + key: 'usdc', + originSymbol: 'USDC', +}); + +export const usdcwh = new Asset({ key: 'usdcwh', originSymbol: 'USDC.Wh', }); @@ -306,7 +312,8 @@ export const assetsList: Asset[] = [ tt1, tur, unit, - usdc, + usdcAH, + usdcwh, usdt, vbnc, vdot, diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index 92e5dbde..ec4825ee 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -46,7 +46,8 @@ import { tt1, tur, unit, - usdc, + usdcAH, + usdcwh, usdt, vbnc, vdot, @@ -425,7 +426,7 @@ export const hydraDX = new Parachain({ id: 18, }, { - asset: usdc, + asset: usdcwh, id: 21, }, { @@ -830,7 +831,12 @@ export const moonbeam = new EvmParachain({ id: '125699734534028342599692732320197985871', }, { - asset: usdc, + asset: usdcAH, + id: '0xFFfffffF7D2B0B761Af01Ca8e25242976ac0aD7D', + metadataId: '166377000701797186346254371275954761085', // registered XC20 id for ERC20 tokens + }, + { + asset: usdcwh, id: '0x931715FEE2d06333043d11F658C8CE934aC61D0c', metadataId: 0, // no metadata for ERC20 tokens }, @@ -841,17 +847,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, @@ -962,17 +968,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, @@ -1131,6 +1137,11 @@ export const polkadotAssetHub = new Parachain({ // NOTE: no meta for native token metadataId: 9999999, }, + { + asset: usdcAH, + id: 1337, + palletInstance: 50, + }, ], ecosystem: Ecosystem.Polkadot, genesisHash: diff --git a/packages/config/src/configs/hydraDX.ts b/packages/config/src/configs/hydraDX.ts index de5583f6..3c6e37af 100644 --- a/packages/config/src/configs/hydraDX.ts +++ b/packages/config/src/configs/hydraDX.ts @@ -3,7 +3,7 @@ import { ExtrinsicBuilder, FeeBuilder, } from '@moonbeam-network/xcm-builder'; -import { dai, glmr, hdx, usdc, wbtc, weth } from '../assets'; +import { dai, glmr, hdx, usdcwh, wbtc, weth } from '../assets'; import { hydraDX, moonbeam } from '../chains'; import { AssetConfig } from '../types/AssetConfig'; import { ChainConfig } from '../types/ChainConfig'; @@ -48,7 +48,7 @@ export const hydraDxConfig = new ChainConfig({ }, }), new AssetConfig({ - asset: usdc, + asset: usdcwh, balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { diff --git a/packages/config/src/configs/moonbeam.ts b/packages/config/src/configs/moonbeam.ts index 7182b306..a4605be4 100644 --- a/packages/config/src/configs/moonbeam.ts +++ b/packages/config/src/configs/moonbeam.ts @@ -17,7 +17,8 @@ import { para, pha, ring, - usdc, + usdcAH, + usdcwh, usdt, vdot, vfil, @@ -348,6 +349,21 @@ export const moonbeamConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), }, }), + new AssetConfig({ + asset: usdcAH, + balance: BalanceBuilder().evm().erc20(), + contract: ContractBuilder().Xtokens().transferMultiCurrencies(), + destination: polkadotAssetHub, + destinationFee: { + amount: 0.7, // TODO + asset: dot, + balance: BalanceBuilder().substrate().assets().account(), + }, + fee: { + asset: glmr, + balance: BalanceBuilder().substrate().system().account(), + }, + }), new AssetConfig({ asset: hdx, balance: BalanceBuilder().substrate().assets().account(), @@ -379,13 +395,13 @@ export const moonbeamConfig = new ChainConfig({ }, }), new AssetConfig({ - asset: usdc, + asset: usdcwh, balance: BalanceBuilder().evm().erc20(), contract: ContractBuilder().Xtokens().transfer(), destination: hydraDX, destinationFee: { amount: 0.004, - asset: usdc, + asset: usdcwh, balance: BalanceBuilder().evm().erc20(), }, fee: { diff --git a/packages/config/src/configs/polkadotAssetHub.ts b/packages/config/src/configs/polkadotAssetHub.ts index bb459261..e8ce0950 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, usdcAH, 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: usdcAH, + balance: BalanceBuilder().substrate().assets().account(), + destination: moonbeam, + destinationFee: { + amount: 0.02, + asset: usdcAH, + balance: BalanceBuilder().substrate().assets().account(), + }, + extrinsic: ExtrinsicBuilder() + .polkadotXcm() + .limitedReserveTransferAssets() + .X2(), + fee: { + asset: dot, + balance: BalanceBuilder().substrate().system().account(), + }, + min: AssetMinBuilder().assets().asset(), + }), ], chain: polkadotAssetHub, }); diff --git a/packages/sdk/src/getTransferData/getSourceData.ts b/packages/sdk/src/getTransferData/getSourceData.ts index 3e9b2eb6..a5eccc79 100644 --- a/packages/sdk/src/getTransferData/getSourceData.ts +++ b/packages/sdk/src/getTransferData/getSourceData.ts @@ -49,8 +49,7 @@ export async function getSourceData({ amount: 0n, decimals: await getDecimals({ address: destinationAddress, - asset: config.fee.asset, - config, + config: config.fee, evmSigner, polkadot, }), @@ -61,8 +60,7 @@ export async function getSourceData({ amount: 0n, decimals: await getDecimals({ address: destinationAddress, - asset: config.destinationFee.asset, - config, + config: config.destinationFee, evmSigner, polkadot, }), diff --git a/packages/sdk/src/getTransferData/getTransferData.utils.ts b/packages/sdk/src/getTransferData/getTransferData.utils.ts index b1af6a52..8650f185 100644 --- a/packages/sdk/src/getTransferData/getTransferData.utils.ts +++ b/packages/sdk/src/getTransferData/getTransferData.utils.ts @@ -1,6 +1,5 @@ import { CallType, SubstrateQueryConfig } from '@moonbeam-network/xcm-builder'; -import { AssetConfig } from '@moonbeam-network/xcm-config'; -import { Asset } from '@moonbeam-network/xcm-types'; +import { AssetConfig, FeeAssetConfig } from '@moonbeam-network/xcm-config'; import { toBigInt } from '@moonbeam-network/xcm-utils'; import { BalanceContractInterface, createContract } from '../contract'; import { PolkadotService } from '../polkadot'; @@ -8,10 +7,9 @@ import { EvmSigner } from '../sdk.interfaces'; export interface GetFeeBalancesParams { address: string; - config: AssetConfig; + config: AssetConfig | FeeAssetConfig; evmSigner: EvmSigner; polkadot: PolkadotService; - asset?: Asset; } export async function getBalance({ @@ -36,18 +34,17 @@ export async function getBalance({ export async function getDecimals({ address, - asset, config, evmSigner, polkadot, }: GetFeeBalancesParams) { const cfg = config.balance.build({ address, - asset: polkadot.chain.getBalanceAssetId(asset || config.asset), + asset: polkadot.chain.getBalanceAssetId(config.asset), }); if (cfg.type === CallType.Substrate) { - return polkadot.getAssetDecimals(asset || config.asset); + return polkadot.getAssetDecimals(config.asset); } const contract = createContract(cfg, evmSigner) as BalanceContractInterface;