@paraspell/swap 14.2.2 → 14.3.3
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 -4
- package/dist/index.mjs +262 -691
- package/package.json +14 -14
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createChainClient as createChainClient$1, registerSwapExtension } from '@paraspell/sdk';
|
|
2
|
-
import { UnsupportedOperationError, assertCurrencyCore, dryRun, getDryRunError, DryRunFailedError, isConfig, getNativeAssets, RoutingResolutionError, findAssetInfoById, getOtherAssets, getChainProviders, parseUnits, getNativeAssetSymbol, padValueBy, formatUnits as formatUnits$1, AmountTooLowError, getBalance, localizeLocation, getAssets, Parents, isSymbolMatch, getParaId, UnableToComputeError, findNativeAssetInfoOrThrow, InvalidCurrencyError, findAssetInfoOrThrow, findAssetInfoByLoc, isSymbolSpecifier, findBestMatches, findAssetInfoBySymbol,
|
|
1
|
+
import { createChainClient as createChainClient$1, getPaymentInfo, registerSwapExtension } from '@paraspell/sdk';
|
|
2
|
+
import { UnsupportedOperationError, assertCurrencyCore, dryRun, getDryRunError, DryRunFailedError, isConfig, getNativeAssets, RoutingResolutionError, findAssetInfoById, getOtherAssets, getChainProviders, parseUnits, getNativeAssetSymbol, padValueBy, formatUnits as formatUnits$1, AmountTooLowError, getBalance, localizeLocation, getAssets, Parents, isSymbolMatch, getParaId, UnableToComputeError, findNativeAssetInfoOrThrow, InvalidCurrencyError, findAssetInfoOrThrow, findAssetInfoByLoc, isSymbolSpecifier, findBestMatches, findAssetInfoBySymbol, getSupportedAssetsImpl, isAssetEqual, findAssetInfoOnDestImpl, normalizeExchange, EXCHANGE_CHAINS, deepEqual, reverseTransformLocation, getAssetsImpl, ScenarioNotSupportedError, applyDecimalAbstraction, findAssetInfo, Builder, isChainEvm, convertBuilderConfig, handleSwapExecuteTransfer, getXcmFee, getOriginXcmFee as getOriginXcmFee$1, InvalidAddressError, MissingParameterError, BatchMode, createChainClient as createChainClient$2, getExistentialDepositOrThrow, buildHopInfo, getRelayChainSymbol, aggregateHopFees, buildDestInfo, buildOriginInfo } from '@paraspell/sdk-core';
|
|
3
3
|
import { toHex } from 'polkadot-api/utils';
|
|
4
4
|
import 'polkadot-api';
|
|
5
5
|
import { Wallet } from '@acala-network/sdk';
|
|
@@ -328,6 +328,23 @@ function _regeneratorDefine(e, r, n, t) {
|
|
|
328
328
|
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
329
329
|
}, _regeneratorDefine(e, r, n, t);
|
|
330
330
|
}
|
|
331
|
+
function _regeneratorValues(e) {
|
|
332
|
+
if (null != e) {
|
|
333
|
+
var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
|
|
334
|
+
r = 0;
|
|
335
|
+
if (t) return t.call(e);
|
|
336
|
+
if ("function" == typeof e.next) return e;
|
|
337
|
+
if (!isNaN(e.length)) return {
|
|
338
|
+
next: function () {
|
|
339
|
+
return e && r >= e.length && (e = void 0), {
|
|
340
|
+
value: e && e[r++],
|
|
341
|
+
done: !e
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
347
|
+
}
|
|
331
348
|
function _setPrototypeOf(t, e) {
|
|
332
349
|
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
333
350
|
return t.__proto__ = e, t;
|
|
@@ -451,7 +468,7 @@ var calculateTxFeePjs = /*#__PURE__*/function () {
|
|
|
451
468
|
}();
|
|
452
469
|
|
|
453
470
|
var isPapiTransaction = function isPapiTransaction(tx) {
|
|
454
|
-
return _typeof(tx) === 'object' && tx !== null && 'getEncodedData' in tx && typeof tx.getEncodedData === 'function' && '
|
|
471
|
+
return _typeof(tx) === 'object' && tx !== null && 'getEncodedData' in tx && typeof tx.getEncodedData === 'function' && 'createSubmitAndWatch' in tx && typeof tx.createSubmitAndWatch === 'function';
|
|
455
472
|
};
|
|
456
473
|
|
|
457
474
|
var isPjsExtrinsic = function isPjsExtrinsic(tx) {
|
|
@@ -1763,22 +1780,6 @@ var Hydration = {
|
|
|
1763
1780
|
]
|
|
1764
1781
|
}
|
|
1765
1782
|
},
|
|
1766
|
-
{
|
|
1767
|
-
parents: 1,
|
|
1768
|
-
interior: {
|
|
1769
|
-
X2: [
|
|
1770
|
-
{
|
|
1771
|
-
Parachain: 2000
|
|
1772
|
-
},
|
|
1773
|
-
{
|
|
1774
|
-
GeneralKey: {
|
|
1775
|
-
length: 21,
|
|
1776
|
-
data: "0x025a4d6acdc4e3e5ab15717f407afe957f7a2425780000000000000000000000"
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
]
|
|
1780
|
-
}
|
|
1781
|
-
},
|
|
1782
1783
|
{
|
|
1783
1784
|
parents: 1,
|
|
1784
1785
|
interior: {
|
|
@@ -1804,32 +1805,6 @@ var Hydration = {
|
|
|
1804
1805
|
]
|
|
1805
1806
|
}
|
|
1806
1807
|
},
|
|
1807
|
-
{
|
|
1808
|
-
parents: 1,
|
|
1809
|
-
interior: {
|
|
1810
|
-
X1: [
|
|
1811
|
-
{
|
|
1812
|
-
Parachain: 2086
|
|
1813
|
-
}
|
|
1814
|
-
]
|
|
1815
|
-
}
|
|
1816
|
-
},
|
|
1817
|
-
{
|
|
1818
|
-
parents: 1,
|
|
1819
|
-
interior: {
|
|
1820
|
-
X2: [
|
|
1821
|
-
{
|
|
1822
|
-
Parachain: 2034
|
|
1823
|
-
},
|
|
1824
|
-
{
|
|
1825
|
-
AccountKey20: {
|
|
1826
|
-
network: null,
|
|
1827
|
-
key: "0x6b9ac524ec8f08c49ec80176b138d16eb461c3d8"
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
]
|
|
1831
|
-
}
|
|
1832
|
-
},
|
|
1833
1808
|
{
|
|
1834
1809
|
parents: 1,
|
|
1835
1810
|
interior: {
|
|
@@ -1855,22 +1830,6 @@ var Hydration = {
|
|
|
1855
1830
|
]
|
|
1856
1831
|
}
|
|
1857
1832
|
},
|
|
1858
|
-
{
|
|
1859
|
-
parents: 1,
|
|
1860
|
-
interior: {
|
|
1861
|
-
X3: [
|
|
1862
|
-
{
|
|
1863
|
-
Parachain: 2094
|
|
1864
|
-
},
|
|
1865
|
-
{
|
|
1866
|
-
PalletInstance: 53
|
|
1867
|
-
},
|
|
1868
|
-
{
|
|
1869
|
-
GeneralIndex: 2
|
|
1870
|
-
}
|
|
1871
|
-
]
|
|
1872
|
-
}
|
|
1873
|
-
},
|
|
1874
1833
|
{
|
|
1875
1834
|
parents: 1,
|
|
1876
1835
|
interior: {
|
|
@@ -1955,19 +1914,6 @@ var Hydration = {
|
|
|
1955
1914
|
]
|
|
1956
1915
|
}
|
|
1957
1916
|
},
|
|
1958
|
-
{
|
|
1959
|
-
parents: 1,
|
|
1960
|
-
interior: {
|
|
1961
|
-
X2: [
|
|
1962
|
-
{
|
|
1963
|
-
Parachain: 2004
|
|
1964
|
-
},
|
|
1965
|
-
{
|
|
1966
|
-
PalletInstance: 10
|
|
1967
|
-
}
|
|
1968
|
-
]
|
|
1969
|
-
}
|
|
1970
|
-
},
|
|
1971
1917
|
{
|
|
1972
1918
|
parents: 1,
|
|
1973
1919
|
interior: {
|
|
@@ -2052,22 +1998,6 @@ var Hydration = {
|
|
|
2052
1998
|
]
|
|
2053
1999
|
}
|
|
2054
2000
|
},
|
|
2055
|
-
{
|
|
2056
|
-
parents: 1,
|
|
2057
|
-
interior: {
|
|
2058
|
-
X2: [
|
|
2059
|
-
{
|
|
2060
|
-
Parachain: 2030
|
|
2061
|
-
},
|
|
2062
|
-
{
|
|
2063
|
-
GeneralKey: {
|
|
2064
|
-
length: 2,
|
|
2065
|
-
data: "0x0001000000000000000000000000000000000000000000000000000000000000"
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
]
|
|
2069
|
-
}
|
|
2070
|
-
},
|
|
2071
2001
|
{
|
|
2072
2002
|
parents: 1,
|
|
2073
2003
|
interior: {
|
|
@@ -2084,22 +2014,6 @@ var Hydration = {
|
|
|
2084
2014
|
]
|
|
2085
2015
|
}
|
|
2086
2016
|
},
|
|
2087
|
-
{
|
|
2088
|
-
parents: 1,
|
|
2089
|
-
interior: {
|
|
2090
|
-
X2: [
|
|
2091
|
-
{
|
|
2092
|
-
Parachain: 2000
|
|
2093
|
-
},
|
|
2094
|
-
{
|
|
2095
|
-
GeneralKey: {
|
|
2096
|
-
length: 21,
|
|
2097
|
-
data: "0x02f4c723e61709d90f89939c1852f516e373d418a80000000000000000000000"
|
|
2098
|
-
}
|
|
2099
|
-
}
|
|
2100
|
-
]
|
|
2101
|
-
}
|
|
2102
|
-
},
|
|
2103
2017
|
{
|
|
2104
2018
|
parents: 2,
|
|
2105
2019
|
interior: {
|
|
@@ -2214,55 +2128,6 @@ var Hydration = {
|
|
|
2214
2128
|
]
|
|
2215
2129
|
}
|
|
2216
2130
|
},
|
|
2217
|
-
{
|
|
2218
|
-
parents: 1,
|
|
2219
|
-
interior: {
|
|
2220
|
-
X2: [
|
|
2221
|
-
{
|
|
2222
|
-
Parachain: 2046
|
|
2223
|
-
},
|
|
2224
|
-
{
|
|
2225
|
-
PalletInstance: 5
|
|
2226
|
-
}
|
|
2227
|
-
]
|
|
2228
|
-
}
|
|
2229
|
-
},
|
|
2230
|
-
{
|
|
2231
|
-
parents: 1,
|
|
2232
|
-
interior: {
|
|
2233
|
-
X2: [
|
|
2234
|
-
{
|
|
2235
|
-
Parachain: 2030
|
|
2236
|
-
},
|
|
2237
|
-
{
|
|
2238
|
-
GeneralKey: {
|
|
2239
|
-
length: 2,
|
|
2240
|
-
data: "0x0903000000000000000000000000000000000000000000000000000000000000"
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
]
|
|
2244
|
-
}
|
|
2245
|
-
},
|
|
2246
|
-
{
|
|
2247
|
-
parents: 2,
|
|
2248
|
-
interior: {
|
|
2249
|
-
X2: [
|
|
2250
|
-
{
|
|
2251
|
-
GlobalConsensus: {
|
|
2252
|
-
Ethereum: {
|
|
2253
|
-
chainId: 1
|
|
2254
|
-
}
|
|
2255
|
-
}
|
|
2256
|
-
},
|
|
2257
|
-
{
|
|
2258
|
-
AccountKey20: {
|
|
2259
|
-
network: null,
|
|
2260
|
-
key: "0xcccccccccc33d538dbc2ee4feab0a7a1ff4e8a94"
|
|
2261
|
-
}
|
|
2262
|
-
}
|
|
2263
|
-
]
|
|
2264
|
-
}
|
|
2265
|
-
},
|
|
2266
2131
|
{
|
|
2267
2132
|
parents: 1,
|
|
2268
2133
|
interior: {
|
|
@@ -2365,35 +2230,6 @@ var Hydration = {
|
|
|
2365
2230
|
]
|
|
2366
2231
|
}
|
|
2367
2232
|
},
|
|
2368
|
-
{
|
|
2369
|
-
parents: 1,
|
|
2370
|
-
interior: {
|
|
2371
|
-
X2: [
|
|
2372
|
-
{
|
|
2373
|
-
Parachain: 2000
|
|
2374
|
-
},
|
|
2375
|
-
{
|
|
2376
|
-
GeneralKey: {
|
|
2377
|
-
length: 21,
|
|
2378
|
-
data: "0x0254a37a01cd75b616d63e0ab665bffdb0143c52ae0000000000000000000000"
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
2381
|
-
]
|
|
2382
|
-
}
|
|
2383
|
-
},
|
|
2384
|
-
{
|
|
2385
|
-
parents: 1,
|
|
2386
|
-
interior: {
|
|
2387
|
-
X2: [
|
|
2388
|
-
{
|
|
2389
|
-
Parachain: 3417
|
|
2390
|
-
},
|
|
2391
|
-
{
|
|
2392
|
-
GeneralIndex: 0
|
|
2393
|
-
}
|
|
2394
|
-
]
|
|
2395
|
-
}
|
|
2396
|
-
},
|
|
2397
2233
|
{
|
|
2398
2234
|
parents: 1,
|
|
2399
2235
|
interior: {
|
|
@@ -2497,77 +2333,6 @@ var Hydration = {
|
|
|
2497
2333
|
]
|
|
2498
2334
|
}
|
|
2499
2335
|
},
|
|
2500
|
-
{
|
|
2501
|
-
parents: 1,
|
|
2502
|
-
interior: {
|
|
2503
|
-
X2: [
|
|
2504
|
-
{
|
|
2505
|
-
Parachain: 2034
|
|
2506
|
-
},
|
|
2507
|
-
{
|
|
2508
|
-
AccountKey20: {
|
|
2509
|
-
network: null,
|
|
2510
|
-
key: "0x6a21891db0940491603f3cca0a9f4dba4c6e810c"
|
|
2511
|
-
}
|
|
2512
|
-
}
|
|
2513
|
-
]
|
|
2514
|
-
}
|
|
2515
|
-
},
|
|
2516
|
-
{
|
|
2517
|
-
parents: 1,
|
|
2518
|
-
interior: {
|
|
2519
|
-
X1: [
|
|
2520
|
-
{
|
|
2521
|
-
Parachain: 3344
|
|
2522
|
-
}
|
|
2523
|
-
]
|
|
2524
|
-
}
|
|
2525
|
-
},
|
|
2526
|
-
{
|
|
2527
|
-
parents: 2,
|
|
2528
|
-
interior: {
|
|
2529
|
-
X2: [
|
|
2530
|
-
{
|
|
2531
|
-
GlobalConsensus: {
|
|
2532
|
-
Ethereum: {
|
|
2533
|
-
chainId: 1
|
|
2534
|
-
}
|
|
2535
|
-
}
|
|
2536
|
-
},
|
|
2537
|
-
{
|
|
2538
|
-
AccountKey20: {
|
|
2539
|
-
network: null,
|
|
2540
|
-
key: "0x1abaea1f7c830bd89acc67ec4af516284b1bc33c"
|
|
2541
|
-
}
|
|
2542
|
-
}
|
|
2543
|
-
]
|
|
2544
|
-
}
|
|
2545
|
-
},
|
|
2546
|
-
{
|
|
2547
|
-
parents: 1,
|
|
2548
|
-
interior: {
|
|
2549
|
-
X4: [
|
|
2550
|
-
{
|
|
2551
|
-
Parachain: 2034
|
|
2552
|
-
},
|
|
2553
|
-
{
|
|
2554
|
-
GeneralKey: {
|
|
2555
|
-
length: 2,
|
|
2556
|
-
data: "0x7768000000000000000000000000000000000000000000000000000000000000"
|
|
2557
|
-
}
|
|
2558
|
-
},
|
|
2559
|
-
{
|
|
2560
|
-
GeneralIndex: 21
|
|
2561
|
-
},
|
|
2562
|
-
{
|
|
2563
|
-
GeneralKey: {
|
|
2564
|
-
length: 32,
|
|
2565
|
-
data: "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3"
|
|
2566
|
-
}
|
|
2567
|
-
}
|
|
2568
|
-
]
|
|
2569
|
-
}
|
|
2570
|
-
},
|
|
2571
2336
|
{
|
|
2572
2337
|
parents: 1,
|
|
2573
2338
|
interior: {
|
|
@@ -2624,22 +2389,6 @@ var Hydration = {
|
|
|
2624
2389
|
]
|
|
2625
2390
|
}
|
|
2626
2391
|
},
|
|
2627
|
-
{
|
|
2628
|
-
parents: 1,
|
|
2629
|
-
interior: {
|
|
2630
|
-
X2: [
|
|
2631
|
-
{
|
|
2632
|
-
Parachain: 2000
|
|
2633
|
-
},
|
|
2634
|
-
{
|
|
2635
|
-
GeneralKey: {
|
|
2636
|
-
length: 21,
|
|
2637
|
-
data: "0x0207df96d1341a7d16ba1ad431e2c847d978bc2bce0000000000000000000000"
|
|
2638
|
-
}
|
|
2639
|
-
}
|
|
2640
|
-
]
|
|
2641
|
-
}
|
|
2642
|
-
},
|
|
2643
2392
|
{
|
|
2644
2393
|
parents: 2,
|
|
2645
2394
|
interior: {
|
|
@@ -2715,26 +2464,6 @@ var Hydration = {
|
|
|
2715
2464
|
]
|
|
2716
2465
|
}
|
|
2717
2466
|
},
|
|
2718
|
-
{
|
|
2719
|
-
parents: 2,
|
|
2720
|
-
interior: {
|
|
2721
|
-
X2: [
|
|
2722
|
-
{
|
|
2723
|
-
GlobalConsensus: {
|
|
2724
|
-
Ethereum: {
|
|
2725
|
-
chainId: 1
|
|
2726
|
-
}
|
|
2727
|
-
}
|
|
2728
|
-
},
|
|
2729
|
-
{
|
|
2730
|
-
AccountKey20: {
|
|
2731
|
-
network: null,
|
|
2732
|
-
key: "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"
|
|
2733
|
-
}
|
|
2734
|
-
}
|
|
2735
|
-
]
|
|
2736
|
-
}
|
|
2737
|
-
},
|
|
2738
2467
|
{
|
|
2739
2468
|
parents: 1,
|
|
2740
2469
|
interior: {
|
|
@@ -2793,56 +2522,6 @@ var Hydration = {
|
|
|
2793
2522
|
]
|
|
2794
2523
|
}
|
|
2795
2524
|
},
|
|
2796
|
-
{
|
|
2797
|
-
parents: 2,
|
|
2798
|
-
interior: {
|
|
2799
|
-
X2: [
|
|
2800
|
-
{
|
|
2801
|
-
GlobalConsensus: {
|
|
2802
|
-
Ethereum: {
|
|
2803
|
-
chainId: 1
|
|
2804
|
-
}
|
|
2805
|
-
}
|
|
2806
|
-
},
|
|
2807
|
-
{
|
|
2808
|
-
AccountKey20: {
|
|
2809
|
-
network: null,
|
|
2810
|
-
key: "0xa3931d71877c0e7a3148cb7eb4463524fec27fbd"
|
|
2811
|
-
}
|
|
2812
|
-
}
|
|
2813
|
-
]
|
|
2814
|
-
}
|
|
2815
|
-
},
|
|
2816
|
-
{
|
|
2817
|
-
parents: 1,
|
|
2818
|
-
interior: {
|
|
2819
|
-
X1: [
|
|
2820
|
-
{
|
|
2821
|
-
Parachain: 2035
|
|
2822
|
-
}
|
|
2823
|
-
]
|
|
2824
|
-
}
|
|
2825
|
-
},
|
|
2826
|
-
{
|
|
2827
|
-
parents: 2,
|
|
2828
|
-
interior: {
|
|
2829
|
-
X2: [
|
|
2830
|
-
{
|
|
2831
|
-
GlobalConsensus: {
|
|
2832
|
-
Ethereum: {
|
|
2833
|
-
chainId: 1
|
|
2834
|
-
}
|
|
2835
|
-
}
|
|
2836
|
-
},
|
|
2837
|
-
{
|
|
2838
|
-
AccountKey20: {
|
|
2839
|
-
network: null,
|
|
2840
|
-
key: "0xd166337499e176bbc38a1fbd113ab144e5bd2df7"
|
|
2841
|
-
}
|
|
2842
|
-
}
|
|
2843
|
-
]
|
|
2844
|
-
}
|
|
2845
|
-
},
|
|
2846
2525
|
{
|
|
2847
2526
|
parents: 2,
|
|
2848
2527
|
interior: {
|
|
@@ -2879,22 +2558,6 @@ var Hydration = {
|
|
|
2879
2558
|
]
|
|
2880
2559
|
}
|
|
2881
2560
|
},
|
|
2882
|
-
{
|
|
2883
|
-
parents: 1,
|
|
2884
|
-
interior: {
|
|
2885
|
-
X2: [
|
|
2886
|
-
{
|
|
2887
|
-
Parachain: 2000
|
|
2888
|
-
},
|
|
2889
|
-
{
|
|
2890
|
-
GeneralKey: {
|
|
2891
|
-
length: 2,
|
|
2892
|
-
data: "0x0003000000000000000000000000000000000000000000000000000000000000"
|
|
2893
|
-
}
|
|
2894
|
-
}
|
|
2895
|
-
]
|
|
2896
|
-
}
|
|
2897
|
-
},
|
|
2898
2561
|
{
|
|
2899
2562
|
parents: 1,
|
|
2900
2563
|
interior: {
|
|
@@ -2940,38 +2603,12 @@ var Hydration = {
|
|
|
2940
2603
|
Ethereum: {
|
|
2941
2604
|
chainId: 1
|
|
2942
2605
|
}
|
|
2943
|
-
}
|
|
2944
|
-
},
|
|
2945
|
-
{
|
|
2946
|
-
AccountKey20: {
|
|
2947
|
-
network: null,
|
|
2948
|
-
key: "0x18084fba666a33d37592fa2633fd49a74dd93a88"
|
|
2949
|
-
}
|
|
2950
|
-
}
|
|
2951
|
-
]
|
|
2952
|
-
}
|
|
2953
|
-
},
|
|
2954
|
-
{
|
|
2955
|
-
parents: 1,
|
|
2956
|
-
interior: {
|
|
2957
|
-
X1: [
|
|
2958
|
-
{
|
|
2959
|
-
Parachain: 3345
|
|
2960
|
-
}
|
|
2961
|
-
]
|
|
2962
|
-
}
|
|
2963
|
-
},
|
|
2964
|
-
{
|
|
2965
|
-
parents: 1,
|
|
2966
|
-
interior: {
|
|
2967
|
-
X2: [
|
|
2968
|
-
{
|
|
2969
|
-
Parachain: 2092
|
|
2606
|
+
}
|
|
2970
2607
|
},
|
|
2971
2608
|
{
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2609
|
+
AccountKey20: {
|
|
2610
|
+
network: null,
|
|
2611
|
+
key: "0x18084fba666a33d37592fa2633fd49a74dd93a88"
|
|
2975
2612
|
}
|
|
2976
2613
|
}
|
|
2977
2614
|
]
|
|
@@ -2980,12 +2617,9 @@ var Hydration = {
|
|
|
2980
2617
|
{
|
|
2981
2618
|
parents: 1,
|
|
2982
2619
|
interior: {
|
|
2983
|
-
|
|
2984
|
-
{
|
|
2985
|
-
Parachain: 2094
|
|
2986
|
-
},
|
|
2620
|
+
X1: [
|
|
2987
2621
|
{
|
|
2988
|
-
|
|
2622
|
+
Parachain: 3345
|
|
2989
2623
|
}
|
|
2990
2624
|
]
|
|
2991
2625
|
}
|
|
@@ -2995,13 +2629,10 @@ var Hydration = {
|
|
|
2995
2629
|
interior: {
|
|
2996
2630
|
X2: [
|
|
2997
2631
|
{
|
|
2998
|
-
Parachain:
|
|
2632
|
+
Parachain: 2094
|
|
2999
2633
|
},
|
|
3000
2634
|
{
|
|
3001
|
-
|
|
3002
|
-
length: 21,
|
|
3003
|
-
data: "0x02c80084af223c8b598536178d9361dc55bfda68180000000000000000000000"
|
|
3004
|
-
}
|
|
2635
|
+
PalletInstance: 10
|
|
3005
2636
|
}
|
|
3006
2637
|
]
|
|
3007
2638
|
}
|
|
@@ -3048,34 +2679,6 @@ var Hydration = {
|
|
|
3048
2679
|
]
|
|
3049
2680
|
}
|
|
3050
2681
|
},
|
|
3051
|
-
{
|
|
3052
|
-
parents: 1,
|
|
3053
|
-
interior: {
|
|
3054
|
-
X5: [
|
|
3055
|
-
{
|
|
3056
|
-
Parachain: 2094
|
|
3057
|
-
},
|
|
3058
|
-
{
|
|
3059
|
-
PalletInstance: 53
|
|
3060
|
-
},
|
|
3061
|
-
{
|
|
3062
|
-
GeneralIndex: 2
|
|
3063
|
-
},
|
|
3064
|
-
{
|
|
3065
|
-
GeneralKey: {
|
|
3066
|
-
length: 4,
|
|
3067
|
-
data: "0x4555524300000000000000000000000000000000000000000000000000000000"
|
|
3068
|
-
}
|
|
3069
|
-
},
|
|
3070
|
-
{
|
|
3071
|
-
GeneralKey: {
|
|
3072
|
-
length: 32,
|
|
3073
|
-
data: "0xcf4f5a26e2090bb3adcf02c7a9d73dbfe6659cc690461475b86437fa49c71136"
|
|
3074
|
-
}
|
|
3075
|
-
}
|
|
3076
|
-
]
|
|
3077
|
-
}
|
|
3078
|
-
},
|
|
3079
2682
|
{
|
|
3080
2683
|
parents: 1,
|
|
3081
2684
|
interior: {
|
|
@@ -3117,42 +2720,6 @@ var Hydration = {
|
|
|
3117
2720
|
]
|
|
3118
2721
|
}
|
|
3119
2722
|
},
|
|
3120
|
-
{
|
|
3121
|
-
parents: 1,
|
|
3122
|
-
interior: {
|
|
3123
|
-
X2: [
|
|
3124
|
-
{
|
|
3125
|
-
Parachain: 2004
|
|
3126
|
-
},
|
|
3127
|
-
{
|
|
3128
|
-
AccountKey20: {
|
|
3129
|
-
network: null,
|
|
3130
|
-
key: "0x9c4c6eaad9b926ba09f702f4ad880ef71998ef18"
|
|
3131
|
-
}
|
|
3132
|
-
}
|
|
3133
|
-
]
|
|
3134
|
-
}
|
|
3135
|
-
},
|
|
3136
|
-
{
|
|
3137
|
-
parents: 2,
|
|
3138
|
-
interior: {
|
|
3139
|
-
X2: [
|
|
3140
|
-
{
|
|
3141
|
-
GlobalConsensus: {
|
|
3142
|
-
Ethereum: {
|
|
3143
|
-
chainId: 1
|
|
3144
|
-
}
|
|
3145
|
-
}
|
|
3146
|
-
},
|
|
3147
|
-
{
|
|
3148
|
-
AccountKey20: {
|
|
3149
|
-
network: null,
|
|
3150
|
-
key: "0x8236a87084f8b84306f72007f36f2618a5634494"
|
|
3151
|
-
}
|
|
3152
|
-
}
|
|
3153
|
-
]
|
|
3154
|
-
}
|
|
3155
|
-
},
|
|
3156
2723
|
{
|
|
3157
2724
|
parents: 1,
|
|
3158
2725
|
interior: {
|
|
@@ -3185,16 +2752,6 @@ var Hydration = {
|
|
|
3185
2752
|
]
|
|
3186
2753
|
}
|
|
3187
2754
|
},
|
|
3188
|
-
{
|
|
3189
|
-
parents: 1,
|
|
3190
|
-
interior: {
|
|
3191
|
-
X1: [
|
|
3192
|
-
{
|
|
3193
|
-
Parachain: 2006
|
|
3194
|
-
}
|
|
3195
|
-
]
|
|
3196
|
-
}
|
|
3197
|
-
},
|
|
3198
2755
|
{
|
|
3199
2756
|
parents: 1,
|
|
3200
2757
|
interior: {
|
|
@@ -3219,26 +2776,6 @@ var Hydration = {
|
|
|
3219
2776
|
}
|
|
3220
2777
|
]
|
|
3221
2778
|
}
|
|
3222
|
-
},
|
|
3223
|
-
{
|
|
3224
|
-
parents: 2,
|
|
3225
|
-
interior: {
|
|
3226
|
-
X2: [
|
|
3227
|
-
{
|
|
3228
|
-
GlobalConsensus: {
|
|
3229
|
-
Ethereum: {
|
|
3230
|
-
chainId: 1
|
|
3231
|
-
}
|
|
3232
|
-
}
|
|
3233
|
-
},
|
|
3234
|
-
{
|
|
3235
|
-
AccountKey20: {
|
|
3236
|
-
network: null,
|
|
3237
|
-
key: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
|
3238
|
-
}
|
|
3239
|
-
}
|
|
3240
|
-
]
|
|
3241
|
-
}
|
|
3242
2779
|
}
|
|
3243
2780
|
],
|
|
3244
2781
|
pairs: [
|
|
@@ -9456,7 +8993,7 @@ var BifrostExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
9456
8993
|
|
|
9457
8994
|
var calculateFee = /*#__PURE__*/function () {
|
|
9458
8995
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, currencyFromDecimals, chain, toDestTransactionFee) {
|
|
9459
|
-
var amount, slippagePct, feeCalcAddress, sender, trade, nativeAsset, substrateTx, tx, _yield$
|
|
8996
|
+
var amount, slippagePct, feeCalcAddress, sender, trade, nativeAsset, substrateTx, tx, _yield$getPaymentInfo, swapFee, feeNative, currencyFromPriceInfo, currencyFromPrice, feeInCurrencyFrom, finalFee;
|
|
9460
8997
|
return _regenerator().w(function (_context) {
|
|
9461
8998
|
while (1) switch (_context.n) {
|
|
9462
8999
|
case 0:
|
|
@@ -9472,10 +9009,10 @@ var calculateFee = /*#__PURE__*/function () {
|
|
|
9472
9009
|
substrateTx = _context.v;
|
|
9473
9010
|
tx = substrateTx.get();
|
|
9474
9011
|
_context.n = 3;
|
|
9475
|
-
return
|
|
9012
|
+
return getPaymentInfo(tx, feeCalcAddress);
|
|
9476
9013
|
case 3:
|
|
9477
|
-
_yield$
|
|
9478
|
-
swapFee = _yield$
|
|
9014
|
+
_yield$getPaymentInfo = _context.v;
|
|
9015
|
+
swapFee = _yield$getPaymentInfo.partial_fee;
|
|
9479
9016
|
feeNative = swapFee + toDestTransactionFee + toDestTransactionFee;
|
|
9480
9017
|
Logger.log('XCM to exch. fee:', toDestTransactionFee, nativeAsset.symbol);
|
|
9481
9018
|
Logger.log('XCM to dest. fee:', toDestTransactionFee, nativeAsset.symbol);
|
|
@@ -9547,78 +9084,77 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
9547
9084
|
key: "swapCurrency",
|
|
9548
9085
|
value: function () {
|
|
9549
9086
|
var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, toDestTransactionFee) {
|
|
9550
|
-
var apiPapi, origin, assetFrom, assetTo, sender, slippagePct, amount,
|
|
9087
|
+
var apiPapi, origin, assetFrom, assetTo, sender, slippagePct, amount, sdk, tradeRouter, assetClient, txBuilderFactory, currencyFromInfo, currencyToInfo, tradeFee, amountWithoutFee, amountNormalized, trade, substrateTx, tx, amountOut, nativeCurrencyInfo, _findNativeAssetInfoO, nativeCurrencyDecimals, priceInfo, currencyToPrice, feeInCurrencyTo, amountOutModified;
|
|
9551
9088
|
return _regenerator().w(function (_context) {
|
|
9552
|
-
while (1) switch (_context.n) {
|
|
9089
|
+
while (1) switch (_context.p = _context.n) {
|
|
9553
9090
|
case 0:
|
|
9554
9091
|
apiPapi = options.apiPapi, origin = options.origin, assetFrom = options.assetFrom, assetTo = options.assetTo, sender = options.sender, slippagePct = options.slippagePct, amount = options.amount;
|
|
9555
9092
|
_context.n = 1;
|
|
9556
9093
|
return createSdkContext(apiPapi);
|
|
9557
9094
|
case 1:
|
|
9558
|
-
|
|
9559
|
-
tradeRouter =
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
_context.n = 2;
|
|
9095
|
+
sdk = _context.v;
|
|
9096
|
+
tradeRouter = sdk.api.router, assetClient = sdk.client.asset, txBuilderFactory = sdk.tx;
|
|
9097
|
+
_context.p = 2;
|
|
9098
|
+
_context.n = 3;
|
|
9563
9099
|
return getAssetInfo(assetClient, assetFrom);
|
|
9564
|
-
case
|
|
9100
|
+
case 3:
|
|
9565
9101
|
currencyFromInfo = _context.v;
|
|
9566
|
-
_context.n =
|
|
9102
|
+
_context.n = 4;
|
|
9567
9103
|
return getAssetInfo(assetClient, assetTo);
|
|
9568
|
-
case
|
|
9104
|
+
case 4:
|
|
9569
9105
|
currencyToInfo = _context.v;
|
|
9570
9106
|
if (!(currencyFromInfo === undefined)) {
|
|
9571
|
-
_context.n =
|
|
9107
|
+
_context.n = 5;
|
|
9572
9108
|
break;
|
|
9573
9109
|
}
|
|
9574
9110
|
throw new InvalidCurrencyError("Currency from doesn't exist");
|
|
9575
|
-
case
|
|
9111
|
+
case 5:
|
|
9576
9112
|
if (!(currencyToInfo === undefined)) {
|
|
9577
|
-
_context.n =
|
|
9113
|
+
_context.n = 6;
|
|
9578
9114
|
break;
|
|
9579
9115
|
}
|
|
9580
9116
|
throw new InvalidCurrencyError("Currency to doesn't exist");
|
|
9581
|
-
case 5:
|
|
9582
|
-
_context.n = 6;
|
|
9583
|
-
return calculateFee(options, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, currencyFromInfo.decimals, this.chain, toDestTransactionFee);
|
|
9584
9117
|
case 6:
|
|
9118
|
+
_context.n = 7;
|
|
9119
|
+
return calculateFee(options, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, currencyFromInfo.decimals, this.chain, toDestTransactionFee);
|
|
9120
|
+
case 7:
|
|
9585
9121
|
tradeFee = _context.v;
|
|
9586
9122
|
amountWithoutFee = origin ? amount - tradeFee : amount;
|
|
9587
9123
|
if (!(amountWithoutFee <= 0n)) {
|
|
9588
|
-
_context.n =
|
|
9124
|
+
_context.n = 8;
|
|
9589
9125
|
break;
|
|
9590
9126
|
}
|
|
9591
9127
|
throw new AmountTooLowError();
|
|
9592
|
-
case
|
|
9128
|
+
case 8:
|
|
9593
9129
|
amountNormalized = formatUnits$1(amountWithoutFee, currencyFromInfo.decimals);
|
|
9594
9130
|
Logger.log('Original amount', amount);
|
|
9595
9131
|
Logger.log('Amount modified', amountWithoutFee);
|
|
9596
|
-
_context.n =
|
|
9132
|
+
_context.n = 9;
|
|
9597
9133
|
return tradeRouter.getBestSell(currencyFromInfo.id, currencyToInfo.id, amountNormalized);
|
|
9598
|
-
case
|
|
9134
|
+
case 9:
|
|
9599
9135
|
trade = _context.v;
|
|
9600
|
-
_context.n =
|
|
9136
|
+
_context.n = 10;
|
|
9601
9137
|
return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(sender).build();
|
|
9602
|
-
case
|
|
9138
|
+
case 10:
|
|
9603
9139
|
substrateTx = _context.v;
|
|
9604
9140
|
tx = substrateTx.get();
|
|
9605
9141
|
amountOut = trade.amountOut;
|
|
9606
|
-
_context.n =
|
|
9142
|
+
_context.n = 11;
|
|
9607
9143
|
return getAssetInfo(assetClient, {
|
|
9608
9144
|
symbol: getNativeAssetSymbol(this.chain)
|
|
9609
9145
|
});
|
|
9610
|
-
case
|
|
9146
|
+
case 11:
|
|
9611
9147
|
nativeCurrencyInfo = _context.v;
|
|
9612
9148
|
if (!(nativeCurrencyInfo === undefined)) {
|
|
9613
|
-
_context.n =
|
|
9149
|
+
_context.n = 12;
|
|
9614
9150
|
break;
|
|
9615
9151
|
}
|
|
9616
9152
|
throw new InvalidCurrencyError('Native currency not found');
|
|
9617
|
-
case
|
|
9153
|
+
case 12:
|
|
9618
9154
|
_findNativeAssetInfoO = findNativeAssetInfoOrThrow(this.chain), nativeCurrencyDecimals = _findNativeAssetInfoO.decimals;
|
|
9619
|
-
_context.n =
|
|
9155
|
+
_context.n = 13;
|
|
9620
9156
|
return tradeRouter.getSpotPrice(currencyToInfo.id, nativeCurrencyInfo.id);
|
|
9621
|
-
case
|
|
9157
|
+
case 13:
|
|
9622
9158
|
priceInfo = _context.v;
|
|
9623
9159
|
if (currencyToInfo.id === nativeCurrencyInfo.id) {
|
|
9624
9160
|
priceInfo = {
|
|
@@ -9627,29 +9163,35 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
9627
9163
|
};
|
|
9628
9164
|
}
|
|
9629
9165
|
if (!(priceInfo === undefined)) {
|
|
9630
|
-
_context.n =
|
|
9166
|
+
_context.n = 14;
|
|
9631
9167
|
break;
|
|
9632
9168
|
}
|
|
9633
9169
|
throw new UnableToComputeError('Price not found');
|
|
9634
|
-
case
|
|
9170
|
+
case 14:
|
|
9635
9171
|
currencyToPrice = priceInfo.amount;
|
|
9636
9172
|
feeInCurrencyTo = toDestTransactionFee * pow10n(priceInfo.decimals + currencyToInfo.decimals) * BigInt(FEE_BUFFER_PCT) / (currencyToPrice * pow10n(nativeCurrencyDecimals) * 100n);
|
|
9637
9173
|
Logger.log('Amount out fee', feeInCurrencyTo, nativeCurrencyInfo.symbol);
|
|
9638
9174
|
amountOutModified = amountOut - feeInCurrencyTo;
|
|
9639
9175
|
if (!(amountOutModified <= 0n)) {
|
|
9640
|
-
_context.n =
|
|
9176
|
+
_context.n = 15;
|
|
9641
9177
|
break;
|
|
9642
9178
|
}
|
|
9643
9179
|
throw new AmountTooLowError();
|
|
9644
|
-
case
|
|
9180
|
+
case 15:
|
|
9645
9181
|
Logger.log('Amount out original', amountOut);
|
|
9646
9182
|
Logger.log('Amount out modified', amountOutModified);
|
|
9647
9183
|
return _context.a(2, {
|
|
9648
9184
|
tx: tx,
|
|
9649
9185
|
amountOut: amountOutModified
|
|
9650
9186
|
});
|
|
9187
|
+
case 16:
|
|
9188
|
+
_context.p = 16;
|
|
9189
|
+
sdk.destroy();
|
|
9190
|
+
return _context.f(16);
|
|
9191
|
+
case 17:
|
|
9192
|
+
return _context.a(2);
|
|
9651
9193
|
}
|
|
9652
|
-
}, _callee, this);
|
|
9194
|
+
}, _callee, this, [[2,, 16, 17]]);
|
|
9653
9195
|
}));
|
|
9654
9196
|
function swapCurrency(_x, _x2) {
|
|
9655
9197
|
return _swapCurrency.apply(this, arguments);
|
|
@@ -9660,49 +9202,55 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
9660
9202
|
key: "getAmountOut",
|
|
9661
9203
|
value: function () {
|
|
9662
9204
|
var _getAmountOut = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
9663
|
-
var apiPapi, assetFrom, assetTo, amount, origin, _options$slippagePct, slippagePct,
|
|
9205
|
+
var apiPapi, assetFrom, assetTo, amount, origin, _options$slippagePct, slippagePct, sdk, tradeRouter, assetClient, currencyFromInfo, currencyToInfo, pctDestFee, amountWithoutFee, amountNormalized, trade, amountOut, slippageMultiplier;
|
|
9664
9206
|
return _regenerator().w(function (_context2) {
|
|
9665
|
-
while (1) switch (_context2.n) {
|
|
9207
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
9666
9208
|
case 0:
|
|
9667
9209
|
apiPapi = options.apiPapi, assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, origin = options.origin, _options$slippagePct = options.slippagePct, slippagePct = _options$slippagePct === void 0 ? '0' : _options$slippagePct;
|
|
9668
9210
|
_context2.n = 1;
|
|
9669
9211
|
return createSdkContext(apiPapi);
|
|
9670
9212
|
case 1:
|
|
9671
|
-
|
|
9672
|
-
tradeRouter =
|
|
9673
|
-
|
|
9674
|
-
_context2.n =
|
|
9213
|
+
sdk = _context2.v;
|
|
9214
|
+
tradeRouter = sdk.api.router, assetClient = sdk.client.asset;
|
|
9215
|
+
_context2.p = 2;
|
|
9216
|
+
_context2.n = 3;
|
|
9675
9217
|
return getAssetInfo(assetClient, assetFrom);
|
|
9676
|
-
case
|
|
9218
|
+
case 3:
|
|
9677
9219
|
currencyFromInfo = _context2.v;
|
|
9678
|
-
_context2.n =
|
|
9220
|
+
_context2.n = 4;
|
|
9679
9221
|
return getAssetInfo(assetClient, assetTo);
|
|
9680
|
-
case
|
|
9222
|
+
case 4:
|
|
9681
9223
|
currencyToInfo = _context2.v;
|
|
9682
9224
|
if (!(currencyFromInfo === undefined)) {
|
|
9683
|
-
_context2.n =
|
|
9225
|
+
_context2.n = 5;
|
|
9684
9226
|
break;
|
|
9685
9227
|
}
|
|
9686
9228
|
throw new InvalidCurrencyError("Currency from doesn't exist");
|
|
9687
|
-
case
|
|
9229
|
+
case 5:
|
|
9688
9230
|
if (!(currencyToInfo === undefined)) {
|
|
9689
|
-
_context2.n =
|
|
9231
|
+
_context2.n = 6;
|
|
9690
9232
|
break;
|
|
9691
9233
|
}
|
|
9692
9234
|
throw new InvalidCurrencyError("Currency to doesn't exist");
|
|
9693
|
-
case
|
|
9235
|
+
case 6:
|
|
9694
9236
|
pctDestFee = origin ? DEST_FEE_BUFFER_PCT : 0;
|
|
9695
9237
|
amountWithoutFee = padValueBy(amount, pctDestFee);
|
|
9696
9238
|
amountNormalized = formatUnits$1(amountWithoutFee, currencyFromInfo.decimals);
|
|
9697
|
-
_context2.n =
|
|
9239
|
+
_context2.n = 7;
|
|
9698
9240
|
return tradeRouter.getBestSell(currencyFromInfo.id, currencyToInfo.id, amountNormalized);
|
|
9699
|
-
case
|
|
9241
|
+
case 7:
|
|
9700
9242
|
trade = _context2.v;
|
|
9701
9243
|
amountOut = trade.amountOut;
|
|
9702
9244
|
slippageMultiplier = Number(slippagePct);
|
|
9703
9245
|
return _context2.a(2, padValueBy(amountOut, -slippageMultiplier));
|
|
9246
|
+
case 8:
|
|
9247
|
+
_context2.p = 8;
|
|
9248
|
+
sdk.destroy();
|
|
9249
|
+
return _context2.f(8);
|
|
9250
|
+
case 9:
|
|
9251
|
+
return _context2.a(2);
|
|
9704
9252
|
}
|
|
9705
|
-
}, _callee2);
|
|
9253
|
+
}, _callee2, null, [[2,, 8, 9]]);
|
|
9706
9254
|
}));
|
|
9707
9255
|
function getAmountOut(_x3) {
|
|
9708
9256
|
return _getAmountOut.apply(this, arguments);
|
|
@@ -9713,7 +9261,7 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
9713
9261
|
key: "getDexConfig",
|
|
9714
9262
|
value: function () {
|
|
9715
9263
|
var _getDexConfig = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(api) {
|
|
9716
|
-
var sdk, assets, sdkAssets, transformedAssets;
|
|
9264
|
+
var sdk, _yield$Promise$all, _yield$Promise$all2, assets, pools, sdkAssets, poolAssetIds, transformedAssets;
|
|
9717
9265
|
return _regenerator().w(function (_context3) {
|
|
9718
9266
|
while (1) switch (_context3.p = _context3.n) {
|
|
9719
9267
|
case 0:
|
|
@@ -9723,14 +9271,27 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
9723
9271
|
sdk = _context3.v;
|
|
9724
9272
|
_context3.p = 2;
|
|
9725
9273
|
_context3.n = 3;
|
|
9726
|
-
return sdk.client.asset.getSupported();
|
|
9274
|
+
return Promise.all([sdk.client.asset.getSupported(), sdk.api.router.getPools()]);
|
|
9727
9275
|
case 3:
|
|
9728
|
-
|
|
9276
|
+
_yield$Promise$all = _context3.v;
|
|
9277
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
9278
|
+
assets = _yield$Promise$all2[0];
|
|
9279
|
+
pools = _yield$Promise$all2[1];
|
|
9729
9280
|
sdkAssets = getAssets(this.chain);
|
|
9730
|
-
|
|
9281
|
+
poolAssetIds = new Set(pools.flatMap(function (_ref) {
|
|
9282
|
+
var tokens = _ref.tokens;
|
|
9283
|
+
return tokens.map(function (_ref2) {
|
|
9284
|
+
var id = _ref2.id;
|
|
9285
|
+
return id.toString();
|
|
9286
|
+
});
|
|
9287
|
+
}));
|
|
9288
|
+
transformedAssets = assets.filter(function (_ref3) {
|
|
9289
|
+
var id = _ref3.id;
|
|
9290
|
+
return poolAssetIds.has(id.toString());
|
|
9291
|
+
}).map(function (_ref4) {
|
|
9731
9292
|
var _sdkAssets$find;
|
|
9732
|
-
var symbol =
|
|
9733
|
-
id =
|
|
9293
|
+
var symbol = _ref4.symbol,
|
|
9294
|
+
id = _ref4.id;
|
|
9734
9295
|
var asset = (_sdkAssets$find = sdkAssets.find(function (a) {
|
|
9735
9296
|
return !a.isNative && a.assetId === id.toString();
|
|
9736
9297
|
})) !== null && _sdkAssets$find !== void 0 ? _sdkAssets$find : sdkAssets.find(function (a) {
|
|
@@ -9834,11 +9395,19 @@ var getExchangeAsset = function getExchangeAsset(exchange, currency) {
|
|
|
9834
9395
|
return null;
|
|
9835
9396
|
};
|
|
9836
9397
|
|
|
9837
|
-
var
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9398
|
+
var resolveOriginAssetOnExchange = function resolveOriginAssetOnExchange(origin, exchange, transferableAssets, originAsset, ctx) {
|
|
9399
|
+
if (!transferableAssets.some(function (asset) {
|
|
9400
|
+
return isAssetEqual(asset, originAsset);
|
|
9401
|
+
})) return null;
|
|
9402
|
+
return findAssetInfoOnDestImpl(origin, exchange, {
|
|
9403
|
+
location: originAsset.location
|
|
9404
|
+
}, originAsset, ctx);
|
|
9405
|
+
};
|
|
9406
|
+
var getExchangeAssetByOriginAsset = function getExchangeAssetByOriginAsset(origin, exchange, originAsset, ctx) {
|
|
9407
|
+
var assetOnExchange = resolveOriginAssetOnExchange(origin, exchange, getSupportedAssetsImpl(origin, exchange, ctx), originAsset, ctx);
|
|
9408
|
+
if (!assetOnExchange) return undefined;
|
|
9409
|
+
return getExchangeAssets(exchange).find(function (asset) {
|
|
9410
|
+
return isAssetEqual(asset, assetOnExchange);
|
|
9842
9411
|
});
|
|
9843
9412
|
};
|
|
9844
9413
|
|
|
@@ -9888,16 +9457,34 @@ var getSupportedAssetsFromImpl = function getSupportedAssetsFromImpl(from, excha
|
|
|
9888
9457
|
if (!from) return [];
|
|
9889
9458
|
return getAssetsImpl(from, ctx);
|
|
9890
9459
|
}
|
|
9891
|
-
var
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9895
|
-
|
|
9460
|
+
var exchanges = Array.isArray(exchange) ? exchange : [exchange];
|
|
9461
|
+
if (!from || !Array.isArray(exchange) && from === exchange) {
|
|
9462
|
+
return exchanges.flatMap(function (ex) {
|
|
9463
|
+
return getExchangeAssets(ex);
|
|
9464
|
+
});
|
|
9896
9465
|
}
|
|
9466
|
+
var entries = exchanges.map(function (ex) {
|
|
9467
|
+
return {
|
|
9468
|
+
exchange: ex,
|
|
9469
|
+
exchangeAssets: getExchangeAssets(ex),
|
|
9470
|
+
transferableAssets: from === ex ? undefined : getSupportedAssetsImpl(from, ex, ctx)
|
|
9471
|
+
};
|
|
9472
|
+
});
|
|
9897
9473
|
var fromAssets = getAssetsImpl(from, ctx);
|
|
9898
9474
|
return fromAssets.filter(function (fromAsset) {
|
|
9899
|
-
return
|
|
9900
|
-
|
|
9475
|
+
return entries.some(function (_ref) {
|
|
9476
|
+
var ex = _ref.exchange,
|
|
9477
|
+
exchangeAssets = _ref.exchangeAssets,
|
|
9478
|
+
transferableAssets = _ref.transferableAssets;
|
|
9479
|
+
if (transferableAssets === undefined) {
|
|
9480
|
+
return exchangeAssets.some(function (exchangeAsset) {
|
|
9481
|
+
return isAssetEqual(exchangeAsset, fromAsset);
|
|
9482
|
+
});
|
|
9483
|
+
}
|
|
9484
|
+
var assetOnExchange = resolveOriginAssetOnExchange(from, ex, transferableAssets, fromAsset, ctx);
|
|
9485
|
+
return assetOnExchange !== null && exchangeAssets.some(function (exchangeAsset) {
|
|
9486
|
+
return isAssetEqual(exchangeAsset, assetOnExchange);
|
|
9487
|
+
});
|
|
9901
9488
|
});
|
|
9902
9489
|
});
|
|
9903
9490
|
};
|
|
@@ -9905,7 +9492,7 @@ var getSupportedAssetsFromImpl = function getSupportedAssetsFromImpl(from, excha
|
|
|
9905
9492
|
* Retrieves the list of assets supported for transfer from the origin chain to the exchange chain.
|
|
9906
9493
|
*
|
|
9907
9494
|
* @param from - The origin chain.
|
|
9908
|
-
* @param
|
|
9495
|
+
* @param exchangeInput - The exchange chain or 'Auto select'.
|
|
9909
9496
|
* @returns An array of supported assets.
|
|
9910
9497
|
*/
|
|
9911
9498
|
var getSupportedAssetsFrom = function getSupportedAssetsFrom(from, exchangeInput) {
|
|
@@ -9914,50 +9501,22 @@ var getSupportedAssetsFrom = function getSupportedAssetsFrom(from, exchangeInput
|
|
|
9914
9501
|
|
|
9915
9502
|
var getSupportedAssetsToImpl = function getSupportedAssetsToImpl(exchangeInput, to, ctx) {
|
|
9916
9503
|
var exchange = normalizeExchange(exchangeInput);
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
|
|
9920
|
-
|
|
9921
|
-
|
|
9922
|
-
|
|
9923
|
-
|
|
9924
|
-
return
|
|
9925
|
-
return isAssetEqual(asset, toAsset);
|
|
9926
|
-
});
|
|
9927
|
-
});
|
|
9928
|
-
if (isExternalChain(to)) {
|
|
9929
|
-
filteredExchangeAssets.push.apply(filteredExchangeAssets, _toConsumableArray(allExchangeAssets.filter(function (asset) {
|
|
9930
|
-
return isSystemAsset(asset);
|
|
9931
|
-
})));
|
|
9932
|
-
}
|
|
9933
|
-
return filteredExchangeAssets;
|
|
9934
|
-
}
|
|
9935
|
-
return allExchangeAssets;
|
|
9936
|
-
}
|
|
9937
|
-
var exchangeAssets = Array.isArray(exchange) ? exchange.flatMap(function (exchange) {
|
|
9938
|
-
return getExchangeAssets(exchange);
|
|
9939
|
-
}) : getExchangeAssets(exchange);
|
|
9940
|
-
if (to) {
|
|
9941
|
-
var _toAssets = getAssetsImpl(to, ctx);
|
|
9942
|
-
var _filteredExchangeAssets = exchangeAssets.filter(function (asset) {
|
|
9943
|
-
return _toAssets.some(function (toAsset) {
|
|
9944
|
-
return isAssetEqual(asset, toAsset);
|
|
9504
|
+
var exchanges = exchange === undefined ? EXCHANGE_CHAINS : Array.isArray(exchange) ? exchange : [exchange];
|
|
9505
|
+
return exchanges.flatMap(function (ex) {
|
|
9506
|
+
var exchangeAssets = getExchangeAssets(ex);
|
|
9507
|
+
if (!to || to === ex) return exchangeAssets;
|
|
9508
|
+
var transferableAssets = getSupportedAssetsImpl(ex, to, ctx);
|
|
9509
|
+
return exchangeAssets.filter(function (asset) {
|
|
9510
|
+
return transferableAssets.some(function (transferable) {
|
|
9511
|
+
return isAssetEqual(transferable, asset);
|
|
9945
9512
|
});
|
|
9946
9513
|
});
|
|
9947
|
-
|
|
9948
|
-
_filteredExchangeAssets.push.apply(_filteredExchangeAssets, _toConsumableArray(exchangeAssets.filter(function (asset) {
|
|
9949
|
-
return isSystemAsset(asset);
|
|
9950
|
-
})));
|
|
9951
|
-
}
|
|
9952
|
-
return _filteredExchangeAssets;
|
|
9953
|
-
}
|
|
9954
|
-
return exchangeAssets;
|
|
9514
|
+
});
|
|
9955
9515
|
};
|
|
9956
9516
|
/**
|
|
9957
|
-
* Retrieves the list of assets supported for transfer to the destination chain.
|
|
9517
|
+
* Retrieves the list of assets supported for transfer from the exchange chain to the destination chain.
|
|
9958
9518
|
*
|
|
9959
|
-
* @param
|
|
9960
|
-
* @param exchange - The exchange chain or 'Auto select'.
|
|
9519
|
+
* @param exchangeInput - The exchange chain or 'Auto select'.
|
|
9961
9520
|
* @param to - The destination chain.
|
|
9962
9521
|
* @returns An array of supported assets.
|
|
9963
9522
|
*/
|
|
@@ -10084,20 +9643,20 @@ var canBuildToExchangeTx = /*#__PURE__*/function () {
|
|
|
10084
9643
|
|
|
10085
9644
|
var selectBestExchangeCommon = /*#__PURE__*/function () {
|
|
10086
9645
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, originApi, computeAmountOut) {
|
|
10087
|
-
var api, from, exchange, to, currencyFrom, currencyTo, assetFromOrigin, filteredExchangeChains, bestExchange, maxAmountOut, errors, triedAnyExchange, _iterator, _step,
|
|
10088
|
-
return _regenerator().w(function (
|
|
10089
|
-
while (1) switch (
|
|
9646
|
+
var api, from, exchange, to, currencyFrom, currencyTo, assetFromOrigin, filteredExchangeChains, bestExchange, maxAmountOut, errors, triedAnyExchange, _iterator, _step, _loop, _ret, _t2;
|
|
9647
|
+
return _regenerator().w(function (_context2) {
|
|
9648
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
10090
9649
|
case 0:
|
|
10091
9650
|
api = options.api, from = options.from, exchange = options.exchange, to = options.to, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo;
|
|
10092
9651
|
assetFromOrigin = from ? findAssetInfo(from, currencyFrom) : undefined;
|
|
10093
9652
|
if (!(from && !assetFromOrigin)) {
|
|
10094
|
-
|
|
9653
|
+
_context2.n = 1;
|
|
10095
9654
|
break;
|
|
10096
9655
|
}
|
|
10097
9656
|
throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(options.currencyFrom), " not found in ").concat(options.from, "."));
|
|
10098
9657
|
case 1:
|
|
10099
9658
|
if (!('id' in currencyTo)) {
|
|
10100
|
-
|
|
9659
|
+
_context2.n = 2;
|
|
10101
9660
|
break;
|
|
10102
9661
|
}
|
|
10103
9662
|
throw new UnsupportedOperationError('Cannot select currencyTo by ID when auto-selecting is enabled. Please specify currencyTo by symbol or location.');
|
|
@@ -10108,114 +9667,126 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
|
|
|
10108
9667
|
errors = new Map();
|
|
10109
9668
|
triedAnyExchange = false;
|
|
10110
9669
|
_iterator = _createForOfIteratorHelper(filteredExchangeChains);
|
|
10111
|
-
|
|
9670
|
+
_context2.p = 3;
|
|
9671
|
+
_loop = /*#__PURE__*/_regenerator().m(function _loop() {
|
|
9672
|
+
var exchangeChain, dex, originSpecified, destinationSpecified, assetFromExchange, assetTo, res, config, parsedAmount, amountOut, _t;
|
|
9673
|
+
return _regenerator().w(function (_context) {
|
|
9674
|
+
while (1) switch (_context.p = _context.n) {
|
|
9675
|
+
case 0:
|
|
9676
|
+
exchangeChain = _step.value;
|
|
9677
|
+
dex = createExchangeInstance(exchangeChain);
|
|
9678
|
+
originSpecified = from && from !== dex.chain;
|
|
9679
|
+
destinationSpecified = to && to !== dex.chain;
|
|
9680
|
+
assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(from, dex.chain, assetFromOrigin) : getExchangeAsset(dex.chain, currencyFrom);
|
|
9681
|
+
if (assetFromExchange) {
|
|
9682
|
+
_context.n = 1;
|
|
9683
|
+
break;
|
|
9684
|
+
}
|
|
9685
|
+
return _context.a(2, 0);
|
|
9686
|
+
case 1:
|
|
9687
|
+
assetTo = getExchangeAsset(dex.chain, currencyTo, true);
|
|
9688
|
+
if (assetTo) {
|
|
9689
|
+
_context.n = 2;
|
|
9690
|
+
break;
|
|
9691
|
+
}
|
|
9692
|
+
return _context.a(2, 0);
|
|
9693
|
+
case 2:
|
|
9694
|
+
if (!(destinationSpecified && !getSupportedAssetsImpl(dex.chain, to).some(function (asset) {
|
|
9695
|
+
return isAssetEqual(asset, assetTo);
|
|
9696
|
+
}))) {
|
|
9697
|
+
_context.n = 3;
|
|
9698
|
+
break;
|
|
9699
|
+
}
|
|
9700
|
+
return _context.a(2, 0);
|
|
9701
|
+
case 3:
|
|
9702
|
+
triedAnyExchange = true;
|
|
9703
|
+
Logger.log("Checking ".concat(exchangeChain, "..."));
|
|
9704
|
+
_context.n = 4;
|
|
9705
|
+
return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin);
|
|
9706
|
+
case 4:
|
|
9707
|
+
res = _context.v;
|
|
9708
|
+
if (res.success) {
|
|
9709
|
+
_context.n = 5;
|
|
9710
|
+
break;
|
|
9711
|
+
}
|
|
9712
|
+
errors.set(dex.chain, res.error);
|
|
9713
|
+
return _context.a(2, 0);
|
|
9714
|
+
case 5:
|
|
9715
|
+
config = api.config;
|
|
9716
|
+
parsedAmount = applyDecimalAbstraction(options.amount, assetFromExchange === null || assetFromExchange === void 0 ? void 0 : assetFromExchange.decimals, !(isConfig(config) && config.abstractDecimals === false)).toString();
|
|
9717
|
+
_context.p = 6;
|
|
9718
|
+
_context.n = 7;
|
|
9719
|
+
return computeAmountOut(dex, assetFromExchange, assetTo, options, parsedAmount);
|
|
9720
|
+
case 7:
|
|
9721
|
+
amountOut = _context.v;
|
|
9722
|
+
if (amountOut > maxAmountOut) {
|
|
9723
|
+
bestExchange = dex;
|
|
9724
|
+
maxAmountOut = amountOut;
|
|
9725
|
+
}
|
|
9726
|
+
_context.n = 9;
|
|
9727
|
+
break;
|
|
9728
|
+
case 8:
|
|
9729
|
+
_context.p = 8;
|
|
9730
|
+
_t = _context.v;
|
|
9731
|
+
if (_t instanceof Error) {
|
|
9732
|
+
errors.set(dex.chain, _t);
|
|
9733
|
+
}
|
|
9734
|
+
return _context.a(2, 0);
|
|
9735
|
+
case 9:
|
|
9736
|
+
return _context.a(2);
|
|
9737
|
+
}
|
|
9738
|
+
}, _loop, null, [[6, 8]]);
|
|
9739
|
+
});
|
|
10112
9740
|
_iterator.s();
|
|
10113
9741
|
case 4:
|
|
10114
9742
|
if ((_step = _iterator.n()).done) {
|
|
10115
|
-
|
|
10116
|
-
break;
|
|
10117
|
-
}
|
|
10118
|
-
exchangeChain = _step.value;
|
|
10119
|
-
dex = createExchangeInstance(exchangeChain);
|
|
10120
|
-
originSpecified = from && from !== dex.chain;
|
|
10121
|
-
destinationSpecified = to && to !== dex.chain;
|
|
10122
|
-
assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.chain, assetFromOrigin) : getExchangeAsset(dex.chain, currencyFrom);
|
|
10123
|
-
if (assetFromExchange) {
|
|
10124
|
-
_context.n = 5;
|
|
9743
|
+
_context2.n = 7;
|
|
10125
9744
|
break;
|
|
10126
9745
|
}
|
|
10127
|
-
return
|
|
9746
|
+
return _context2.d(_regeneratorValues(_loop()), 5);
|
|
10128
9747
|
case 5:
|
|
10129
|
-
|
|
10130
|
-
if (
|
|
10131
|
-
|
|
9748
|
+
_ret = _context2.v;
|
|
9749
|
+
if (!(_ret === 0)) {
|
|
9750
|
+
_context2.n = 6;
|
|
10132
9751
|
break;
|
|
10133
9752
|
}
|
|
10134
|
-
return
|
|
9753
|
+
return _context2.a(3, 6);
|
|
10135
9754
|
case 6:
|
|
10136
|
-
|
|
10137
|
-
location: assetTo.location
|
|
10138
|
-
}))) {
|
|
10139
|
-
_context.n = 7;
|
|
10140
|
-
break;
|
|
10141
|
-
}
|
|
10142
|
-
return _context.a(3, 14);
|
|
10143
|
-
case 7:
|
|
10144
|
-
if (!(from && getRelayChainOf(from) !== getRelayChainOf(dex.chain))) {
|
|
10145
|
-
_context.n = 8;
|
|
10146
|
-
break;
|
|
10147
|
-
}
|
|
10148
|
-
return _context.a(3, 14);
|
|
10149
|
-
case 8:
|
|
10150
|
-
triedAnyExchange = true;
|
|
10151
|
-
Logger.log("Checking ".concat(exchangeChain, "..."));
|
|
10152
|
-
_context.n = 9;
|
|
10153
|
-
return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin);
|
|
10154
|
-
case 9:
|
|
10155
|
-
res = _context.v;
|
|
10156
|
-
if (res.success) {
|
|
10157
|
-
_context.n = 10;
|
|
10158
|
-
break;
|
|
10159
|
-
}
|
|
10160
|
-
errors.set(dex.chain, res.error);
|
|
10161
|
-
return _context.a(3, 14);
|
|
10162
|
-
case 10:
|
|
10163
|
-
config = api.config;
|
|
10164
|
-
parsedAmount = applyDecimalAbstraction(options.amount, assetFromExchange === null || assetFromExchange === void 0 ? void 0 : assetFromExchange.decimals, !(isConfig(config) && config.abstractDecimals === false)).toString();
|
|
10165
|
-
_context.p = 11;
|
|
10166
|
-
_context.n = 12;
|
|
10167
|
-
return computeAmountOut(dex, assetFromExchange, assetTo, options, parsedAmount);
|
|
10168
|
-
case 12:
|
|
10169
|
-
amountOut = _context.v;
|
|
10170
|
-
if (amountOut > maxAmountOut) {
|
|
10171
|
-
bestExchange = dex;
|
|
10172
|
-
maxAmountOut = amountOut;
|
|
10173
|
-
}
|
|
10174
|
-
_context.n = 14;
|
|
10175
|
-
break;
|
|
10176
|
-
case 13:
|
|
10177
|
-
_context.p = 13;
|
|
10178
|
-
_t = _context.v;
|
|
10179
|
-
if (_t instanceof Error) {
|
|
10180
|
-
errors.set(dex.chain, _t);
|
|
10181
|
-
}
|
|
10182
|
-
return _context.a(3, 14);
|
|
10183
|
-
case 14:
|
|
10184
|
-
_context.n = 4;
|
|
9755
|
+
_context2.n = 4;
|
|
10185
9756
|
break;
|
|
10186
|
-
case
|
|
10187
|
-
|
|
9757
|
+
case 7:
|
|
9758
|
+
_context2.n = 9;
|
|
10188
9759
|
break;
|
|
10189
|
-
case
|
|
10190
|
-
|
|
10191
|
-
_t2 =
|
|
9760
|
+
case 8:
|
|
9761
|
+
_context2.p = 8;
|
|
9762
|
+
_t2 = _context2.v;
|
|
10192
9763
|
_iterator.e(_t2);
|
|
10193
|
-
case
|
|
10194
|
-
|
|
9764
|
+
case 9:
|
|
9765
|
+
_context2.p = 9;
|
|
10195
9766
|
_iterator.f();
|
|
10196
|
-
return
|
|
10197
|
-
case
|
|
9767
|
+
return _context2.f(9);
|
|
9768
|
+
case 10:
|
|
10198
9769
|
if (!(bestExchange === undefined)) {
|
|
10199
|
-
|
|
9770
|
+
_context2.n = 12;
|
|
10200
9771
|
break;
|
|
10201
9772
|
}
|
|
10202
9773
|
if (!(!triedAnyExchange && errors.size === 0)) {
|
|
10203
|
-
|
|
9774
|
+
_context2.n = 11;
|
|
10204
9775
|
break;
|
|
10205
9776
|
}
|
|
10206
9777
|
throw new RoutingResolutionError("No exchange found that supports asset pair: " + "".concat(JSON.stringify(assetFromOrigin === null || assetFromOrigin === void 0 ? void 0 : assetFromOrigin.symbol), " -> ").concat(JSON.stringify('symbol' in currencyTo ? currencyTo.symbol : ''), "."));
|
|
10207
|
-
case
|
|
9778
|
+
case 11:
|
|
10208
9779
|
throw new RoutingResolutionError("Could not select best exchange automatically. Please specify one manually. Errors: \n\n".concat(Array.from(errors.entries()).map(function (_ref2) {
|
|
10209
9780
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
10210
9781
|
key = _ref3[0],
|
|
10211
9782
|
value = _ref3[1];
|
|
10212
9783
|
return "".concat(key, ": ").concat(value.message);
|
|
10213
9784
|
}).join('\n\n')));
|
|
10214
|
-
case
|
|
9785
|
+
case 12:
|
|
10215
9786
|
Logger.log("Selected exchange: ".concat(bestExchange.chain));
|
|
10216
|
-
return
|
|
9787
|
+
return _context2.a(2, bestExchange);
|
|
10217
9788
|
}
|
|
10218
|
-
}, _callee, null, [[
|
|
9789
|
+
}, _callee, null, [[3, 8, 9, 10]]);
|
|
10219
9790
|
}));
|
|
10220
9791
|
return function selectBestExchangeCommon(_x, _x2, _x3) {
|
|
10221
9792
|
return _ref.apply(this, arguments);
|
|
@@ -10363,7 +9934,7 @@ var resolveAssets = function resolveAssets(dex, _ref) {
|
|
|
10363
9934
|
if (originSpecified && !assetFromOrigin) {
|
|
10364
9935
|
throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " not found in ").concat(from, "."));
|
|
10365
9936
|
}
|
|
10366
|
-
var assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.chain, assetFromOrigin) : getExchangeAsset(dex.chain, currencyFrom);
|
|
9937
|
+
var assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(from, dex.chain, assetFromOrigin) : getExchangeAsset(dex.chain, currencyFrom);
|
|
10367
9938
|
if (!assetFromExchange) {
|
|
10368
9939
|
if (!originSpecified && findAssetInfo(dex.chain, currencyFrom)) {
|
|
10369
9940
|
throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " exists in ").concat(dex.chain, " but is not swappable on ").concat(dex.chain, "."));
|
|
@@ -10374,8 +9945,8 @@ var resolveAssets = function resolveAssets(dex, _ref) {
|
|
|
10374
9945
|
if (!assetTo) {
|
|
10375
9946
|
throw new RoutingResolutionError("Currency to ".concat(JSON.stringify(currencyTo), " not found in ").concat(dex.chain, "."));
|
|
10376
9947
|
}
|
|
10377
|
-
if (destinationSpecified && !
|
|
10378
|
-
|
|
9948
|
+
if (destinationSpecified && !getSupportedAssetsImpl(dex.chain, to).some(function (asset) {
|
|
9949
|
+
return isAssetEqual(asset, assetTo);
|
|
10379
9950
|
})) {
|
|
10380
9951
|
throw new RoutingResolutionError("Currency to ".concat(JSON.stringify(currencyTo), " not supported by ").concat(to, "."));
|
|
10381
9952
|
}
|
|
@@ -10383,7 +9954,7 @@ var resolveAssets = function resolveAssets(dex, _ref) {
|
|
|
10383
9954
|
if (feeAsset && originSpecified && !feeAssetFromOrigin) {
|
|
10384
9955
|
throw new RoutingResolutionError("Fee asset ".concat(JSON.stringify(feeAsset), " not found in ").concat(from, "."));
|
|
10385
9956
|
}
|
|
10386
|
-
var feeAssetFromExchange = feeAsset ? feeAssetFromOrigin ? getExchangeAssetByOriginAsset(dex.chain, feeAssetFromOrigin) : (_getExchangeAsset = getExchangeAsset(dex.chain, feeAsset)) !== null && _getExchangeAsset !== void 0 ? _getExchangeAsset : undefined : undefined;
|
|
9957
|
+
var feeAssetFromExchange = feeAsset ? from && feeAssetFromOrigin ? getExchangeAssetByOriginAsset(from, dex.chain, feeAssetFromOrigin) : (_getExchangeAsset = getExchangeAsset(dex.chain, feeAsset)) !== null && _getExchangeAsset !== void 0 ? _getExchangeAsset : undefined : undefined;
|
|
10387
9958
|
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;
|
|
10388
9959
|
if (feeAsset && resolvedFeeAssetLocation) {
|
|
10389
9960
|
var sdkAsset = findAssetInfoOrThrow(from !== null && from !== void 0 ? from : dex.chain, {
|