From 5be0a0c0c48b2d25e45c6e8e2c39a9a151e2e34f Mon Sep 17 00:00:00 2001 From: Mario J Maurello Date: Fri, 29 Nov 2024 14:05:21 +0100 Subject: [PATCH] more adjustments --- packages/config/src/chains.ts | 5 +++++ packages/config/src/mrl-configs/fantomTestnet.ts | 1 - packages/mrl/src/getTransferData/getSourceData.ts | 6 ++++-- packages/mrl/src/getTransferData/getTransferData.ts | 6 ++++-- .../mrl/src/getTransferData/getTransferData.utils.ts | 9 +++------ packages/mrl/src/mrl.interfaces.ts | 1 + 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index 2762c568..3c341536 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -962,6 +962,7 @@ export const moonbaseAlpha = new EvmParachain({ }), ], ecosystem: Ecosystem.AlphanetRelay, + explorer: 'https://moonbase.moonscan.io', genesisHash: '0x91bc6e169807aaa54802737e1c504b2577d4fafedd5a02c10293b1cd60e39527', id: 1287, @@ -1014,6 +1015,9 @@ export const moonbaseBeta = new EvmParachain({ }), ], ecosystem: Ecosystem.AlphanetRelay, + explorer: getPolkadotAppsUrl( + 'wss://moonbase-beta.api.moonbase.moonbeam.network', + ), genesisHash: '0xeebb5d05763801e54d6a7a60a4b7998ac125c4d050dcec418dd07ea959a54464', id: 1282, @@ -1347,6 +1351,7 @@ export const moonbeam = new EvmParachain({ }), ], ecosystem: Ecosystem.Polkadot, + explorer: 'https://moonbeam.moonscan.io', genesisHash: '0xfe58ea77779b7abda7da4ec526d14db9b1e9cd40a217c34892af80a9b332b76d', id: 1284, diff --git a/packages/config/src/mrl-configs/fantomTestnet.ts b/packages/config/src/mrl-configs/fantomTestnet.ts index 8ec0679b..3059b96c 100644 --- a/packages/config/src/mrl-configs/fantomTestnet.ts +++ b/packages/config/src/mrl-configs/fantomTestnet.ts @@ -5,7 +5,6 @@ import { moonbaseAlpha, moonbaseBeta, peaqAlphanet, - peaqEvm, peaqEvmAlphanet, } from '../chains'; import { MrlChainRoutes } from '../types/MrlChainRoutes'; diff --git a/packages/mrl/src/getTransferData/getSourceData.ts b/packages/mrl/src/getTransferData/getSourceData.ts index 4b693352..9c9c79bc 100644 --- a/packages/mrl/src/getTransferData/getSourceData.ts +++ b/packages/mrl/src/getTransferData/getSourceData.ts @@ -31,6 +31,7 @@ import { } from './getTransferData.utils'; interface GetSourceDataParams { + isAutomatic: boolean; route: MrlAssetRoute; destinationAddress: string; destinationFee: AssetAmount; @@ -38,6 +39,7 @@ interface GetSourceDataParams { } export async function getSourceData({ + isAutomatic, route, destinationAddress, destinationFee, @@ -95,7 +97,7 @@ export async function getSourceData({ asset: balance, destinationAddress, feeAsset: feeBalance, - isAutomatic: route.mrl.isAutomaticPossible, + isAutomatic, route, sourceAddress, }); @@ -115,7 +117,7 @@ export async function getSourceData({ transfer, asset: balance, feeAsset: feeBalance, - isAutomatic: route.mrl.isAutomaticPossible, + isAutomatic, destinationAddress, route, sourceAddress, diff --git a/packages/mrl/src/getTransferData/getTransferData.ts b/packages/mrl/src/getTransferData/getTransferData.ts index 353fe407..fb675777 100644 --- a/packages/mrl/src/getTransferData/getTransferData.ts +++ b/packages/mrl/src/getTransferData/getTransferData.ts @@ -60,6 +60,7 @@ export async function getTransferData({ }); const sourceData = await getSourceData({ + isAutomatic: route.mrl.isAutomaticPossible && isAutomatic, route, destinationAddress, destinationFee, @@ -88,18 +89,19 @@ export async function getTransferData({ .minus( isSameAssetPayingDestinationFee ? destinationFee.toBig() : Big(0), ) - .minus(fee); + .minus(fee) + .minus(sourceData.relayerFee?.toBig() || Big(0)); return sourceData.balance.copyWith({ amount: result.lt(0) ? 0n : BigInt(result.toFixed()), }); }, + isAutomaticPossible: route.mrl.isAutomaticPossible, max: sourceData.max, min: getMrlMin({ destinationData, moonChainData, sourceData, - isAutomatic, }), moonChain: moonChainData, source: sourceData, diff --git a/packages/mrl/src/getTransferData/getTransferData.utils.ts b/packages/mrl/src/getTransferData/getTransferData.utils.ts index 23bfafd7..d9223a44 100644 --- a/packages/mrl/src/getTransferData/getTransferData.utils.ts +++ b/packages/mrl/src/getTransferData/getTransferData.utils.ts @@ -46,7 +46,6 @@ interface DataParams { destinationData: DestinationChainTransferData; moonChainData: MoonChainTransferData; sourceData: SourceTransferData; - isAutomatic?: boolean; } export function getMoonChainFeeValueOnSource({ @@ -75,7 +74,6 @@ export function getMrlMin({ destinationData, moonChainData, sourceData, - isAutomatic, }: DataParams): AssetAmount { const minInDestination = getMin(destinationData); const min = AssetAmount.fromChainAsset( @@ -89,10 +87,9 @@ export function getMrlMin({ moonChainData, sourceData, }); - const relayerFee = - sourceData.relayerFee?.amount && isAutomatic - ? sourceData.relayerFee.toBig() - : Big(0); + const relayerFee = sourceData.relayerFee?.amount + ? sourceData.relayerFee.toBig() + : Big(0); return min.copyWith({ amount: BigInt(min.toBig().add(moonChainFee).add(relayerFee).toFixed()), diff --git a/packages/mrl/src/mrl.interfaces.ts b/packages/mrl/src/mrl.interfaces.ts index ef4a89eb..ac80beb0 100644 --- a/packages/mrl/src/mrl.interfaces.ts +++ b/packages/mrl/src/mrl.interfaces.ts @@ -16,6 +16,7 @@ export interface Signers { export interface TransferData { destination: DestinationTransferData; getEstimate(amount: number | string): AssetAmount; + isAutomaticPossible: boolean; max: AssetAmount; min: AssetAmount; moonChain: MoonChainTransferData;