Skip to content

Commit

Permalink
more adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaurello committed Nov 29, 2024
1 parent 1ee1a58 commit 5be0a0c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
5 changes: 5 additions & 0 deletions packages/config/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,7 @@ export const moonbaseAlpha = new EvmParachain({
}),
],
ecosystem: Ecosystem.AlphanetRelay,
explorer: 'https://moonbase.moonscan.io',
genesisHash:
'0x91bc6e169807aaa54802737e1c504b2577d4fafedd5a02c10293b1cd60e39527',
id: 1287,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1347,6 +1351,7 @@ export const moonbeam = new EvmParachain({
}),
],
ecosystem: Ecosystem.Polkadot,
explorer: 'https://moonbeam.moonscan.io',
genesisHash:
'0xfe58ea77779b7abda7da4ec526d14db9b1e9cd40a217c34892af80a9b332b76d',
id: 1284,
Expand Down
1 change: 0 additions & 1 deletion packages/config/src/mrl-configs/fantomTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
moonbaseAlpha,
moonbaseBeta,
peaqAlphanet,
peaqEvm,
peaqEvmAlphanet,
} from '../chains';
import { MrlChainRoutes } from '../types/MrlChainRoutes';
Expand Down
6 changes: 4 additions & 2 deletions packages/mrl/src/getTransferData/getSourceData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ import {
} from './getTransferData.utils';

interface GetSourceDataParams {
isAutomatic: boolean;
route: MrlAssetRoute;
destinationAddress: string;
destinationFee: AssetAmount;
sourceAddress: string;
}

export async function getSourceData({
isAutomatic,
route,
destinationAddress,
destinationFee,
Expand Down Expand Up @@ -95,7 +97,7 @@ export async function getSourceData({
asset: balance,
destinationAddress,
feeAsset: feeBalance,
isAutomatic: route.mrl.isAutomaticPossible,
isAutomatic,
route,
sourceAddress,
});
Expand All @@ -115,7 +117,7 @@ export async function getSourceData({
transfer,
asset: balance,
feeAsset: feeBalance,
isAutomatic: route.mrl.isAutomaticPossible,
isAutomatic,
destinationAddress,
route,
sourceAddress,
Expand Down
6 changes: 4 additions & 2 deletions packages/mrl/src/getTransferData/getTransferData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export async function getTransferData({
});

const sourceData = await getSourceData({
isAutomatic: route.mrl.isAutomaticPossible && isAutomatic,
route,
destinationAddress,
destinationFee,
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 3 additions & 6 deletions packages/mrl/src/getTransferData/getTransferData.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ interface DataParams {
destinationData: DestinationChainTransferData;
moonChainData: MoonChainTransferData;
sourceData: SourceTransferData;
isAutomatic?: boolean;
}

export function getMoonChainFeeValueOnSource({
Expand Down Expand Up @@ -75,7 +74,6 @@ export function getMrlMin({
destinationData,
moonChainData,
sourceData,
isAutomatic,
}: DataParams): AssetAmount {
const minInDestination = getMin(destinationData);
const min = AssetAmount.fromChainAsset(
Expand All @@ -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()),
Expand Down
1 change: 1 addition & 0 deletions packages/mrl/src/mrl.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5be0a0c

Please sign in to comment.