@paraspell/swap 14.3.3 → 14.3.5
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.mjs +29 -23
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -577,11 +577,11 @@ var assignIsExchange = function assignIsExchange(result, options) {
|
|
|
577
577
|
var dryRunTransaction = /*#__PURE__*/function () {
|
|
578
578
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, transaction, destChain, bypassOptions) {
|
|
579
579
|
var _ref2;
|
|
580
|
-
var api, exchange, sender, evmSenderAddress, destination, currencyFrom, currencyTo, amount, tx, chain, senderResolved, resolvedDest;
|
|
580
|
+
var api, exchange, sender, evmSenderAddress, destination, currencyFrom, currencyTo, feeAsset, amount, tx, chain, senderResolved, resolvedDest;
|
|
581
581
|
return _regenerator().w(function (_context) {
|
|
582
582
|
while (1) switch (_context.n) {
|
|
583
583
|
case 0:
|
|
584
|
-
api = options.api, exchange = options.exchange, sender = options.sender, evmSenderAddress = options.evmSenderAddress, destination = options.destination, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, amount = options.amount;
|
|
584
|
+
api = options.api, exchange = options.exchange, sender = options.sender, evmSenderAddress = options.evmSenderAddress, destination = options.destination, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, feeAsset = options.feeAsset, amount = options.amount;
|
|
585
585
|
tx = transaction.tx, chain = transaction.chain;
|
|
586
586
|
assertCurrencyCore(currencyTo);
|
|
587
587
|
senderResolved = evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender;
|
|
@@ -599,6 +599,7 @@ var dryRunTransaction = /*#__PURE__*/function () {
|
|
|
599
599
|
currency: _objectSpread2(_objectSpread2({}, currencyFrom), {}, {
|
|
600
600
|
amount: BigInt(amount)
|
|
601
601
|
}),
|
|
602
|
+
feeAsset: feeAsset,
|
|
602
603
|
bypassOptions: bypassOptions
|
|
603
604
|
}));
|
|
604
605
|
}
|
|
@@ -1647,10 +1648,7 @@ var Hydration = {
|
|
|
1647
1648
|
Parachain: 2034
|
|
1648
1649
|
},
|
|
1649
1650
|
{
|
|
1650
|
-
|
|
1651
|
-
network: null,
|
|
1652
|
-
key: "0x531a654d1696ed52e7275a8cede955e82620f99a"
|
|
1653
|
-
}
|
|
1651
|
+
GeneralIndex: 222
|
|
1654
1652
|
}
|
|
1655
1653
|
]
|
|
1656
1654
|
}
|
|
@@ -9525,20 +9523,8 @@ var getSupportedAssetsTo = function getSupportedAssetsTo(exchangeInput, to) {
|
|
|
9525
9523
|
};
|
|
9526
9524
|
|
|
9527
9525
|
var getSupportedFeeAssetsImpl = function getSupportedFeeAssetsImpl(from, exchangeInput, ctx) {
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
var chains = from ? [from] : (exchange === undefined ? EXCHANGE_CHAINS : Array.isArray(exchange) ? exchange : [exchange]).map(function (ex) {
|
|
9531
|
-
return createExchangeInstance(ex).chain;
|
|
9532
|
-
}).filter(function (chain, i, arr) {
|
|
9533
|
-
return arr.indexOf(chain) === i;
|
|
9534
|
-
});
|
|
9535
|
-
var chainAssets = chains.flatMap(function (chain) {
|
|
9536
|
-
return getAssetsImpl(chain, ctx);
|
|
9537
|
-
});
|
|
9538
|
-
return supportedAssets.filter(function (asset) {
|
|
9539
|
-
return chainAssets.some(function (chainAsset) {
|
|
9540
|
-
return chainAsset.isFeeAsset && isAssetEqual(asset, chainAsset);
|
|
9541
|
-
});
|
|
9526
|
+
return getSupportedAssetsFromImpl(from, exchangeInput, ctx).filter(function (asset) {
|
|
9527
|
+
return asset.isFeeAsset;
|
|
9542
9528
|
});
|
|
9543
9529
|
};
|
|
9544
9530
|
/**
|
|
@@ -9955,6 +9941,9 @@ var resolveAssets = function resolveAssets(dex, _ref) {
|
|
|
9955
9941
|
throw new RoutingResolutionError("Fee asset ".concat(JSON.stringify(feeAsset), " not found in ").concat(from, "."));
|
|
9956
9942
|
}
|
|
9957
9943
|
var feeAssetFromExchange = feeAsset ? from && feeAssetFromOrigin ? getExchangeAssetByOriginAsset(from, dex.chain, feeAssetFromOrigin) : (_getExchangeAsset = getExchangeAsset(dex.chain, feeAsset)) !== null && _getExchangeAsset !== void 0 ? _getExchangeAsset : undefined : undefined;
|
|
9944
|
+
if (feeAsset && !feeAssetFromOrigin && !feeAssetFromExchange) {
|
|
9945
|
+
throw new RoutingResolutionError("Fee asset ".concat(JSON.stringify(feeAsset), " not found in ").concat(dex.chain, "."));
|
|
9946
|
+
}
|
|
9958
9947
|
var resolvedFeeAssetLocation = (_feeAssetFromOrigin$l = feeAssetFromOrigin === null || feeAssetFromOrigin === void 0 ? void 0 : feeAssetFromOrigin.location) !== null && _feeAssetFromOrigin$l !== void 0 ? _feeAssetFromOrigin$l : feeAssetFromExchange === null || feeAssetFromExchange === void 0 ? void 0 : feeAssetFromExchange.location;
|
|
9959
9948
|
if (feeAsset && resolvedFeeAssetLocation) {
|
|
9960
9949
|
var sdkAsset = findAssetInfoOrThrow(from !== null && from !== void 0 ? from : dex.chain, {
|
|
@@ -10340,6 +10329,12 @@ var validateTransferOptions = function validateTransferOptions(options) {
|
|
|
10340
10329
|
throw new MissingParameterError('evmSenderAddress', 'EVM sender address is required');
|
|
10341
10330
|
}
|
|
10342
10331
|
};
|
|
10332
|
+
var validateRoutedFeeAsset = function validateRoutedFeeAsset(_ref) {
|
|
10333
|
+
var feeAsset = _ref.feeAsset;
|
|
10334
|
+
if (feeAsset) {
|
|
10335
|
+
throw new ScenarioNotSupportedError('Fee asset is only supported for swaps that use the execute transfer');
|
|
10336
|
+
}
|
|
10337
|
+
};
|
|
10343
10338
|
|
|
10344
10339
|
var FEE_ESTIMATION_UNITS = '100';
|
|
10345
10340
|
var calculateFromExchangeFee = /*#__PURE__*/function () {
|
|
@@ -10453,6 +10448,8 @@ var prepareExtrinsics = /*#__PURE__*/function () {
|
|
|
10453
10448
|
}
|
|
10454
10449
|
throw _t;
|
|
10455
10450
|
case 4:
|
|
10451
|
+
validateRoutedFeeAsset(options);
|
|
10452
|
+
// 1. Create transfer origin -> exchange (optional)
|
|
10456
10453
|
if (!(origin && origin.chain !== exchange.chain)) {
|
|
10457
10454
|
_context.n = 6;
|
|
10458
10455
|
break;
|
|
@@ -10628,6 +10625,8 @@ var getSwapOriginFee = /*#__PURE__*/function () {
|
|
|
10628
10625
|
}
|
|
10629
10626
|
throw _t;
|
|
10630
10627
|
case 4:
|
|
10628
|
+
validateRoutedFeeAsset(options);
|
|
10629
|
+
// Origin chain is upstream from the exchange — fee is the cost of origin -> exchange
|
|
10631
10630
|
if (!(origin && origin.chain !== exchange.chain)) {
|
|
10632
10631
|
_context.n = 5;
|
|
10633
10632
|
break;
|
|
@@ -10756,8 +10755,8 @@ var getSwapFee = /*#__PURE__*/function () {
|
|
|
10756
10755
|
|
|
10757
10756
|
var getRouterFees = /*#__PURE__*/function () {
|
|
10758
10757
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options, disableFallback) {
|
|
10759
|
-
var _sendingChain$hops, _receivingChain$origi, _receivingChain$hops, _sendingChain$origin, _receivingChain$desti, _sendingChain$dryRunE;
|
|
10760
|
-
var api, origin, exchange, destination, sender, _yield$getSwapExecute, result, transformedHops, sendingChain, _yield$getSwapFee, swapChain, amountOut, receivingChain, mergedHops, finalOrigin, finalDestination, dryRunError, _t, _t2, _t3;
|
|
10758
|
+
var _sendingChain$hops, _receivingChain$origi, _receivingChain$hops, _sendingChain$origin, _receivingChain$desti, _ref2, _sendingChain$dryRunE;
|
|
10759
|
+
var api, origin, exchange, destination, sender, _yield$getSwapExecute, result, transformedHops, sendingChain, _yield$getSwapFee, swapChain, amountOut, receivingChain, mergedHops, finalOrigin, finalDestination, swapDryRunError, dryRunError, _t, _t2, _t3;
|
|
10761
10760
|
return _regenerator().w(function (_context) {
|
|
10762
10761
|
while (1) switch (_context.p = _context.n) {
|
|
10763
10762
|
case 0:
|
|
@@ -10798,6 +10797,8 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10798
10797
|
}
|
|
10799
10798
|
throw _t;
|
|
10800
10799
|
case 4:
|
|
10800
|
+
validateRoutedFeeAsset(options);
|
|
10801
|
+
// 1. Get fees for origin -> exchange (optional)
|
|
10801
10802
|
if (!(origin && origin.chain !== exchange.chain)) {
|
|
10802
10803
|
_context.n = 6;
|
|
10803
10804
|
break;
|
|
@@ -10855,7 +10856,11 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10855
10856
|
}), !origin && !destination && {
|
|
10856
10857
|
fee: 0n
|
|
10857
10858
|
});
|
|
10858
|
-
|
|
10859
|
+
swapDryRunError = swapChain.dryRunError && _objectSpread2(_objectSpread2({}, swapChain.dryRunError), {}, {
|
|
10860
|
+
chainKind: !sendingChain ? 'origin' : !receivingChain ? 'destination' : 'hop',
|
|
10861
|
+
chain: exchange.chain
|
|
10862
|
+
});
|
|
10863
|
+
dryRunError = (_ref2 = (_sendingChain$dryRunE = sendingChain === null || sendingChain === void 0 ? void 0 : sendingChain.dryRunError) !== null && _sendingChain$dryRunE !== void 0 ? _sendingChain$dryRunE : swapDryRunError) !== null && _ref2 !== void 0 ? _ref2 : receivingChain === null || receivingChain === void 0 ? void 0 : receivingChain.dryRunError;
|
|
10859
10864
|
return _context.a(2, {
|
|
10860
10865
|
success: !dryRunError,
|
|
10861
10866
|
dryRunError: dryRunError,
|
|
@@ -11543,6 +11548,7 @@ var getSwapInfo = /*#__PURE__*/function () {
|
|
|
11543
11548
|
}
|
|
11544
11549
|
throw _t;
|
|
11545
11550
|
case 5:
|
|
11551
|
+
validateRoutedFeeAsset(options);
|
|
11546
11552
|
api = options.api, origin = options.origin, exchange = options.exchange, currencyTo = options.currencyTo, destination = options.destination, amount = options.amount, sender = options.sender, evmSenderAddress = options.evmSenderAddress;
|
|
11547
11553
|
assertCurrencyCore(currencyTo);
|
|
11548
11554
|
senderAddress = evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/swap",
|
|
3
|
-
"version": "14.3.
|
|
3
|
+
"version": "14.3.5",
|
|
4
4
|
"description": "Tool for XCM cross-chain asset exchanging across Polkadot and Kusama ecosystems",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"@crypto-dex-sdk/token-lists": "^0.1.4",
|
|
39
39
|
"@galacticcouncil/descriptors": "^2.7.0",
|
|
40
40
|
"@galacticcouncil/sdk-next": "^2.1.0",
|
|
41
|
-
"@paraspell/sdk": "14.3.
|
|
42
|
-
"@paraspell/sdk-common": "14.3.
|
|
43
|
-
"@paraspell/sdk-core": "14.3.
|
|
44
|
-
"@paraspell/sdk-pjs": "14.3.
|
|
41
|
+
"@paraspell/sdk": "14.3.5",
|
|
42
|
+
"@paraspell/sdk-common": "14.3.5",
|
|
43
|
+
"@paraspell/sdk-core": "14.3.5",
|
|
44
|
+
"@paraspell/sdk-pjs": "14.3.5",
|
|
45
45
|
"@polkadot/api": "^16.5.6",
|
|
46
46
|
"@polkadot/types": "^16.5.6",
|
|
47
47
|
"@polkadot/util": "^14.0.3",
|