diff --git a/packages/builder/fixtures/builderParamsMock.ts b/packages/builder/fixtures/builderParamsMock.ts index 05dadba2..4b14992e 100644 --- a/packages/builder/fixtures/builderParamsMock.ts +++ b/packages/builder/fixtures/builderParamsMock.ts @@ -216,14 +216,3 @@ export const wormholeToMoonchainConfigBuilderParams: MrlBuilderParams = { sourceAddress: '0xeF46c7649270C912704fB09B75097f6E32208b85', sourceApi: apiMock, }; - -export const buildParamsMockEth: ExtrinsicConfigBuilderPrams = { - address: '0xeF46c7649270C912704fB09B75097f6E32208b85', - amount: 99_000_000_000n, - asset: '0xeF46c7649270C912704fB09B75097f6E32208b85', - destination: moonbaseAlphaMock, - fee: 5_000_000_000n, - feeAsset: 'WETH.e', - palletInstance: 10, - source: alphanetAssetHubMock, -}; diff --git a/packages/builder/src/asset-min/AssetMinBuilder.interfaces.ts b/packages/builder/src/asset-min/AssetMinBuilder.interfaces.ts index cea8f714..2cb22830 100644 --- a/packages/builder/src/asset-min/AssetMinBuilder.interfaces.ts +++ b/packages/builder/src/asset-min/AssetMinBuilder.interfaces.ts @@ -8,5 +8,6 @@ export type AssetMinConfigBuilder = ConfigBuilder< >; export interface AssetMinConfigBuilderParams { + address?: string; asset: ChainAssetId; } diff --git a/packages/builder/src/asset-min/AssetMinBuilder.test.ts b/packages/builder/src/asset-min/AssetMinBuilder.test.ts index 5d251ffb..bd63e7df 100644 --- a/packages/builder/src/asset-min/AssetMinBuilder.test.ts +++ b/packages/builder/src/asset-min/AssetMinBuilder.test.ts @@ -83,7 +83,10 @@ describe('assetMinBuilder', () => { const config = AssetMinBuilder() .foreignAssets() .asset() - .build({ asset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' }); + .build({ + asset, + address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + }); it('should be correct config', () => { expect(config).toMatchSnapshot(); diff --git a/packages/builder/src/asset-min/AssetMinBuilder.ts b/packages/builder/src/asset-min/AssetMinBuilder.ts index 7bffe740..c5dc5228 100644 --- a/packages/builder/src/asset-min/AssetMinBuilder.ts +++ b/packages/builder/src/asset-min/AssetMinBuilder.ts @@ -60,7 +60,12 @@ function assets() { function foreignAssets() { return { asset: (): AssetMinConfigBuilder => ({ - build: ({ asset }) => { + build: ({ address }) => { + if (!address) { + throw new Error( + 'Asset address is missing for foreignAssets.asset min calculation', + ); + } const multilocation = { parents: 2, interior: { @@ -72,7 +77,7 @@ function foreignAssets() { }, }, }, - getExtrinsicAccount(asset as string), + getExtrinsicAccount(address), ], }, }; diff --git a/packages/builder/src/asset-min/__snapshots__/AssetMinBuilder.test.ts.snap b/packages/builder/src/asset-min/__snapshots__/AssetMinBuilder.test.ts.snap index f667eb77..db603689 100644 --- a/packages/builder/src/asset-min/__snapshots__/AssetMinBuilder.test.ts.snap +++ b/packages/builder/src/asset-min/__snapshots__/AssetMinBuilder.test.ts.snap @@ -65,50 +65,7 @@ SubstrateQueryConfig { "func": "asset", "module": "foreignAssets", "transform": [Function], - "type": "Substrate", } `; exports[`assetMinBuilder > foreignAssets > asset > should transform correctly 1`] = `999n`; - -exports[`assetMinBuilder assetRegistry assetMetadatas should be correct config 1`] = ` -SubstrateQueryConfig { - "args": [ - "", - ], - "func": "assetMetadatas", - "module": "assetRegistry", - "transform": [Function], - "type": "Substrate", -} -`; - -exports[`assetMinBuilder assetRegistry assetMetadatas should transform correctly 1`] = `999n`; - -exports[`assetMinBuilder assetRegistry currencyMetadatas should be correct config 1`] = ` -SubstrateQueryConfig { - "args": [ - "", - ], - "func": "currencyMetadatas", - "module": "assetRegistry", - "transform": [Function], - "type": "Substrate", -} -`; - -exports[`assetMinBuilder assetRegistry currencyMetadatas should transform correctly 1`] = `999n`; - -exports[`assetMinBuilder assets asset should be correct config 1`] = ` -SubstrateQueryConfig { - "args": [ - "", - ], - "func": "asset", - "module": "assets", - "transform": [Function], - "type": "Substrate", -} -`; - -exports[`assetMinBuilder assets asset should transform correctly 1`] = `999n`; diff --git a/packages/builder/src/balance/BalanceBuilder.ts b/packages/builder/src/balance/BalanceBuilder.ts index 30be6b2e..de5b51f9 100644 --- a/packages/builder/src/balance/BalanceBuilder.ts +++ b/packages/builder/src/balance/BalanceBuilder.ts @@ -89,12 +89,18 @@ function foreignAssets() { return { account: (): BalanceConfigBuilder => ({ build: ({ address, asset }) => { + if (!asset.address) { + throw new Error( + 'Asset address is needed to calculate balance with foreignAssets.account function', + ); + } + const multilocation = { parents: 2, interior: { X2: [ { GlobalConsensus: { ethereum: { chainId: 1 } } }, - getExtrinsicAccount(asset.address as string), // TODO mjm fix + getExtrinsicAccount(asset.address), ], }, }; diff --git a/packages/builder/src/balance/__snapshots__/BalanceBuilder.test.ts.snap b/packages/builder/src/balance/__snapshots__/BalanceBuilder.test.ts.snap index aae0ecde..89bf73e0 100644 --- a/packages/builder/src/balance/__snapshots__/BalanceBuilder.test.ts.snap +++ b/packages/builder/src/balance/__snapshots__/BalanceBuilder.test.ts.snap @@ -29,19 +29,18 @@ SubstrateQueryConfig { }, { "AccountKey20": { - "key": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "key": "0x98891e5FD24Ef33A488A47101F65D212Ff6E650E", }, }, ], }, "parents": 2, }, - "", + "
", ], "func": "account", "module": "foreignAssets", "transform": [Function], - "type": "Substrate", } `; diff --git a/packages/builder/src/extrinsic/pallets/polkadotXcm/__snapshots__/polkadotXcm.test.ts.snap b/packages/builder/src/extrinsic/pallets/polkadotXcm/__snapshots__/polkadotXcm.test.ts.snap index 7f17342b..7866c313 100644 --- a/packages/builder/src/extrinsic/pallets/polkadotXcm/__snapshots__/polkadotXcm.test.ts.snap +++ b/packages/builder/src/extrinsic/pallets/polkadotXcm/__snapshots__/polkadotXcm.test.ts.snap @@ -455,23 +455,22 @@ exports[`polkadotXcm > limitedReserveWithdrawAssets > x2 > should get correct ar ] `; -exports[`polkadotXcm > transferAssetsUsingTypeAndThen > x2 > should be correct config 1`] = ` +exports[`polkadotXcm > transferAssetsUsingTypeAndThen > globalConsensusEthereum > should be correct config 1`] = ` ExtrinsicConfig { "func": "transferAssetsUsingTypeAndThen", "getArgs": [Function], "module": "polkadotXcm", - "type": "Substrate", } `; -exports[`polkadotXcm > transferAssetsUsingTypeAndThen > x2 > should get correct arguments 1`] = ` +exports[`polkadotXcm > transferAssetsUsingTypeAndThen > globalConsensusEthereum > should get correct arguments 1`] = ` [ { - "V4": { + "V1": { "interior": { "X1": [ { - "Parachain": 1000, + "Parachain": 2032, }, ], }, @@ -479,410 +478,77 @@ exports[`polkadotXcm > transferAssetsUsingTypeAndThen > x2 > should get correct }, }, { - "V4": [ + "V1": [ { "fun": { "fungible": 99000000000n, }, "id": { - "interior": { - "X2": [ - { - "globalConsensus": { - "Ethereum": { - "ChainId": 1, + "Concrete": { + "interior": { + "X2": [ + { + "globalConsensus": { + "Ethereum": { + "ChainId": 1, + }, }, }, - }, - { - "AccountKey20": { - "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - }, - }, - ], - }, - "parents": 2, - }, - }, - ], - }, - "LocalReserve", - { - "V4": { - "interior": { - "X2": [ - { - "globalConsensus": { - "Ethereum": { - "ChainId": 1, - }, - }, - }, - { - "AccountKey20": { - "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - }, - }, - ], - }, - "parents": 2, - }, - }, - "LocalReserve", - { - "V4": [ - { - "DepositAsset": { - "assets": { - "Wild": { - "AllCounted": 1, - }, - }, - "beneficiary": { - "interior": { - "X1": [ { "AccountKey20": { - "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", + "key": "0x98891e5FD24Ef33A488A47101F65D212Ff6E650E", }, }, ], }, - "parents": 0, + "parents": 2, }, }, }, ], }, - "Unlimited", -] -`; - -exports[`polkadotXcm limitedReserveTransferAssets here should be correct config 1`] = ` -ExtrinsicConfig { - "func": "limitedReserveTransferAssets", - "getArgs": [Function], - "module": "polkadotXcm", - "type": "Substrate", -} -`; - -exports[`polkadotXcm limitedReserveTransferAssets here should get correct arguments 1`] = ` -[ - { - "V1": { - "interior": { - "X1": { - "Parachain": 1000, - }, - }, - "parents": 1, - }, - }, - { - "V1": { - "interior": { - "X1": { - "AccountKey20": { - "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - }, - }, - }, - "parents": 0, - }, - }, - { - "V1": [ - { - "fun": { - "Fungible": 99000000000n, - }, - "id": { - "Concrete": { - "interior": "Here", - "parents": 0, - }, - }, - }, - ], - }, - 0, - "Unlimited", -] -`; - -exports[`polkadotXcm limitedReserveTransferAssets parachain should be correct config 1`] = ` -ExtrinsicConfig { - "func": "limitedReserveTransferAssets", - "getArgs": [Function], - "module": "polkadotXcm", - "type": "Substrate", -} -`; - -exports[`polkadotXcm limitedReserveTransferAssets parachain should get correct arguments 1`] = ` -[ - { - "V1": { - "interior": { - "X1": { - "Parachain": 2032, - }, - }, - "parents": 1, - }, - }, + "LocalReserve", { "V1": { - "interior": { - "X1": { - "AccountId32": { - "id": "0x18e6c7ad45fbab18778710642072fdd057470b76d4d568b44dea6accd5b0c423", - "network": null, - }, - }, - }, - "parents": 0, - }, - }, - { - "V1": [ - { - "fun": { - "Fungible": 99000000000n, - }, - "id": { - "Concrete": { - "interior": { - "X2": [ - { - "PalletInstance": 10, + "Concrete": { + "interior": { + "X2": [ + { + "globalConsensus": { + "Ethereum": { + "ChainId": 1, }, - { - "GeneralIndex": "USDT", - }, - ], - }, - "parents": 0, - }, - }, - }, - { - "fun": { - "Fungible": 5000000000n, - }, - "id": { - "Concrete": { - "interior": { - "X2": [ - { - "PalletInstance": 10, - }, - { - "GeneralIndex": "RMRK", - }, - ], + }, }, - "parents": 0, - }, - }, - }, - ], - }, - 1, - "Unlimited", -] -`; - -exports[`polkadotXcm limitedReserveTransferAssets x1 should be correct config 1`] = ` -ExtrinsicConfig { - "func": "limitedReserveTransferAssets", - "getArgs": [Function], - "module": "polkadotXcm", - "type": "Substrate", -} -`; - -exports[`polkadotXcm limitedReserveTransferAssets x1 should get correct arguments 1`] = ` -[ - { - "V1": { - "interior": { - "X1": { - "Parachain": 1000, - }, - }, - "parents": 1, - }, - }, - { - "V1": { - "interior": { - "X1": { - "AccountKey20": { - "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - }, - }, - }, - "parents": 0, - }, - }, - { - "V1": [ - { - "fun": { - "Fungible": 99000000000n, - }, - "id": { - "Concrete": { - "interior": { - "X1": { - "PalletInstance": 10, + { + "AccountKey20": { + "key": "0x98891e5FD24Ef33A488A47101F65D212Ff6E650E", }, }, - "parents": 0, - }, + ], }, + "parents": 2, }, - ], - }, - 0, - "Unlimited", -] -`; - -exports[`polkadotXcm limitedReserveTransferAssets x2 different assets should be correct config 1`] = ` -ExtrinsicConfig { - "func": "limitedReserveTransferAssets", - "getArgs": [Function], - "module": "polkadotXcm", - "type": "Substrate", -} -`; - -exports[`polkadotXcm limitedReserveTransferAssets x2 different assets should get correct arguments 1`] = ` -[ - { - "V1": { - "interior": { - "X1": { - "Parachain": 1000, - }, - }, - "parents": 1, - }, - }, - { - "V1": { - "interior": { - "X1": { - "AccountKey20": { - "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - }, - }, - }, - "parents": 0, }, }, + "LocalReserve", { "V1": [ { - "fun": { - "Fungible": 99000000000n, - }, - "id": { - "Concrete": { - "interior": { - "X2": [ - { - "PalletInstance": 10, - }, - { - "GeneralIndex": "USDT", - }, - ], - }, - "parents": 0, - }, - }, - }, - { - "fun": { - "Fungible": 5000000000n, - }, - "id": { - "Concrete": { - "interior": { - "X2": [ - { - "PalletInstance": 10, - }, - { - "GeneralIndex": "RMRK", - }, - ], + "DepositAsset": { + "assets": { + "Wild": { + "AllCounted": 1, }, - "parents": 0, }, - }, - }, - ], - }, - 1, - "Unlimited", -] -`; - -exports[`polkadotXcm limitedReserveTransferAssets x2 the same asset should be correct config 1`] = ` -ExtrinsicConfig { - "func": "limitedReserveTransferAssets", - "getArgs": [Function], - "module": "polkadotXcm", - "type": "Substrate", -} -`; - -exports[`polkadotXcm limitedReserveTransferAssets x2 the same asset should get correct arguments 1`] = ` -[ - { - "V1": { - "interior": { - "X1": { - "Parachain": 1000, - }, - }, - "parents": 1, - }, - }, - { - "V1": { - "interior": { - "X1": { - "AccountKey20": { - "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - }, - }, - }, - "parents": 0, - }, - }, - { - "V1": [ - { - "fun": { - "Fungible": 99000000000n, - }, - "id": { - "Concrete": { + "beneficiary": { "interior": { - "X2": [ - { - "PalletInstance": 10, - }, - { - "GeneralIndex": "USDT", + "X1": { + "AccountId32": { + "id": "0x18e6c7ad45fbab18778710642072fdd057470b76d4d568b44dea6accd5b0c423", + "network": null, }, - ], + }, }, "parents": 0, }, @@ -890,132 +556,6 @@ exports[`polkadotXcm limitedReserveTransferAssets x2 the same asset should get c }, ], }, - 0, - "Unlimited", -] -`; - -exports[`polkadotXcm limitedReserveWithdrawAssets parachain should be correct config 1`] = ` -ExtrinsicConfig { - "func": "limitedReserveWithdrawAssets", - "getArgs": [Function], - "module": "polkadotXcm", - "type": "Substrate", -} -`; - -exports[`polkadotXcm limitedReserveWithdrawAssets parachain should get correct arguments 1`] = ` -[ - { - "V1": { - "interior": { - "X1": { - "Parachain": 2032, - }, - }, - "parents": 1, - }, - }, - { - "V1": { - "interior": { - "X1": { - "AccountId32": { - "id": "0x18e6c7ad45fbab18778710642072fdd057470b76d4d568b44dea6accd5b0c423", - "network": null, - }, - }, - }, - "parents": 0, - }, - }, - { - "V1": [ - { - "fun": { - "Fungible": 99000000000n, - }, - "id": { - "Concrete": { - "interior": { - "X2": [ - { - "Parachain": 2032, - }, - { - "PalletInstance": 10, - }, - ], - }, - "parents": 1, - }, - }, - }, - ], - }, - 0, - "Unlimited", -] -`; - -exports[`polkadotXcm limitedReserveWithdrawAssets x2 should be correct config 1`] = ` -ExtrinsicConfig { - "func": "limitedReserveWithdrawAssets", - "getArgs": [Function], - "module": "polkadotXcm", - "type": "Substrate", -} -`; - -exports[`polkadotXcm limitedReserveWithdrawAssets x2 should get correct arguments 1`] = ` -[ - { - "V1": { - "interior": { - "X1": { - "Parachain": 1000, - }, - }, - "parents": 1, - }, - }, - { - "V1": { - "interior": { - "X1": { - "AccountKey20": { - "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - }, - }, - }, - "parents": 0, - }, - }, - { - "V1": [ - { - "fun": { - "Fungible": 99000000000n, - }, - "id": { - "Concrete": { - "interior": { - "X2": [ - { - "Parachain": 1000, - }, - { - "PalletInstance": 10, - }, - ], - }, - "parents": 1, - }, - }, - }, - ], - }, - 0, "Unlimited", ] `; diff --git a/packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.test.ts b/packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.test.ts index 623fbb58..54d83da8 100644 --- a/packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.test.ts +++ b/packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.test.ts @@ -3,7 +3,6 @@ import { describe, expect, it } from 'vitest'; import { buildParachainParamsMock, buildParamsMock, - buildParamsMockEth, buildParamsSameAssetMock, } from '../../../../fixtures'; import { polkadotXcm } from './polkadotXcm'; @@ -121,11 +120,11 @@ describe('polkadotXcm', () => { }); describe('transferAssetsUsingTypeAndThen', () => { - describe('x2', () => { + describe('globalConsensusEthereum', () => { const extrinsic = polkadotXcm() .transferAssetsUsingTypeAndThen() .globalConsensusEthereum() - .build(buildParamsMockEth); + .build(buildParachainParamsMock); it('should be correct config', () => { expect(extrinsic).toMatchSnapshot(); diff --git a/packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.ts b/packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.ts index 73a99ecd..029f8c64 100644 --- a/packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.ts +++ b/packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.ts @@ -1,4 +1,3 @@ -import { XcmVersion } from '../../../../build'; import { ExtrinsicConfig } from '../../../types/substrate/ExtrinsicConfig'; import type { ExtrinsicConfigBuilder } from '../../ExtrinsicBuilder.interfaces'; import { @@ -228,83 +227,86 @@ export function polkadotXcm() { transferAssetsUsingTypeAndThen: () => { const func = 'transferAssetsUsingTypeAndThen'; return { - // TODO we could pass a parameter globalConsensus in the chain asset - // but we can do it in V3 + // TODO we could pass a parameter globalConsensus in the chain asset if we need a different one globalConsensusEthereum: (): ExtrinsicConfigBuilder => ({ - build: (params) => { - const version = XcmVersion.v4; - return new ExtrinsicConfig({ + build: (params) => + new ExtrinsicConfig({ module: pallet, func, - getArgs: () => [ - { - [version]: { - parents: 1, - interior: { - X1: [ - { - Parachain: params.destination.parachainId, - }, - ], - }, - }, - }, - { - [version]: [ - { - id: { - parents: 2, - interior: { - X2: [ - // TODO param - { globalConsensus: { Ethereum: { ChainId: 1 } } }, - getExtrinsicAccount(params.asset.address as string), - ], - }, + getArgs: (extrinsicFunction) => { + if (!params.asset.address) { + throw new Error( + 'Asset address is needed for transferAssetsUsingTypeAndThen.globalConsensus function', + ); + } + + const version = getExtrinsicArgumentVersion(extrinsicFunction); + return [ + { + [version]: { + parents: 1, + interior: { + X1: [ + { + Parachain: params.destination.parachainId, + }, + ], }, - fun: { fungible: params.asset.amount }, - }, - ], - }, - 'LocalReserve', - { - [version]: { - parents: 2, - interior: { - X2: [ - { globalConsensus: { Ethereum: { ChainId: 1 } } }, - getExtrinsicAccount(params.asset.address as string), - ], }, }, - }, - 'LocalReserve', - { - [version]: [ - { - DepositAsset: { - assets: { - Wild: { AllCounted: 1 }, - }, - beneficiary: { - parents: 0, + { + [version]: [ + { + id: normalizeConcrete(version, { + parents: 2, interior: { - X1: [ - getExtrinsicAccount( - params.asset.address as string, - ), + X2: [ + { globalConsensus: { Ethereum: { ChainId: 1 } } }, + getExtrinsicAccount(params.asset.address), ], }, + }), + fun: { fungible: params.asset.amount }, + }, + ], + }, + 'LocalReserve', + { + [version]: normalizeConcrete(version, { + parents: 2, + interior: { + X2: [ + { globalConsensus: { Ethereum: { ChainId: 1 } } }, + getExtrinsicAccount(params.asset.address), + ], + }, + }), + }, + 'LocalReserve', + { + [version]: [ + { + DepositAsset: { + assets: { + Wild: { AllCounted: 1 }, + }, + beneficiary: normalizeX1(version, { + parents: 0, + interior: { + X1: getExtrinsicAccount( + params.destinationAddress, + ), + }, + }), }, }, - }, - ], - }, - 'Unlimited', - ], - }); - }, + ], + }, + 'Unlimited', + ]; + }, + }), }), }; }, diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index 3fcfb5f2..2762c568 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -1325,21 +1325,21 @@ export const moonbeam = new EvmParachain({ }, }), ChainAsset.fromAsset(wbtce, { - // address: '0xffffffff2e1d1ac9ea1686255befe995b31abc96', + address: '0xffffffff1b4bb1ac5749f73d866ffc91a3432c47', decimals: 8, ids: { id: '36282181791341254438422467838694599751', }, }), ChainAsset.fromAsset(wethe, { - // address: '0xffffffff2e1d1ac9ea1686255befe995b31abc96', + address: '0xffffffff86829afe1521ad2296719df3ace8ded7', decimals: 18, ids: { id: '178794693648360392906933130845919698647', }, }), ChainAsset.fromAsset(wstethe, { - // address: '0xffffffff2e1d1ac9ea1686255befe995b31abc96', + address: '0xffffffff5d5deb44bf7278dee5381beb24cb6573', decimals: 18, ids: { id: '124105859028862849477017063633156007283', @@ -2037,7 +2037,7 @@ export const polkadotAssetHub = new Parachain({ address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, }), - ChainAsset.fromAsset(wethe, { + ChainAsset.fromAsset(wstethe, { address: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0', decimals: 18, }), diff --git a/packages/config/src/xcm-configs/moonbeam.ts b/packages/config/src/xcm-configs/moonbeam.ts index fba792db..7748ee83 100644 --- a/packages/config/src/xcm-configs/moonbeam.ts +++ b/packages/config/src/xcm-configs/moonbeam.ts @@ -40,8 +40,11 @@ import { vglmr, vmanta, wbtc, + wbtce, weth, + wethe, wifd, + wstethe, ztg, } from '../assets'; import { @@ -1463,5 +1466,80 @@ export const moonbeamRoutes = new ChainRoutes({ }, contract: ContractBuilder().Xtokens().transfer(), }, + { + source: { + asset: wbtce, + balance: BalanceBuilder().substrate().assets().account(), + fee: { + asset: glmr, + balance: BalanceBuilder().substrate().system().account(), + }, + destinationFee: { + balance: BalanceBuilder().substrate().assets().account(), + }, + }, + destination: { + asset: wbtce, + chain: polkadotAssetHub, + balance: BalanceBuilder().substrate().foreignAssets().account(), + fee: { + amount: 0.0000004, + asset: wbtce, + balance: BalanceBuilder().substrate().foreignAssets().account(), + }, + min: AssetMinBuilder().foreignAssets().asset(), + }, + contract: ContractBuilder().Xtokens().transfer(), + }, + { + source: { + asset: wethe, + balance: BalanceBuilder().substrate().assets().account(), + fee: { + asset: glmr, + balance: BalanceBuilder().substrate().system().account(), + }, + destinationFee: { + balance: BalanceBuilder().substrate().assets().account(), + }, + }, + destination: { + asset: wethe, + chain: polkadotAssetHub, + balance: BalanceBuilder().substrate().foreignAssets().account(), + fee: { + amount: 0.0000035, + asset: wethe, + balance: BalanceBuilder().substrate().foreignAssets().account(), + }, + min: AssetMinBuilder().foreignAssets().asset(), + }, + contract: ContractBuilder().Xtokens().transfer(), + }, + { + source: { + asset: wstethe, + balance: BalanceBuilder().substrate().assets().account(), + fee: { + asset: glmr, + balance: BalanceBuilder().substrate().system().account(), + }, + destinationFee: { + balance: BalanceBuilder().substrate().assets().account(), + }, + }, + destination: { + asset: wstethe, + chain: polkadotAssetHub, + balance: BalanceBuilder().substrate().foreignAssets().account(), + fee: { + amount: 0.000006, + asset: wstethe, + balance: BalanceBuilder().substrate().foreignAssets().account(), + }, + min: AssetMinBuilder().foreignAssets().asset(), + }, + contract: ContractBuilder().Xtokens().transfer(), + }, ], }); diff --git a/packages/config/src/xcm-configs/polkadotAssetHub.ts b/packages/config/src/xcm-configs/polkadotAssetHub.ts index b8208799..4f539e6f 100644 --- a/packages/config/src/xcm-configs/polkadotAssetHub.ts +++ b/packages/config/src/xcm-configs/polkadotAssetHub.ts @@ -4,7 +4,19 @@ import { ExtrinsicBuilder, FeeBuilder, } from '@moonbeam-network/xcm-builder'; -import { apillon, ded, dot, pink, stink, usdc, usdt, wifd } from '../assets'; +import { + apillon, + ded, + dot, + pink, + stink, + usdc, + usdt, + wbtce, + wethe, + wifd, + wstethe, +} from '../assets'; import { moonbeam, polkadotAssetHub } from '../chains'; import { ChainRoutes } from '../types/ChainRoutes'; @@ -253,5 +265,95 @@ export const polkadotAssetHubRoutes = new ChainRoutes({ .limitedReserveTransferAssets() .X2(), }, + { + source: { + asset: wbtce, + balance: BalanceBuilder().substrate().foreignAssets().account(), + fee: { + asset: dot, + balance: BalanceBuilder().substrate().system().account(), + extra, + }, + min: AssetMinBuilder().foreignAssets().asset(), + destinationFee: { + balance: BalanceBuilder().substrate().foreignAssets().account(), + }, + }, + destination: { + asset: wbtce, + chain: moonbeam, + balance: BalanceBuilder().substrate().assets().account(), + fee: { + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), + asset: wbtce, + }, + }, + extrinsic: ExtrinsicBuilder() + .polkadotXcm() + .transferAssetsUsingTypeAndThen() + .globalConsensusEthereum(), + }, + { + source: { + asset: wethe, + balance: BalanceBuilder().substrate().foreignAssets().account(), + fee: { + asset: dot, + balance: BalanceBuilder().substrate().system().account(), + extra, + }, + min: AssetMinBuilder().foreignAssets().asset(), + destinationFee: { + balance: BalanceBuilder().substrate().foreignAssets().account(), + }, + }, + destination: { + asset: wethe, + chain: moonbeam, + balance: BalanceBuilder().substrate().assets().account(), + fee: { + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), + asset: wethe, + }, + }, + extrinsic: ExtrinsicBuilder() + .polkadotXcm() + .transferAssetsUsingTypeAndThen() + .globalConsensusEthereum(), + }, + { + source: { + asset: wstethe, + balance: BalanceBuilder().substrate().foreignAssets().account(), + fee: { + asset: dot, + balance: BalanceBuilder().substrate().system().account(), + extra, + }, + min: AssetMinBuilder().foreignAssets().asset(), + destinationFee: { + balance: BalanceBuilder().substrate().foreignAssets().account(), + }, + }, + destination: { + asset: wstethe, + chain: moonbeam, + balance: BalanceBuilder().substrate().assets().account(), + fee: { + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), + asset: wstethe, + }, + }, + extrinsic: ExtrinsicBuilder() + .polkadotXcm() + .transferAssetsUsingTypeAndThen() + .globalConsensusEthereum(), + }, ], }); diff --git a/packages/sdk/src/getTransferData/getTransferData.utils.ts b/packages/sdk/src/getTransferData/getTransferData.utils.ts index 61e6909b..12660347 100644 --- a/packages/sdk/src/getTransferData/getTransferData.utils.ts +++ b/packages/sdk/src/getTransferData/getTransferData.utils.ts @@ -94,7 +94,7 @@ export async function getAssetMin({ if (builder && EvmParachain.isAnyParachain(chain)) { const polkadot = await PolkadotService.create(chain); const min = await polkadot.query( - builder.build({ asset: zero.getMinAssetId() }), + builder.build({ asset: zero.getMinAssetId(), address: zero.address }), ); return zero.copyWith({ amount: min });