@moonbeam-network/mrl 1.0.0-dev.287 → 1.0.0-dev.288

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.mjs CHANGED
@@ -17053,7 +17053,6 @@ import {
17053
17053
  getDestinationFeeBalance,
17054
17054
  getExistentialDeposit,
17055
17055
  getExtrinsicFee,
17056
- getMax,
17057
17056
  PolkadotService as PolkadotService2
17058
17057
  } from "@moonbeam-network/xcm-sdk";
17059
17058
  import {
@@ -17076,6 +17075,7 @@ import {
17076
17075
  } from "@moonbeam-network/xcm-config";
17077
17076
  import {
17078
17077
  convertToChainDecimals,
17078
+ getMax,
17079
17079
  getMin,
17080
17080
  PolkadotService
17081
17081
  } from "@moonbeam-network/xcm-sdk";
@@ -17281,6 +17281,26 @@ function getAmountForTransferSimulation(balance, protocolFee) {
17281
17281
  amount: balance.amount - protocolFee.amount > 0 ? balance.amount - protocolFee.amount : 0n
17282
17282
  });
17283
17283
  }
17284
+ function getMrlMax({
17285
+ balance,
17286
+ existentialDeposit,
17287
+ fee,
17288
+ min,
17289
+ extraFees
17290
+ }) {
17291
+ const xcmMax = getMax({
17292
+ balance,
17293
+ existentialDeposit,
17294
+ fee,
17295
+ min
17296
+ });
17297
+ const result = xcmMax.toBig().minus(
17298
+ extraFees?.local && balance.isSame(extraFees.local.fee) ? extraFees.local.fee.toBig() : Big(0)
17299
+ );
17300
+ return balance.copyWith({
17301
+ amount: result.lt(0) ? 0n : BigInt(result.toFixed())
17302
+ });
17303
+ }
17284
17304
 
17285
17305
  // src/getTransferData/getSourceData.ts
17286
17306
  async function getSourceData({
@@ -17361,12 +17381,6 @@ async function getSourceData({
17361
17381
  feeConfig: route.source.fee,
17362
17382
  sourceAddress
17363
17383
  });
17364
- const max = getMax({
17365
- balance,
17366
- existentialDeposit,
17367
- fee,
17368
- min
17369
- });
17370
17384
  const extraFees = await getExtraFees({
17371
17385
  chain: source,
17372
17386
  transfer,
@@ -17379,6 +17393,13 @@ async function getSourceData({
17379
17393
  bridgeChainFee: bridgeChainData.fee,
17380
17394
  protocolFee
17381
17395
  });
17396
+ const max = getMrlMax({
17397
+ balance,
17398
+ existentialDeposit,
17399
+ fee,
17400
+ min,
17401
+ extraFees
17402
+ });
17382
17403
  return {
17383
17404
  balance,
17384
17405
  chain: source,