diff --git a/packages/builder/src/contract/contracts/Xtokens/Xtokens.ts b/packages/builder/src/contract/contracts/Xtokens/Xtokens.ts index 30fda2ac..f2285a62 100644 --- a/packages/builder/src/contract/contracts/Xtokens/Xtokens.ts +++ b/packages/builder/src/contract/contracts/Xtokens/Xtokens.ts @@ -117,7 +117,6 @@ type DestinationMultilocation = [ ), ]; -// TODO test if this is needed function getDestinationMultilocationForPrecompileDestination( address: string, destination: AnyParachain, diff --git a/packages/config/src/assets.ts b/packages/config/src/assets.ts index e6395c2f..06dc02cb 100644 --- a/packages/config/src/assets.ts +++ b/packages/config/src/assets.ts @@ -110,6 +110,11 @@ export const eqd = new Asset({ originSymbol: 'EQD', }); +export const eth = new Asset({ + key: 'eth', + originSymbol: 'ETH', +}); + export const fil = new Asset({ key: 'fil', originSymbol: 'FIL', @@ -428,6 +433,7 @@ export const assetsList: Asset[] = [ dot, eq, eqd, + eth, fil, ftm, ftmwh, diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index 74370c8d..8f23cbba 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -30,6 +30,7 @@ import { dot, eq, eqd, + eth, fil, ftm, ftmwh, @@ -461,12 +462,53 @@ export const darwiniaCrab = new EvmParachain({ ws: ['wss://darwiniacrab-rpc.dwellir.com', 'wss://crab-rpc.darwinia.network'], }); +export const ethereum = new EvmChain({ + assets: [ + ChainAsset.fromAsset(eth, { + decimals: 18, + }), + ChainAsset.fromAsset(usdc, { + address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', + decimals: 6, + }), + ChainAsset.fromAsset(usdt, { + address: '0xdac17f958d2ee523a2206206994597c13d831ec7', + decimals: 6, + }), + ChainAsset.fromAsset(dai, { + address: '0x6b175474e89094c44da98b954eedeac495271d0f', + decimals: 18, + }), + ChainAsset.fromAsset(wbtc, { + address: '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599', + decimals: 8, + }), + ChainAsset.fromAsset(glmr, { + address: '0x93d3696A9F879b331f40CB5059e37015423A3Bd0', + decimals: 18, + }), + ChainAsset.fromAsset(peaq, { + address: '0x6e642b4dfe787b8f101d1fb66c2ef56e2b4c6c52', + decimals: 18, + }), + ], + ecosystem: Ecosystem.Polkadot, + explorer: 'https://etherscan.io', + id: 1, + key: 'ethereum', + name: 'Ethereum', + nativeAsset: eth, + rpc: 'https://ethereum-rpc.publicnode.com', + wh: { + name: 'Ethereum', + }, +}); + export const fantomTestnet = new EvmChain({ assets: [ ChainAsset.fromAsset(ftm, { decimals: 18, }), - // TODO should be WGLMR ? ChainAsset.fromAsset(dev, { address: '0x41E3CFDFC255A4bF3C8D3560Bc8D3D9b5080338e', decimals: 18, @@ -1367,6 +1409,9 @@ export const moonbeam = new EvmParachain({ rpc: 'https://rpc.api.moonbeam.network', ss58Format: 1284, ws: ['wss://wss.api.moonbeam.network'], + wh: { + name: 'Moonbeam', + }, }); export const moonriver = new EvmParachain({ @@ -2262,6 +2307,7 @@ export const chainsList: AnyChain[] = [ crustShadow, darwinia, darwiniaCrab, + ethereum, fantomTestnet, hydration, hydrationAlphanet, diff --git a/packages/config/src/mrl-configs/ethereum.ts b/packages/config/src/mrl-configs/ethereum.ts new file mode 100644 index 00000000..0eeb4052 --- /dev/null +++ b/packages/config/src/mrl-configs/ethereum.ts @@ -0,0 +1,282 @@ +import { BalanceBuilder, MrlBuilder } from '@moonbeam-network/xcm-builder'; +import { + dai, + eth, + glmr, + usdc, + usdcwh, + usdt, + usdtwh, + wbtc, + weth, +} from '../assets'; +import { ethereum, hydration, moonbeam } from '../chains'; +import { MrlChainRoutes } from '../types/MrlChainRoutes'; + +export const ethereumRoutes = new MrlChainRoutes({ + chain: ethereum, + routes: [ + /** + * Destination Hydration + */ + { + source: { + asset: usdc, + balance: BalanceBuilder().evm().erc20(), + destinationFee: { + asset: usdc, + balance: BalanceBuilder().evm().erc20(), + }, + }, + destination: { + asset: usdcwh, + chain: hydration, + balance: BalanceBuilder().substrate().tokens().accounts(), + fee: { + asset: usdcwh, + amount: 0.004, + }, + }, + mrl: { + isAutomaticPossible: false, + transfer: MrlBuilder().wormhole().wormhole().tokenTransfer(), + moonChain: { + asset: usdcwh, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0.15, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + { + source: { + asset: dai, + balance: BalanceBuilder().evm().erc20(), + destinationFee: { + asset: dai, + balance: BalanceBuilder().evm().erc20(), + }, + }, + destination: { + asset: dai, + chain: hydration, + balance: BalanceBuilder().substrate().tokens().accounts(), + fee: { + asset: dai, + amount: 0.004, + }, + }, + mrl: { + isAutomaticPossible: false, + transfer: MrlBuilder().wormhole().wormhole().tokenTransfer(), + moonChain: { + asset: dai, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0.15, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + /** + * Destination Moonbeam + */ + { + source: { + asset: eth, + balance: BalanceBuilder().evm().native(), + destinationFee: { + asset: eth, + balance: BalanceBuilder().evm().native(), + }, + }, + destination: { + asset: weth, + chain: moonbeam, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: weth, + amount: 0, + }, + }, + mrl: { + isAutomaticPossible: true, + transfer: MrlBuilder().wormhole().wormhole().tokenTransfer(), + moonChain: { + asset: weth, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0.15, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + { + source: { + asset: usdc, + balance: BalanceBuilder().evm().erc20(), + destinationFee: { + asset: usdc, + balance: BalanceBuilder().evm().erc20(), + }, + }, + destination: { + asset: usdcwh, + chain: moonbeam, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: usdcwh, + amount: 0, + }, + }, + mrl: { + isAutomaticPossible: true, + transfer: MrlBuilder().wormhole().wormhole().tokenTransfer(), + moonChain: { + asset: usdcwh, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0.15, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + { + source: { + asset: usdt, + balance: BalanceBuilder().evm().erc20(), + destinationFee: { + asset: usdt, + balance: BalanceBuilder().evm().erc20(), + }, + }, + destination: { + asset: usdtwh, + chain: moonbeam, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: usdtwh, + amount: 0, + }, + }, + mrl: { + isAutomaticPossible: true, + transfer: MrlBuilder().wormhole().wormhole().tokenTransfer(), + moonChain: { + asset: usdtwh, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0.15, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + { + source: { + asset: dai, + balance: BalanceBuilder().evm().erc20(), + destinationFee: { + asset: dai, + balance: BalanceBuilder().evm().erc20(), + }, + }, + destination: { + asset: dai, + chain: moonbeam, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: dai, + amount: 0, + }, + }, + mrl: { + isAutomaticPossible: true, + transfer: MrlBuilder().wormhole().wormhole().tokenTransfer(), + moonChain: { + asset: dai, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0.15, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + { + source: { + asset: wbtc, + balance: BalanceBuilder().evm().erc20(), + destinationFee: { + asset: wbtc, + balance: BalanceBuilder().evm().erc20(), + }, + }, + destination: { + asset: wbtc, + chain: moonbeam, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: wbtc, + amount: 0, + }, + }, + mrl: { + isAutomaticPossible: true, + transfer: MrlBuilder().wormhole().wormhole().tokenTransfer(), + moonChain: { + asset: wbtc, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0.15, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + { + source: { + asset: glmr, + balance: BalanceBuilder().evm().erc20(), + destinationFee: { + asset: glmr, + balance: BalanceBuilder().evm().erc20(), + }, + }, + destination: { + asset: glmr, + chain: moonbeam, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0, + }, + }, + mrl: { + isAutomaticPossible: true, + transfer: MrlBuilder().wormhole().wormhole().tokenTransfer(), + moonChain: { + asset: glmr, + balance: BalanceBuilder().substrate().system().account(), + fee: { + asset: glmr, + amount: 0.15, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + ], +}); diff --git a/packages/config/src/mrl-configs/hydration.ts b/packages/config/src/mrl-configs/hydration.ts new file mode 100644 index 00000000..13b6a32a --- /dev/null +++ b/packages/config/src/mrl-configs/hydration.ts @@ -0,0 +1,221 @@ +import { BalanceBuilder, MrlBuilder } from '@moonbeam-network/xcm-builder'; +import { + dai, + eth, + glmr, + hdx, + usdc, + usdcwh, + usdt, + usdtwh, + wbtc, + weth, +} from '../assets'; +import { ethereum, hydration } from '../chains'; +import { MrlChainRoutes } from '../types/MrlChainRoutes'; + +export const hydrationRoutes = new MrlChainRoutes({ + chain: hydration, + routes: [ + { + source: { + asset: weth, + balance: BalanceBuilder().substrate().tokens().accounts(), + destinationFee: { + asset: weth, + balance: BalanceBuilder().substrate().tokens().accounts(), + }, + moonChainFee: { + asset: glmr, + balance: BalanceBuilder().substrate().tokens().accounts(), + }, + fee: { + asset: hdx, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + destination: { + asset: eth, + chain: ethereum, + balance: BalanceBuilder().evm().native(), + fee: { + asset: eth, + amount: 0, + }, + }, + mrl: { + isAutomaticPossible: true, + transfer: MrlBuilder().wormhole().extrinsic().polkadotXcm().send(), + moonChain: { + asset: weth, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0.1, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + { + source: { + asset: usdcwh, + balance: BalanceBuilder().substrate().tokens().accounts(), + destinationFee: { + asset: usdcwh, + balance: BalanceBuilder().substrate().tokens().accounts(), + }, + moonChainFee: { + asset: glmr, + balance: BalanceBuilder().substrate().tokens().accounts(), + }, + fee: { + asset: hdx, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + destination: { + asset: usdc, + chain: ethereum, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: usdc, + amount: 0, + }, + }, + mrl: { + isAutomaticPossible: true, + transfer: MrlBuilder().wormhole().extrinsic().polkadotXcm().send(), + moonChain: { + asset: usdcwh, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0.1, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + { + source: { + asset: usdtwh, + balance: BalanceBuilder().substrate().tokens().accounts(), + destinationFee: { + asset: usdtwh, + balance: BalanceBuilder().substrate().tokens().accounts(), + }, + moonChainFee: { + asset: glmr, + balance: BalanceBuilder().substrate().tokens().accounts(), + }, + fee: { + asset: hdx, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + destination: { + asset: usdt, + chain: ethereum, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: usdt, + amount: 0, + }, + }, + mrl: { + isAutomaticPossible: true, + transfer: MrlBuilder().wormhole().extrinsic().polkadotXcm().send(), + moonChain: { + asset: usdtwh, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0.1, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + { + source: { + asset: dai, + balance: BalanceBuilder().substrate().tokens().accounts(), + destinationFee: { + asset: dai, + balance: BalanceBuilder().substrate().tokens().accounts(), + }, + moonChainFee: { + asset: glmr, + balance: BalanceBuilder().substrate().tokens().accounts(), + }, + fee: { + asset: hdx, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + destination: { + asset: dai, + chain: ethereum, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: dai, + amount: 0, + }, + }, + mrl: { + isAutomaticPossible: true, + transfer: MrlBuilder().wormhole().extrinsic().polkadotXcm().send(), + moonChain: { + asset: dai, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0.1, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + { + source: { + asset: wbtc, + balance: BalanceBuilder().substrate().tokens().accounts(), + destinationFee: { + asset: wbtc, + balance: BalanceBuilder().substrate().tokens().accounts(), + }, + moonChainFee: { + asset: glmr, + balance: BalanceBuilder().substrate().tokens().accounts(), + }, + fee: { + asset: hdx, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + destination: { + asset: wbtc, + chain: ethereum, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: wbtc, + amount: 0, + }, + }, + mrl: { + isAutomaticPossible: true, + transfer: MrlBuilder().wormhole().extrinsic().polkadotXcm().send(), + moonChain: { + asset: wbtc, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0.1, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + ], +}); diff --git a/packages/config/src/mrl-configs/moonbeam.ts b/packages/config/src/mrl-configs/moonbeam.ts new file mode 100644 index 00000000..4c273ab6 --- /dev/null +++ b/packages/config/src/mrl-configs/moonbeam.ts @@ -0,0 +1,52 @@ +import { BalanceBuilder, MrlBuilder } from '@moonbeam-network/xcm-builder'; +import { + dai, + glmr, + peaq, + usdc, + usdcwh, + usdt, + usdtwh, + wbtc, + weth, +} from '../assets'; +import { ethereum, hydration, moonbeam, peaqChain } from '../chains'; +import { MrlChainRoutes } from '../types/MrlChainRoutes'; + +export const moonbeamRoutes = new MrlChainRoutes({ + chain: moonbeam, + routes: [ + { + source: { + asset: peaq, + balance: BalanceBuilder().evm().erc20(), + destinationFee: { + asset: peaq, + balance: BalanceBuilder().evm().erc20(), + }, + }, + destination: { + asset: peaq, + chain: ethereum, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: peaq, + amount: 0.004, + }, + }, + mrl: { + isAutomaticPossible: false, + transfer: MrlBuilder().wormhole().wormhole().tokenTransfer(), + moonChain: { + asset: peaq, + balance: BalanceBuilder().evm().erc20(), + fee: { + asset: glmr, + amount: 0.15, + balance: BalanceBuilder().substrate().system().account(), + }, + }, + }, + }, + ], +}); diff --git a/packages/mrl/src/getTransferData/getMoonChainData.ts b/packages/mrl/src/getTransferData/getMoonChainData.ts index ed03836d..f333d39a 100644 --- a/packages/mrl/src/getTransferData/getMoonChainData.ts +++ b/packages/mrl/src/getTransferData/getMoonChainData.ts @@ -34,7 +34,6 @@ export async function getMoonChainData({ destinationAddress, }); - console.log('sourceAddress', sourceAddress); const fee = await getDestinationFee({ address: moonChainAddress, asset: route.source.asset,