@moonbeam-network/mrl 1.0.0-dev.282 → 1.0.0-dev.283
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.d.ts +11 -8
- package/build/index.mjs +53 -27
- package/build/index.mjs.map +1 -1
- package/package.json +6 -6
package/build/index.d.ts
CHANGED
|
@@ -28,19 +28,22 @@ interface TransferParams {
|
|
|
28
28
|
statusCallback?: (status: ISubmittableResult) => void;
|
|
29
29
|
sendOnlyRemoteExecution?: boolean;
|
|
30
30
|
}
|
|
31
|
-
interface
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
interface FeeWithBalance {
|
|
32
|
+
fee: AssetAmount;
|
|
33
|
+
balance: AssetAmount;
|
|
34
|
+
}
|
|
35
|
+
interface MrlExtraFees {
|
|
36
|
+
/** Deducted from source balance */
|
|
37
|
+
local?: FeeWithBalance;
|
|
38
|
+
/** Deducted from transfer amount*/
|
|
39
|
+
remote?: FeeWithBalance;
|
|
36
40
|
}
|
|
37
41
|
interface SourceTransferData extends SourceChainTransferData {
|
|
38
42
|
destinationFeeBalance: AssetAmount;
|
|
39
43
|
bridgeChainFeeBalance?: AssetAmount;
|
|
40
|
-
protocolFeeBalance?: AssetAmount;
|
|
41
44
|
feeBalance: AssetAmount;
|
|
42
45
|
max: AssetAmount;
|
|
43
|
-
|
|
46
|
+
extraFees: MrlExtraFees;
|
|
44
47
|
}
|
|
45
48
|
interface DestinationTransferData extends ChainTransferData {
|
|
46
49
|
}
|
|
@@ -89,4 +92,4 @@ declare function Mrl(options?: MrlOptions): {
|
|
|
89
92
|
getExecuteTransferData({ txId, chain }: WormholeExecuteTransferParams): Promise<ExecuteTransferData>;
|
|
90
93
|
};
|
|
91
94
|
|
|
92
|
-
export { type BridgeChainTransferData, type ChainTransferData, type DestinationTransferData, type ExecuteTransferData, Mrl, type
|
|
95
|
+
export { type BridgeChainTransferData, type ChainTransferData, type DestinationTransferData, type ExecuteTransferData, type FeeWithBalance, Mrl, type MrlExtraFees, type MrlOptions, type Signers, type SourceTransferData, type TransferData, type TransferParams };
|
package/build/index.mjs
CHANGED
|
@@ -17131,7 +17131,7 @@ function getMrlMin({
|
|
|
17131
17131
|
bridgeChainData,
|
|
17132
17132
|
sourceData
|
|
17133
17133
|
});
|
|
17134
|
-
const relayerFee = sourceData.
|
|
17134
|
+
const relayerFee = sourceData.extraFees?.remote?.fee.amount ? sourceData.extraFees.remote?.fee.toBig() : Big(0);
|
|
17135
17135
|
return min.copyWith({
|
|
17136
17136
|
amount: BigInt(min.toBig().add(bridgeChainFee).add(relayerFee).toFixed())
|
|
17137
17137
|
});
|
|
@@ -17345,13 +17345,6 @@ async function getSourceData({
|
|
|
17345
17345
|
bridgeChain,
|
|
17346
17346
|
bridgeChainFee: bridgeChainData.fee
|
|
17347
17347
|
});
|
|
17348
|
-
const protocolFeeConfig = route.source.protocolFee;
|
|
17349
|
-
const protocolFeeBalance = protocolFeeConfig ? await getBalance2({
|
|
17350
|
-
address: sourceAddress,
|
|
17351
|
-
asset: source.getChainAsset(protocolFeeConfig.asset),
|
|
17352
|
-
builder: protocolFeeConfig.balance,
|
|
17353
|
-
chain: source
|
|
17354
|
-
}) : void 0;
|
|
17355
17348
|
const transfer = await buildTransfer({
|
|
17356
17349
|
asset: getAmountForTransferSimulation(balance, protocolFee),
|
|
17357
17350
|
protocolFee,
|
|
@@ -17371,7 +17364,13 @@ async function getSourceData({
|
|
|
17371
17364
|
feeConfig: route.source.fee,
|
|
17372
17365
|
sourceAddress
|
|
17373
17366
|
});
|
|
17374
|
-
const
|
|
17367
|
+
const max = getMax({
|
|
17368
|
+
balance,
|
|
17369
|
+
existentialDeposit,
|
|
17370
|
+
fee,
|
|
17371
|
+
min
|
|
17372
|
+
});
|
|
17373
|
+
const extraFees = await getExtraFees({
|
|
17375
17374
|
chain: source,
|
|
17376
17375
|
transfer,
|
|
17377
17376
|
asset: balance,
|
|
@@ -17380,13 +17379,8 @@ async function getSourceData({
|
|
|
17380
17379
|
destinationAddress,
|
|
17381
17380
|
route,
|
|
17382
17381
|
sourceAddress,
|
|
17383
|
-
bridgeChainFee: bridgeChainData.fee
|
|
17384
|
-
|
|
17385
|
-
const max = getMax({
|
|
17386
|
-
balance,
|
|
17387
|
-
existentialDeposit,
|
|
17388
|
-
fee,
|
|
17389
|
-
min
|
|
17382
|
+
bridgeChainFee: bridgeChainData.fee,
|
|
17383
|
+
protocolFee
|
|
17390
17384
|
});
|
|
17391
17385
|
return {
|
|
17392
17386
|
balance,
|
|
@@ -17394,16 +17388,12 @@ async function getSourceData({
|
|
|
17394
17388
|
destinationFee,
|
|
17395
17389
|
destinationFeeBalance,
|
|
17396
17390
|
bridgeChainFeeBalance,
|
|
17397
|
-
protocolFeeBalance,
|
|
17398
17391
|
existentialDeposit,
|
|
17399
17392
|
fee,
|
|
17400
17393
|
feeBalance,
|
|
17401
17394
|
max,
|
|
17402
17395
|
min,
|
|
17403
|
-
|
|
17404
|
-
protocol: protocolFee,
|
|
17405
|
-
relayer: relayerFee?.amount ? relayerFee : void 0
|
|
17406
|
-
}
|
|
17396
|
+
extraFees
|
|
17407
17397
|
};
|
|
17408
17398
|
}
|
|
17409
17399
|
async function getFee({
|
|
@@ -17534,7 +17524,6 @@ async function getBridgeChainFeeBalance({
|
|
|
17534
17524
|
async function getProtocolFee({
|
|
17535
17525
|
address,
|
|
17536
17526
|
asset,
|
|
17537
|
-
feeAsset,
|
|
17538
17527
|
balance,
|
|
17539
17528
|
protocolFee,
|
|
17540
17529
|
destination,
|
|
@@ -17568,21 +17557,58 @@ async function getProtocolFee({
|
|
|
17568
17557
|
`Error getting bridge fee: expected bigint from contract call, but received ${typeof amount}. `
|
|
17569
17558
|
);
|
|
17570
17559
|
}
|
|
17571
|
-
return AssetAmount2.fromChainAsset(
|
|
17560
|
+
return AssetAmount2.fromChainAsset(protocolFeeAsset, {
|
|
17572
17561
|
amount
|
|
17573
17562
|
});
|
|
17574
17563
|
}
|
|
17575
17564
|
if (SubstrateQueryConfig.is(config)) {
|
|
17576
17565
|
const polkadot = await PolkadotService2.create(bridgeChain);
|
|
17577
17566
|
const amount = await polkadot.query(config);
|
|
17578
|
-
return AssetAmount2.fromChainAsset(
|
|
17567
|
+
return AssetAmount2.fromChainAsset(protocolFeeAsset, {
|
|
17579
17568
|
amount
|
|
17580
17569
|
});
|
|
17581
17570
|
}
|
|
17582
|
-
return AssetAmount2.fromChainAsset(
|
|
17571
|
+
return AssetAmount2.fromChainAsset(protocolFeeAsset, {
|
|
17583
17572
|
amount: 0n
|
|
17584
17573
|
});
|
|
17585
17574
|
}
|
|
17575
|
+
async function getExtraFees({
|
|
17576
|
+
asset,
|
|
17577
|
+
chain: chain2,
|
|
17578
|
+
destinationAddress,
|
|
17579
|
+
feeAsset,
|
|
17580
|
+
isAutomatic,
|
|
17581
|
+
route,
|
|
17582
|
+
sourceAddress,
|
|
17583
|
+
transfer,
|
|
17584
|
+
bridgeChainFee,
|
|
17585
|
+
protocolFee
|
|
17586
|
+
}) {
|
|
17587
|
+
const relayerFee = await getRelayerFee({
|
|
17588
|
+
chain: chain2,
|
|
17589
|
+
transfer,
|
|
17590
|
+
asset,
|
|
17591
|
+
feeAsset,
|
|
17592
|
+
isAutomatic,
|
|
17593
|
+
destinationAddress,
|
|
17594
|
+
route,
|
|
17595
|
+
sourceAddress,
|
|
17596
|
+
bridgeChainFee
|
|
17597
|
+
});
|
|
17598
|
+
const protocolFeeConfig = route.source.protocolFee;
|
|
17599
|
+
const protocolFeeBalance = protocolFeeConfig ? await getBalance2({
|
|
17600
|
+
address: sourceAddress,
|
|
17601
|
+
asset: chain2.getChainAsset(protocolFeeConfig.asset),
|
|
17602
|
+
builder: protocolFeeConfig.balance,
|
|
17603
|
+
chain: chain2
|
|
17604
|
+
}) : void 0;
|
|
17605
|
+
const localFee = protocolFee && protocolFeeBalance ? { fee: protocolFee, balance: protocolFeeBalance } : void 0;
|
|
17606
|
+
const remoteFee = relayerFee ? { fee: relayerFee, balance: feeAsset } : void 0;
|
|
17607
|
+
return {
|
|
17608
|
+
local: localFee,
|
|
17609
|
+
remote: remoteFee
|
|
17610
|
+
};
|
|
17611
|
+
}
|
|
17586
17612
|
|
|
17587
17613
|
// src/getTransferData/getTransferData.ts
|
|
17588
17614
|
async function getTransferData({
|
|
@@ -17631,7 +17657,7 @@ async function getTransferData({
|
|
|
17631
17657
|
});
|
|
17632
17658
|
const result = bigAmount.minus(
|
|
17633
17659
|
isSameAssetPayingDestinationFee ? destinationFee.toBig() : Big2(0)
|
|
17634
|
-
).minus(fee).minus(sourceData.
|
|
17660
|
+
).minus(fee).minus(sourceData.extraFees.remote?.fee.toBig() || Big2(0));
|
|
17635
17661
|
return sourceData.balance.copyWith({
|
|
17636
17662
|
amount: result.lt(0) ? 0n : BigInt(result.toFixed())
|
|
17637
17663
|
});
|
|
@@ -17666,7 +17692,7 @@ async function getTransferData({
|
|
|
17666
17692
|
);
|
|
17667
17693
|
const transfer = await buildTransfer({
|
|
17668
17694
|
asset,
|
|
17669
|
-
protocolFee: sourceData.
|
|
17695
|
+
protocolFee: sourceData.extraFees.local?.fee,
|
|
17670
17696
|
bridgeChainFee: bridgeChainData.fee,
|
|
17671
17697
|
destinationAddress,
|
|
17672
17698
|
feeAsset,
|