@paraspell/swap 14.2.1 → 14.3.0

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 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, deepEqual, normalizeExchange, EXCHANGE_CHAINS, reverseTransformLocation, getAssetsImpl, isAssetEqual, isExternalChain, isSystemAsset, ScenarioNotSupportedError, applyDecimalAbstraction, findAssetInfo, getRelayChainOf, 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';
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' && 'signSubmitAndWatch' in tx && typeof tx.signSubmitAndWatch === '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,19 +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
2131
  {
2231
2132
  parents: 1,
2232
2133
  interior: {
@@ -2243,26 +2144,6 @@ var Hydration = {
2243
2144
  ]
2244
2145
  }
2245
2146
  },
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
2147
  {
2267
2148
  parents: 1,
2268
2149
  interior: {
@@ -2365,35 +2246,6 @@ var Hydration = {
2365
2246
  ]
2366
2247
  }
2367
2248
  },
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
2249
  {
2398
2250
  parents: 1,
2399
2251
  interior: {
@@ -2497,52 +2349,6 @@ var Hydration = {
2497
2349
  ]
2498
2350
  }
2499
2351
  },
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
2352
  {
2547
2353
  parents: 1,
2548
2354
  interior: {
@@ -2624,22 +2430,6 @@ var Hydration = {
2624
2430
  ]
2625
2431
  }
2626
2432
  },
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
2433
  {
2644
2434
  parents: 2,
2645
2435
  interior: {
@@ -2715,26 +2505,6 @@ var Hydration = {
2715
2505
  ]
2716
2506
  }
2717
2507
  },
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
2508
  {
2739
2509
  parents: 1,
2740
2510
  interior: {
@@ -2793,56 +2563,6 @@ var Hydration = {
2793
2563
  ]
2794
2564
  }
2795
2565
  },
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
2566
  {
2847
2567
  parents: 2,
2848
2568
  interior: {
@@ -2879,22 +2599,6 @@ var Hydration = {
2879
2599
  ]
2880
2600
  }
2881
2601
  },
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
2602
  {
2899
2603
  parents: 1,
2900
2604
  interior: {
@@ -2961,22 +2665,6 @@ var Hydration = {
2961
2665
  ]
2962
2666
  }
2963
2667
  },
2964
- {
2965
- parents: 1,
2966
- interior: {
2967
- X2: [
2968
- {
2969
- Parachain: 2092
2970
- },
2971
- {
2972
- GeneralKey: {
2973
- length: 2,
2974
- data: "0x0001000000000000000000000000000000000000000000000000000000000000"
2975
- }
2976
- }
2977
- ]
2978
- }
2979
- },
2980
2668
  {
2981
2669
  parents: 1,
2982
2670
  interior: {
@@ -2990,22 +2678,6 @@ var Hydration = {
2990
2678
  ]
2991
2679
  }
2992
2680
  },
2993
- {
2994
- parents: 1,
2995
- interior: {
2996
- X2: [
2997
- {
2998
- Parachain: 2000
2999
- },
3000
- {
3001
- GeneralKey: {
3002
- length: 21,
3003
- data: "0x02c80084af223c8b598536178d9361dc55bfda68180000000000000000000000"
3004
- }
3005
- }
3006
- ]
3007
- }
3008
- },
3009
2681
  {
3010
2682
  parents: 1,
3011
2683
  interior: {
@@ -3048,34 +2720,6 @@ var Hydration = {
3048
2720
  ]
3049
2721
  }
3050
2722
  },
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
2723
  {
3080
2724
  parents: 1,
3081
2725
  interior: {
@@ -3117,42 +2761,6 @@ var Hydration = {
3117
2761
  ]
3118
2762
  }
3119
2763
  },
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
2764
  {
3157
2765
  parents: 1,
3158
2766
  interior: {
@@ -3219,26 +2827,6 @@ var Hydration = {
3219
2827
  }
3220
2828
  ]
3221
2829
  }
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
2830
  }
3243
2831
  ],
3244
2832
  pairs: [
@@ -6649,15 +6237,49 @@ var Acala = {
6649
6237
  {
6650
6238
  parents: 1,
6651
6239
  interior: {
6652
- X2: [
6240
+ X2: [
6241
+ {
6242
+ Parachain: 2032
6243
+ },
6244
+ {
6245
+ GeneralKey: {
6246
+ length: 2,
6247
+ data: "0x0002000000000000000000000000000000000000000000000000000000000000"
6248
+ }
6249
+ }
6250
+ ]
6251
+ }
6252
+ }
6253
+ ],
6254
+ [
6255
+ {
6256
+ parents: 1,
6257
+ interior: {
6258
+ X3: [
6259
+ {
6260
+ Parachain: 1000
6261
+ },
6262
+ {
6263
+ PalletInstance: 50
6264
+ },
6265
+ {
6266
+ GeneralIndex: 22222012
6267
+ }
6268
+ ]
6269
+ }
6270
+ },
6271
+ {
6272
+ parents: 1,
6273
+ interior: {
6274
+ X3: [
6653
6275
  {
6654
- Parachain: 2032
6276
+ Parachain: 1000
6655
6277
  },
6656
6278
  {
6657
- GeneralKey: {
6658
- length: 2,
6659
- data: "0x0002000000000000000000000000000000000000000000000000000000000000"
6660
- }
6279
+ PalletInstance: 50
6280
+ },
6281
+ {
6282
+ GeneralIndex: 1984
6661
6283
  }
6662
6284
  ]
6663
6285
  }
@@ -6691,7 +6313,7 @@ var Acala = {
6691
6313
  PalletInstance: 50
6692
6314
  },
6693
6315
  {
6694
- GeneralIndex: 1984
6316
+ GeneralIndex: 50000069
6695
6317
  }
6696
6318
  ]
6697
6319
  }
@@ -6717,15 +6339,15 @@ var Acala = {
6717
6339
  {
6718
6340
  parents: 1,
6719
6341
  interior: {
6720
- X3: [
6721
- {
6722
- Parachain: 1000
6723
- },
6342
+ X2: [
6724
6343
  {
6725
- PalletInstance: 50
6344
+ Parachain: 2032
6726
6345
  },
6727
6346
  {
6728
- GeneralIndex: 50000069
6347
+ GeneralKey: {
6348
+ length: 2,
6349
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
6350
+ }
6729
6351
  }
6730
6352
  ]
6731
6353
  }
@@ -7173,9 +6795,15 @@ var BifrostKusama = {
7173
6795
  {
7174
6796
  parents: 1,
7175
6797
  interior: {
7176
- X1: [
6798
+ X2: [
7177
6799
  {
7178
6800
  Parachain: 2001
6801
+ },
6802
+ {
6803
+ GeneralKey: {
6804
+ length: 2,
6805
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
6806
+ }
7179
6807
  }
7180
6808
  ]
7181
6809
  }
@@ -7333,9 +6961,15 @@ var BifrostKusama = {
7333
6961
  {
7334
6962
  parents: 1,
7335
6963
  interior: {
7336
- X1: [
6964
+ X2: [
7337
6965
  {
7338
6966
  Parachain: 2001
6967
+ },
6968
+ {
6969
+ GeneralKey: {
6970
+ length: 2,
6971
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
6972
+ }
7339
6973
  }
7340
6974
  ]
7341
6975
  }
@@ -7351,9 +6985,15 @@ var BifrostKusama = {
7351
6985
  {
7352
6986
  parents: 1,
7353
6987
  interior: {
7354
- X1: [
6988
+ X2: [
7355
6989
  {
7356
6990
  Parachain: 2001
6991
+ },
6992
+ {
6993
+ GeneralKey: {
6994
+ length: 2,
6995
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
6996
+ }
7357
6997
  }
7358
6998
  ]
7359
6999
  }
@@ -7379,9 +7019,15 @@ var BifrostKusama = {
7379
7019
  {
7380
7020
  parents: 1,
7381
7021
  interior: {
7382
- X1: [
7022
+ X2: [
7383
7023
  {
7384
7024
  Parachain: 2001
7025
+ },
7026
+ {
7027
+ GeneralKey: {
7028
+ length: 2,
7029
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
7030
+ }
7385
7031
  }
7386
7032
  ]
7387
7033
  }
@@ -7602,9 +7248,15 @@ var BifrostKusama = {
7602
7248
  {
7603
7249
  parents: 1,
7604
7250
  interior: {
7605
- X1: [
7251
+ X2: [
7606
7252
  {
7607
7253
  Parachain: 2001
7254
+ },
7255
+ {
7256
+ GeneralKey: {
7257
+ length: 2,
7258
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
7259
+ }
7608
7260
  }
7609
7261
  ]
7610
7262
  }
@@ -7630,9 +7282,15 @@ var BifrostKusama = {
7630
7282
  {
7631
7283
  parents: 1,
7632
7284
  interior: {
7633
- X1: [
7285
+ X2: [
7634
7286
  {
7635
7287
  Parachain: 2001
7288
+ },
7289
+ {
7290
+ GeneralKey: {
7291
+ length: 2,
7292
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
7293
+ }
7636
7294
  }
7637
7295
  ]
7638
7296
  }
@@ -7686,9 +7344,15 @@ var BifrostPolkadot = {
7686
7344
  {
7687
7345
  parents: 1,
7688
7346
  interior: {
7689
- X1: [
7347
+ X2: [
7690
7348
  {
7691
7349
  Parachain: 2030
7350
+ },
7351
+ {
7352
+ GeneralKey: {
7353
+ length: 2,
7354
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
7355
+ }
7692
7356
  }
7693
7357
  ]
7694
7358
  }
@@ -7798,9 +7462,15 @@ var BifrostPolkadot = {
7798
7462
  {
7799
7463
  parents: 1,
7800
7464
  interior: {
7801
- X1: [
7465
+ X2: [
7802
7466
  {
7803
7467
  Parachain: 2030
7468
+ },
7469
+ {
7470
+ GeneralKey: {
7471
+ length: 2,
7472
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
7473
+ }
7804
7474
  }
7805
7475
  ]
7806
7476
  }
@@ -7857,9 +7527,15 @@ var BifrostPolkadot = {
7857
7527
  {
7858
7528
  parents: 1,
7859
7529
  interior: {
7860
- X1: [
7530
+ X2: [
7861
7531
  {
7862
7532
  Parachain: 2030
7533
+ },
7534
+ {
7535
+ GeneralKey: {
7536
+ length: 2,
7537
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
7538
+ }
7863
7539
  }
7864
7540
  ]
7865
7541
  }
@@ -7919,9 +7595,15 @@ var BifrostPolkadot = {
7919
7595
  {
7920
7596
  parents: 1,
7921
7597
  interior: {
7922
- X1: [
7598
+ X2: [
7923
7599
  {
7924
7600
  Parachain: 2030
7601
+ },
7602
+ {
7603
+ GeneralKey: {
7604
+ length: 2,
7605
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
7606
+ }
7925
7607
  }
7926
7608
  ]
7927
7609
  }
@@ -9362,7 +9044,7 @@ var BifrostExchange = /*#__PURE__*/function (_ExchangeChain) {
9362
9044
 
9363
9045
  var calculateFee = /*#__PURE__*/function () {
9364
9046
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, currencyFromDecimals, chain, toDestTransactionFee) {
9365
- var amount, slippagePct, feeCalcAddress, sender, trade, nativeAsset, substrateTx, tx, _yield$tx$getPaymentI, swapFee, feeNative, currencyFromPriceInfo, currencyFromPrice, feeInCurrencyFrom, finalFee;
9047
+ var amount, slippagePct, feeCalcAddress, sender, trade, nativeAsset, substrateTx, tx, _yield$getPaymentInfo, swapFee, feeNative, currencyFromPriceInfo, currencyFromPrice, feeInCurrencyFrom, finalFee;
9366
9048
  return _regenerator().w(function (_context) {
9367
9049
  while (1) switch (_context.n) {
9368
9050
  case 0:
@@ -9378,10 +9060,10 @@ var calculateFee = /*#__PURE__*/function () {
9378
9060
  substrateTx = _context.v;
9379
9061
  tx = substrateTx.get();
9380
9062
  _context.n = 3;
9381
- return tx.getPaymentInfo(feeCalcAddress);
9063
+ return getPaymentInfo(tx, feeCalcAddress);
9382
9064
  case 3:
9383
- _yield$tx$getPaymentI = _context.v;
9384
- swapFee = _yield$tx$getPaymentI.partial_fee;
9065
+ _yield$getPaymentInfo = _context.v;
9066
+ swapFee = _yield$getPaymentInfo.partial_fee;
9385
9067
  feeNative = swapFee + toDestTransactionFee + toDestTransactionFee;
9386
9068
  Logger.log('XCM to exch. fee:', toDestTransactionFee, nativeAsset.symbol);
9387
9069
  Logger.log('XCM to dest. fee:', toDestTransactionFee, nativeAsset.symbol);
@@ -9453,78 +9135,77 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
9453
9135
  key: "swapCurrency",
9454
9136
  value: function () {
9455
9137
  var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, toDestTransactionFee) {
9456
- var apiPapi, origin, assetFrom, assetTo, sender, slippagePct, amount, _yield$createSdkConte, tradeRouter, assetClient, txBuilderFactory, currencyFromInfo, currencyToInfo, tradeFee, amountWithoutFee, amountNormalized, trade, substrateTx, tx, amountOut, nativeCurrencyInfo, _findNativeAssetInfoO, nativeCurrencyDecimals, priceInfo, currencyToPrice, feeInCurrencyTo, amountOutModified;
9138
+ 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;
9457
9139
  return _regenerator().w(function (_context) {
9458
- while (1) switch (_context.n) {
9140
+ while (1) switch (_context.p = _context.n) {
9459
9141
  case 0:
9460
9142
  apiPapi = options.apiPapi, origin = options.origin, assetFrom = options.assetFrom, assetTo = options.assetTo, sender = options.sender, slippagePct = options.slippagePct, amount = options.amount;
9461
9143
  _context.n = 1;
9462
9144
  return createSdkContext(apiPapi);
9463
9145
  case 1:
9464
- _yield$createSdkConte = _context.v;
9465
- tradeRouter = _yield$createSdkConte.api.router;
9466
- assetClient = _yield$createSdkConte.client.asset;
9467
- txBuilderFactory = _yield$createSdkConte.tx;
9468
- _context.n = 2;
9146
+ sdk = _context.v;
9147
+ tradeRouter = sdk.api.router, assetClient = sdk.client.asset, txBuilderFactory = sdk.tx;
9148
+ _context.p = 2;
9149
+ _context.n = 3;
9469
9150
  return getAssetInfo(assetClient, assetFrom);
9470
- case 2:
9151
+ case 3:
9471
9152
  currencyFromInfo = _context.v;
9472
- _context.n = 3;
9153
+ _context.n = 4;
9473
9154
  return getAssetInfo(assetClient, assetTo);
9474
- case 3:
9155
+ case 4:
9475
9156
  currencyToInfo = _context.v;
9476
9157
  if (!(currencyFromInfo === undefined)) {
9477
- _context.n = 4;
9158
+ _context.n = 5;
9478
9159
  break;
9479
9160
  }
9480
9161
  throw new InvalidCurrencyError("Currency from doesn't exist");
9481
- case 4:
9162
+ case 5:
9482
9163
  if (!(currencyToInfo === undefined)) {
9483
- _context.n = 5;
9164
+ _context.n = 6;
9484
9165
  break;
9485
9166
  }
9486
9167
  throw new InvalidCurrencyError("Currency to doesn't exist");
9487
- case 5:
9488
- _context.n = 6;
9489
- return calculateFee(options, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, currencyFromInfo.decimals, this.chain, toDestTransactionFee);
9490
9168
  case 6:
9169
+ _context.n = 7;
9170
+ return calculateFee(options, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, currencyFromInfo.decimals, this.chain, toDestTransactionFee);
9171
+ case 7:
9491
9172
  tradeFee = _context.v;
9492
9173
  amountWithoutFee = origin ? amount - tradeFee : amount;
9493
9174
  if (!(amountWithoutFee <= 0n)) {
9494
- _context.n = 7;
9175
+ _context.n = 8;
9495
9176
  break;
9496
9177
  }
9497
9178
  throw new AmountTooLowError();
9498
- case 7:
9179
+ case 8:
9499
9180
  amountNormalized = formatUnits$1(amountWithoutFee, currencyFromInfo.decimals);
9500
9181
  Logger.log('Original amount', amount);
9501
9182
  Logger.log('Amount modified', amountWithoutFee);
9502
- _context.n = 8;
9183
+ _context.n = 9;
9503
9184
  return tradeRouter.getBestSell(currencyFromInfo.id, currencyToInfo.id, amountNormalized);
9504
- case 8:
9185
+ case 9:
9505
9186
  trade = _context.v;
9506
- _context.n = 9;
9187
+ _context.n = 10;
9507
9188
  return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(sender).build();
9508
- case 9:
9189
+ case 10:
9509
9190
  substrateTx = _context.v;
9510
9191
  tx = substrateTx.get();
9511
9192
  amountOut = trade.amountOut;
9512
- _context.n = 10;
9193
+ _context.n = 11;
9513
9194
  return getAssetInfo(assetClient, {
9514
9195
  symbol: getNativeAssetSymbol(this.chain)
9515
9196
  });
9516
- case 10:
9197
+ case 11:
9517
9198
  nativeCurrencyInfo = _context.v;
9518
9199
  if (!(nativeCurrencyInfo === undefined)) {
9519
- _context.n = 11;
9200
+ _context.n = 12;
9520
9201
  break;
9521
9202
  }
9522
9203
  throw new InvalidCurrencyError('Native currency not found');
9523
- case 11:
9204
+ case 12:
9524
9205
  _findNativeAssetInfoO = findNativeAssetInfoOrThrow(this.chain), nativeCurrencyDecimals = _findNativeAssetInfoO.decimals;
9525
- _context.n = 12;
9206
+ _context.n = 13;
9526
9207
  return tradeRouter.getSpotPrice(currencyToInfo.id, nativeCurrencyInfo.id);
9527
- case 12:
9208
+ case 13:
9528
9209
  priceInfo = _context.v;
9529
9210
  if (currencyToInfo.id === nativeCurrencyInfo.id) {
9530
9211
  priceInfo = {
@@ -9533,29 +9214,35 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
9533
9214
  };
9534
9215
  }
9535
9216
  if (!(priceInfo === undefined)) {
9536
- _context.n = 13;
9217
+ _context.n = 14;
9537
9218
  break;
9538
9219
  }
9539
9220
  throw new UnableToComputeError('Price not found');
9540
- case 13:
9221
+ case 14:
9541
9222
  currencyToPrice = priceInfo.amount;
9542
9223
  feeInCurrencyTo = toDestTransactionFee * pow10n(priceInfo.decimals + currencyToInfo.decimals) * BigInt(FEE_BUFFER_PCT) / (currencyToPrice * pow10n(nativeCurrencyDecimals) * 100n);
9543
9224
  Logger.log('Amount out fee', feeInCurrencyTo, nativeCurrencyInfo.symbol);
9544
9225
  amountOutModified = amountOut - feeInCurrencyTo;
9545
9226
  if (!(amountOutModified <= 0n)) {
9546
- _context.n = 14;
9227
+ _context.n = 15;
9547
9228
  break;
9548
9229
  }
9549
9230
  throw new AmountTooLowError();
9550
- case 14:
9231
+ case 15:
9551
9232
  Logger.log('Amount out original', amountOut);
9552
9233
  Logger.log('Amount out modified', amountOutModified);
9553
9234
  return _context.a(2, {
9554
9235
  tx: tx,
9555
9236
  amountOut: amountOutModified
9556
9237
  });
9238
+ case 16:
9239
+ _context.p = 16;
9240
+ sdk.destroy();
9241
+ return _context.f(16);
9242
+ case 17:
9243
+ return _context.a(2);
9557
9244
  }
9558
- }, _callee, this);
9245
+ }, _callee, this, [[2,, 16, 17]]);
9559
9246
  }));
9560
9247
  function swapCurrency(_x, _x2) {
9561
9248
  return _swapCurrency.apply(this, arguments);
@@ -9566,49 +9253,55 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
9566
9253
  key: "getAmountOut",
9567
9254
  value: function () {
9568
9255
  var _getAmountOut = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
9569
- var apiPapi, assetFrom, assetTo, amount, origin, _options$slippagePct, slippagePct, _yield$createSdkConte2, tradeRouter, assetClient, currencyFromInfo, currencyToInfo, pctDestFee, amountWithoutFee, amountNormalized, trade, amountOut, slippageMultiplier;
9256
+ var apiPapi, assetFrom, assetTo, amount, origin, _options$slippagePct, slippagePct, sdk, tradeRouter, assetClient, currencyFromInfo, currencyToInfo, pctDestFee, amountWithoutFee, amountNormalized, trade, amountOut, slippageMultiplier;
9570
9257
  return _regenerator().w(function (_context2) {
9571
- while (1) switch (_context2.n) {
9258
+ while (1) switch (_context2.p = _context2.n) {
9572
9259
  case 0:
9573
9260
  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;
9574
9261
  _context2.n = 1;
9575
9262
  return createSdkContext(apiPapi);
9576
9263
  case 1:
9577
- _yield$createSdkConte2 = _context2.v;
9578
- tradeRouter = _yield$createSdkConte2.api.router;
9579
- assetClient = _yield$createSdkConte2.client.asset;
9580
- _context2.n = 2;
9264
+ sdk = _context2.v;
9265
+ tradeRouter = sdk.api.router, assetClient = sdk.client.asset;
9266
+ _context2.p = 2;
9267
+ _context2.n = 3;
9581
9268
  return getAssetInfo(assetClient, assetFrom);
9582
- case 2:
9269
+ case 3:
9583
9270
  currencyFromInfo = _context2.v;
9584
- _context2.n = 3;
9271
+ _context2.n = 4;
9585
9272
  return getAssetInfo(assetClient, assetTo);
9586
- case 3:
9273
+ case 4:
9587
9274
  currencyToInfo = _context2.v;
9588
9275
  if (!(currencyFromInfo === undefined)) {
9589
- _context2.n = 4;
9276
+ _context2.n = 5;
9590
9277
  break;
9591
9278
  }
9592
9279
  throw new InvalidCurrencyError("Currency from doesn't exist");
9593
- case 4:
9280
+ case 5:
9594
9281
  if (!(currencyToInfo === undefined)) {
9595
- _context2.n = 5;
9282
+ _context2.n = 6;
9596
9283
  break;
9597
9284
  }
9598
9285
  throw new InvalidCurrencyError("Currency to doesn't exist");
9599
- case 5:
9286
+ case 6:
9600
9287
  pctDestFee = origin ? DEST_FEE_BUFFER_PCT : 0;
9601
9288
  amountWithoutFee = padValueBy(amount, pctDestFee);
9602
9289
  amountNormalized = formatUnits$1(amountWithoutFee, currencyFromInfo.decimals);
9603
- _context2.n = 6;
9290
+ _context2.n = 7;
9604
9291
  return tradeRouter.getBestSell(currencyFromInfo.id, currencyToInfo.id, amountNormalized);
9605
- case 6:
9292
+ case 7:
9606
9293
  trade = _context2.v;
9607
9294
  amountOut = trade.amountOut;
9608
9295
  slippageMultiplier = Number(slippagePct);
9609
9296
  return _context2.a(2, padValueBy(amountOut, -slippageMultiplier));
9297
+ case 8:
9298
+ _context2.p = 8;
9299
+ sdk.destroy();
9300
+ return _context2.f(8);
9301
+ case 9:
9302
+ return _context2.a(2);
9610
9303
  }
9611
- }, _callee2);
9304
+ }, _callee2, null, [[2,, 8, 9]]);
9612
9305
  }));
9613
9306
  function getAmountOut(_x3) {
9614
9307
  return _getAmountOut.apply(this, arguments);
@@ -9619,7 +9312,7 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
9619
9312
  key: "getDexConfig",
9620
9313
  value: function () {
9621
9314
  var _getDexConfig = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(api) {
9622
- var sdk, assets, sdkAssets, transformedAssets;
9315
+ var sdk, _yield$Promise$all, _yield$Promise$all2, assets, pools, sdkAssets, poolAssetIds, transformedAssets;
9623
9316
  return _regenerator().w(function (_context3) {
9624
9317
  while (1) switch (_context3.p = _context3.n) {
9625
9318
  case 0:
@@ -9629,14 +9322,27 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
9629
9322
  sdk = _context3.v;
9630
9323
  _context3.p = 2;
9631
9324
  _context3.n = 3;
9632
- return sdk.client.asset.getSupported();
9325
+ return Promise.all([sdk.client.asset.getSupported(), sdk.api.router.getPools()]);
9633
9326
  case 3:
9634
- assets = _context3.v;
9327
+ _yield$Promise$all = _context3.v;
9328
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
9329
+ assets = _yield$Promise$all2[0];
9330
+ pools = _yield$Promise$all2[1];
9635
9331
  sdkAssets = getAssets(this.chain);
9636
- transformedAssets = assets.map(function (_ref) {
9332
+ poolAssetIds = new Set(pools.flatMap(function (_ref) {
9333
+ var tokens = _ref.tokens;
9334
+ return tokens.map(function (_ref2) {
9335
+ var id = _ref2.id;
9336
+ return id.toString();
9337
+ });
9338
+ }));
9339
+ transformedAssets = assets.filter(function (_ref3) {
9340
+ var id = _ref3.id;
9341
+ return poolAssetIds.has(id.toString());
9342
+ }).map(function (_ref4) {
9637
9343
  var _sdkAssets$find;
9638
- var symbol = _ref.symbol,
9639
- id = _ref.id;
9344
+ var symbol = _ref4.symbol,
9345
+ id = _ref4.id;
9640
9346
  var asset = (_sdkAssets$find = sdkAssets.find(function (a) {
9641
9347
  return !a.isNative && a.assetId === id.toString();
9642
9348
  })) !== null && _sdkAssets$find !== void 0 ? _sdkAssets$find : sdkAssets.find(function (a) {
@@ -9740,11 +9446,19 @@ var getExchangeAsset = function getExchangeAsset(exchange, currency) {
9740
9446
  return null;
9741
9447
  };
9742
9448
 
9743
- var getExchangeAssetByOriginAsset = function getExchangeAssetByOriginAsset(exchange, originAsset) {
9744
- var exchangeAssets = getExchangeAssets(exchange);
9745
- return exchangeAssets.find(function (_ref) {
9746
- var location = _ref.location;
9747
- return deepEqual(location, originAsset.location);
9449
+ var resolveOriginAssetOnExchange = function resolveOriginAssetOnExchange(origin, exchange, transferableAssets, originAsset, ctx) {
9450
+ if (!transferableAssets.some(function (asset) {
9451
+ return isAssetEqual(asset, originAsset);
9452
+ })) return null;
9453
+ return findAssetInfoOnDestImpl(origin, exchange, {
9454
+ location: originAsset.location
9455
+ }, originAsset, ctx);
9456
+ };
9457
+ var getExchangeAssetByOriginAsset = function getExchangeAssetByOriginAsset(origin, exchange, originAsset, ctx) {
9458
+ var assetOnExchange = resolveOriginAssetOnExchange(origin, exchange, getSupportedAssetsImpl(origin, exchange, ctx), originAsset, ctx);
9459
+ if (!assetOnExchange) return undefined;
9460
+ return getExchangeAssets(exchange).find(function (asset) {
9461
+ return isAssetEqual(asset, assetOnExchange);
9748
9462
  });
9749
9463
  };
9750
9464
 
@@ -9794,16 +9508,34 @@ var getSupportedAssetsFromImpl = function getSupportedAssetsFromImpl(from, excha
9794
9508
  if (!from) return [];
9795
9509
  return getAssetsImpl(from, ctx);
9796
9510
  }
9797
- var exchangeAssets = Array.isArray(exchange) ? exchange.flatMap(function (exchange) {
9798
- return getExchangeAssets(exchange);
9799
- }) : getExchangeAssets(exchange);
9800
- if (!from || !Array.isArray(exchange) && from === createExchangeInstance(exchange).chain) {
9801
- return exchangeAssets;
9511
+ var exchanges = Array.isArray(exchange) ? exchange : [exchange];
9512
+ if (!from || !Array.isArray(exchange) && from === exchange) {
9513
+ return exchanges.flatMap(function (ex) {
9514
+ return getExchangeAssets(ex);
9515
+ });
9802
9516
  }
9517
+ var entries = exchanges.map(function (ex) {
9518
+ return {
9519
+ exchange: ex,
9520
+ exchangeAssets: getExchangeAssets(ex),
9521
+ transferableAssets: from === ex ? undefined : getSupportedAssetsImpl(from, ex, ctx)
9522
+ };
9523
+ });
9803
9524
  var fromAssets = getAssetsImpl(from, ctx);
9804
9525
  return fromAssets.filter(function (fromAsset) {
9805
- return exchangeAssets.some(function (exchangeAsset) {
9806
- return isAssetEqual(fromAsset, exchangeAsset);
9526
+ return entries.some(function (_ref) {
9527
+ var ex = _ref.exchange,
9528
+ exchangeAssets = _ref.exchangeAssets,
9529
+ transferableAssets = _ref.transferableAssets;
9530
+ if (transferableAssets === undefined) {
9531
+ return exchangeAssets.some(function (exchangeAsset) {
9532
+ return isAssetEqual(exchangeAsset, fromAsset);
9533
+ });
9534
+ }
9535
+ var assetOnExchange = resolveOriginAssetOnExchange(from, ex, transferableAssets, fromAsset, ctx);
9536
+ return assetOnExchange !== null && exchangeAssets.some(function (exchangeAsset) {
9537
+ return isAssetEqual(exchangeAsset, assetOnExchange);
9538
+ });
9807
9539
  });
9808
9540
  });
9809
9541
  };
@@ -9811,7 +9543,7 @@ var getSupportedAssetsFromImpl = function getSupportedAssetsFromImpl(from, excha
9811
9543
  * Retrieves the list of assets supported for transfer from the origin chain to the exchange chain.
9812
9544
  *
9813
9545
  * @param from - The origin chain.
9814
- * @param exchange - The exchange chain or 'Auto select'.
9546
+ * @param exchangeInput - The exchange chain or 'Auto select'.
9815
9547
  * @returns An array of supported assets.
9816
9548
  */
9817
9549
  var getSupportedAssetsFrom = function getSupportedAssetsFrom(from, exchangeInput) {
@@ -9820,50 +9552,22 @@ var getSupportedAssetsFrom = function getSupportedAssetsFrom(from, exchangeInput
9820
9552
 
9821
9553
  var getSupportedAssetsToImpl = function getSupportedAssetsToImpl(exchangeInput, to, ctx) {
9822
9554
  var exchange = normalizeExchange(exchangeInput);
9823
- if (exchange === undefined) {
9824
- var allExchangeAssets = EXCHANGE_CHAINS.map(function (exchangeChain) {
9825
- return getExchangeAssets(exchangeChain);
9826
- }).flat();
9827
- if (to) {
9828
- var toAssets = getAssetsImpl(to, ctx);
9829
- var filteredExchangeAssets = allExchangeAssets.filter(function (asset) {
9830
- return toAssets.some(function (toAsset) {
9831
- return isAssetEqual(asset, toAsset);
9832
- });
9833
- });
9834
- if (isExternalChain(to)) {
9835
- filteredExchangeAssets.push.apply(filteredExchangeAssets, _toConsumableArray(allExchangeAssets.filter(function (asset) {
9836
- return isSystemAsset(asset);
9837
- })));
9838
- }
9839
- return filteredExchangeAssets;
9840
- }
9841
- return allExchangeAssets;
9842
- }
9843
- var exchangeAssets = Array.isArray(exchange) ? exchange.flatMap(function (exchange) {
9844
- return getExchangeAssets(exchange);
9845
- }) : getExchangeAssets(exchange);
9846
- if (to) {
9847
- var _toAssets = getAssetsImpl(to, ctx);
9848
- var _filteredExchangeAssets = exchangeAssets.filter(function (asset) {
9849
- return _toAssets.some(function (toAsset) {
9850
- return isAssetEqual(asset, toAsset);
9555
+ var exchanges = exchange === undefined ? EXCHANGE_CHAINS : Array.isArray(exchange) ? exchange : [exchange];
9556
+ return exchanges.flatMap(function (ex) {
9557
+ var exchangeAssets = getExchangeAssets(ex);
9558
+ if (!to || to === ex) return exchangeAssets;
9559
+ var transferableAssets = getSupportedAssetsImpl(ex, to, ctx);
9560
+ return exchangeAssets.filter(function (asset) {
9561
+ return transferableAssets.some(function (transferable) {
9562
+ return isAssetEqual(transferable, asset);
9851
9563
  });
9852
9564
  });
9853
- if (isExternalChain(to)) {
9854
- _filteredExchangeAssets.push.apply(_filteredExchangeAssets, _toConsumableArray(exchangeAssets.filter(function (asset) {
9855
- return isSystemAsset(asset);
9856
- })));
9857
- }
9858
- return _filteredExchangeAssets;
9859
- }
9860
- return exchangeAssets;
9565
+ });
9861
9566
  };
9862
9567
  /**
9863
- * Retrieves the list of assets supported for transfer to the destination chain.
9568
+ * Retrieves the list of assets supported for transfer from the exchange chain to the destination chain.
9864
9569
  *
9865
- * @param origin - The origin chain.
9866
- * @param exchange - The exchange chain or 'Auto select'.
9570
+ * @param exchangeInput - The exchange chain or 'Auto select'.
9867
9571
  * @param to - The destination chain.
9868
9572
  * @returns An array of supported assets.
9869
9573
  */
@@ -9990,20 +9694,20 @@ var canBuildToExchangeTx = /*#__PURE__*/function () {
9990
9694
 
9991
9695
  var selectBestExchangeCommon = /*#__PURE__*/function () {
9992
9696
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, originApi, computeAmountOut) {
9993
- var api, from, exchange, to, currencyFrom, currencyTo, assetFromOrigin, filteredExchangeChains, bestExchange, maxAmountOut, errors, triedAnyExchange, _iterator, _step, exchangeChain, dex, originSpecified, destinationSpecified, assetFromExchange, assetTo, res, config, parsedAmount, amountOut, _t, _t2;
9994
- return _regenerator().w(function (_context) {
9995
- while (1) switch (_context.p = _context.n) {
9697
+ var api, from, exchange, to, currencyFrom, currencyTo, assetFromOrigin, filteredExchangeChains, bestExchange, maxAmountOut, errors, triedAnyExchange, _iterator, _step, _loop, _ret, _t2;
9698
+ return _regenerator().w(function (_context2) {
9699
+ while (1) switch (_context2.p = _context2.n) {
9996
9700
  case 0:
9997
9701
  api = options.api, from = options.from, exchange = options.exchange, to = options.to, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo;
9998
9702
  assetFromOrigin = from ? findAssetInfo(from, currencyFrom) : undefined;
9999
9703
  if (!(from && !assetFromOrigin)) {
10000
- _context.n = 1;
9704
+ _context2.n = 1;
10001
9705
  break;
10002
9706
  }
10003
9707
  throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(options.currencyFrom), " not found in ").concat(options.from, "."));
10004
9708
  case 1:
10005
9709
  if (!('id' in currencyTo)) {
10006
- _context.n = 2;
9710
+ _context2.n = 2;
10007
9711
  break;
10008
9712
  }
10009
9713
  throw new UnsupportedOperationError('Cannot select currencyTo by ID when auto-selecting is enabled. Please specify currencyTo by symbol or location.');
@@ -10014,114 +9718,126 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
10014
9718
  errors = new Map();
10015
9719
  triedAnyExchange = false;
10016
9720
  _iterator = _createForOfIteratorHelper(filteredExchangeChains);
10017
- _context.p = 3;
9721
+ _context2.p = 3;
9722
+ _loop = /*#__PURE__*/_regenerator().m(function _loop() {
9723
+ var exchangeChain, dex, originSpecified, destinationSpecified, assetFromExchange, assetTo, res, config, parsedAmount, amountOut, _t;
9724
+ return _regenerator().w(function (_context) {
9725
+ while (1) switch (_context.p = _context.n) {
9726
+ case 0:
9727
+ exchangeChain = _step.value;
9728
+ dex = createExchangeInstance(exchangeChain);
9729
+ originSpecified = from && from !== dex.chain;
9730
+ destinationSpecified = to && to !== dex.chain;
9731
+ assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(from, dex.chain, assetFromOrigin) : getExchangeAsset(dex.chain, currencyFrom);
9732
+ if (assetFromExchange) {
9733
+ _context.n = 1;
9734
+ break;
9735
+ }
9736
+ return _context.a(2, 0);
9737
+ case 1:
9738
+ assetTo = getExchangeAsset(dex.chain, currencyTo, true);
9739
+ if (assetTo) {
9740
+ _context.n = 2;
9741
+ break;
9742
+ }
9743
+ return _context.a(2, 0);
9744
+ case 2:
9745
+ if (!(destinationSpecified && !getSupportedAssetsImpl(dex.chain, to).some(function (asset) {
9746
+ return isAssetEqual(asset, assetTo);
9747
+ }))) {
9748
+ _context.n = 3;
9749
+ break;
9750
+ }
9751
+ return _context.a(2, 0);
9752
+ case 3:
9753
+ triedAnyExchange = true;
9754
+ Logger.log("Checking ".concat(exchangeChain, "..."));
9755
+ _context.n = 4;
9756
+ return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin);
9757
+ case 4:
9758
+ res = _context.v;
9759
+ if (res.success) {
9760
+ _context.n = 5;
9761
+ break;
9762
+ }
9763
+ errors.set(dex.chain, res.error);
9764
+ return _context.a(2, 0);
9765
+ case 5:
9766
+ config = api.config;
9767
+ parsedAmount = applyDecimalAbstraction(options.amount, assetFromExchange === null || assetFromExchange === void 0 ? void 0 : assetFromExchange.decimals, !(isConfig(config) && config.abstractDecimals === false)).toString();
9768
+ _context.p = 6;
9769
+ _context.n = 7;
9770
+ return computeAmountOut(dex, assetFromExchange, assetTo, options, parsedAmount);
9771
+ case 7:
9772
+ amountOut = _context.v;
9773
+ if (amountOut > maxAmountOut) {
9774
+ bestExchange = dex;
9775
+ maxAmountOut = amountOut;
9776
+ }
9777
+ _context.n = 9;
9778
+ break;
9779
+ case 8:
9780
+ _context.p = 8;
9781
+ _t = _context.v;
9782
+ if (_t instanceof Error) {
9783
+ errors.set(dex.chain, _t);
9784
+ }
9785
+ return _context.a(2, 0);
9786
+ case 9:
9787
+ return _context.a(2);
9788
+ }
9789
+ }, _loop, null, [[6, 8]]);
9790
+ });
10018
9791
  _iterator.s();
10019
9792
  case 4:
10020
9793
  if ((_step = _iterator.n()).done) {
10021
- _context.n = 15;
10022
- break;
10023
- }
10024
- exchangeChain = _step.value;
10025
- dex = createExchangeInstance(exchangeChain);
10026
- originSpecified = from && from !== dex.chain;
10027
- destinationSpecified = to && to !== dex.chain;
10028
- assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.chain, assetFromOrigin) : getExchangeAsset(dex.chain, currencyFrom);
10029
- if (assetFromExchange) {
10030
- _context.n = 5;
9794
+ _context2.n = 7;
10031
9795
  break;
10032
9796
  }
10033
- return _context.a(3, 14);
9797
+ return _context2.d(_regeneratorValues(_loop()), 5);
10034
9798
  case 5:
10035
- assetTo = getExchangeAsset(dex.chain, currencyTo, true);
10036
- if (assetTo) {
10037
- _context.n = 6;
9799
+ _ret = _context2.v;
9800
+ if (!(_ret === 0)) {
9801
+ _context2.n = 6;
10038
9802
  break;
10039
9803
  }
10040
- return _context.a(3, 14);
9804
+ return _context2.a(3, 6);
10041
9805
  case 6:
10042
- if (!(destinationSpecified && !findAssetInfo(to, {
10043
- location: assetTo.location
10044
- }))) {
10045
- _context.n = 7;
10046
- break;
10047
- }
10048
- return _context.a(3, 14);
10049
- case 7:
10050
- if (!(from && getRelayChainOf(from) !== getRelayChainOf(dex.chain))) {
10051
- _context.n = 8;
10052
- break;
10053
- }
10054
- return _context.a(3, 14);
10055
- case 8:
10056
- triedAnyExchange = true;
10057
- Logger.log("Checking ".concat(exchangeChain, "..."));
10058
- _context.n = 9;
10059
- return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin);
10060
- case 9:
10061
- res = _context.v;
10062
- if (res.success) {
10063
- _context.n = 10;
10064
- break;
10065
- }
10066
- errors.set(dex.chain, res.error);
10067
- return _context.a(3, 14);
10068
- case 10:
10069
- config = api.config;
10070
- parsedAmount = applyDecimalAbstraction(options.amount, assetFromExchange === null || assetFromExchange === void 0 ? void 0 : assetFromExchange.decimals, !(isConfig(config) && config.abstractDecimals === false)).toString();
10071
- _context.p = 11;
10072
- _context.n = 12;
10073
- return computeAmountOut(dex, assetFromExchange, assetTo, options, parsedAmount);
10074
- case 12:
10075
- amountOut = _context.v;
10076
- if (amountOut > maxAmountOut) {
10077
- bestExchange = dex;
10078
- maxAmountOut = amountOut;
10079
- }
10080
- _context.n = 14;
10081
- break;
10082
- case 13:
10083
- _context.p = 13;
10084
- _t = _context.v;
10085
- if (_t instanceof Error) {
10086
- errors.set(dex.chain, _t);
10087
- }
10088
- return _context.a(3, 14);
10089
- case 14:
10090
- _context.n = 4;
9806
+ _context2.n = 4;
10091
9807
  break;
10092
- case 15:
10093
- _context.n = 17;
9808
+ case 7:
9809
+ _context2.n = 9;
10094
9810
  break;
10095
- case 16:
10096
- _context.p = 16;
10097
- _t2 = _context.v;
9811
+ case 8:
9812
+ _context2.p = 8;
9813
+ _t2 = _context2.v;
10098
9814
  _iterator.e(_t2);
10099
- case 17:
10100
- _context.p = 17;
9815
+ case 9:
9816
+ _context2.p = 9;
10101
9817
  _iterator.f();
10102
- return _context.f(17);
10103
- case 18:
9818
+ return _context2.f(9);
9819
+ case 10:
10104
9820
  if (!(bestExchange === undefined)) {
10105
- _context.n = 20;
9821
+ _context2.n = 12;
10106
9822
  break;
10107
9823
  }
10108
9824
  if (!(!triedAnyExchange && errors.size === 0)) {
10109
- _context.n = 19;
9825
+ _context2.n = 11;
10110
9826
  break;
10111
9827
  }
10112
9828
  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 : ''), "."));
10113
- case 19:
9829
+ case 11:
10114
9830
  throw new RoutingResolutionError("Could not select best exchange automatically. Please specify one manually. Errors: \n\n".concat(Array.from(errors.entries()).map(function (_ref2) {
10115
9831
  var _ref3 = _slicedToArray(_ref2, 2),
10116
9832
  key = _ref3[0],
10117
9833
  value = _ref3[1];
10118
9834
  return "".concat(key, ": ").concat(value.message);
10119
9835
  }).join('\n\n')));
10120
- case 20:
9836
+ case 12:
10121
9837
  Logger.log("Selected exchange: ".concat(bestExchange.chain));
10122
- return _context.a(2, bestExchange);
9838
+ return _context2.a(2, bestExchange);
10123
9839
  }
10124
- }, _callee, null, [[11, 13], [3, 16, 17, 18]]);
9840
+ }, _callee, null, [[3, 8, 9, 10]]);
10125
9841
  }));
10126
9842
  return function selectBestExchangeCommon(_x, _x2, _x3) {
10127
9843
  return _ref.apply(this, arguments);
@@ -10269,7 +9985,7 @@ var resolveAssets = function resolveAssets(dex, _ref) {
10269
9985
  if (originSpecified && !assetFromOrigin) {
10270
9986
  throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " not found in ").concat(from, "."));
10271
9987
  }
10272
- var assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.chain, assetFromOrigin) : getExchangeAsset(dex.chain, currencyFrom);
9988
+ var assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(from, dex.chain, assetFromOrigin) : getExchangeAsset(dex.chain, currencyFrom);
10273
9989
  if (!assetFromExchange) {
10274
9990
  if (!originSpecified && findAssetInfo(dex.chain, currencyFrom)) {
10275
9991
  throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " exists in ").concat(dex.chain, " but is not swappable on ").concat(dex.chain, "."));
@@ -10280,8 +9996,8 @@ var resolveAssets = function resolveAssets(dex, _ref) {
10280
9996
  if (!assetTo) {
10281
9997
  throw new RoutingResolutionError("Currency to ".concat(JSON.stringify(currencyTo), " not found in ").concat(dex.chain, "."));
10282
9998
  }
10283
- if (destinationSpecified && !findAssetInfo(to, {
10284
- location: assetTo.location
9999
+ if (destinationSpecified && !getSupportedAssetsImpl(dex.chain, to).some(function (asset) {
10000
+ return isAssetEqual(asset, assetTo);
10285
10001
  })) {
10286
10002
  throw new RoutingResolutionError("Currency to ".concat(JSON.stringify(currencyTo), " not supported by ").concat(to, "."));
10287
10003
  }
@@ -10289,7 +10005,7 @@ var resolveAssets = function resolveAssets(dex, _ref) {
10289
10005
  if (feeAsset && originSpecified && !feeAssetFromOrigin) {
10290
10006
  throw new RoutingResolutionError("Fee asset ".concat(JSON.stringify(feeAsset), " not found in ").concat(from, "."));
10291
10007
  }
10292
- var feeAssetFromExchange = feeAsset ? feeAssetFromOrigin ? getExchangeAssetByOriginAsset(dex.chain, feeAssetFromOrigin) : (_getExchangeAsset = getExchangeAsset(dex.chain, feeAsset)) !== null && _getExchangeAsset !== void 0 ? _getExchangeAsset : undefined : undefined;
10008
+ var feeAssetFromExchange = feeAsset ? from && feeAssetFromOrigin ? getExchangeAssetByOriginAsset(from, dex.chain, feeAssetFromOrigin) : (_getExchangeAsset = getExchangeAsset(dex.chain, feeAsset)) !== null && _getExchangeAsset !== void 0 ? _getExchangeAsset : undefined : undefined;
10293
10009
  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;
10294
10010
  if (feeAsset && resolvedFeeAssetLocation) {
10295
10011
  var sdkAsset = findAssetInfoOrThrow(from !== null && from !== void 0 ? from : dex.chain, {