@paraspell/sdk-core 14.5.2 → 14.5.4
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/dist/index.d.ts +3 -5
- package/dist/index.mjs +221 -179
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -157,7 +157,6 @@ declare abstract class SubstrateChain<TApi, TRes, TSigner, TCustomChain extends
|
|
|
157
157
|
canReceiveFrom<TCustomChain extends string = never>(_origin: TChain | TCustomChain): boolean;
|
|
158
158
|
shouldUseNativeAssetTeleport({ api, assetInfo: asset, to }: TTransferInternalOptions<TApi, TRes, TSigner, TCustomChain>): boolean;
|
|
159
159
|
shouldUseExecuteTransfer(_options: TPolkadotXCMTransferOptions<TApi, TRes, TSigner, TCustomChain>): boolean;
|
|
160
|
-
protected shouldUseReserveTransfer(): boolean;
|
|
161
160
|
createAsset(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, asset: WithAmount<TAssetInfo>, version: Version): TAsset;
|
|
162
161
|
getNativeAssetSymbol(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>): string;
|
|
163
162
|
transferLocal(options: TTransferInternalOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
|
|
@@ -216,7 +215,6 @@ declare class AssetHubWestend<TApi, TRes, TSigner, TCustomChain extends string =
|
|
|
216
215
|
declare class Astar<TApi, TRes, TSigner, TCustomChain extends string = never> extends SubstrateChain<TApi, TRes, TSigner, TCustomChain> implements IPolkadotXCMTransfer<TApi, TRes, TSigner, TCustomChain> {
|
|
217
216
|
constructor(chain?: TParachain, info?: string, ecosystem?: TRelaychain, version?: Version);
|
|
218
217
|
protected getMintConfig(): TMintConfig;
|
|
219
|
-
protected shouldUseReserveTransfer(): boolean;
|
|
220
218
|
isSendingTempDisabled(assetInfo: TAssetInfo): boolean;
|
|
221
219
|
transferPolkadotXCM(input: TPolkadotXCMTransferOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
|
|
222
220
|
isRelayToParaEnabled(): boolean;
|
|
@@ -364,7 +362,6 @@ declare class EnergyWebX<TApi, TRes, TSigner, TCustomChain extends string = neve
|
|
|
364
362
|
constructor(chain?: TParachain, info?: string, ecosystem?: TRelaychain, version?: Version);
|
|
365
363
|
transferPolkadotXCM(input: TPolkadotXCMTransferOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
|
|
366
364
|
isRelayToParaEnabled(): boolean;
|
|
367
|
-
protected shouldUseReserveTransfer(): boolean;
|
|
368
365
|
protected getMintConfig(): TMintConfig;
|
|
369
366
|
transferLocalNonNativeAsset(options: TTransferLocalOptions<TApi, TRes, TSigner, TCustomChain>): TRes;
|
|
370
367
|
getBalanceForeign(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, address: string, asset: TAssetInfo): Promise<bigint>;
|
|
@@ -1528,6 +1525,7 @@ type TGetXcmFeeBaseOptions<TRes, TDisableFallback extends boolean = boolean, TCu
|
|
|
1528
1525
|
disableFallback: TDisableFallback;
|
|
1529
1526
|
swapConfig?: TXcmFeeSwapConfig;
|
|
1530
1527
|
skipReverseFeeCalculation?: boolean;
|
|
1528
|
+
skipEdDeposit?: boolean;
|
|
1531
1529
|
};
|
|
1532
1530
|
type TGetXcmFeeOptions<TApi, TRes, TSigner, TDisableFallback extends boolean = boolean, TCustomChain extends string = never> = WithApi<TGetXcmFeeBaseOptions<TRes, TDisableFallback, TCustomChain>, TApi, TRes, TSigner, TCustomChain>;
|
|
1533
1531
|
type TGetXcmFeeInternalOptions<TApi, TRes, TSigner, TDisableFallback extends boolean = boolean, TCustomChain extends string = never> = Omit<TGetXcmFeeOptions<TApi, TRes, TSigner, TDisableFallback, TCustomChain>, 'buildTx'> & {
|
|
@@ -2151,7 +2149,7 @@ type TCreateBaseSwapXcmOptions = {
|
|
|
2151
2149
|
feeAssetInfo?: TAssetInfo;
|
|
2152
2150
|
sender: string;
|
|
2153
2151
|
recipient: string;
|
|
2154
|
-
calculateMinAmountOut: (amountIn: bigint, assetTo?: TAssetInfo) => Promise<bigint>;
|
|
2152
|
+
calculateMinAmountOut: (amountIn: bigint, assetTo?: TAssetInfo, slippagePct?: string) => Promise<bigint>;
|
|
2155
2153
|
};
|
|
2156
2154
|
type TCreateSwapXcmOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = WithApi<TCreateBaseSwapXcmOptions, TApi, TRes, TSigner, TCustomChain>;
|
|
2157
2155
|
type TSwapFeeEstimates = {
|
|
@@ -2382,7 +2380,7 @@ declare const getOriginXcmFeeInternal: <TApi, TRes, TSigner, TCustomChain extend
|
|
|
2382
2380
|
declare const getXcmFeeInternal: <TApi, TRes, TSigner, TDisableFallback extends boolean, TCustomChain extends string = never>(options: TGetXcmFeeOptions<TApi, TRes, TSigner, TDisableFallback, TCustomChain>) => Promise<TGetXcmFeeResult<TDisableFallback, TCustomChain>>;
|
|
2383
2381
|
declare const getXcmFee: <TApi, TRes, TSigner, TDisableFallback extends boolean, TCustomChain extends string = never>(options: TGetXcmFeeOptions<TApi, TRes, TSigner, TDisableFallback, TCustomChain>) => Promise<TGetXcmFeeResult<TDisableFallback, TCustomChain>>;
|
|
2384
2382
|
|
|
2385
|
-
declare const getXcmFeeOnce: <TApi, TRes, TSigner, TDisableFallback extends boolean, TCustomChain extends string = never>({ api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation }: TGetXcmFeeInternalOptions<TApi, TRes, TSigner, TDisableFallback, TCustomChain>) => Promise<TGetXcmFeeResult<TDisableFallback, TCustomChain>>;
|
|
2383
|
+
declare const getXcmFeeOnce: <TApi, TRes, TSigner, TDisableFallback extends boolean, TCustomChain extends string = never>({ api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, skipEdDeposit }: TGetXcmFeeInternalOptions<TApi, TRes, TSigner, TDisableFallback, TCustomChain>) => Promise<TGetXcmFeeResult<TDisableFallback, TCustomChain>>;
|
|
2386
2384
|
|
|
2387
2385
|
declare const getBridgeStatus: <TApi, TRes, TSigner, TCustomChain extends string = never>(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>) => Promise<TBridgeStatus>;
|
|
2388
2386
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { blake2b } from '@noble/hashes/blake2.js';
|
|
2
|
-
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isAssetEqual, isSymbolMatch, isStableCoinAsset, isAdditionalSubstrateBridgeAsset, isBridgedSystemAsset, STABLECOIN_IDS, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, extractAssetLocation, normalizeSymbol,
|
|
2
|
+
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isAssetEqual, isSymbolMatch, isStableCoinAsset, isAdditionalSubstrateBridgeAsset, isBridgedSystemAsset, STABLECOIN_IDS, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, extractAssetLocation, normalizeSymbol, findNativeAssetInfoOrThrow, getOtherAssets, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, isChainEvmImpl, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, getExistentialDepositImpl, normalizeCustomAssets } from '@paraspell/assets';
|
|
3
3
|
export * from '@paraspell/assets';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
5
|
import { isAddress, isHex, createPublicClient, http, formatUnits as formatUnits$1, parseUnits as parseUnits$1, stringToHex, numberToBytes } from 'viem';
|
|
@@ -2661,7 +2661,7 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
|
|
|
2661
2661
|
key: "transfer",
|
|
2662
2662
|
value: function () {
|
|
2663
2663
|
var _transfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(transferOptions) {
|
|
2664
|
-
var api, asset, currency, feeAsset, feeCurrency, recipient, destination, paraIdTo, overriddenAsset, version, sender, ahAddress, pallet, method, keepAlive, transactOptions, scenario, paraId, destChain, isLocalTransfer, isRelayAsset,
|
|
2664
|
+
var api, asset, currency, feeAsset, feeCurrency, recipient, destination, paraIdTo, overriddenAsset, version, sender, ahAddress, pallet, method, keepAlive, transactOptions, scenario, paraId, destChain, isLocalTransfer, isRelayAsset, supportsTypeAndThen, options, promise, isSubBridge, isAHOrigin, isExternalAsset, isEthDest, isExternalAssetViaAh, input, _t, _t2;
|
|
2665
2665
|
return _regenerator().w(function (_context) {
|
|
2666
2666
|
while (1) switch (_context.n) {
|
|
2667
2667
|
case 0:
|
|
@@ -2687,26 +2687,20 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
|
|
|
2687
2687
|
this.throwIfTempDisabled(transferOptions, destChain);
|
|
2688
2688
|
this.throwIfCantReceive(destChain);
|
|
2689
2689
|
isRelayAsset = deepEqual(asset.location, RELAY_LOCATION) && isSymbolMatch(api.getRelayChainSymbol(this.chain), asset.symbol);
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2690
|
+
if (!(supportsPolkadotXCM(this) || isRelayAsset)) {
|
|
2691
|
+
_context.n = 11;
|
|
2692
|
+
break;
|
|
2693
|
+
}
|
|
2694
2694
|
_context.n = 3;
|
|
2695
|
-
return api.hasMethod(api.
|
|
2695
|
+
return api.hasMethod(api.getXcmPallet(this.chain), 'transfer_assets_using_type_and_then');
|
|
2696
2696
|
case 3:
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
if (!(assetNeedsTypeThen && !supportsTypeThen && (!shouldUseReserveTransfer || isSubBridge))) {
|
|
2697
|
+
supportsTypeAndThen = _context.v;
|
|
2698
|
+
if (supportsTypeAndThen) {
|
|
2700
2699
|
_context.n = 4;
|
|
2701
2700
|
break;
|
|
2702
2701
|
}
|
|
2703
|
-
throw new TypeAndThenUnavailableError(
|
|
2702
|
+
throw new TypeAndThenUnavailableError("Chain ".concat(this.chain, " does not support the type-and-then method required for this transfer."));
|
|
2704
2703
|
case 4:
|
|
2705
|
-
useTypeAndThen = !shouldUseReserveTransfer && assetNeedsTypeThen && supportsTypeThen && destChain && !isExternalChain(destChain) && (!isTrustedChain(this.chain) || !isTrustedChain(destChain)) || isSubBridge;
|
|
2706
|
-
if (!(supportsPolkadotXCM(this) || useTypeAndThen)) {
|
|
2707
|
-
_context.n = 14;
|
|
2708
|
-
break;
|
|
2709
|
-
}
|
|
2710
2704
|
options = {
|
|
2711
2705
|
api: api,
|
|
2712
2706
|
chain: this.chain,
|
|
@@ -2751,53 +2745,31 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
|
|
|
2751
2745
|
case 6:
|
|
2752
2746
|
return _context.a(2, _t.deserializeExtrinsics.call(_t, _context.v));
|
|
2753
2747
|
case 7:
|
|
2748
|
+
isSubBridge = !isTLocation(destination) && isSubstrateBridge(this.chain, destination);
|
|
2754
2749
|
isAHOrigin = this.chain.includes('AssetHub');
|
|
2755
|
-
isAHDest = !isTLocation(destination) && destination.includes('AssetHub'); // Handle common cases
|
|
2756
2750
|
isExternalAsset = asset.location.parents === Parents.TWO;
|
|
2757
|
-
isEthDest = _typeof(destination) !== 'object' && isExternalChain(destination);
|
|
2758
|
-
isExternalAssetViaAh = isExternalAsset && !isAHOrigin && !
|
|
2759
|
-
|
|
2760
|
-
if (!(isExternalAssetViaAh || isExternalAssetToAh || useTypeAndThen)) {
|
|
2761
|
-
_context.n = 11;
|
|
2762
|
-
break;
|
|
2763
|
-
}
|
|
2764
|
-
if (!(useTypeAndThen && supportsPolkadotXCM(this) && !isSubBridge)) {
|
|
2751
|
+
isEthDest = _typeof(destination) !== 'object' && isExternalChain(destination);
|
|
2752
|
+
isExternalAssetViaAh = isExternalAsset && !isAHOrigin && !isEthDest;
|
|
2753
|
+
if (!(!supportsPolkadotXCM(this) || isSubBridge || isExternalAssetViaAh)) {
|
|
2765
2754
|
_context.n = 9;
|
|
2766
2755
|
break;
|
|
2767
2756
|
}
|
|
2757
|
+
_t2 = api;
|
|
2768
2758
|
_context.n = 8;
|
|
2769
|
-
return
|
|
2759
|
+
return createTypeAndThenCall(options);
|
|
2770
2760
|
case 8:
|
|
2771
|
-
|
|
2772
|
-
if (!this.shouldUseExecuteTransfer(options)) {
|
|
2773
|
-
_context.n = 9;
|
|
2774
|
-
break;
|
|
2775
|
-
}
|
|
2776
|
-
return _context.a(2, tx);
|
|
2761
|
+
return _context.a(2, _t2.deserializeExtrinsics.call(_t2, _context.v));
|
|
2777
2762
|
case 9:
|
|
2778
|
-
_context.n = 10;
|
|
2779
|
-
return createTypeAndThenCall(options);
|
|
2780
|
-
case 10:
|
|
2781
|
-
call = _context.v;
|
|
2782
|
-
return _context.a(2, api.deserializeExtrinsics(call));
|
|
2783
|
-
case 11:
|
|
2784
|
-
if (!supportsPolkadotXCM(this)) {
|
|
2785
|
-
_context.n = 13;
|
|
2786
|
-
break;
|
|
2787
|
-
}
|
|
2788
2763
|
if (!(this.shouldUseNativeAssetTeleport(transferOptions) && !getFeeAssetInfo(asset, feeAsset) && !this.shouldUseExecuteTransfer(options))) {
|
|
2789
|
-
_context.n =
|
|
2764
|
+
_context.n = 10;
|
|
2790
2765
|
break;
|
|
2791
2766
|
}
|
|
2792
2767
|
return _context.a(2, transferPolkadotXcm(options, 'limited_teleport_assets', 'Unlimited'));
|
|
2793
|
-
case
|
|
2768
|
+
case 10:
|
|
2794
2769
|
return _context.a(2, this.transferPolkadotXCM(options));
|
|
2795
|
-
case
|
|
2796
|
-
_context.n = 15;
|
|
2797
|
-
break;
|
|
2798
|
-
case 14:
|
|
2770
|
+
case 11:
|
|
2799
2771
|
if (!supportsXTokens(this)) {
|
|
2800
|
-
_context.n =
|
|
2772
|
+
_context.n = 12;
|
|
2801
2773
|
break;
|
|
2802
2774
|
}
|
|
2803
2775
|
validateFeeAssetSupport(asset, feeAsset, overriddenAsset, 'XTokens');
|
|
@@ -2815,9 +2787,9 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
|
|
|
2815
2787
|
method: method
|
|
2816
2788
|
};
|
|
2817
2789
|
return _context.a(2, this.transferXTokens(input));
|
|
2818
|
-
case
|
|
2790
|
+
case 12:
|
|
2819
2791
|
throw new NoXCMSupportImplementedError(this.chain);
|
|
2820
|
-
case
|
|
2792
|
+
case 13:
|
|
2821
2793
|
return _context.a(2);
|
|
2822
2794
|
}
|
|
2823
2795
|
}, _callee, this);
|
|
@@ -2885,11 +2857,6 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
|
|
|
2885
2857
|
value: function shouldUseExecuteTransfer(_options) {
|
|
2886
2858
|
return false;
|
|
2887
2859
|
}
|
|
2888
|
-
}, {
|
|
2889
|
-
key: "shouldUseReserveTransfer",
|
|
2890
|
-
value: function shouldUseReserveTransfer() {
|
|
2891
|
-
return false;
|
|
2892
|
-
}
|
|
2893
2860
|
}, {
|
|
2894
2861
|
key: "createAsset",
|
|
2895
2862
|
value: function createAsset$1(api, asset, version) {
|
|
@@ -3048,7 +3015,7 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
|
|
|
3048
3015
|
key: "getBalanceForeign",
|
|
3049
3016
|
value: function () {
|
|
3050
3017
|
var _getBalanceForeign = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(api, address, asset) {
|
|
3051
|
-
var pallets, lastError, customCurrencyId, _iterator, _step, pallet, instance,
|
|
3018
|
+
var pallets, lastError, customCurrencyId, _iterator, _step, pallet, instance, _t3, _t4;
|
|
3052
3019
|
return _regenerator().w(function (_context3) {
|
|
3053
3020
|
while (1) switch (_context3.p = _context3.n) {
|
|
3054
3021
|
case 0:
|
|
@@ -3077,8 +3044,8 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
|
|
|
3077
3044
|
return _context3.a(2, _context3.v);
|
|
3078
3045
|
case 6:
|
|
3079
3046
|
_context3.p = 6;
|
|
3080
|
-
|
|
3081
|
-
lastError =
|
|
3047
|
+
_t3 = _context3.v;
|
|
3048
|
+
lastError = _t3;
|
|
3082
3049
|
case 7:
|
|
3083
3050
|
_context3.n = 3;
|
|
3084
3051
|
break;
|
|
@@ -3087,8 +3054,8 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
|
|
|
3087
3054
|
break;
|
|
3088
3055
|
case 9:
|
|
3089
3056
|
_context3.p = 9;
|
|
3090
|
-
|
|
3091
|
-
_iterator.e(
|
|
3057
|
+
_t4 = _context3.v;
|
|
3058
|
+
_iterator.e(_t4);
|
|
3092
3059
|
case 10:
|
|
3093
3060
|
_context3.p = 10;
|
|
3094
3061
|
_iterator.f();
|
|
@@ -3545,7 +3512,7 @@ var createTransfer = /*#__PURE__*/function () {
|
|
|
3545
3512
|
return api.init(origin, TX_CLIENT_TIMEOUT_MS, destination);
|
|
3546
3513
|
case 1:
|
|
3547
3514
|
_resolveTransferParam = resolveTransferParams(options), resolvedFeeAsset = _resolveTransferParam.resolvedFeeAsset, resolvedVersion = _resolveTransferParam.resolvedVersion, overriddenAsset = _resolveTransferParam.overriddenAsset, normalizedAsset = _resolveTransferParam.normalizedAsset;
|
|
3548
|
-
customCtx = api
|
|
3515
|
+
customCtx = api._customCtx;
|
|
3549
3516
|
chainInstance = getSubstrateChainImpl(origin, customCtx);
|
|
3550
3517
|
return _context.a(2, chainInstance.transfer({
|
|
3551
3518
|
api: api,
|
|
@@ -3598,13 +3565,11 @@ var padFee = function padFee(raw, origin, dest, side) {
|
|
|
3598
3565
|
var sysParaDest = isSystemPara(dest);
|
|
3599
3566
|
var relayToPara = relayOrigin && !relayDest;
|
|
3600
3567
|
var sysParaToPara = sysParaOrigin && !sysParaDest;
|
|
3601
|
-
var paraToPara = !relayOrigin && !sysParaOrigin;
|
|
3602
3568
|
if (sysParaToPara) return raw * 40n;
|
|
3603
3569
|
if (relayToPara) return side === 'origin' ? mul(raw, 320n, 100n) : mul(raw, 3000n, 100n);
|
|
3604
|
-
if (
|
|
3570
|
+
if (side === 'origin' && origin === 'Mythos' && dest !== 'Ethereum') {
|
|
3605
3571
|
return 150000000000000000n;
|
|
3606
3572
|
}
|
|
3607
|
-
if (paraToPara) return mul(raw, 130n, 100n);
|
|
3608
3573
|
// apply default 30% padding
|
|
3609
3574
|
return mul(raw, 130n, 100n);
|
|
3610
3575
|
};
|
|
@@ -5314,7 +5279,7 @@ var getEthErc20Balance = /*#__PURE__*/function () {
|
|
|
5314
5279
|
|
|
5315
5280
|
var isSufficientOrigin = /*#__PURE__*/function () {
|
|
5316
5281
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, sender, feeNative, asset, feeAsset) {
|
|
5317
|
-
var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset,
|
|
5282
|
+
var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, remainingAsset, isSufficientAsset;
|
|
5318
5283
|
return _regenerator().w(function (_context) {
|
|
5319
5284
|
while (1) switch (_context.n) {
|
|
5320
5285
|
case 0:
|
|
@@ -5355,8 +5320,8 @@ var isSufficientOrigin = /*#__PURE__*/function () {
|
|
|
5355
5320
|
});
|
|
5356
5321
|
case 4:
|
|
5357
5322
|
balanceAsset = _context.v;
|
|
5358
|
-
|
|
5359
|
-
isSufficientAsset =
|
|
5323
|
+
remainingAsset = balanceAsset - asset.amount;
|
|
5324
|
+
isSufficientAsset = remainingAsset === 0n || remainingAsset >= BigInt(asset.existentialDeposit);
|
|
5360
5325
|
return _context.a(2, isSufficientNative && isSufficientAsset);
|
|
5361
5326
|
case 5:
|
|
5362
5327
|
return _context.a(2, balanceNative - edNative - feeNative - asset.amount > 0n);
|
|
@@ -5976,7 +5941,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5976
5941
|
break;
|
|
5977
5942
|
}
|
|
5978
5943
|
_context2.n = 8;
|
|
5979
|
-
return addEthereumBridgeFees(api, bridgeHubHop
|
|
5944
|
+
return addEthereumBridgeFees(api, bridgeHubHop.result, destination, assetHubChain);
|
|
5980
5945
|
case 8:
|
|
5981
5946
|
_t9 = _context2.v;
|
|
5982
5947
|
_context2.n = 10;
|
|
@@ -6250,7 +6215,7 @@ var localizeLocationInner = function localizeLocationInner(chain, location, orig
|
|
|
6250
6215
|
if (locationRelay && targetRelay && locationRelay !== targetRelay && (!origin || !ecosystemDiffers && isConsensusAnchored)) {
|
|
6251
6216
|
return location;
|
|
6252
6217
|
}
|
|
6253
|
-
if (origin && ecosystemDiffers && location.parents === Parents.TWO &&
|
|
6218
|
+
if (origin && ecosystemDiffers && location.parents === Parents.TWO && deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, targetRelay, null)) && junctionCount === 1) {
|
|
6254
6219
|
return RELAY_LOCATION;
|
|
6255
6220
|
}
|
|
6256
6221
|
var newInterior = location.interior === 'Here' ? {
|
|
@@ -6299,7 +6264,7 @@ var localizeLocationInner = function localizeLocationInner(chain, location, orig
|
|
|
6299
6264
|
parents: Parents.ONE
|
|
6300
6265
|
});
|
|
6301
6266
|
}
|
|
6302
|
-
if (origin && ecosystemDiffers && isOriginRelayHere && !hasGlobalConsensus
|
|
6267
|
+
if (origin && ecosystemDiffers && isOriginRelayHere && !hasGlobalConsensus) {
|
|
6303
6268
|
return {
|
|
6304
6269
|
parents: Parents.TWO,
|
|
6305
6270
|
interior: {
|
|
@@ -6309,7 +6274,7 @@ var localizeLocationInner = function localizeLocationInner(chain, location, orig
|
|
|
6309
6274
|
}
|
|
6310
6275
|
};
|
|
6311
6276
|
}
|
|
6312
|
-
if (origin && ecosystemDiffers && newInterior.Here === undefined && !hasGlobalConsensus
|
|
6277
|
+
if (origin && ecosystemDiffers && newInterior.Here === undefined && !hasGlobalConsensus) {
|
|
6313
6278
|
var _junctions = flattenJunctions(newInterior);
|
|
6314
6279
|
var updatedJunctions = [{
|
|
6315
6280
|
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
@@ -6600,7 +6565,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
6600
6565
|
case 1:
|
|
6601
6566
|
balance = _context.v;
|
|
6602
6567
|
bonus = mintBonusForSent(chain, sentAsset, feeAsset, !!mintFeeAssets, api);
|
|
6603
|
-
if (
|
|
6568
|
+
if (options.sentAssetMintMode === 'bypass') {
|
|
6604
6569
|
mintAmount = parseUnits(bypassMintAmount, sentAsset.decimals) + sentAsset.amount + BigInt(sentAsset.existentialDeposit);
|
|
6605
6570
|
} else {
|
|
6606
6571
|
missing = calcSentAssetPreviewMint(sentAsset, balance, dryRunOptions.keepAlive);
|
|
@@ -7042,7 +7007,8 @@ var computeAllFees = /*#__PURE__*/function () {
|
|
|
7042
7007
|
currency: currency,
|
|
7043
7008
|
feeAsset: feeCurrency,
|
|
7044
7009
|
disableFallback: false,
|
|
7045
|
-
skipReverseFeeCalculation: true
|
|
7010
|
+
skipReverseFeeCalculation: true,
|
|
7011
|
+
skipEdDeposit: true
|
|
7046
7012
|
});
|
|
7047
7013
|
case 3:
|
|
7048
7014
|
result = _context.v;
|
|
@@ -7175,11 +7141,11 @@ var resolveEdDeposit = /*#__PURE__*/function () {
|
|
|
7175
7141
|
|
|
7176
7142
|
var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
7177
7143
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
7178
|
-
var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, resolvedFeeAsset, _resolveCurrency, asset, assets, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _dryRunError, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, convertToFeeDetail, result, dryRunError, _t, _t2, _t3, _t4;
|
|
7144
|
+
var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, skipEdDeposit, resolvedFeeAsset, _resolveCurrency, asset, assets, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _dryRunError, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, convertToFeeDetail, result, dryRunError, _t, _t2, _t3, _t4;
|
|
7179
7145
|
return _regenerator().w(function (_context2) {
|
|
7180
7146
|
while (1) switch (_context2.p = _context2.n) {
|
|
7181
7147
|
case 0:
|
|
7182
|
-
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, sender = _ref.sender, recipient = _ref.recipient, currency = _ref.currency, feeAsset = _ref.feeAsset, version = _ref.version, disableFallback = _ref.disableFallback, swapConfig = _ref.swapConfig, useRootOrigin = _ref.useRootOrigin, skipReverseFeeCalculation = _ref.skipReverseFeeCalculation;
|
|
7148
|
+
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, sender = _ref.sender, recipient = _ref.recipient, currency = _ref.currency, feeAsset = _ref.feeAsset, version = _ref.version, disableFallback = _ref.disableFallback, swapConfig = _ref.swapConfig, useRootOrigin = _ref.useRootOrigin, skipReverseFeeCalculation = _ref.skipReverseFeeCalculation, skipEdDeposit = _ref.skipEdDeposit;
|
|
7183
7149
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
7184
7150
|
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), asset = _resolveCurrency.asset, assets = _resolveCurrency.assets;
|
|
7185
7151
|
resolvedVersion = pickCompatibleXcmVersion(api, origin, destination, version);
|
|
@@ -7348,7 +7314,7 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
7348
7314
|
});
|
|
7349
7315
|
case 1:
|
|
7350
7316
|
hopResult = _context.v;
|
|
7351
|
-
if (!(!isDestination || hopResult.fee === undefined || hopResult.dryRunError || isAssetEqual(hopResult.asset, hopApi.findNativeAssetInfoOrThrow(currentChain)))) {
|
|
7317
|
+
if (!(skipEdDeposit || !isDestination || hopResult.fee === undefined || hopResult.dryRunError || isAssetEqual(hopResult.asset, hopApi.findNativeAssetInfoOrThrow(currentChain)))) {
|
|
7352
7318
|
_context.n = 2;
|
|
7353
7319
|
break;
|
|
7354
7320
|
}
|
|
@@ -7854,7 +7820,8 @@ var buildHopInfo = /*#__PURE__*/function () {
|
|
|
7854
7820
|
var _excluded$1 = ["amount"];
|
|
7855
7821
|
var buildOriginInfo = /*#__PURE__*/function () {
|
|
7856
7822
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
7857
|
-
var
|
|
7823
|
+
var _transferredFeeAsset$;
|
|
7824
|
+
var api, origin, sender, assets, amount, originFee, originFeeAsset, isOriginFeeAsset, buildSelectedCurrency, selectedCurrency, originBalanceFee, transferredFeeAsset, originBalanceFeeAfter, ed, isNativeFeeAsset, remaining;
|
|
7858
7825
|
return _regenerator().w(function (_context2) {
|
|
7859
7826
|
while (1) switch (_context2.n) {
|
|
7860
7827
|
case 0:
|
|
@@ -7902,11 +7869,17 @@ var buildOriginInfo = /*#__PURE__*/function () {
|
|
|
7902
7869
|
});
|
|
7903
7870
|
case 2:
|
|
7904
7871
|
originBalanceFee = _context2.v;
|
|
7905
|
-
|
|
7872
|
+
transferredFeeAsset = isOriginFeeAsset ? undefined : assets.find(function (asset) {
|
|
7873
|
+
return isAssetEqual(asset, originFeeAsset);
|
|
7874
|
+
});
|
|
7875
|
+
originBalanceFeeAfter = isOriginFeeAsset ? originBalanceFee - amount : originBalanceFee - originFee - ((_transferredFeeAsset$ = transferredFeeAsset === null || transferredFeeAsset === void 0 ? void 0 : transferredFeeAsset.amount) !== null && _transferredFeeAsset$ !== void 0 ? _transferredFeeAsset$ : 0n);
|
|
7876
|
+
ed = BigInt(originFeeAsset.existentialDeposit);
|
|
7877
|
+
isNativeFeeAsset = isAssetEqual(originFeeAsset, api.findNativeAssetInfoOrThrow(origin));
|
|
7878
|
+
remaining = originBalanceFeeAfter + (isNativeFeeAsset ? ed : 0n);
|
|
7906
7879
|
return _context2.a(2, {
|
|
7907
7880
|
selectedCurrency: selectedCurrency,
|
|
7908
7881
|
xcmFee: {
|
|
7909
|
-
sufficient: originBalanceFee >= originFee,
|
|
7882
|
+
sufficient: transferredFeeAsset ? remaining === 0n || remaining >= ed : originBalanceFee >= originFee,
|
|
7910
7883
|
fee: originFee,
|
|
7911
7884
|
balance: originBalanceFee,
|
|
7912
7885
|
balanceAfter: originBalanceFeeAfter,
|
|
@@ -7983,7 +7956,7 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
7983
7956
|
selectedCurrency = _yield$buildOriginInf.selectedCurrency;
|
|
7984
7957
|
originXcmFee = _yield$buildOriginInf.xcmFee;
|
|
7985
7958
|
builtHops = [];
|
|
7986
|
-
if (!(hops
|
|
7959
|
+
if (!(hops.length > 0)) {
|
|
7987
7960
|
_context2.n = 7;
|
|
7988
7961
|
break;
|
|
7989
7962
|
}
|
|
@@ -8220,33 +8193,35 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
8220
8193
|
return createTx(amounts);
|
|
8221
8194
|
case 5:
|
|
8222
8195
|
tx = _context3.v;
|
|
8223
|
-
_context3.n =
|
|
8196
|
+
_context3.n = 11;
|
|
8224
8197
|
break;
|
|
8225
8198
|
case 6:
|
|
8226
8199
|
_context3.p = 6;
|
|
8227
8200
|
_t = _context3.v;
|
|
8228
|
-
if (
|
|
8229
|
-
_context3.n =
|
|
8201
|
+
if (_t instanceof AmountTooLowError) {
|
|
8202
|
+
_context3.n = 7;
|
|
8230
8203
|
break;
|
|
8231
8204
|
}
|
|
8205
|
+
throw _t;
|
|
8206
|
+
case 7:
|
|
8232
8207
|
amounts = amounts.map(function (amount) {
|
|
8233
8208
|
return padValueBy(amount, FEE_PADDING);
|
|
8234
8209
|
});
|
|
8235
|
-
_context3.p =
|
|
8236
|
-
_context3.n =
|
|
8210
|
+
_context3.p = 8;
|
|
8211
|
+
_context3.n = 9;
|
|
8237
8212
|
return createTx(amounts);
|
|
8238
|
-
case
|
|
8213
|
+
case 9:
|
|
8239
8214
|
tx = _context3.v;
|
|
8240
|
-
_context3.n =
|
|
8215
|
+
_context3.n = 11;
|
|
8241
8216
|
break;
|
|
8242
|
-
case
|
|
8243
|
-
_context3.p =
|
|
8217
|
+
case 10:
|
|
8218
|
+
_context3.p = 10;
|
|
8244
8219
|
_context3.v;
|
|
8245
8220
|
return _context3.a(2, toResult(amounts.map(function () {
|
|
8246
8221
|
return 0n;
|
|
8247
8222
|
})));
|
|
8248
|
-
case
|
|
8249
|
-
_context3.n =
|
|
8223
|
+
case 11:
|
|
8224
|
+
_context3.n = 12;
|
|
8250
8225
|
return dryRunInternal({
|
|
8251
8226
|
api: api,
|
|
8252
8227
|
tx: tx,
|
|
@@ -8257,19 +8232,19 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
8257
8232
|
currency: buildMinCurrency(amounts),
|
|
8258
8233
|
feeAsset: feeAsset
|
|
8259
8234
|
});
|
|
8260
|
-
case
|
|
8235
|
+
case 12:
|
|
8261
8236
|
dryRunResult = _context3.v;
|
|
8262
8237
|
if (dryRunResult.success) {
|
|
8263
|
-
_context3.n =
|
|
8238
|
+
_context3.n = 13;
|
|
8264
8239
|
break;
|
|
8265
8240
|
}
|
|
8266
8241
|
return _context3.a(2, toResult(amounts.map(function () {
|
|
8267
8242
|
return 0n;
|
|
8268
8243
|
})));
|
|
8269
|
-
case
|
|
8244
|
+
case 13:
|
|
8270
8245
|
return _context3.a(2, toResult(amounts));
|
|
8271
8246
|
}
|
|
8272
|
-
}, _callee3, null, [[
|
|
8247
|
+
}, _callee3, null, [[8, 10], [4, 6]]);
|
|
8273
8248
|
}));
|
|
8274
8249
|
return function getMinTransferableAmountInternal(_x) {
|
|
8275
8250
|
return _ref2.apply(this, arguments);
|
|
@@ -9165,7 +9140,7 @@ var calculateTotalXcmFee = function calculateTotalXcmFee(asset, feeResult) {
|
|
|
9165
9140
|
var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
9166
9141
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
9167
9142
|
var _destAssets$find;
|
|
9168
|
-
var api, buildTx, origin, destination, currency, sender, recipient, feeAsset, version, isSubBridge, resolvedFeeAsset, destApi, resolvedAssets, destAssets, _destAssets, firstAsset, feeElement, xcmFeeResult, dryRunError, hops, _xcmFeeResult$destina, destFee, destFeeType, destFeeAsset, destDryRunError, erroredHop, hopError, isUnableToCompute, tx, method,
|
|
9143
|
+
var api, buildTx, origin, destination, currency, sender, recipient, feeAsset, version, isSubBridge, resolvedFeeAsset, destApi, resolvedAssets, destAssets, _destAssets, firstAsset, feeElement, xcmFeeResult, dryRunError, hops, _xcmFeeResult$destina, destFee, destFeeType, destFeeAsset, destDryRunError, erroredHop, hopError, isUnableToCompute, tx, method, subtractsHopFees, verifyAsset, results;
|
|
9169
9144
|
return _regenerator().w(function (_context2) {
|
|
9170
9145
|
while (1) switch (_context2.n) {
|
|
9171
9146
|
case 0:
|
|
@@ -9271,7 +9246,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
9271
9246
|
case 9:
|
|
9272
9247
|
tx = _context2.v;
|
|
9273
9248
|
method = api.getMethod(tx);
|
|
9274
|
-
|
|
9249
|
+
subtractsHopFees = method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen' || method === 'execute';
|
|
9275
9250
|
verifyAsset = /*#__PURE__*/function () {
|
|
9276
9251
|
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref4) {
|
|
9277
9252
|
var destAsset, amount, paysDestFee, ed, balance, feeToSubtract;
|
|
@@ -9289,7 +9264,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
9289
9264
|
});
|
|
9290
9265
|
case 1:
|
|
9291
9266
|
balance = _context.v;
|
|
9292
|
-
feeToSubtract =
|
|
9267
|
+
feeToSubtract = subtractsHopFees ? calculateTotalXcmFee(destAsset, xcmFeeResult) : paysDestFee && isAssetEqual(destFeeAsset, destAsset) ? destFee : 0n;
|
|
9293
9268
|
return _context.a(2, amount - feeToSubtract > (balance < ed ? ed : 0));
|
|
9294
9269
|
}
|
|
9295
9270
|
}, _callee);
|
|
@@ -9554,13 +9529,13 @@ var prepareExecuteContext = function prepareExecuteContext(_ref) {
|
|
|
9554
9529
|
var asset = createAsset(version, amount, assetInfo.location);
|
|
9555
9530
|
var assetLocalized = createAsset(version, amount, api.localizeLocation(chain, assetInfo.location));
|
|
9556
9531
|
var assetLocalizedToDest = createAsset(version, amount, localizeLocation(destChain, assetInfo.location));
|
|
9557
|
-
var assetLocalizedToReserve = createAsset(version, amount, api.localizeLocation(reserveChain
|
|
9532
|
+
var assetLocalizedToReserve = createAsset(version, amount, api.localizeLocation(reserveChain, assetInfo.location));
|
|
9558
9533
|
var resolvedFeeAssetInfo = getFeeAssetInfo(assetInfo, feeAssetInfo);
|
|
9559
9534
|
var feeAssetTotal = originFee + reserveFee + destFee;
|
|
9560
9535
|
var feeAsset = resolvedFeeAssetInfo && createAsset(version, feeAssetTotal, resolvedFeeAssetInfo.location);
|
|
9561
9536
|
var feeAssetLocalized = resolvedFeeAssetInfo && createAsset(version, feeAssetTotal, api.localizeLocation(chain, resolvedFeeAssetInfo.location));
|
|
9562
9537
|
var feeAssetLocalizedToDest = resolvedFeeAssetInfo && createAsset(version, destFee, localizeLocation(destChain, resolvedFeeAssetInfo.location));
|
|
9563
|
-
var feeAssetLocalizedToReserve = resolvedFeeAssetInfo && createAsset(version, reserveFee, api.localizeLocation(reserveChain
|
|
9538
|
+
var feeAssetLocalizedToReserve = resolvedFeeAssetInfo && createAsset(version, reserveFee, api.localizeLocation(reserveChain, resolvedFeeAssetInfo.location));
|
|
9564
9539
|
var feeReserveChain = resolvedFeeAssetInfo && api.getAssetReserveChain(chain, resolvedFeeAssetInfo.location);
|
|
9565
9540
|
return {
|
|
9566
9541
|
amount: amount,
|
|
@@ -9646,13 +9621,11 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
|
|
|
9646
9621
|
// currency and must not be subtracted from the transfer amount.
|
|
9647
9622
|
var originFeeDeduction = feeAssetInfo && !feeAsset ? originFee : 0n;
|
|
9648
9623
|
var destLocation = createDestination(api, version, chain, destChain, paraIdTo);
|
|
9649
|
-
if (chain !== 'AssetHubPolkadot' && reserveChain === undefined) {
|
|
9650
|
-
throw new UnsupportedOperationError('Sending local reserve assets with custom fee asset is not yet supported for this chain.');
|
|
9651
|
-
}
|
|
9652
9624
|
if (feeReserveChain !== undefined && feeReserveChain !== reserveChain) {
|
|
9653
9625
|
throw new ScenarioNotSupportedError("Fee asset cannot pay fees on hops and destination because its reserve chain (".concat(feeReserveChain, ") differs from the reserve chain of the transferred asset (").concat(reserveChain, ")."));
|
|
9654
9626
|
}
|
|
9655
9627
|
var transferType = getInstructionType(api, version, chain, destChain, assetInfo, reserveChain, transactOptions);
|
|
9628
|
+
var hasReserveHop = transferType !== 'DepositAsset';
|
|
9656
9629
|
var createRoutingFilter = function createRoutingFilter(asset) {
|
|
9657
9630
|
return feeAsset ? createAllCountedFilter(2) : createAssetsFilter(asset, version);
|
|
9658
9631
|
};
|
|
@@ -9662,16 +9635,16 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
|
|
|
9662
9635
|
throw new ScenarioNotSupportedError("Fee asset ".concat(feeAssetInfo.symbol, " cannot be teleported from ").concat(from, " to ").concat(to, ", so it cannot pay fees there."));
|
|
9663
9636
|
}
|
|
9664
9637
|
};
|
|
9665
|
-
var reserveToDestInstruction = isTeleportLeg(api, reserveChain
|
|
9638
|
+
var reserveToDestInstruction = isTeleportLeg(api, reserveChain, destChain, assetInfo) ? 'InitiateTeleport' : 'DepositReserveAsset';
|
|
9666
9639
|
var createReserveToDestXcm = function createReserveToDestXcm() {
|
|
9667
9640
|
if (isReserveDest) return suffixXcm;
|
|
9668
9641
|
if (reserveToDestInstruction === 'InitiateTeleport') {
|
|
9669
|
-
assertFeeAssetTeleportable(reserveChain
|
|
9642
|
+
assertFeeAssetTeleportable(reserveChain, destChain);
|
|
9670
9643
|
}
|
|
9671
9644
|
return [_defineProperty({}, reserveToDestInstruction, {
|
|
9672
9645
|
assets: createRoutingFilter(assetLocalizedToReserve),
|
|
9673
|
-
dest: createDestination(api, version, reserveChain
|
|
9674
|
-
xcm: [].concat(_toConsumableArray(createBuyExecution(feeAssetLocalizedToDest !== null && feeAssetLocalizedToDest !== void 0 ? feeAssetLocalizedToDest : updateAsset(assetLocalizedToDest, reserveFee === 1000n ? amount / 2n : amount - originFeeDeduction - reserveFee))), _toConsumableArray(suffixXcm))
|
|
9646
|
+
dest: createDestination(api, version, reserveChain, destChain, paraIdTo),
|
|
9647
|
+
xcm: [].concat(_toConsumableArray(createBuyExecution(feeAssetLocalizedToDest !== null && feeAssetLocalizedToDest !== void 0 ? feeAssetLocalizedToDest : updateAsset(assetLocalizedToDest, reserveFee === 1000n && hasReserveHop ? amount / 2n : amount - originFeeDeduction - reserveFee))), _toConsumableArray(suffixXcm))
|
|
9675
9648
|
})];
|
|
9676
9649
|
};
|
|
9677
9650
|
var mainInstructions;
|
|
@@ -10126,75 +10099,79 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(options, origin, mess
|
|
|
10126
10099
|
|
|
10127
10100
|
var isMultiHopSwap = function isMultiHopSwap(exchangeChain, assetFrom, assetTo) {
|
|
10128
10101
|
var isAssetHub = exchangeChain.includes('AssetHub');
|
|
10129
|
-
var
|
|
10130
|
-
return isAssetHub && assetFrom
|
|
10102
|
+
var nativeAsset = findNativeAssetInfoOrThrow(exchangeChain);
|
|
10103
|
+
return isAssetHub && !isAssetEqual(assetFrom, nativeAsset) && !isAssetEqual(assetTo, nativeAsset);
|
|
10131
10104
|
};
|
|
10132
10105
|
|
|
10106
|
+
var createExchangeAsset = function createExchangeAsset(give, want) {
|
|
10107
|
+
return {
|
|
10108
|
+
ExchangeAsset: {
|
|
10109
|
+
give: give,
|
|
10110
|
+
want: want,
|
|
10111
|
+
maximal: true
|
|
10112
|
+
}
|
|
10113
|
+
};
|
|
10114
|
+
};
|
|
10133
10115
|
var createExchangeInstructions = /*#__PURE__*/function () {
|
|
10134
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options,
|
|
10135
|
-
var api, chain, exchangeChain, assetInfoFrom, assetInfoTo, version, calculateMinAmountOut, _options$fees, originReserveFee, exchangeFee, hasSeparateFeeAsset,
|
|
10116
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, separateFeeAssetInfo) {
|
|
10117
|
+
var api, chain, exchangeChain, assetInfoFrom, assetInfoTo, version, calculateMinAmountOut, _options$fees, originReserveFee, exchangeFee, hasSeparateFeeAsset, needsMultiHop, isDummyRun, halveOnDummyFees, createWant, amountIn, give, assetTo, nativeAsset, isNativeFeeAsset, nativeAmountOut, assetNative;
|
|
10136
10118
|
return _regenerator().w(function (_context) {
|
|
10137
10119
|
while (1) switch (_context.n) {
|
|
10138
10120
|
case 0:
|
|
10139
10121
|
api = options.api, chain = options.chain, exchangeChain = options.exchangeChain, assetInfoFrom = options.assetInfoFrom, assetInfoTo = options.assetInfoTo, version = options.version, calculateMinAmountOut = options.calculateMinAmountOut, _options$fees = options.fees, originReserveFee = _options$fees.originReserveFee, exchangeFee = _options$fees.exchangeFee;
|
|
10140
10122
|
hasSeparateFeeAsset = separateFeeAssetInfo !== undefined;
|
|
10141
|
-
nativeSymbol = getNativeAssetSymbol(exchangeChain);
|
|
10142
10123
|
needsMultiHop = isMultiHopSwap(exchangeChain, assetInfoFrom, assetInfoTo);
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10124
|
+
isDummyRun = exchangeFee === 0n;
|
|
10125
|
+
halveOnDummyFees = function halveOnDummyFees(amount) {
|
|
10126
|
+
return chain && isDummyRun ? (amount + 1n) / 2n : amount;
|
|
10127
|
+
};
|
|
10128
|
+
createWant = function createWant(asset) {
|
|
10129
|
+
return [isDummyRun ? _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
10130
|
+
fun: {
|
|
10131
|
+
Fungible: 1n
|
|
10132
|
+
}
|
|
10133
|
+
}) : asset];
|
|
10134
|
+
};
|
|
10135
|
+
amountIn = assetInfoFrom.amount - (chain && !hasSeparateFeeAsset ? originReserveFee + exchangeFee : 0n);
|
|
10136
|
+
give = {
|
|
10137
|
+
Definite: [createAsset(version, halveOnDummyFees(amountIn), localizeLocation(exchangeChain, assetInfoFrom.location))]
|
|
10138
|
+
};
|
|
10139
|
+
assetTo = createAsset(version, assetInfoTo.amount, localizeLocation(exchangeChain, assetInfoTo.location));
|
|
10146
10140
|
if (needsMultiHop) {
|
|
10147
10141
|
_context.n = 1;
|
|
10148
10142
|
break;
|
|
10149
10143
|
}
|
|
10150
|
-
return _context.a(2, [
|
|
10151
|
-
ExchangeAsset: {
|
|
10152
|
-
give: createAssetsFilter(assetFrom, version),
|
|
10153
|
-
want: [assetTo],
|
|
10154
|
-
maximal: hasSeparateFeeAsset
|
|
10155
|
-
}
|
|
10156
|
-
}]);
|
|
10144
|
+
return _context.a(2, [createExchangeAsset(give, createWant(assetTo))]);
|
|
10157
10145
|
case 1:
|
|
10146
|
+
// Multi-hop through native asset
|
|
10147
|
+
nativeAsset = api.findNativeAssetInfoOrThrow(exchangeChain);
|
|
10148
|
+
isNativeFeeAsset = hasSeparateFeeAsset && isAssetEqual(separateFeeAssetInfo, nativeAsset);
|
|
10158
10149
|
_context.n = 2;
|
|
10159
|
-
return calculateMinAmountOut(
|
|
10150
|
+
return calculateMinAmountOut(amountIn, nativeAsset, isNativeFeeAsset ? '0' : undefined);
|
|
10160
10151
|
case 2:
|
|
10161
10152
|
nativeAmountOut = _context.v;
|
|
10162
|
-
assetNative = createAsset(version,
|
|
10163
|
-
return _context.a(2, [{
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
want: [assetNative],
|
|
10167
|
-
maximal: hasSeparateFeeAsset
|
|
10168
|
-
}
|
|
10169
|
-
}, {
|
|
10170
|
-
ExchangeAsset: {
|
|
10171
|
-
give: separateFeeAssetInfo && isAssetEqual(separateFeeAssetInfo, nativeAsset) ? {
|
|
10172
|
-
Definite: [assetNative]
|
|
10173
|
-
} : createAssetsFilter(assetNative, version),
|
|
10174
|
-
want: [assetTo],
|
|
10175
|
-
maximal: true
|
|
10176
|
-
}
|
|
10177
|
-
}]);
|
|
10153
|
+
assetNative = createAsset(version, halveOnDummyFees(nativeAmountOut), localizeLocation(exchangeChain, nativeAsset.location));
|
|
10154
|
+
return _context.a(2, [createExchangeAsset(give, createWant(assetNative)), createExchangeAsset(isNativeFeeAsset ? {
|
|
10155
|
+
Definite: [assetNative]
|
|
10156
|
+
} : createAssetsFilter(assetNative, version), createWant(assetTo))]);
|
|
10178
10157
|
}
|
|
10179
10158
|
}, _callee);
|
|
10180
10159
|
}));
|
|
10181
|
-
return function createExchangeInstructions(_x, _x2
|
|
10160
|
+
return function createExchangeInstructions(_x, _x2) {
|
|
10182
10161
|
return _ref.apply(this, arguments);
|
|
10183
10162
|
};
|
|
10184
10163
|
}();
|
|
10185
10164
|
var createSwapExecuteXcm = /*#__PURE__*/function () {
|
|
10186
10165
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
10187
10166
|
var _ref3, _ref4;
|
|
10188
|
-
var api, chain, exchangeChain, destChain, assetInfoFrom, assetInfoTo, feeAssetInfo, _options$fees2, originFee, originReserveFee, exchangeFee, destReserveFee, destFee, sender, recipient, version, paraIdTo, isEthereumDest, resolvedDestChain,
|
|
10167
|
+
var api, chain, exchangeChain, destChain, assetInfoFrom, assetInfoTo, feeAssetInfo, _options$fees2, originFee, originReserveFee, exchangeFee, destReserveFee, destFee, sender, recipient, version, paraIdTo, isEthereumDest, resolvedDestChain, amountOut, assetToLocalizedToDest, ethFeeAssetInfo, ethBridgeFee, nativeFeeAssetInfo, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, executionFee, resolvedFeeAssetInfo, hasSeparateFeeAsset, createLegFees, feeAssetBudget, isFeeLeftoverAboveEd, _prepareCommonExecute, prefix, depositInstruction, exchangeInstructions, exchangeToDestXcm, ethAsset, messageId, snowbridgeInstructions, finalXcm, fullXcm;
|
|
10189
10168
|
return _regenerator().w(function (_context2) {
|
|
10190
10169
|
while (1) switch (_context2.n) {
|
|
10191
10170
|
case 0:
|
|
10192
10171
|
api = options.api, chain = options.chain, exchangeChain = options.exchangeChain, destChain = options.destChain, assetInfoFrom = options.assetInfoFrom, assetInfoTo = options.assetInfoTo, feeAssetInfo = options.feeAssetInfo, _options$fees2 = options.fees, originFee = _options$fees2.originFee, originReserveFee = _options$fees2.originReserveFee, exchangeFee = _options$fees2.exchangeFee, destReserveFee = _options$fees2.destReserveFee, destFee = _options$fees2.destFee, sender = options.sender, recipient = options.recipient, version = options.version, paraIdTo = options.paraIdTo;
|
|
10193
10172
|
isEthereumDest = destChain !== undefined && isExternalChain(destChain); // For Ethereum destination, the actual hop target is AssetHub (bridge hub)
|
|
10194
10173
|
resolvedDestChain = isEthereumDest ? "AssetHub".concat(getRelayChainOf(chain !== null && chain !== void 0 ? chain : exchangeChain)) : undefined;
|
|
10195
|
-
|
|
10196
|
-
amountOut = assetInfoTo.amount;
|
|
10197
|
-
assetTo = createAsset(version, amountOut, localizeLocation(exchangeChain, assetInfoTo.location)); // For Ethereum, localize to AssetHub since that's where instructions execute
|
|
10174
|
+
amountOut = assetInfoTo.amount; // For Ethereum, localize to AssetHub since that's where instructions execute
|
|
10198
10175
|
assetToLocalizedToDest = createAsset(version, amountOut, localizeLocation((_ref3 = resolvedDestChain !== null && resolvedDestChain !== void 0 ? resolvedDestChain : destChain) !== null && _ref3 !== void 0 ? _ref3 : exchangeChain, assetInfoTo.location)); // For Ethereum destination, use DOT as feeAsset for bridge fees
|
|
10199
10176
|
ethBridgeFee = 0n;
|
|
10200
10177
|
if (!isEthereumDest) {
|
|
@@ -10252,7 +10229,7 @@ var createSwapExecuteXcm = /*#__PURE__*/function () {
|
|
|
10252
10229
|
version: version
|
|
10253
10230
|
}, assetToLocalizedToDest, isFeeLeftoverAboveEd()), prefix = _prepareCommonExecute.prefix, depositInstruction = _prepareCommonExecute.depositInstruction;
|
|
10254
10231
|
_context2.n = 4;
|
|
10255
|
-
return createExchangeInstructions(options,
|
|
10232
|
+
return createExchangeInstructions(options, resolvedFeeAssetInfo);
|
|
10256
10233
|
case 4:
|
|
10257
10234
|
exchangeInstructions = _context2.v;
|
|
10258
10235
|
if (!isEthereumDest) {
|
|
@@ -10320,22 +10297,86 @@ var createSwapExecuteXcm = /*#__PURE__*/function () {
|
|
|
10320
10297
|
}
|
|
10321
10298
|
}, _callee2);
|
|
10322
10299
|
}));
|
|
10323
|
-
return function createSwapExecuteXcm(
|
|
10300
|
+
return function createSwapExecuteXcm(_x3) {
|
|
10324
10301
|
return _ref2.apply(this, arguments);
|
|
10325
10302
|
};
|
|
10326
10303
|
}();
|
|
10327
10304
|
|
|
10305
|
+
var scaleFeeToPostTradePrice = function scaleFeeToPostTradePrice(fee, soldAmount, nativeForFee, nativeForSoldAmount) {
|
|
10306
|
+
var spotToAverageNumerator = nativeForFee * soldAmount;
|
|
10307
|
+
var spotToAverageDenominator = fee * nativeForSoldAmount;
|
|
10308
|
+
var postTradeFee = fee * spotToAverageNumerator * spotToAverageNumerator / (spotToAverageDenominator * spotToAverageDenominator);
|
|
10309
|
+
return postTradeFee > fee ? postTradeFee : fee;
|
|
10310
|
+
};
|
|
10311
|
+
/**
|
|
10312
|
+
* AssetHub pays the onward delivery fee from the sold asset after the swap moved the pool price,
|
|
10313
|
+
* so the pre-trade fee estimate is scaled to the post-trade price to avoid NotHoldingFees.
|
|
10314
|
+
*/
|
|
10315
|
+
var getExchangeFeeAtPostTradePrice = /*#__PURE__*/function () {
|
|
10316
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, _ref2, hasSeparateFeeAsset) {
|
|
10317
|
+
var api, chain, exchangeChain, destChain, assetInfoFrom, calculateMinAmountOut, originReserveFee, exchangeFee, nativeAsset, isOnwardFeeTakenFromSoldAsset, soldAmount, _yield$Promise$all, _yield$Promise$all2, nativeForFee, nativeForSoldAmount;
|
|
10318
|
+
return _regenerator().w(function (_context) {
|
|
10319
|
+
while (1) switch (_context.n) {
|
|
10320
|
+
case 0:
|
|
10321
|
+
api = _ref.api, chain = _ref.chain, exchangeChain = _ref.exchangeChain, destChain = _ref.destChain, assetInfoFrom = _ref.assetInfoFrom, calculateMinAmountOut = _ref.calculateMinAmountOut;
|
|
10322
|
+
originReserveFee = _ref2.originReserveFee, exchangeFee = _ref2.exchangeFee;
|
|
10323
|
+
nativeAsset = api.findNativeAssetInfoOrThrow(exchangeChain);
|
|
10324
|
+
isOnwardFeeTakenFromSoldAsset = chain !== undefined && destChain !== undefined && !hasSeparateFeeAsset && exchangeChain.includes('AssetHub') && !isAssetEqual(assetInfoFrom, nativeAsset);
|
|
10325
|
+
if (isOnwardFeeTakenFromSoldAsset) {
|
|
10326
|
+
_context.n = 1;
|
|
10327
|
+
break;
|
|
10328
|
+
}
|
|
10329
|
+
return _context.a(2, exchangeFee);
|
|
10330
|
+
case 1:
|
|
10331
|
+
soldAmount = assetInfoFrom.amount - originReserveFee - exchangeFee;
|
|
10332
|
+
_context.n = 2;
|
|
10333
|
+
return Promise.all([calculateMinAmountOut(exchangeFee, nativeAsset, '0'), calculateMinAmountOut(soldAmount, nativeAsset, '0')]);
|
|
10334
|
+
case 2:
|
|
10335
|
+
_yield$Promise$all = _context.v;
|
|
10336
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
10337
|
+
nativeForFee = _yield$Promise$all2[0];
|
|
10338
|
+
nativeForSoldAmount = _yield$Promise$all2[1];
|
|
10339
|
+
if (!(nativeForSoldAmount === 0n)) {
|
|
10340
|
+
_context.n = 3;
|
|
10341
|
+
break;
|
|
10342
|
+
}
|
|
10343
|
+
return _context.a(2, exchangeFee);
|
|
10344
|
+
case 3:
|
|
10345
|
+
return _context.a(2, scaleFeeToPostTradePrice(exchangeFee, soldAmount, nativeForFee, nativeForSoldAmount));
|
|
10346
|
+
}
|
|
10347
|
+
}, _callee);
|
|
10348
|
+
}));
|
|
10349
|
+
return function getExchangeFeeAtPostTradePrice(_x, _x2, _x3) {
|
|
10350
|
+
return _ref3.apply(this, arguments);
|
|
10351
|
+
};
|
|
10352
|
+
}();
|
|
10353
|
+
|
|
10328
10354
|
var FEE_PADDING_PERCENTAGE = 20;
|
|
10355
|
+
var FEE_SHORTFALL_REASONS = ['NotHoldingFees', 'TooExpensive'];
|
|
10329
10356
|
var validateAmount = function validateAmount(amount, requiredFee) {
|
|
10330
10357
|
if (amount <= requiredFee) {
|
|
10331
10358
|
throw new AmountTooLowError("Asset amount is too low, please increase the amount or use a different fee asset.");
|
|
10332
10359
|
}
|
|
10333
10360
|
};
|
|
10361
|
+
var hasRealFeeShortfall = function hasRealFeeShortfall(_ref, exchangeChain, destChain) {
|
|
10362
|
+
var hops = _ref.hops,
|
|
10363
|
+
destination = _ref.destination;
|
|
10364
|
+
var exchangeIndex = hops.findIndex(function (hop) {
|
|
10365
|
+
return hop.chain === exchangeChain;
|
|
10366
|
+
});
|
|
10367
|
+
var checkedHops = exchangeIndex === -1 ? hops : hops.slice(0, exchangeIndex + 1);
|
|
10368
|
+
var results = [].concat(_toConsumableArray(checkedHops.map(function (hop) {
|
|
10369
|
+
return hop.result;
|
|
10370
|
+
})), _toConsumableArray(destChain ? [] : [destination]));
|
|
10371
|
+
return results.some(function (result) {
|
|
10372
|
+
return (result === null || result === void 0 ? void 0 : result.success) === false && FEE_SHORTFALL_REASONS.includes(result.dryRunError.reason);
|
|
10373
|
+
});
|
|
10374
|
+
};
|
|
10334
10375
|
var calculateTotalFees = function calculateTotalFees(chain, fees) {
|
|
10335
10376
|
return chain ? fees.originReserveFee + fees.exchangeFee : 0n;
|
|
10336
10377
|
};
|
|
10337
10378
|
var executeDryRun = /*#__PURE__*/function () {
|
|
10338
|
-
var
|
|
10379
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
10339
10380
|
var result;
|
|
10340
10381
|
return _regenerator().w(function (_context) {
|
|
10341
10382
|
while (1) switch (_context.n) {
|
|
@@ -10358,7 +10399,7 @@ var executeDryRun = /*#__PURE__*/function () {
|
|
|
10358
10399
|
}, _callee);
|
|
10359
10400
|
}));
|
|
10360
10401
|
return function executeDryRun(_x) {
|
|
10361
|
-
return
|
|
10402
|
+
return _ref2.apply(this, arguments);
|
|
10362
10403
|
};
|
|
10363
10404
|
}();
|
|
10364
10405
|
var findExchangeHopIndex = function findExchangeHopIndex(chain, dryRunResult, exchangeChain, destChain) {
|
|
@@ -10471,7 +10512,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, exchangeChain,
|
|
|
10471
10512
|
return fees;
|
|
10472
10513
|
};
|
|
10473
10514
|
var createXcmAndCall = /*#__PURE__*/function () {
|
|
10474
|
-
var
|
|
10515
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, dryRunWeight) {
|
|
10475
10516
|
var xcm, api, chain, exchangeChain, hasApiSupport, weight, call, _t;
|
|
10476
10517
|
return _regenerator().w(function (_context2) {
|
|
10477
10518
|
while (1) switch (_context2.n) {
|
|
@@ -10506,13 +10547,13 @@ var createXcmAndCall = /*#__PURE__*/function () {
|
|
|
10506
10547
|
}, _callee2);
|
|
10507
10548
|
}));
|
|
10508
10549
|
return function createXcmAndCall(_x2, _x3) {
|
|
10509
|
-
return
|
|
10550
|
+
return _ref3.apply(this, arguments);
|
|
10510
10551
|
};
|
|
10511
10552
|
}();
|
|
10512
10553
|
var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
10513
|
-
var
|
|
10514
|
-
var
|
|
10515
|
-
var api, chain, exchangeChain, destChain, assetFrom, assetTo, currencyTo, feeAssetInfo, sender, recipient, calculateMinAmountOut, version, isEthereumDest, separateFeeAssetInfo, hasSeparateFeeAsset, internalOptions, dryRunParams, FEE_ASSET_AMOUNT, dummyFeeAssetAmount, dummyDestFee, fees, totalFeesPre, _yield$createXcmAndCa, initialCall, firstDryRunResult, exchangeHopIndex, extractedFees, totalFees, updatedAssetTo, amountAvailableForSwap, recalculatedMinAmountOut, _yield$createXcmAndCa2, finalCall;
|
|
10554
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
10555
|
+
var _ref5;
|
|
10556
|
+
var api, chain, exchangeChain, destChain, assetFrom, assetTo, currencyTo, feeAssetInfo, sender, recipient, calculateMinAmountOut, version, isEthereumDest, separateFeeAssetInfo, hasSeparateFeeAsset, internalOptions, dryRunParams, FEE_ASSET_AMOUNT, dummyFeeAssetAmount, dummyDestFee, fees, totalFeesPre, _yield$createXcmAndCa, initialCall, firstDryRunResult, dryRunError, exchangeHopIndex, extractedFees, totalFees, updatedAssetTo, amountAvailableForSwap, recalculatedMinAmountOut, _yield$createXcmAndCa2, finalCall;
|
|
10516
10557
|
return _regenerator().w(function (_context3) {
|
|
10517
10558
|
while (1) switch (_context3.n) {
|
|
10518
10559
|
case 0:
|
|
@@ -10554,7 +10595,7 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
|
10554
10595
|
};
|
|
10555
10596
|
FEE_ASSET_AMOUNT = 100;
|
|
10556
10597
|
dummyFeeAssetAmount = separateFeeAssetInfo ? parseUnits(FEE_ASSET_AMOUNT.toString(), separateFeeAssetInfo.decimals) : undefined;
|
|
10557
|
-
dummyDestFee = (
|
|
10598
|
+
dummyDestFee = (_ref5 = separateFeeAssetInfo && getFeeAssetInfo(assetTo, separateFeeAssetInfo) && dummyFeeAssetAmount) !== null && _ref5 !== void 0 ? _ref5 : MIN_FEE;
|
|
10558
10599
|
fees = {
|
|
10559
10600
|
originFee: dummyFeeAssetAmount !== null && dummyFeeAssetAmount !== void 0 ? dummyFeeAssetAmount : 0n,
|
|
10560
10601
|
originReserveFee: dummyFeeAssetAmount !== null && dummyFeeAssetAmount !== void 0 ? dummyFeeAssetAmount : MIN_FEE,
|
|
@@ -10584,18 +10625,26 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
|
10584
10625
|
}));
|
|
10585
10626
|
case 3:
|
|
10586
10627
|
firstDryRunResult = _context3.v;
|
|
10587
|
-
|
|
10628
|
+
dryRunError = firstDryRunResult.dryRunError;
|
|
10629
|
+
if (!separateFeeAssetInfo) {
|
|
10588
10630
|
_context3.n = 5;
|
|
10589
10631
|
break;
|
|
10590
10632
|
}
|
|
10591
|
-
if (!
|
|
10633
|
+
if (!((dryRunError === null || dryRunError === void 0 ? void 0 : dryRunError.reason) === 'NotHoldingFees')) {
|
|
10592
10634
|
_context3.n = 4;
|
|
10593
10635
|
break;
|
|
10594
10636
|
}
|
|
10595
|
-
throw new DryRunFailedError(
|
|
10637
|
+
throw new DryRunFailedError(dryRunError);
|
|
10596
10638
|
case 4:
|
|
10597
|
-
|
|
10639
|
+
_context3.n = 6;
|
|
10640
|
+
break;
|
|
10598
10641
|
case 5:
|
|
10642
|
+
if (!hasRealFeeShortfall(firstDryRunResult, exchangeChain, destChain)) {
|
|
10643
|
+
_context3.n = 6;
|
|
10644
|
+
break;
|
|
10645
|
+
}
|
|
10646
|
+
throw new AmountTooLowError('Asset amount is too low to cover the fees, please increase the amount.');
|
|
10647
|
+
case 6:
|
|
10599
10648
|
exchangeHopIndex = findExchangeHopIndex(chain, firstDryRunResult, exchangeChain, destChain);
|
|
10600
10649
|
extractedFees = extractFeesFromDryRun(chain, exchangeChain, firstDryRunResult, exchangeHopIndex, destChain, false); // Set originFee from dry run origin fee (padded), same as handleExecuteTransfer
|
|
10601
10650
|
extractedFees.originFee = separateFeeAssetInfo && firstDryRunResult.origin.success ? padValueBy(firstDryRunResult.origin.fee, FEE_PADDING_PERCENTAGE) : 0n;
|
|
@@ -10603,32 +10652,36 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
|
10603
10652
|
// We set the exchange fee to non-zero value to prevent creating dummy tx
|
|
10604
10653
|
extractedFees.exchangeFee = MIN_FEE;
|
|
10605
10654
|
}
|
|
10655
|
+
_context3.n = 7;
|
|
10656
|
+
return getExchangeFeeAtPostTradePrice(options, extractedFees, hasSeparateFeeAsset);
|
|
10657
|
+
case 7:
|
|
10658
|
+
extractedFees.exchangeFee = _context3.v;
|
|
10606
10659
|
totalFees = calculateTotalFees(chain, extractedFees);
|
|
10607
10660
|
if (!hasSeparateFeeAsset) {
|
|
10608
10661
|
validateAmount(assetFrom.amount, totalFees);
|
|
10609
10662
|
}
|
|
10610
10663
|
updatedAssetTo = assetTo;
|
|
10611
10664
|
if (!chain) {
|
|
10612
|
-
_context3.n =
|
|
10665
|
+
_context3.n = 9;
|
|
10613
10666
|
break;
|
|
10614
10667
|
}
|
|
10615
10668
|
// When fees are paid from a separate asset (e.g. DOT for Ethereum),
|
|
10616
10669
|
// the full main asset amount is available for the swap
|
|
10617
10670
|
amountAvailableForSwap = hasSeparateFeeAsset ? assetFrom.amount : assetFrom.amount - totalFees;
|
|
10618
|
-
_context3.n =
|
|
10671
|
+
_context3.n = 8;
|
|
10619
10672
|
return calculateMinAmountOut(amountAvailableForSwap);
|
|
10620
|
-
case
|
|
10673
|
+
case 8:
|
|
10621
10674
|
recalculatedMinAmountOut = _context3.v;
|
|
10622
10675
|
updatedAssetTo = _objectSpread2(_objectSpread2({}, assetTo), {}, {
|
|
10623
10676
|
amount: recalculatedMinAmountOut
|
|
10624
10677
|
});
|
|
10625
|
-
case
|
|
10626
|
-
_context3.n =
|
|
10678
|
+
case 9:
|
|
10679
|
+
_context3.n = 10;
|
|
10627
10680
|
return createXcmAndCall(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
10628
10681
|
assetInfoTo: updatedAssetTo,
|
|
10629
10682
|
fees: extractedFees
|
|
10630
10683
|
}), firstDryRunResult.origin.success ? firstDryRunResult.origin.weight : undefined);
|
|
10631
|
-
case
|
|
10684
|
+
case 10:
|
|
10632
10685
|
_yield$createXcmAndCa2 = _context3.v;
|
|
10633
10686
|
finalCall = _yield$createXcmAndCa2.call;
|
|
10634
10687
|
return _context3.a(2, api.deserializeExtrinsics(finalCall));
|
|
@@ -10636,7 +10689,7 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
|
10636
10689
|
}, _callee3);
|
|
10637
10690
|
}));
|
|
10638
10691
|
return function handleSwapExecuteTransfer(_x4) {
|
|
10639
|
-
return
|
|
10692
|
+
return _ref4.apply(this, arguments);
|
|
10640
10693
|
};
|
|
10641
10694
|
}();
|
|
10642
10695
|
|
|
@@ -10986,11 +11039,6 @@ var Astar = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
10986
11039
|
useBigIntId: true
|
|
10987
11040
|
};
|
|
10988
11041
|
}
|
|
10989
|
-
}, {
|
|
10990
|
-
key: "shouldUseReserveTransfer",
|
|
10991
|
-
value: function shouldUseReserveTransfer() {
|
|
10992
|
-
return true;
|
|
10993
|
-
}
|
|
10994
11042
|
}, {
|
|
10995
11043
|
key: "isSendingTempDisabled",
|
|
10996
11044
|
value: function isSendingTempDisabled(assetInfo) {
|
|
@@ -11221,7 +11269,7 @@ var BifrostPolkadot = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
11221
11269
|
}
|
|
11222
11270
|
var isVToken = asset.symbol && asset.symbol.startsWith('v');
|
|
11223
11271
|
var isVSToken = asset.symbol && asset.symbol.startsWith('vs');
|
|
11224
|
-
if (asset.isNative || !asset.
|
|
11272
|
+
if (asset.isNative || !asset.assetId) {
|
|
11225
11273
|
return isVToken ? {
|
|
11226
11274
|
VToken: asset.symbol.substring(1)
|
|
11227
11275
|
} : {
|
|
@@ -11352,8 +11400,7 @@ var resolveLocationFromDest = function resolveLocationFromDest(destination, asse
|
|
|
11352
11400
|
if (isRelayChain(destination)) return DOT_LOCATION;
|
|
11353
11401
|
// If it is a native asset, search by symbol on AssetHub and use the location from there
|
|
11354
11402
|
var assetHubAsset = getOtherAssets(destination).find(function (ahAsset) {
|
|
11355
|
-
|
|
11356
|
-
return ((_ahAsset$symbol = ahAsset.symbol) === null || _ahAsset$symbol === void 0 ? void 0 : _ahAsset$symbol.toLowerCase()) === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase());
|
|
11403
|
+
return ahAsset.symbol.toLowerCase() === asset.symbol.toLowerCase();
|
|
11357
11404
|
});
|
|
11358
11405
|
if (!assetHubAsset) {
|
|
11359
11406
|
throw new InvalidCurrencyError("Asset ".concat(asset.symbol, " not found"));
|
|
@@ -11753,11 +11800,6 @@ var EnergyWebX = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
11753
11800
|
value: function isRelayToParaEnabled() {
|
|
11754
11801
|
return false;
|
|
11755
11802
|
}
|
|
11756
|
-
}, {
|
|
11757
|
-
key: "shouldUseReserveTransfer",
|
|
11758
|
-
value: function shouldUseReserveTransfer() {
|
|
11759
|
-
return true;
|
|
11760
|
-
}
|
|
11761
11803
|
}, {
|
|
11762
11804
|
key: "getMintConfig",
|
|
11763
11805
|
value: function getMintConfig() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-core",
|
|
3
|
-
"version": "14.5.
|
|
3
|
+
"version": "14.5.4",
|
|
4
4
|
"description": "SDK core for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@noble/hashes": "^2.4.0",
|
|
26
|
-
"@paraspell/assets": "14.5.
|
|
27
|
-
"@paraspell/pallets": "14.5.
|
|
28
|
-
"@paraspell/sdk-common": "14.5.
|
|
26
|
+
"@paraspell/assets": "14.5.4",
|
|
27
|
+
"@paraspell/pallets": "14.5.4",
|
|
28
|
+
"@paraspell/sdk-common": "14.5.4",
|
|
29
29
|
"@scure/base": "^2.4.0",
|
|
30
30
|
"viem": "^2.57.13"
|
|
31
31
|
},
|