@paraspell/swap 13.4.1 → 13.6.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +55 -12
  2. package/dist/index.mjs +2052 -943
  3. package/package.json +20 -20
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createChainClient as createChainClient$1, registerSwapExtension } from '@paraspell/sdk';
2
- import { getNativeAssets, RoutingResolutionError, findAssetInfoById, getOtherAssets, getChainProviders, parseUnits, getNativeAssetSymbol, padValueBy, formatUnits as formatUnits$1, AmountTooLowError, getBalance, localizeLocation, getAssets, Parents, isSymbolMatch, getParaId, UnableToComputeError, getAssetDecimals, InvalidCurrencyError, findAssetInfoOrThrow, isOverrideLocationSpecifier, UnsupportedOperationError, isSymbolSpecifier, findBestMatches, findAssetInfoBySymbol, findAssetInfoByLoc, deepEqual, normalizeExchange, EXCHANGE_CHAINS, reverseTransformLocation, isAssetEqual, isExternalChain, isSystemAsset, TransferToAhNotSupported, ScenarioNotSupportedError, applyDecimalAbstraction, isConfig, findAssetInfo, getRelayChainOf, hasSupportForAsset, Builder, isChainEvm, convertBuilderConfig, InvalidAddressError, MissingParameterError, DryRunFailedError, handleSwapExecuteTransfer, BatchMode, dryRun, getFailureInfo, getOriginXcmFee, getXcmFee, createChainClient as createChainClient$2, getExistentialDepositOrThrow } from '@paraspell/sdk-core';
2
+ import { UnsupportedOperationError, assertCurrencyCore, dryRun, getFailureInfo, DryRunFailedError, isConfig, getNativeAssets, RoutingResolutionError, findAssetInfoById, getOtherAssets, getChainProviders, parseUnits, getNativeAssetSymbol, padValueBy, formatUnits as formatUnits$1, AmountTooLowError, getBalance, localizeLocation, getAssets, Parents, isSymbolMatch, getParaId, UnableToComputeError, getAssetDecimals, findNativeAssetInfoOrThrow, InvalidCurrencyError, findAssetInfoOrThrow, isOverrideLocationSpecifier, isSymbolSpecifier, findBestMatches, findAssetInfoBySymbol, findAssetInfoByLoc, deepEqual, normalizeExchange, EXCHANGE_CHAINS, reverseTransformLocation, getAssetsImpl, isAssetEqual, isExternalChain, isSystemAsset, TransferToAhNotSupported, ScenarioNotSupportedError, applyDecimalAbstraction, findAssetInfo, getRelayChainOf, hasSupportForAsset, 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
+ import { toHex } from 'polkadot-api/utils';
3
4
  import 'polkadot-api';
4
5
  import { Wallet } from '@acala-network/sdk';
5
6
  import { FixedPointNumber } from '@acala-network/sdk-core';
@@ -15,7 +16,7 @@ import { Trade, Pair } from '@crypto-dex-sdk/amm';
15
16
  import { ParachainId } from '@crypto-dex-sdk/chain';
16
17
  import { addressToZenlinkAssetId } from '@crypto-dex-sdk/format';
17
18
  import { DEFULT_TOKEN_LIST_MAP, WrappedTokenInfo } from '@crypto-dex-sdk/token-lists';
18
- import { BigNumber, createSdkContext } from '@galacticcouncil/sdk';
19
+ import { createSdkContext } from '@galacticcouncil/sdk-next';
19
20
  import { parseUnits as parseUnits$1, ethers } from 'ethers-v6';
20
21
 
21
22
  function _arrayLikeToArray(r, a) {
@@ -368,6 +369,66 @@ function _unsupportedIterableToArray(r, a) {
368
369
  }
369
370
  }
370
371
 
372
+ var buildExchangeApiVariant = /*#__PURE__*/function () {
373
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, builderOptions) {
374
+ var _t, _t2;
375
+ return _regenerator().w(function (_context) {
376
+ while (1) switch (_context.n) {
377
+ case 0:
378
+ if (!(dex.apiType === 'PAPI')) {
379
+ _context.n = 2;
380
+ break;
381
+ }
382
+ _context.n = 1;
383
+ return dex.createApiInstancePapi(builderOptions);
384
+ case 1:
385
+ _t = _context.v;
386
+ return _context.a(2, {
387
+ apiType: 'PAPI',
388
+ apiPapi: _t
389
+ });
390
+ case 2:
391
+ if (!(dex.apiType === 'PJS')) {
392
+ _context.n = 4;
393
+ break;
394
+ }
395
+ _context.n = 3;
396
+ return dex.createApiInstance(builderOptions);
397
+ case 3:
398
+ _t2 = _context.v;
399
+ return _context.a(2, {
400
+ apiType: 'PJS',
401
+ apiPjs: _t2
402
+ });
403
+ case 4:
404
+ return _context.a(2, {
405
+ apiType: 'GENERIC'
406
+ });
407
+ }
408
+ }, _callee);
409
+ }));
410
+ return function buildExchangeApiVariant(_x, _x2) {
411
+ return _ref.apply(this, arguments);
412
+ };
413
+ }();
414
+ var pickExchangeApiVariant = function pickExchangeApiVariant(exchange) {
415
+ if (exchange.apiType === 'PAPI') {
416
+ return {
417
+ apiType: 'PAPI',
418
+ apiPapi: exchange.apiPapi
419
+ };
420
+ }
421
+ if (exchange.apiType === 'PJS') {
422
+ return {
423
+ apiType: 'PJS',
424
+ apiPjs: exchange.apiPjs
425
+ };
426
+ }
427
+ return {
428
+ apiType: 'GENERIC'
429
+ };
430
+ };
431
+
371
432
  var calculateTxFeePjs = /*#__PURE__*/function () {
372
433
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(tx, address) {
373
434
  var _yield$tx$paymentInfo, partialFee;
@@ -388,6 +449,10 @@ var calculateTxFeePjs = /*#__PURE__*/function () {
388
449
  };
389
450
  }();
390
451
 
452
+ var isPapiTransaction = function isPapiTransaction(tx) {
453
+ return _typeof(tx) === 'object' && tx !== null && 'getEncodedData' in tx && typeof tx.getEncodedData === 'function' && 'signSubmitAndWatch' in tx && typeof tx.signSubmitAndWatch === 'function';
454
+ };
455
+
391
456
  var isPjsExtrinsic = function isPjsExtrinsic(tx) {
392
457
  return _typeof(tx) === 'object' && tx !== null && 'send' in tx && typeof tx.send === 'function' && 'signAndSend' in tx && typeof tx.signAndSend === 'function' && 'signAsync' in tx && typeof tx.signAsync === 'function' && 'paymentInfo' in tx && typeof tx.paymentInfo === 'function';
393
458
  };
@@ -399,6 +464,14 @@ var pow10n = function pow10n(d) {
399
464
  return result;
400
465
  };
401
466
 
467
+ var SAFE_INT = BigInt(Number.MAX_SAFE_INTEGER);
468
+ // JSON.stringify replacer that converts bigint to number (or hex string if out
469
+ // of safe-integer range) so papi-decoded values stringify identically to the
470
+ // numeric form used in stored asset locations.
471
+ var replaceBigIntNumeric = function replaceBigIntNumeric(_key, value) {
472
+ return typeof value === 'bigint' ? value <= SAFE_INT ? Number(value) : "0x".concat(value.toString(16)) : value;
473
+ };
474
+
402
475
  var stripHeaderBytes = function stripHeaderBytes(hex, byteCount) {
403
476
  return '0x' + hex.slice(2 + byteCount * 2);
404
477
  };
@@ -413,44 +486,236 @@ var convertTxToTarget = /*#__PURE__*/function () {
413
486
  _context.n = 1;
414
487
  break;
415
488
  }
416
- _t = tx.toHex();
417
- _context.n = 3;
489
+ hex = tx.toHex();
490
+ _context.n = 5;
418
491
  break;
419
492
  case 1:
493
+ if (!isPapiTransaction(tx)) {
494
+ _context.n = 3;
495
+ break;
496
+ }
497
+ _t = toHex;
420
498
  _context.n = 2;
421
- return api.txToHex(tx);
499
+ return tx.getEncodedData();
422
500
  case 2:
423
- _t = _context.v;
501
+ hex = _t(_context.v);
502
+ _context.n = 5;
503
+ break;
424
504
  case 3:
425
- hex = _t;
505
+ _context.n = 4;
506
+ return api.txToHex(tx);
507
+ case 4:
508
+ hex = _context.v;
509
+ case 5:
426
510
  if (!(isPjsTx && api.type === 'PAPI')) {
427
- _context.n = 8;
511
+ _context.n = 10;
428
512
  break;
429
513
  }
430
- _context.p = 4;
514
+ _context.p = 6;
431
515
  hex2 = stripHeaderBytes(hex, 2);
432
- _context.n = 5;
516
+ _context.n = 7;
433
517
  return api.txFromHex(hex2);
434
- case 5:
518
+ case 7:
435
519
  return _context.a(2, _context.v);
436
- case 6:
437
- _context.p = 6;
520
+ case 8:
521
+ _context.p = 8;
438
522
  _context.v;
439
523
  hex3 = stripHeaderBytes(hex, 3);
440
- _context.n = 7;
524
+ _context.n = 9;
441
525
  return api.txFromHex(hex3);
442
- case 7:
526
+ case 9:
443
527
  return _context.a(2, _context.v);
444
- case 8:
528
+ case 10:
445
529
  return _context.a(2, api.txFromHex(hex));
446
530
  }
447
- }, _callee, null, [[4, 6]]);
531
+ }, _callee, null, [[6, 8]]);
448
532
  }));
449
533
  return function convertTxToTarget(_x, _x2) {
450
534
  return _ref.apply(this, arguments);
451
535
  };
452
536
  }();
453
537
 
538
+ var assignIsExchange = function assignIsExchange(result, options) {
539
+ var origin = options.origin,
540
+ exchange = options.exchange,
541
+ destination = options.destination;
542
+ if (!origin) {
543
+ result.origin.isExchange = true;
544
+ }
545
+ if (!destination && result.destination) {
546
+ result.destination.isExchange = true;
547
+ }
548
+ result.hops = result.hops.map(function (hop) {
549
+ var isExchange = hop.chain === exchange.chain;
550
+ return _objectSpread2(_objectSpread2({}, hop), {}, {
551
+ result: _objectSpread2(_objectSpread2({}, hop.result), {}, {
552
+ isExchange: isExchange
553
+ }),
554
+ isExchange: isExchange
555
+ });
556
+ });
557
+ return result;
558
+ };
559
+ var dryRunTransaction = /*#__PURE__*/function () {
560
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, transaction, destChain, bypassOptions) {
561
+ var _ref2;
562
+ var api, exchange, sender, evmSenderAddress, destination, currencyFrom, currencyTo, amount, tx, chain, senderResolved, resolvedDest;
563
+ return _regenerator().w(function (_context) {
564
+ while (1) switch (_context.n) {
565
+ case 0:
566
+ api = options.api, exchange = options.exchange, sender = options.sender, evmSenderAddress = options.evmSenderAddress, destination = options.destination, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, amount = options.amount;
567
+ tx = transaction.tx, chain = transaction.chain;
568
+ assertCurrencyCore(currencyTo);
569
+ senderResolved = evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender;
570
+ resolvedDest = (_ref2 = destChain !== null && destChain !== void 0 ? destChain : destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _ref2 !== void 0 ? _ref2 : exchange.chain;
571
+ return _context.a(2, dryRun({
572
+ api: api.clone(),
573
+ tx: tx,
574
+ origin: chain,
575
+ destination: resolvedDest,
576
+ sender: senderResolved,
577
+ swapConfig: {
578
+ currencyTo: currencyTo,
579
+ exchangeChain: exchange.chain
580
+ },
581
+ currency: _objectSpread2(_objectSpread2({}, currencyFrom), {}, {
582
+ amount: BigInt(amount)
583
+ }),
584
+ bypassOptions: bypassOptions
585
+ }));
586
+ }
587
+ }, _callee);
588
+ }));
589
+ return function dryRunTransaction(_x, _x2, _x3, _x4) {
590
+ return _ref.apply(this, arguments);
591
+ };
592
+ }();
593
+ var mergeDryRunResults = function mergeDryRunResults(options, originResult, exchangeResult) {
594
+ var exchange = options.exchange,
595
+ destination = options.destination;
596
+ var result = {
597
+ origin: originResult.origin,
598
+ destination: destination ? exchangeResult.destination : exchangeResult.origin,
599
+ hops: [].concat(_toConsumableArray(originResult.hops), _toConsumableArray(destination ? [{
600
+ chain: exchange.chain,
601
+ result: exchangeResult.origin
602
+ }] : []), _toConsumableArray(exchangeResult.hops))
603
+ };
604
+ return _objectSpread2(_objectSpread2({}, getFailureInfo(result)), result);
605
+ };
606
+ var dryRun2Transactions = /*#__PURE__*/function () {
607
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, transactions, originBypass, exchangeBypass) {
608
+ var _originBypass$mintFee;
609
+ var exchange, _transactions, firstTx, secondTx, firstRes, _getFailureInfo, failureReason, exchangeBypassOptions, secondRes;
610
+ return _regenerator().w(function (_context2) {
611
+ while (1) switch (_context2.n) {
612
+ case 0:
613
+ exchange = options.exchange;
614
+ _transactions = _slicedToArray(transactions, 2), firstTx = _transactions[0], secondTx = _transactions[1];
615
+ _context2.n = 1;
616
+ return dryRunTransaction(options, firstTx, exchange.chain, originBypass);
617
+ case 1:
618
+ firstRes = _context2.v;
619
+ _getFailureInfo = getFailureInfo(firstRes), failureReason = _getFailureInfo.failureReason;
620
+ exchangeBypassOptions = exchangeBypass !== null && exchangeBypass !== void 0 ? exchangeBypass : !failureReason ? {
621
+ sentAssetMintMode: 'preview',
622
+ mintFeeAssets: (_originBypass$mintFee = originBypass === null || originBypass === void 0 ? void 0 : originBypass.mintFeeAssets) !== null && _originBypass$mintFee !== void 0 ? _originBypass$mintFee : false
623
+ } : undefined;
624
+ _context2.n = 2;
625
+ return dryRunTransaction(options, secondTx, undefined, exchangeBypassOptions);
626
+ case 2:
627
+ secondRes = _context2.v;
628
+ return _context2.a(2, mergeDryRunResults(options, firstRes, secondRes));
629
+ }
630
+ }, _callee2);
631
+ }));
632
+ return function dryRun2Transactions(_x5, _x6, _x7, _x8) {
633
+ return _ref3.apply(this, arguments);
634
+ };
635
+ }();
636
+ var dryRunTransactions = function dryRunTransactions(transactions, options, originBypass, exchangeBypass) {
637
+ if (transactions.length === 1) {
638
+ return dryRunTransaction(options, transactions[0], undefined, originBypass);
639
+ }
640
+ if (transactions.length === 2) {
641
+ return dryRun2Transactions(options, transactions, originBypass, exchangeBypass);
642
+ }
643
+ throw new UnsupportedOperationError('Router dry run supports up to two transactions per flow.');
644
+ };
645
+ var runDryRun = /*#__PURE__*/function () {
646
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(initialOptions, originBypassOptions) {
647
+ var _yield$prepareTransfo, options, dex, routerPlan, result;
648
+ return _regenerator().w(function (_context3) {
649
+ while (1) switch (_context3.n) {
650
+ case 0:
651
+ validateTransferOptions(initialOptions);
652
+ _context3.n = 1;
653
+ return prepareTransformedOptions(initialOptions);
654
+ case 1:
655
+ _yield$prepareTransfo = _context3.v;
656
+ options = _yield$prepareTransfo.options;
657
+ dex = _yield$prepareTransfo.dex;
658
+ _context3.n = 2;
659
+ return buildTransactions(dex, options);
660
+ case 2:
661
+ routerPlan = _context3.v;
662
+ _context3.n = 3;
663
+ return dryRunTransactions(routerPlan, options, originBypassOptions);
664
+ case 3:
665
+ result = _context3.v;
666
+ return _context3.a(2, assignIsExchange(result, options));
667
+ }
668
+ }, _callee3);
669
+ }));
670
+ return function runDryRun(_x9, _x0) {
671
+ return _ref4.apply(this, arguments);
672
+ };
673
+ }();
674
+ var dryRunRouter = function dryRunRouter(initialOptions) {
675
+ return runDryRun(initialOptions);
676
+ };
677
+ var dryRunRouterPreview = function dryRunRouterPreview(initialOptions, previewOptions) {
678
+ return runDryRun(initialOptions, {
679
+ sentAssetMintMode: 'preview',
680
+ mintFeeAssets: previewOptions === null || previewOptions === void 0 ? void 0 : previewOptions.mintFeeAssets
681
+ });
682
+ };
683
+
684
+ var BYPASS = {
685
+ sentAssetMintMode: 'bypass'
686
+ };
687
+ var maybePerformXcmFormatCheck = /*#__PURE__*/function () {
688
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, options, routerPlan) {
689
+ var config, result;
690
+ return _regenerator().w(function (_context) {
691
+ while (1) switch (_context.n) {
692
+ case 0:
693
+ config = api.config;
694
+ if (!(!isConfig(config) || !config.xcmFormatCheck)) {
695
+ _context.n = 1;
696
+ break;
697
+ }
698
+ return _context.a(2);
699
+ case 1:
700
+ _context.n = 2;
701
+ return dryRunTransactions(routerPlan, options, BYPASS, BYPASS);
702
+ case 2:
703
+ result = _context.v;
704
+ if (!result.failureReason) {
705
+ _context.n = 3;
706
+ break;
707
+ }
708
+ throw new DryRunFailedError(result.failureReason, result.failureChain, 'XCM format check failed.');
709
+ case 3:
710
+ return _context.a(2);
711
+ }
712
+ }, _callee);
713
+ }));
714
+ return function maybePerformXcmFormatCheck(_x, _x2, _x3) {
715
+ return _ref.apply(this, arguments);
716
+ };
717
+ }();
718
+
454
719
  var AssetHubPolkadot = {
455
720
  isOmni: true,
456
721
  assets: [
@@ -1150,6 +1415,16 @@ var AssetHubPaseo = {
1150
1415
  ]
1151
1416
  }
1152
1417
  },
1418
+ {
1419
+ parents: 1,
1420
+ interior: {
1421
+ X1: [
1422
+ {
1423
+ Parachain: 3377
1424
+ }
1425
+ ]
1426
+ }
1427
+ },
1153
1428
  {
1154
1429
  parents: 1,
1155
1430
  interior: {
@@ -1272,17 +1547,13 @@ var Hydration = {
1272
1547
  isOmni: true,
1273
1548
  assets: [
1274
1549
  {
1275
- parents: 1,
1550
+ parents: 2,
1276
1551
  interior: {
1277
- X3: [
1278
- {
1279
- Parachain: 1000
1280
- },
1281
- {
1282
- PalletInstance: 50
1283
- },
1552
+ X1: [
1284
1553
  {
1285
- GeneralIndex: 1337
1554
+ GlobalConsensus: {
1555
+ kusama: null
1556
+ }
1286
1557
  }
1287
1558
  ]
1288
1559
  }
@@ -1297,7 +1568,7 @@ var Hydration = {
1297
1568
  {
1298
1569
  AccountKey20: {
1299
1570
  network: null,
1300
- key: "0x2ec4884088d84e5c2970a034732e5209b0acfa93"
1571
+ key: "0x52e1311e26610e6662a1e5b5bd113130b6815213"
1301
1572
  }
1302
1573
  }
1303
1574
  ]
@@ -1306,15 +1577,15 @@ var Hydration = {
1306
1577
  {
1307
1578
  parents: 1,
1308
1579
  interior: {
1309
- X3: [
1310
- {
1311
- Parachain: 1000
1312
- },
1580
+ X2: [
1313
1581
  {
1314
- PalletInstance: 50
1582
+ Parachain: 2034
1315
1583
  },
1316
1584
  {
1317
- GeneralIndex: 1984
1585
+ AccountKey20: {
1586
+ network: null,
1587
+ key: "0x531a654d1696ed52e7275a8cede955e82620f99a"
1588
+ }
1318
1589
  }
1319
1590
  ]
1320
1591
  }
@@ -1329,7 +1600,7 @@ var Hydration = {
1329
1600
  {
1330
1601
  AccountKey20: {
1331
1602
  network: null,
1332
- key: "0xc64980e4eaf9a1151bd21712b9946b81e41e2b92"
1603
+ key: "0x2b55b6a5751f26c5cfb02429085bfd5236751443"
1333
1604
  }
1334
1605
  }
1335
1606
  ]
@@ -1338,17 +1609,14 @@ var Hydration = {
1338
1609
  {
1339
1610
  parents: 1,
1340
1611
  interior: {
1341
- X3: [
1342
- {
1343
- Parachain: 2004
1344
- },
1612
+ X2: [
1345
1613
  {
1346
- PalletInstance: 110
1614
+ Parachain: 2034
1347
1615
  },
1348
1616
  {
1349
1617
  AccountKey20: {
1350
1618
  network: null,
1351
- key: "0xe57ebd2d67b462e9926e04a8e33f01cd0d64346d"
1619
+ key: "0x987ddc8b236fb23e1e48882b206396ca9b42648b"
1352
1620
  }
1353
1621
  }
1354
1622
  ]
@@ -1364,7 +1632,7 @@ var Hydration = {
1364
1632
  {
1365
1633
  AccountKey20: {
1366
1634
  network: null,
1367
- key: "0x02759d14d0d4f452b9c76f5a230750e8857d36f2"
1635
+ key: "0x8a598fe3e3a471ce865332e330d303502a0e2f52"
1368
1636
  }
1369
1637
  }
1370
1638
  ]
@@ -1373,7 +1641,30 @@ var Hydration = {
1373
1641
  {
1374
1642
  parents: 1,
1375
1643
  interior: {
1376
- Here: null
1644
+ X2: [
1645
+ {
1646
+ Parachain: 2034
1647
+ },
1648
+ {
1649
+ GeneralIndex: 0
1650
+ }
1651
+ ]
1652
+ }
1653
+ },
1654
+ {
1655
+ parents: 1,
1656
+ interior: {
1657
+ X3: [
1658
+ {
1659
+ Parachain: 1000
1660
+ },
1661
+ {
1662
+ PalletInstance: 50
1663
+ },
1664
+ {
1665
+ GeneralIndex: 1984
1666
+ }
1667
+ ]
1377
1668
  }
1378
1669
  },
1379
1670
  {
@@ -1397,12 +1688,12 @@ var Hydration = {
1397
1688
  interior: {
1398
1689
  X2: [
1399
1690
  {
1400
- Parachain: 2030
1691
+ Parachain: 2034
1401
1692
  },
1402
1693
  {
1403
- GeneralKey: {
1404
- length: 2,
1405
- data: "0x0900000000000000000000000000000000000000000000000000000000000000"
1694
+ AccountKey20: {
1695
+ network: null,
1696
+ key: "0x1806860d27ee903c1ec7586d4f7d598d7591f124"
1406
1697
  }
1407
1698
  }
1408
1699
  ]
@@ -1413,32 +1704,31 @@ var Hydration = {
1413
1704
  interior: {
1414
1705
  X2: [
1415
1706
  {
1416
- Parachain: 2034
1707
+ Parachain: 2000
1417
1708
  },
1418
1709
  {
1419
- AccountKey20: {
1420
- network: null,
1421
- key: "0x0e13b904f4168f93814216b6874ca8349457f263"
1710
+ GeneralKey: {
1711
+ length: 21,
1712
+ data: "0x025a4d6acdc4e3e5ab15717f407afe957f7a2425780000000000000000000000"
1422
1713
  }
1423
1714
  }
1424
1715
  ]
1425
1716
  }
1426
1717
  },
1427
1718
  {
1428
- parents: 2,
1719
+ parents: 1,
1429
1720
  interior: {
1430
- X2: [
1721
+ X3: [
1431
1722
  {
1432
- GlobalConsensus: {
1433
- Ethereum: {
1434
- chainId: 1
1435
- }
1436
- }
1723
+ Parachain: 2004
1724
+ },
1725
+ {
1726
+ PalletInstance: 110
1437
1727
  },
1438
1728
  {
1439
1729
  AccountKey20: {
1440
1730
  network: null,
1441
- key: "0x18084fba666a33d37592fa2633fd49a74dd93a88"
1731
+ key: "0x931715fee2d06333043d11f658c8ce934ac61d0c"
1442
1732
  }
1443
1733
  }
1444
1734
  ]
@@ -1447,14 +1737,27 @@ var Hydration = {
1447
1737
  {
1448
1738
  parents: 1,
1449
1739
  interior: {
1450
- X2: [
1740
+ X1: [
1451
1741
  {
1452
- Parachain: 2034
1742
+ Parachain: 2086
1743
+ }
1744
+ ]
1745
+ }
1746
+ },
1747
+ {
1748
+ parents: 1,
1749
+ interior: {
1750
+ X3: [
1751
+ {
1752
+ Parachain: 2004
1753
+ },
1754
+ {
1755
+ PalletInstance: 110
1453
1756
  },
1454
1757
  {
1455
1758
  AccountKey20: {
1456
1759
  network: null,
1457
- key: "0x69003a65189f6ed993d3bd3e2b74f1db39f405ce"
1760
+ key: "0xab3f0245b83feb11d15aaffefd7ad465a59817ed"
1458
1761
  }
1459
1762
  }
1460
1763
  ]
@@ -1462,31 +1765,65 @@ var Hydration = {
1462
1765
  },
1463
1766
  {
1464
1767
  parents: 1,
1768
+ interior: {
1769
+ X3: [
1770
+ {
1771
+ Parachain: 2094
1772
+ },
1773
+ {
1774
+ PalletInstance: 53
1775
+ },
1776
+ {
1777
+ GeneralIndex: 2
1778
+ }
1779
+ ]
1780
+ }
1781
+ },
1782
+ {
1783
+ parents: 1,
1784
+ interior: {
1785
+ X1: [
1786
+ {
1787
+ Parachain: 3369
1788
+ }
1789
+ ]
1790
+ }
1791
+ },
1792
+ {
1793
+ parents: 2,
1465
1794
  interior: {
1466
1795
  X2: [
1467
1796
  {
1468
- Parachain: 2034
1797
+ GlobalConsensus: {
1798
+ Ethereum: {
1799
+ chainId: 1
1800
+ }
1801
+ }
1469
1802
  },
1470
1803
  {
1471
1804
  AccountKey20: {
1472
1805
  network: null,
1473
- key: "0x34d5ffb83d14d82f87aaf2f13be895a3c814c2ad"
1806
+ key: "0x45804880de22913dafe09f4980848ece6ecbaf78"
1474
1807
  }
1475
1808
  }
1476
1809
  ]
1477
1810
  }
1478
1811
  },
1479
1812
  {
1480
- parents: 1,
1813
+ parents: 2,
1481
1814
  interior: {
1482
1815
  X2: [
1483
1816
  {
1484
- Parachain: 2034
1817
+ GlobalConsensus: {
1818
+ Ethereum: {
1819
+ chainId: 1
1820
+ }
1821
+ }
1485
1822
  },
1486
1823
  {
1487
1824
  AccountKey20: {
1488
1825
  network: null,
1489
- key: "0x8a598fe3e3a471ce865332e330d303502a0e2f52"
1826
+ key: "0x57e114b691db790c35207b2e685d4a43181e6061"
1490
1827
  }
1491
1828
  }
1492
1829
  ]
@@ -1511,13 +1848,10 @@ var Hydration = {
1511
1848
  interior: {
1512
1849
  X2: [
1513
1850
  {
1514
- Parachain: 2034
1851
+ Parachain: 2004
1515
1852
  },
1516
1853
  {
1517
- AccountKey20: {
1518
- network: null,
1519
- key: "0x11a8f7ffbb7e0fbed88bc20179dd45b4bd6874ff"
1520
- }
1854
+ PalletInstance: 10
1521
1855
  }
1522
1856
  ]
1523
1857
  }
@@ -1527,12 +1861,12 @@ var Hydration = {
1527
1861
  interior: {
1528
1862
  X2: [
1529
1863
  {
1530
- Parachain: 2034
1864
+ Parachain: 2032
1531
1865
  },
1532
1866
  {
1533
- AccountKey20: {
1534
- network: null,
1535
- key: "0xc09cf2f85367f3c2ab66e094283de3a499cb9108"
1867
+ GeneralKey: {
1868
+ length: 2,
1869
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
1536
1870
  }
1537
1871
  }
1538
1872
  ]
@@ -1548,7 +1882,7 @@ var Hydration = {
1548
1882
  {
1549
1883
  AccountKey20: {
1550
1884
  network: null,
1551
- key: "0x35774c305aaf441a102d47988d35f0f5428471b3"
1885
+ key: "0xc09cf2f85367f3c2ab66e094283de3a499cb9108"
1552
1886
  }
1553
1887
  }
1554
1888
  ]
@@ -1557,15 +1891,15 @@ var Hydration = {
1557
1891
  {
1558
1892
  parents: 1,
1559
1893
  interior: {
1560
- X2: [
1894
+ X3: [
1561
1895
  {
1562
- Parachain: 2034
1896
+ Parachain: 1000
1563
1897
  },
1564
1898
  {
1565
- AccountKey20: {
1566
- network: null,
1567
- key: "0x1806860d27ee903c1ec7586d4f7d598d7591f124"
1568
- }
1899
+ PalletInstance: 50
1900
+ },
1901
+ {
1902
+ GeneralIndex: 31337
1569
1903
  }
1570
1904
  ]
1571
1905
  }
@@ -1591,12 +1925,12 @@ var Hydration = {
1591
1925
  interior: {
1592
1926
  X2: [
1593
1927
  {
1594
- Parachain: 2034
1928
+ Parachain: 2000
1595
1929
  },
1596
1930
  {
1597
- AccountKey20: {
1598
- network: null,
1599
- key: "0x52e1311e26610e6662a1e5b5bd113130b6815213"
1931
+ GeneralKey: {
1932
+ length: 2,
1933
+ data: "0x0000000000000000000000000000000000000000000000000000000000000000"
1600
1934
  }
1601
1935
  }
1602
1936
  ]
@@ -1616,7 +1950,7 @@ var Hydration = {
1616
1950
  {
1617
1951
  AccountKey20: {
1618
1952
  network: null,
1619
- key: "0x45804880de22913dafe09f4980848ece6ecbaf78"
1953
+ key: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
1620
1954
  }
1621
1955
  }
1622
1956
  ]
@@ -1627,12 +1961,12 @@ var Hydration = {
1627
1961
  interior: {
1628
1962
  X2: [
1629
1963
  {
1630
- Parachain: 2034
1964
+ Parachain: 2030
1631
1965
  },
1632
1966
  {
1633
- AccountKey20: {
1634
- network: null,
1635
- key: "0x00f283c7a97ecb60dd905cdab52febceec04dc0f"
1967
+ GeneralKey: {
1968
+ length: 2,
1969
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
1636
1970
  }
1637
1971
  }
1638
1972
  ]
@@ -1641,17 +1975,14 @@ var Hydration = {
1641
1975
  {
1642
1976
  parents: 1,
1643
1977
  interior: {
1644
- X3: [
1645
- {
1646
- Parachain: 2004
1647
- },
1978
+ X2: [
1648
1979
  {
1649
- PalletInstance: 110
1980
+ Parachain: 2034
1650
1981
  },
1651
1982
  {
1652
1983
  AccountKey20: {
1653
1984
  network: null,
1654
- key: "0x52b2f622f5676e92dbea3092004eb9ffb85a8d07"
1985
+ key: "0x69003a65189f6ed993d3bd3e2b74f1db39f405ce"
1655
1986
  }
1656
1987
  }
1657
1988
  ]
@@ -1662,28 +1993,32 @@ var Hydration = {
1662
1993
  interior: {
1663
1994
  X2: [
1664
1995
  {
1665
- Parachain: 2034
1996
+ Parachain: 2000
1666
1997
  },
1667
1998
  {
1668
- AccountKey20: {
1669
- network: null,
1670
- key: "0x4c892a298a9c6b4ced988b3d6e9cf93333aadcf7"
1999
+ GeneralKey: {
2000
+ length: 21,
2001
+ data: "0x02f4c723e61709d90f89939c1852f516e373d418a80000000000000000000000"
1671
2002
  }
1672
2003
  }
1673
2004
  ]
1674
2005
  }
1675
2006
  },
1676
2007
  {
1677
- parents: 1,
2008
+ parents: 2,
1678
2009
  interior: {
1679
2010
  X2: [
1680
2011
  {
1681
- Parachain: 2034
2012
+ GlobalConsensus: {
2013
+ Ethereum: {
2014
+ chainId: 1
2015
+ }
2016
+ }
1682
2017
  },
1683
2018
  {
1684
2019
  AccountKey20: {
1685
2020
  network: null,
1686
- key: "0xf5f744a4d14a5f49ce173e39b8361733a6e55152"
2021
+ key: "0x5a98fcbea516cf06857215779fd812ca3bef1b32"
1687
2022
  }
1688
2023
  }
1689
2024
  ]
@@ -1702,23 +2037,27 @@ var Hydration = {
1702
2037
  {
1703
2038
  AccountKey20: {
1704
2039
  network: null,
1705
- key: "0x99fec54a5ad36d50a4bba3a41cab983a5bb86a7d"
2040
+ key: "0xe57ebd2d67b462e9926e04a8e33f01cd0d64346d"
1706
2041
  }
1707
2042
  }
1708
2043
  ]
1709
2044
  }
1710
2045
  },
1711
2046
  {
1712
- parents: 1,
2047
+ parents: 2,
1713
2048
  interior: {
1714
2049
  X2: [
1715
2050
  {
1716
- Parachain: 2034
2051
+ GlobalConsensus: {
2052
+ Ethereum: {
2053
+ chainId: 1
2054
+ }
2055
+ }
1717
2056
  },
1718
2057
  {
1719
2058
  AccountKey20: {
1720
2059
  network: null,
1721
- key: "0x2b55b6a5751f26c5cfb02429085bfd5236751443"
2060
+ key: "0x56072c95faa701256059aa122697b133aded9279"
1722
2061
  }
1723
2062
  }
1724
2063
  ]
@@ -1727,33 +2066,34 @@ var Hydration = {
1727
2066
  {
1728
2067
  parents: 1,
1729
2068
  interior: {
1730
- X3: [
1731
- {
1732
- Parachain: 2004
1733
- },
2069
+ X2: [
1734
2070
  {
1735
- PalletInstance: 110
2071
+ Parachain: 2034
1736
2072
  },
1737
2073
  {
1738
2074
  AccountKey20: {
1739
2075
  network: null,
1740
- key: "0x3f9610a50630bc7d4530736942ee2bc9e00e8de8"
2076
+ key: "0x49f925bf72718f4abbc57adef1b705931f928a2a"
1741
2077
  }
1742
2078
  }
1743
2079
  ]
1744
2080
  }
1745
2081
  },
1746
2082
  {
1747
- parents: 1,
2083
+ parents: 2,
1748
2084
  interior: {
1749
2085
  X2: [
1750
2086
  {
1751
- Parachain: 2034
2087
+ GlobalConsensus: {
2088
+ Ethereum: {
2089
+ chainId: 1
2090
+ }
2091
+ }
1752
2092
  },
1753
2093
  {
1754
2094
  AccountKey20: {
1755
2095
  network: null,
1756
- key: "0xca30f9ff99394c55deda293df223e3740635c72e"
2096
+ key: "0xaa7a9ca87d3694b5755f213b5d04094b8d0f0a6f"
1757
2097
  }
1758
2098
  }
1759
2099
  ]
@@ -1764,13 +2104,10 @@ var Hydration = {
1764
2104
  interior: {
1765
2105
  X2: [
1766
2106
  {
1767
- Parachain: 2034
2107
+ Parachain: 2043
1768
2108
  },
1769
2109
  {
1770
- AccountKey20: {
1771
- network: null,
1772
- key: "0x49f925bf72718f4abbc57adef1b705931f928a2a"
1773
- }
2110
+ PalletInstance: 10
1774
2111
  }
1775
2112
  ]
1776
2113
  }
@@ -1780,13 +2117,10 @@ var Hydration = {
1780
2117
  interior: {
1781
2118
  X2: [
1782
2119
  {
1783
- Parachain: 2034
2120
+ Parachain: 2046
1784
2121
  },
1785
2122
  {
1786
- AccountKey20: {
1787
- network: null,
1788
- key: "0x987ddc8b236fb23e1e48882b206396ca9b42648b"
1789
- }
2123
+ PalletInstance: 5
1790
2124
  }
1791
2125
  ]
1792
2126
  }
@@ -1796,33 +2130,33 @@ var Hydration = {
1796
2130
  interior: {
1797
2131
  X2: [
1798
2132
  {
1799
- Parachain: 2034
2133
+ Parachain: 2030
1800
2134
  },
1801
2135
  {
1802
- GeneralIndex: 0
2136
+ GeneralKey: {
2137
+ length: 2,
2138
+ data: "0x0903000000000000000000000000000000000000000000000000000000000000"
2139
+ }
1803
2140
  }
1804
2141
  ]
1805
2142
  }
1806
2143
  },
1807
2144
  {
1808
- parents: 1,
1809
- interior: {
1810
- X1: [
1811
- {
1812
- Parachain: 2008
1813
- }
1814
- ]
1815
- }
1816
- },
1817
- {
1818
- parents: 1,
2145
+ parents: 2,
1819
2146
  interior: {
1820
2147
  X2: [
1821
2148
  {
1822
- Parachain: 2026
2149
+ GlobalConsensus: {
2150
+ Ethereum: {
2151
+ chainId: 1
2152
+ }
2153
+ }
1823
2154
  },
1824
2155
  {
1825
- PalletInstance: 2
2156
+ AccountKey20: {
2157
+ network: null,
2158
+ key: "0xcccccccccc33d538dbc2ee4feab0a7a1ff4e8a94"
2159
+ }
1826
2160
  }
1827
2161
  ]
1828
2162
  }
@@ -1830,9 +2164,18 @@ var Hydration = {
1830
2164
  {
1831
2165
  parents: 1,
1832
2166
  interior: {
1833
- X1: [
2167
+ X3: [
1834
2168
  {
1835
- Parachain: 2037
2169
+ Parachain: 2004
2170
+ },
2171
+ {
2172
+ PalletInstance: 110
2173
+ },
2174
+ {
2175
+ AccountKey20: {
2176
+ network: null,
2177
+ key: "0x3f9610a50630bc7d4530736942ee2bc9e00e8de8"
2178
+ }
1836
2179
  }
1837
2180
  ]
1838
2181
  }
@@ -1840,9 +2183,15 @@ var Hydration = {
1840
2183
  {
1841
2184
  parents: 1,
1842
2185
  interior: {
1843
- X1: [
2186
+ X2: [
1844
2187
  {
1845
- Parachain: 3369
2188
+ Parachain: 2030
2189
+ },
2190
+ {
2191
+ GeneralKey: {
2192
+ length: 2,
2193
+ data: "0x0900000000000000000000000000000000000000000000000000000000000000"
2194
+ }
1846
2195
  }
1847
2196
  ]
1848
2197
  }
@@ -1852,20 +2201,33 @@ var Hydration = {
1852
2201
  interior: {
1853
2202
  X2: [
1854
2203
  {
1855
- Parachain: 2094
2204
+ Parachain: 2034
1856
2205
  },
1857
2206
  {
1858
- PalletInstance: 10
2207
+ AccountKey20: {
2208
+ network: null,
2209
+ key: "0x00f283c7a97ecb60dd905cdab52febceec04dc0f"
2210
+ }
1859
2211
  }
1860
2212
  ]
1861
2213
  }
1862
2214
  },
1863
2215
  {
1864
- parents: 1,
2216
+ parents: 2,
1865
2217
  interior: {
1866
- X1: [
2218
+ X2: [
1867
2219
  {
1868
- Parachain: 3370
2220
+ GlobalConsensus: {
2221
+ Ethereum: {
2222
+ chainId: 1
2223
+ }
2224
+ }
2225
+ },
2226
+ {
2227
+ AccountKey20: {
2228
+ network: null,
2229
+ key: "0x514910771af9ca656af840dff83e8264ecf986ca"
2230
+ }
1869
2231
  }
1870
2232
  ]
1871
2233
  }
@@ -1883,7 +2245,7 @@ var Hydration = {
1883
2245
  {
1884
2246
  AccountKey20: {
1885
2247
  network: null,
1886
- key: "0x931715fee2d06333043d11f658c8ce934ac61d0c"
2248
+ key: "0xe9f9a2e3deae4093c00fbc57b22bb51a4c05ad88"
1887
2249
  }
1888
2250
  }
1889
2251
  ]
@@ -1892,15 +2254,15 @@ var Hydration = {
1892
2254
  {
1893
2255
  parents: 1,
1894
2256
  interior: {
1895
- X3: [
1896
- {
1897
- Parachain: 1000
1898
- },
2257
+ X2: [
1899
2258
  {
1900
- PalletInstance: 50
2259
+ Parachain: 2000
1901
2260
  },
1902
2261
  {
1903
- GeneralIndex: 31337
2262
+ GeneralKey: {
2263
+ length: 21,
2264
+ data: "0x0254a37a01cd75b616d63e0ab665bffdb0143c52ae0000000000000000000000"
2265
+ }
1904
2266
  }
1905
2267
  ]
1906
2268
  }
@@ -1910,10 +2272,10 @@ var Hydration = {
1910
2272
  interior: {
1911
2273
  X2: [
1912
2274
  {
1913
- Parachain: 2043
2275
+ Parachain: 3417
1914
2276
  },
1915
2277
  {
1916
- PalletInstance: 10
2278
+ GeneralIndex: 0
1917
2279
  }
1918
2280
  ]
1919
2281
  }
@@ -1921,19 +2283,15 @@ var Hydration = {
1921
2283
  {
1922
2284
  parents: 1,
1923
2285
  interior: {
1924
- X1: [
2286
+ X2: [
1925
2287
  {
1926
- Parachain: 3345
1927
- }
1928
- ]
1929
- }
1930
- },
1931
- {
1932
- parents: 1,
1933
- interior: {
1934
- X1: [
2288
+ Parachain: 2031
2289
+ },
1935
2290
  {
1936
- Parachain: 2101
2291
+ GeneralKey: {
2292
+ length: 2,
2293
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
2294
+ }
1937
2295
  }
1938
2296
  ]
1939
2297
  }
@@ -1948,7 +2306,7 @@ var Hydration = {
1948
2306
  {
1949
2307
  AccountKey20: {
1950
2308
  network: null,
1951
- key: "0x531a654d1696ed52e7275a8cede955e82620f99a"
2309
+ key: "0xc64980e4eaf9a1151bd21712b9946b81e41e2b92"
1952
2310
  }
1953
2311
  }
1954
2312
  ]
@@ -1973,27 +2331,28 @@ var Hydration = {
1973
2331
  {
1974
2332
  parents: 1,
1975
2333
  interior: {
1976
- X2: [
2334
+ X3: [
1977
2335
  {
1978
- Parachain: 2032
2336
+ Parachain: 2004
1979
2337
  },
1980
2338
  {
1981
- GeneralKey: {
1982
- length: 2,
1983
- data: "0x0002000000000000000000000000000000000000000000000000000000000000"
2339
+ PalletInstance: 110
2340
+ },
2341
+ {
2342
+ AccountKey20: {
2343
+ network: null,
2344
+ key: "0xda430218862d3db25de9f61458645dde49a9e9c1"
1984
2345
  }
1985
2346
  }
1986
2347
  ]
1987
2348
  }
1988
2349
  },
1989
2350
  {
1990
- parents: 2,
2351
+ parents: 1,
1991
2352
  interior: {
1992
2353
  X1: [
1993
2354
  {
1994
- GlobalConsensus: {
1995
- kusama: null
1996
- }
2355
+ Parachain: 2008
1997
2356
  }
1998
2357
  ]
1999
2358
  }
@@ -2012,7 +2371,7 @@ var Hydration = {
2012
2371
  {
2013
2372
  AccountKey20: {
2014
2373
  network: null,
2015
- key: "0x57e114b691db790c35207b2e685d4a43181e6061"
2374
+ key: "0x9d39a5de30e57443bff2a8307a4256c8797a3497"
2016
2375
  }
2017
2376
  }
2018
2377
  ]
@@ -2021,28 +2380,9 @@ var Hydration = {
2021
2380
  {
2022
2381
  parents: 1,
2023
2382
  interior: {
2024
- X2: [
2025
- {
2026
- Parachain: 2004
2027
- },
2028
- {
2029
- PalletInstance: 10
2030
- }
2031
- ]
2032
- }
2033
- },
2034
- {
2035
- parents: 1,
2036
- interior: {
2037
- X2: [
2038
- {
2039
- Parachain: 2030
2040
- },
2383
+ X1: [
2041
2384
  {
2042
- GeneralKey: {
2043
- length: 2,
2044
- data: "0x0001000000000000000000000000000000000000000000000000000000000000"
2045
- }
2385
+ Parachain: 3344
2046
2386
  }
2047
2387
  ]
2048
2388
  }
@@ -2061,47 +2401,45 @@ var Hydration = {
2061
2401
  {
2062
2402
  AccountKey20: {
2063
2403
  network: null,
2064
- key: "0x5a98fcbea516cf06857215779fd812ca3bef1b32"
2404
+ key: "0x1abaea1f7c830bd89acc67ec4af516284b1bc33c"
2065
2405
  }
2066
2406
  }
2067
2407
  ]
2068
2408
  }
2069
2409
  },
2070
2410
  {
2071
- parents: 2,
2411
+ parents: 1,
2072
2412
  interior: {
2073
- X2: [
2413
+ X3: [
2074
2414
  {
2075
- GlobalConsensus: {
2076
- Ethereum: {
2077
- chainId: 1
2078
- }
2079
- }
2415
+ Parachain: 2004
2416
+ },
2417
+ {
2418
+ PalletInstance: 110
2080
2419
  },
2081
2420
  {
2082
2421
  AccountKey20: {
2083
2422
  network: null,
2084
- key: "0x56072c95faa701256059aa122697b133aded9279"
2423
+ key: "0x484ecce6775143d3335ed2c7bcb22151c53b9f49"
2085
2424
  }
2086
2425
  }
2087
2426
  ]
2088
2427
  }
2089
2428
  },
2090
2429
  {
2091
- parents: 2,
2430
+ parents: 1,
2092
2431
  interior: {
2093
- X2: [
2432
+ X3: [
2094
2433
  {
2095
- GlobalConsensus: {
2096
- Ethereum: {
2097
- chainId: 1
2098
- }
2099
- }
2434
+ Parachain: 2004
2435
+ },
2436
+ {
2437
+ PalletInstance: 110
2100
2438
  },
2101
2439
  {
2102
2440
  AccountKey20: {
2103
2441
  network: null,
2104
- key: "0xaa7a9ca87d3694b5755f213b5d04094b8d0f0a6f"
2442
+ key: "0x52b2f622f5676e92dbea3092004eb9ffb85a8d07"
2105
2443
  }
2106
2444
  }
2107
2445
  ]
@@ -2110,34 +2448,23 @@ var Hydration = {
2110
2448
  {
2111
2449
  parents: 1,
2112
2450
  interior: {
2113
- X2: [
2114
- {
2115
- Parachain: 2030
2116
- },
2117
- {
2118
- GeneralKey: {
2119
- length: 2,
2120
- data: "0x0903000000000000000000000000000000000000000000000000000000000000"
2121
- }
2122
- }
2123
- ]
2451
+ Here: null
2124
2452
  }
2125
2453
  },
2126
2454
  {
2127
- parents: 2,
2455
+ parents: 1,
2128
2456
  interior: {
2129
- X2: [
2457
+ X3: [
2130
2458
  {
2131
- GlobalConsensus: {
2132
- Ethereum: {
2133
- chainId: 1
2134
- }
2135
- }
2459
+ Parachain: 2004
2460
+ },
2461
+ {
2462
+ PalletInstance: 110
2136
2463
  },
2137
2464
  {
2138
2465
  AccountKey20: {
2139
2466
  network: null,
2140
- key: "0x514910771af9ca656af840dff83e8264ecf986ca"
2467
+ key: "0x06e605775296e851ff43b4daa541bb0984e9d6fd"
2141
2468
  }
2142
2469
  }
2143
2470
  ]
@@ -2146,17 +2473,14 @@ var Hydration = {
2146
2473
  {
2147
2474
  parents: 1,
2148
2475
  interior: {
2149
- X3: [
2150
- {
2151
- Parachain: 2004
2152
- },
2476
+ X2: [
2153
2477
  {
2154
- PalletInstance: 110
2478
+ Parachain: 2000
2155
2479
  },
2156
2480
  {
2157
- AccountKey20: {
2158
- network: null,
2159
- key: "0x484ecce6775143d3335ed2c7bcb22151c53b9f49"
2481
+ GeneralKey: {
2482
+ length: 21,
2483
+ data: "0x0207df96d1341a7d16ba1ad431e2c847d978bc2bce0000000000000000000000"
2160
2484
  }
2161
2485
  }
2162
2486
  ]
@@ -2185,28 +2509,12 @@ var Hydration = {
2185
2509
  {
2186
2510
  parents: 1,
2187
2511
  interior: {
2188
- X1: [
2189
- {
2190
- Parachain: 2006
2191
- }
2192
- ]
2193
- }
2194
- },
2195
- {
2196
- parents: 1,
2197
- interior: {
2198
- X3: [
2199
- {
2200
- Parachain: 2004
2201
- },
2512
+ X2: [
2202
2513
  {
2203
- PalletInstance: 110
2514
+ Parachain: 2026
2204
2515
  },
2205
2516
  {
2206
- AccountKey20: {
2207
- network: null,
2208
- key: "0x06e605775296e851ff43b4daa541bb0984e9d6fd"
2209
- }
2517
+ PalletInstance: 2
2210
2518
  }
2211
2519
  ]
2212
2520
  }
@@ -2214,17 +2522,14 @@ var Hydration = {
2214
2522
  {
2215
2523
  parents: 1,
2216
2524
  interior: {
2217
- X3: [
2218
- {
2219
- Parachain: 2004
2220
- },
2525
+ X2: [
2221
2526
  {
2222
- PalletInstance: 110
2527
+ Parachain: 2034
2223
2528
  },
2224
2529
  {
2225
2530
  AccountKey20: {
2226
2531
  network: null,
2227
- key: "0xc30e9ca94cf52f3bf5692aacf81353a27052c46f"
2532
+ key: "0x2ec4884088d84e5c2970a034732e5209b0acfa93"
2228
2533
  }
2229
2534
  }
2230
2535
  ]
@@ -2235,12 +2540,12 @@ var Hydration = {
2235
2540
  interior: {
2236
2541
  X2: [
2237
2542
  {
2238
- Parachain: 2032
2543
+ Parachain: 2034
2239
2544
  },
2240
2545
  {
2241
- GeneralKey: {
2242
- length: 2,
2243
- data: "0x0001000000000000000000000000000000000000000000000000000000000000"
2546
+ AccountKey20: {
2547
+ network: null,
2548
+ key: "0xca30f9ff99394c55deda293df223e3740635c72e"
2244
2549
  }
2245
2550
  }
2246
2551
  ]
@@ -2260,27 +2565,363 @@ var Hydration = {
2260
2565
  {
2261
2566
  AccountKey20: {
2262
2567
  network: null,
2263
- key: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
2568
+ key: "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"
2264
2569
  }
2265
2570
  }
2266
2571
  ]
2267
2572
  }
2268
2573
  },
2269
2574
  {
2270
- parents: 2,
2575
+ parents: 1,
2271
2576
  interior: {
2272
- X2: [
2577
+ X3: [
2578
+ {
2579
+ Parachain: 1000
2580
+ },
2581
+ {
2582
+ PalletInstance: 50
2583
+ },
2584
+ {
2585
+ GeneralIndex: 1337
2586
+ }
2587
+ ]
2588
+ }
2589
+ },
2590
+ {
2591
+ parents: 1,
2592
+ interior: {
2593
+ X2: [
2594
+ {
2595
+ Parachain: 2034
2596
+ },
2597
+ {
2598
+ AccountKey20: {
2599
+ network: null,
2600
+ key: "0x0e13b904f4168f93814216b6874ca8349457f263"
2601
+ }
2602
+ }
2603
+ ]
2604
+ }
2605
+ },
2606
+ {
2607
+ parents: 1,
2608
+ interior: {
2609
+ X2: [
2610
+ {
2611
+ Parachain: 2034
2612
+ },
2613
+ {
2614
+ AccountKey20: {
2615
+ network: null,
2616
+ key: "0x11a8f7ffbb7e0fbed88bc20179dd45b4bd6874ff"
2617
+ }
2618
+ }
2619
+ ]
2620
+ }
2621
+ },
2622
+ {
2623
+ parents: 1,
2624
+ interior: {
2625
+ X1: [
2626
+ {
2627
+ Parachain: 2101
2628
+ }
2629
+ ]
2630
+ }
2631
+ },
2632
+ {
2633
+ parents: 2,
2634
+ interior: {
2635
+ X2: [
2636
+ {
2637
+ GlobalConsensus: {
2638
+ Ethereum: {
2639
+ chainId: 1
2640
+ }
2641
+ }
2642
+ },
2643
+ {
2644
+ AccountKey20: {
2645
+ network: null,
2646
+ key: "0xa3931d71877c0e7a3148cb7eb4463524fec27fbd"
2647
+ }
2648
+ }
2649
+ ]
2650
+ }
2651
+ },
2652
+ {
2653
+ parents: 1,
2654
+ interior: {
2655
+ X1: [
2656
+ {
2657
+ Parachain: 2035
2658
+ }
2659
+ ]
2660
+ }
2661
+ },
2662
+ {
2663
+ parents: 2,
2664
+ interior: {
2665
+ X2: [
2666
+ {
2667
+ GlobalConsensus: {
2668
+ Ethereum: {
2669
+ chainId: 1
2670
+ }
2671
+ }
2672
+ },
2673
+ {
2674
+ AccountKey20: {
2675
+ network: null,
2676
+ key: "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0"
2677
+ }
2678
+ }
2679
+ ]
2680
+ }
2681
+ },
2682
+ {
2683
+ parents: 1,
2684
+ interior: {
2685
+ X2: [
2686
+ {
2687
+ Parachain: 2034
2688
+ },
2689
+ {
2690
+ AccountKey20: {
2691
+ network: null,
2692
+ key: "0x35774c305aaf441a102d47988d35f0f5428471b3"
2693
+ }
2694
+ }
2695
+ ]
2696
+ }
2697
+ },
2698
+ {
2699
+ parents: 1,
2700
+ interior: {
2701
+ X2: [
2702
+ {
2703
+ Parachain: 2000
2704
+ },
2705
+ {
2706
+ GeneralKey: {
2707
+ length: 2,
2708
+ data: "0x0003000000000000000000000000000000000000000000000000000000000000"
2709
+ }
2710
+ }
2711
+ ]
2712
+ }
2713
+ },
2714
+ {
2715
+ parents: 1,
2716
+ interior: {
2717
+ X2: [
2718
+ {
2719
+ Parachain: 2034
2720
+ },
2721
+ {
2722
+ AccountKey20: {
2723
+ network: null,
2724
+ key: "0x02759d14d0d4f452b9c76f5a230750e8857d36f2"
2725
+ }
2726
+ }
2727
+ ]
2728
+ }
2729
+ },
2730
+ {
2731
+ parents: 2,
2732
+ interior: {
2733
+ X2: [
2734
+ {
2735
+ GlobalConsensus: {
2736
+ Ethereum: {
2737
+ chainId: 1
2738
+ }
2739
+ }
2740
+ },
2741
+ {
2742
+ AccountKey20: {
2743
+ network: null,
2744
+ key: "0xdac17f958d2ee523a2206206994597c13d831ec7"
2745
+ }
2746
+ }
2747
+ ]
2748
+ }
2749
+ },
2750
+ {
2751
+ parents: 2,
2752
+ interior: {
2753
+ X2: [
2754
+ {
2755
+ GlobalConsensus: {
2756
+ Ethereum: {
2757
+ chainId: 1
2758
+ }
2759
+ }
2760
+ },
2761
+ {
2762
+ AccountKey20: {
2763
+ network: null,
2764
+ key: "0x18084fba666a33d37592fa2633fd49a74dd93a88"
2765
+ }
2766
+ }
2767
+ ]
2768
+ }
2769
+ },
2770
+ {
2771
+ parents: 1,
2772
+ interior: {
2773
+ X1: [
2774
+ {
2775
+ Parachain: 3345
2776
+ }
2777
+ ]
2778
+ }
2779
+ },
2780
+ {
2781
+ parents: 1,
2782
+ interior: {
2783
+ X2: [
2784
+ {
2785
+ Parachain: 2092
2786
+ },
2787
+ {
2788
+ GeneralKey: {
2789
+ length: 2,
2790
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
2791
+ }
2792
+ }
2793
+ ]
2794
+ }
2795
+ },
2796
+ {
2797
+ parents: 1,
2798
+ interior: {
2799
+ X2: [
2800
+ {
2801
+ Parachain: 2094
2802
+ },
2803
+ {
2804
+ PalletInstance: 10
2805
+ }
2806
+ ]
2807
+ }
2808
+ },
2809
+ {
2810
+ parents: 1,
2811
+ interior: {
2812
+ X2: [
2813
+ {
2814
+ Parachain: 2000
2815
+ },
2816
+ {
2817
+ GeneralKey: {
2818
+ length: 21,
2819
+ data: "0x02c80084af223c8b598536178d9361dc55bfda68180000000000000000000000"
2820
+ }
2821
+ }
2822
+ ]
2823
+ }
2824
+ },
2825
+ {
2826
+ parents: 1,
2827
+ interior: {
2828
+ X2: [
2829
+ {
2830
+ Parachain: 2032
2831
+ },
2832
+ {
2833
+ GeneralKey: {
2834
+ length: 2,
2835
+ data: "0x0002000000000000000000000000000000000000000000000000000000000000"
2836
+ }
2837
+ }
2838
+ ]
2839
+ }
2840
+ },
2841
+ {
2842
+ parents: 1,
2843
+ interior: {
2844
+ X1: [
2845
+ {
2846
+ Parachain: 2037
2847
+ }
2848
+ ]
2849
+ }
2850
+ },
2851
+ {
2852
+ parents: 1,
2853
+ interior: {
2854
+ X5: [
2855
+ {
2856
+ Parachain: 2094
2857
+ },
2858
+ {
2859
+ PalletInstance: 53
2860
+ },
2861
+ {
2862
+ GeneralIndex: 2
2863
+ },
2864
+ {
2865
+ GeneralKey: {
2866
+ length: 4,
2867
+ data: "0x4555524300000000000000000000000000000000000000000000000000000000"
2868
+ }
2869
+ },
2870
+ {
2871
+ GeneralKey: {
2872
+ length: 32,
2873
+ data: "0xcf4f5a26e2090bb3adcf02c7a9d73dbfe6659cc690461475b86437fa49c71136"
2874
+ }
2875
+ }
2876
+ ]
2877
+ }
2878
+ },
2879
+ {
2880
+ parents: 1,
2881
+ interior: {
2882
+ X2: [
2883
+ {
2884
+ Parachain: 2034
2885
+ },
2886
+ {
2887
+ AccountKey20: {
2888
+ network: null,
2889
+ key: "0x34d5ffb83d14d82f87aaf2f13be895a3c814c2ad"
2890
+ }
2891
+ }
2892
+ ]
2893
+ }
2894
+ },
2895
+ {
2896
+ parents: 1,
2897
+ interior: {
2898
+ X3: [
2273
2899
  {
2274
- GlobalConsensus: {
2275
- Ethereum: {
2276
- chainId: 1
2277
- }
2900
+ Parachain: 2004
2901
+ },
2902
+ {
2903
+ PalletInstance: 110
2904
+ },
2905
+ {
2906
+ AccountKey20: {
2907
+ network: null,
2908
+ key: "0xc30e9ca94cf52f3bf5692aacf81353a27052c46f"
2278
2909
  }
2910
+ }
2911
+ ]
2912
+ }
2913
+ },
2914
+ {
2915
+ parents: 1,
2916
+ interior: {
2917
+ X2: [
2918
+ {
2919
+ Parachain: 2004
2279
2920
  },
2280
2921
  {
2281
2922
  AccountKey20: {
2282
2923
  network: null,
2283
- key: "0xdac17f958d2ee523a2206206994597c13d831ec7"
2924
+ key: "0x9c4c6eaad9b926ba09f702f4ad880ef71998ef18"
2284
2925
  }
2285
2926
  }
2286
2927
  ]
@@ -2300,7 +2941,7 @@ var Hydration = {
2300
2941
  {
2301
2942
  AccountKey20: {
2302
2943
  network: null,
2303
- key: "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0"
2944
+ key: "0x8236a87084f8b84306f72007f36f2618a5634494"
2304
2945
  }
2305
2946
  }
2306
2947
  ]
@@ -2309,17 +2950,14 @@ var Hydration = {
2309
2950
  {
2310
2951
  parents: 1,
2311
2952
  interior: {
2312
- X3: [
2313
- {
2314
- Parachain: 2004
2315
- },
2953
+ X2: [
2316
2954
  {
2317
- PalletInstance: 110
2955
+ Parachain: 2034
2318
2956
  },
2319
2957
  {
2320
2958
  AccountKey20: {
2321
2959
  network: null,
2322
- key: "0xab3f0245b83feb11d15aaffefd7ad465a59817ed"
2960
+ key: "0xf5f744a4d14a5f49ce173e39b8361733a6e55152"
2323
2961
  }
2324
2962
  }
2325
2963
  ]
@@ -2328,22 +2966,29 @@ var Hydration = {
2328
2966
  {
2329
2967
  parents: 1,
2330
2968
  interior: {
2331
- X3: [
2332
- {
2333
- Parachain: 2004
2334
- },
2969
+ X2: [
2335
2970
  {
2336
- PalletInstance: 110
2971
+ Parachain: 2034
2337
2972
  },
2338
2973
  {
2339
2974
  AccountKey20: {
2340
2975
  network: null,
2341
- key: "0xe9f9a2e3deae4093c00fbc57b22bb51a4c05ad88"
2976
+ key: "0x4c892a298a9c6b4ced988b3d6e9cf93333aadcf7"
2342
2977
  }
2343
2978
  }
2344
2979
  ]
2345
2980
  }
2346
2981
  },
2982
+ {
2983
+ parents: 1,
2984
+ interior: {
2985
+ X1: [
2986
+ {
2987
+ Parachain: 2006
2988
+ }
2989
+ ]
2990
+ }
2991
+ },
2347
2992
  {
2348
2993
  parents: 1,
2349
2994
  interior: {
@@ -2357,7 +3002,7 @@ var Hydration = {
2357
3002
  {
2358
3003
  AccountKey20: {
2359
3004
  network: null,
2360
- key: "0xda430218862d3db25de9f61458645dde49a9e9c1"
3005
+ key: "0x99fec54a5ad36d50a4bba3a41cab983a5bb86a7d"
2361
3006
  }
2362
3007
  }
2363
3008
  ]
@@ -2377,7 +3022,7 @@ var Hydration = {
2377
3022
  {
2378
3023
  AccountKey20: {
2379
3024
  network: null,
2380
- key: "0x9d39a5de30e57443bff2a8307a4256c8797a3497"
3025
+ key: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
2381
3026
  }
2382
3027
  }
2383
3028
  ]
@@ -5390,6 +6035,40 @@ var Acala = {
5390
6035
  }
5391
6036
  }
5392
6037
  ],
6038
+ [
6039
+ {
6040
+ parents: 1,
6041
+ interior: {
6042
+ X2: [
6043
+ {
6044
+ Parachain: 2000
6045
+ },
6046
+ {
6047
+ GeneralKey: {
6048
+ length: 2,
6049
+ data: "0x0000000000000000000000000000000000000000000000000000000000000000"
6050
+ }
6051
+ }
6052
+ ]
6053
+ }
6054
+ },
6055
+ {
6056
+ parents: 1,
6057
+ interior: {
6058
+ X2: [
6059
+ {
6060
+ Parachain: 2032
6061
+ },
6062
+ {
6063
+ GeneralKey: {
6064
+ length: 2,
6065
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
6066
+ }
6067
+ }
6068
+ ]
6069
+ }
6070
+ }
6071
+ ],
5393
6072
  [
5394
6073
  {
5395
6074
  parents: 1,
@@ -5874,6 +6553,40 @@ var Acala = {
5874
6553
  }
5875
6554
  }
5876
6555
  ],
6556
+ [
6557
+ {
6558
+ parents: 1,
6559
+ interior: {
6560
+ X3: [
6561
+ {
6562
+ Parachain: 1000
6563
+ },
6564
+ {
6565
+ PalletInstance: 50
6566
+ },
6567
+ {
6568
+ GeneralIndex: 22222012
6569
+ }
6570
+ ]
6571
+ }
6572
+ },
6573
+ {
6574
+ parents: 1,
6575
+ interior: {
6576
+ X2: [
6577
+ {
6578
+ Parachain: 2032
6579
+ },
6580
+ {
6581
+ GeneralKey: {
6582
+ length: 2,
6583
+ data: "0x0001000000000000000000000000000000000000000000000000000000000000"
6584
+ }
6585
+ }
6586
+ ]
6587
+ }
6588
+ }
6589
+ ],
5877
6590
  [
5878
6591
  {
5879
6592
  parents: 1,
@@ -7495,8 +8208,11 @@ var createAcalaClient = /*#__PURE__*/function () {
7495
8208
 
7496
8209
  var AcalaExchange = /*#__PURE__*/function (_ExchangeChain) {
7497
8210
  function AcalaExchange() {
8211
+ var _this;
7498
8212
  _classCallCheck(this, AcalaExchange);
7499
- return _callSuper(this, AcalaExchange, arguments);
8213
+ _this = _callSuper(this, AcalaExchange, arguments);
8214
+ _this.apiType = 'PJS';
8215
+ return _this;
7500
8216
  }
7501
8217
  _inherits(AcalaExchange, _ExchangeChain);
7502
8218
  return _createClass(AcalaExchange, [{
@@ -7673,97 +8389,80 @@ var AcalaExchange = /*#__PURE__*/function (_ExchangeChain) {
7673
8389
  }]);
7674
8390
  }(ExchangeChain);
7675
8391
 
7676
- /* eslint-disable @typescript-eslint/no-unsafe-return */
7677
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
7678
- /* eslint-disable @typescript-eslint/no-explicit-any */
7679
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
7680
- var capitalizeLocation = function capitalizeLocation(obj) {
7681
- obj.interior = _capitalizeKeys(obj.interior);
7682
- return obj;
8392
+ // NetworkId enum variants that polkadot.js `.toJSON()` lowercases when the
8393
+ // variant carries no data (e.g. `Kusama` -> `kusama`). Struct/tuple variants
8394
+ // like `Ethereum { chain_id }` keep their PascalCase.
8395
+ var LOWERCASED_PLAIN_VARIANTS = new Set(['Polkadot', 'Kusama', 'Westend', 'Rococo', 'Wococo', 'BitcoinCore', 'BitcoinCash', 'PolkadotBulletin']);
8396
+ var snakeToCamel = function snakeToCamel(key) {
8397
+ return key.replace(/_([a-z])/g, function (_, c) {
8398
+ return c.toUpperCase();
8399
+ });
7683
8400
  };
7684
- var _capitalizeKeys = function capitalizeKeys(obj) {
7685
- var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
7686
- if (_typeof(obj) !== 'object' || obj === null) {
7687
- return obj; // Primitive value, return as is
7688
- }
7689
- if (Array.isArray(obj)) {
7690
- // Process each element in the array
7691
- return obj.map(function (element) {
7692
- return _capitalizeKeys(element, depth);
7693
- });
7694
- }
7695
- var newObj = {};
7696
- for (var key in obj) {
7697
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
7698
- var value = obj[key];
7699
- var isLeafNode = _typeof(value) !== 'object' || value === null;
7700
- var capitalizedKey = void 0;
7701
- if (depth <= 2 || !isLeafNode) {
7702
- // Capitalize the key
7703
- capitalizedKey = key.charAt(0).toUpperCase() + key.slice(1);
7704
- } else {
7705
- // Do not capitalize leaf nodes beyond depth 2
7706
- capitalizedKey = key;
7707
- }
7708
- if (key === 'generalKey' && typeof value === 'string') {
7709
- var data = value;
7710
- var hexString = data.startsWith('0x') ? data.slice(2) : data;
7711
- var byteLength = hexString.length / 2; // Each byte is two hex characters
7712
- // Pad hexString with trailing zeros to make it 32 bytes (64 hex characters)
7713
- var paddedHexString = hexString.padEnd(64, '0'); // 64 hex chars = 32 bytes
7714
- data = '0x' + paddedHexString;
7715
- value = {
7716
- length: byteLength,
7717
- data: data
7718
- };
7719
- }
7720
- // Recursively process nested objects
7721
- newObj[capitalizedKey] = _capitalizeKeys(value, depth + 1);
8401
+ var isBinary = function isBinary(v) {
8402
+ return _typeof(v) === 'object' && v !== null && 'asHex' in v && typeof v.asHex === 'function';
8403
+ };
8404
+ var JUNCTIONS_VARIANT = /^X[1-8]$/;
8405
+ // Recursively convert polkadot-api's `{ type, value }` enum encoding into the
8406
+ // flat `{ VariantName: value }` shape used by stored asset locations (which
8407
+ // originate from polkadot.js's `.toJSON()`).
8408
+ //
8409
+ // Reproduces three pjs `.toJSON()` quirks so output is byte-identical:
8410
+ // - plain NetworkId variants lowercased (`Kusama` -> `kusama`)
8411
+ // - struct field names snake_case -> camelCase (`chain_id` -> `chainId`)
8412
+ // - `Binary` byte values rendered as `0x...` hex strings
8413
+ var _papiLocationToJson = function papiLocationToJson(value) {
8414
+ if (value === undefined) return null;
8415
+ if (isBinary(value)) return value.asHex();
8416
+ if (_typeof(value) !== 'object' || value === null) return value;
8417
+ if (Array.isArray(value)) return value.map(_papiLocationToJson);
8418
+ var obj = value;
8419
+ if (Object.keys(obj).length === 2 && typeof obj.type === 'string' && Object.prototype.hasOwnProperty.call(obj, 'value')) {
8420
+ // v3 Junctions encode X1 as a single Junction (not an array). pjs
8421
+ // normalizes X1..X8 to array form, so we do the same.
8422
+ if (JUNCTIONS_VARIANT.test(obj.type) && !Array.isArray(obj.value)) {
8423
+ return _defineProperty({}, obj.type, [_papiLocationToJson(obj.value)]);
7722
8424
  }
8425
+ var variant = obj.value === undefined && LOWERCASED_PLAIN_VARIANTS.has(obj.type) ? obj.type[0].toLowerCase() + obj.type.slice(1) : obj.type;
8426
+ return _defineProperty({}, variant, _papiLocationToJson(obj.value));
8427
+ }
8428
+ var out = {};
8429
+ for (var _i = 0, _Object$entries = Object.entries(obj); _i < _Object$entries.length; _i++) {
8430
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
8431
+ k = _Object$entries$_i[0],
8432
+ v = _Object$entries$_i[1];
8433
+ out[snakeToCamel(k)] = _papiLocationToJson(v);
7723
8434
  }
7724
- return newObj;
8435
+ return out;
7725
8436
  };
7726
8437
 
7727
8438
  var getDexConfig$1 = /*#__PURE__*/function () {
7728
8439
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, chain) {
7729
- var assets, response, pairs, poolLocations, filteredAssets, locations;
8440
+ var assets, entries, poolLocations, filteredAssets;
7730
8441
  return _regenerator().w(function (_context) {
7731
8442
  while (1) switch (_context.n) {
7732
8443
  case 0:
7733
8444
  assets = getAssets(chain);
7734
8445
  _context.n = 1;
7735
- return api.query.assetConversion.pools.entries();
8446
+ return api.getUnsafeApi().query.AssetConversion.Pools.getEntries();
7736
8447
  case 1:
7737
- response = _context.v;
7738
- pairs = response.map(function (_ref2) {
7739
- var _ref3 = _slicedToArray(_ref2, 1),
7740
- _ref3$0$args = _slicedToArray(_ref3[0].args, 1),
7741
- era = _ref3$0$args[0];
7742
- var _era$toJSON = era.toJSON(),
7743
- _era$toJSON2 = _slicedToArray(_era$toJSON, 2),
7744
- ml1 = _era$toJSON2[0],
7745
- ml2 = _era$toJSON2[1];
7746
- return [ml1, ml2];
7747
- });
8448
+ entries = _context.v;
7748
8449
  poolLocations = new Set();
7749
- pairs.forEach(function (_ref4) {
7750
- var _ref5 = _slicedToArray(_ref4, 2),
7751
- ml1 = _ref5[0],
7752
- ml2 = _ref5[1];
7753
- var ml1Transformed = capitalizeLocation(ml1);
7754
- var ml2Transformed = capitalizeLocation(ml2);
7755
- poolLocations.add(JSON.stringify(ml1Transformed));
7756
- poolLocations.add(JSON.stringify(ml2Transformed));
8450
+ entries.forEach(function (_ref2) {
8451
+ var _ref2$keyArgs = _slicedToArray(_ref2.keyArgs, 1),
8452
+ _ref2$keyArgs$ = _slicedToArray(_ref2$keyArgs[0], 2),
8453
+ ml1 = _ref2$keyArgs$[0],
8454
+ ml2 = _ref2$keyArgs$[1];
8455
+ poolLocations.add(JSON.stringify(_papiLocationToJson(ml1), replaceBigIntNumeric));
8456
+ poolLocations.add(JSON.stringify(_papiLocationToJson(ml2), replaceBigIntNumeric));
7757
8457
  });
7758
8458
  filteredAssets = assets.filter(function (asset) {
7759
- return poolLocations.has(JSON.stringify(asset.location)) || poolLocations.has(JSON.stringify(localizeLocation('AssetHubPolkadot', asset.location)));
7760
- });
7761
- locations = filteredAssets.map(function (asset) {
7762
- return asset.location;
8459
+ return poolLocations.has(JSON.stringify(asset.location, replaceBigIntNumeric)) || poolLocations.has(JSON.stringify(localizeLocation('AssetHubPolkadot', asset.location), replaceBigIntNumeric));
7763
8460
  });
7764
8461
  return _context.a(2, {
7765
8462
  isOmni: true,
7766
- assets: locations,
8463
+ assets: filteredAssets.map(function (asset) {
8464
+ return asset.location;
8465
+ }),
7767
8466
  pairs: []
7768
8467
  });
7769
8468
  }
@@ -7776,8 +8475,11 @@ var getDexConfig$1 = /*#__PURE__*/function () {
7776
8475
 
7777
8476
  var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
7778
8477
  function AssetHubExchange() {
8478
+ var _this;
7779
8479
  _classCallCheck(this, AssetHubExchange);
7780
- return _callSuper(this, AssetHubExchange, arguments);
8480
+ _this = _callSuper(this, AssetHubExchange, arguments);
8481
+ _this.apiType = 'GENERIC';
8482
+ return _this;
7781
8483
  }
7782
8484
  _inherits(AssetHubExchange, _ExchangeChain);
7783
8485
  return _createClass(AssetHubExchange, [{
@@ -7950,7 +8652,7 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
7950
8652
  hop1Received = resultHop1.amountOut;
7951
8653
  assumedInputForHop2 = padValueBy(hop1Received, -2);
7952
8654
  optionsHop2 = {
7953
- apiPjs: options.apiPjs,
8655
+ apiType: 'GENERIC',
7954
8656
  api: options.api,
7955
8657
  slippagePct: options.slippagePct,
7956
8658
  sender: options.sender,
@@ -8408,8 +9110,11 @@ var getDexConfig = /*#__PURE__*/function () {
8408
9110
 
8409
9111
  var BifrostExchange = /*#__PURE__*/function (_ExchangeChain) {
8410
9112
  function BifrostExchange() {
9113
+ var _this;
8411
9114
  _classCallCheck(this, BifrostExchange);
8412
- return _callSuper(this, BifrostExchange, arguments);
9115
+ _this = _callSuper(this, BifrostExchange, arguments);
9116
+ _this.apiType = 'PJS';
9117
+ return _this;
8413
9118
  }
8414
9119
  _inherits(BifrostExchange, _ExchangeChain);
8415
9120
  return _createClass(BifrostExchange, [{
@@ -8572,17 +9277,17 @@ var BifrostExchange = /*#__PURE__*/function (_ExchangeChain) {
8572
9277
  }(ExchangeChain);
8573
9278
 
8574
9279
  var getAssetInfo = /*#__PURE__*/function () {
8575
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(tradeRouter, asset) {
9280
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(assetClient, asset) {
8576
9281
  var assets;
8577
9282
  return _regenerator().w(function (_context) {
8578
9283
  while (1) switch (_context.n) {
8579
9284
  case 0:
8580
9285
  _context.n = 1;
8581
- return tradeRouter.getAllAssets();
9286
+ return assetClient.getSupported();
8582
9287
  case 1:
8583
9288
  assets = _context.v;
8584
9289
  return _context.a(2, asset.assetId ? assets.find(function (a) {
8585
- return a.id === asset.assetId;
9290
+ return a.id.toString() === asset.assetId;
8586
9291
  }) : assets.find(function (a) {
8587
9292
  return a.symbol === asset.symbol;
8588
9293
  }));
@@ -8595,8 +9300,8 @@ var getAssetInfo = /*#__PURE__*/function () {
8595
9300
  }();
8596
9301
 
8597
9302
  var calculateFee = /*#__PURE__*/function () {
8598
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, currencyFromDecimals, chain, toDestTransactionFee) {
8599
- var amount, slippagePct, feeCalcAddress, sender, trade, nativeCurrencyInfo, nativeCurrencyDecimals, substrateTx, tx, swapFee, feeNative, currencyFromPriceInfo, currencyFromPrice, feeInCurrencyFrom, finalFee;
9303
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, tradeRouter, txBuilderFactory, assetClient, currencyFromInfo, currencyToInfo, currencyFromDecimals, chain, toDestTransactionFee) {
9304
+ var amount, slippagePct, feeCalcAddress, sender, trade, nativeCurrencyInfo, nativeCurrencyDecimals, substrateTx, tx, _yield$tx$getPaymentI, swapFee, feeNative, currencyFromPriceInfo, currencyFromPrice, feeInCurrencyFrom, finalFee;
8600
9305
  return _regenerator().w(function (_context) {
8601
9306
  while (1) switch (_context.n) {
8602
9307
  case 0:
@@ -8606,7 +9311,7 @@ var calculateFee = /*#__PURE__*/function () {
8606
9311
  case 1:
8607
9312
  trade = _context.v;
8608
9313
  _context.n = 2;
8609
- return getAssetInfo(tradeRouter, {
9314
+ return getAssetInfo(assetClient, {
8610
9315
  symbol: getNativeAssetSymbol(chain)
8611
9316
  });
8612
9317
  case 2:
@@ -8630,9 +9335,10 @@ var calculateFee = /*#__PURE__*/function () {
8630
9335
  substrateTx = _context.v;
8631
9336
  tx = substrateTx.get();
8632
9337
  _context.n = 6;
8633
- return calculateTxFeePjs(tx, feeCalcAddress);
9338
+ return tx.getPaymentInfo(feeCalcAddress);
8634
9339
  case 6:
8635
- swapFee = _context.v;
9340
+ _yield$tx$getPaymentI = _context.v;
9341
+ swapFee = _yield$tx$getPaymentI.partial_fee;
8636
9342
  feeNative = swapFee + toDestTransactionFee + toDestTransactionFee;
8637
9343
  Logger.log('XCM to exch. fee:', toDestTransactionFee, nativeCurrencyInfo.symbol);
8638
9344
  Logger.log('XCM to dest. fee:', toDestTransactionFee, nativeCurrencyInfo.symbol);
@@ -8645,7 +9351,7 @@ var calculateFee = /*#__PURE__*/function () {
8645
9351
  return _context.a(2, feeNative);
8646
9352
  case 7:
8647
9353
  _context.n = 8;
8648
- return tradeRouter.getBestSpotPrice(currencyFromInfo.id, nativeCurrencyInfo.id);
9354
+ return tradeRouter.getSpotPrice(currencyFromInfo.id, nativeCurrencyInfo.id);
8649
9355
  case 8:
8650
9356
  currencyFromPriceInfo = _context.v;
8651
9357
  if (!(currencyFromPriceInfo === undefined)) {
@@ -8654,7 +9360,7 @@ var calculateFee = /*#__PURE__*/function () {
8654
9360
  }
8655
9361
  throw new UnableToComputeError('Price not found');
8656
9362
  case 9:
8657
- currencyFromPrice = BigInt(currencyFromPriceInfo.amount.decimalPlaces(0).toString());
9363
+ currencyFromPrice = currencyFromPriceInfo.amount;
8658
9364
  feeInCurrencyFrom = feeNative * pow10n(currencyFromPriceInfo.decimals + currencyFromDecimals) / (currencyFromPrice * pow10n(nativeCurrencyDecimals));
8659
9365
  Logger.log('Total fee in currency from:', feeInCurrencyFrom, currencyFromInfo.symbol);
8660
9366
  finalFee = padValueBy(feeInCurrencyFrom, FEE_BUFFER_PCT);
@@ -8663,97 +9369,100 @@ var calculateFee = /*#__PURE__*/function () {
8663
9369
  }
8664
9370
  }, _callee);
8665
9371
  }));
8666
- return function calculateFee(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
9372
+ return function calculateFee(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9) {
8667
9373
  return _ref2.apply(this, arguments);
8668
9374
  };
8669
9375
  }();
8670
9376
 
8671
9377
  var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
8672
9378
  function HydrationExchange() {
9379
+ var _this;
8673
9380
  _classCallCheck(this, HydrationExchange);
8674
- return _callSuper(this, HydrationExchange, arguments);
9381
+ _this = _callSuper(this, HydrationExchange, arguments);
9382
+ _this.apiType = 'PAPI';
9383
+ return _this;
8675
9384
  }
8676
9385
  _inherits(HydrationExchange, _ExchangeChain);
8677
9386
  return _createClass(HydrationExchange, [{
8678
9387
  key: "swapCurrency",
8679
9388
  value: function () {
8680
9389
  var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, toDestTransactionFee) {
8681
- var apiPjs, origin, assetFrom, assetTo, sender, slippagePct, amount, _createSdkContext, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, tradeFee, amountWithoutFee, amountNormalized, trade, substrateTx, tx, amountOut, nativeCurrencyInfo, nativeCurrencyDecimals, priceInfo, currencyToPrice, feeInCurrencyTo, amountOutModified;
9390
+ 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;
8682
9391
  return _regenerator().w(function (_context) {
8683
9392
  while (1) switch (_context.n) {
8684
9393
  case 0:
8685
- apiPjs = options.apiPjs, origin = options.origin, assetFrom = options.assetFrom, assetTo = options.assetTo, sender = options.sender, slippagePct = options.slippagePct, amount = options.amount;
8686
- _createSdkContext = createSdkContext(apiPjs), tradeRouter = _createSdkContext.api.router, txBuilderFactory = _createSdkContext.tx;
9394
+ apiPapi = options.apiPapi, origin = options.origin, assetFrom = options.assetFrom, assetTo = options.assetTo, sender = options.sender, slippagePct = options.slippagePct, amount = options.amount;
8687
9395
  _context.n = 1;
8688
- return getAssetInfo(tradeRouter, assetFrom);
9396
+ return createSdkContext(apiPapi);
8689
9397
  case 1:
8690
- currencyFromInfo = _context.v;
9398
+ _yield$createSdkConte = _context.v;
9399
+ tradeRouter = _yield$createSdkConte.api.router;
9400
+ assetClient = _yield$createSdkConte.client.asset;
9401
+ txBuilderFactory = _yield$createSdkConte.tx;
8691
9402
  _context.n = 2;
8692
- return getAssetInfo(tradeRouter, assetTo);
9403
+ return getAssetInfo(assetClient, assetFrom);
8693
9404
  case 2:
9405
+ currencyFromInfo = _context.v;
9406
+ _context.n = 3;
9407
+ return getAssetInfo(assetClient, assetTo);
9408
+ case 3:
8694
9409
  currencyToInfo = _context.v;
8695
9410
  if (!(currencyFromInfo === undefined)) {
8696
- _context.n = 3;
9411
+ _context.n = 4;
8697
9412
  break;
8698
9413
  }
8699
9414
  throw new InvalidCurrencyError("Currency from doesn't exist");
8700
- case 3:
9415
+ case 4:
8701
9416
  if (!(currencyToInfo === undefined)) {
8702
- _context.n = 4;
9417
+ _context.n = 5;
8703
9418
  break;
8704
9419
  }
8705
9420
  throw new InvalidCurrencyError("Currency to doesn't exist");
8706
- case 4:
8707
- _context.n = 5;
8708
- return calculateFee(options, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, currencyFromInfo.decimals, this.chain, toDestTransactionFee);
8709
9421
  case 5:
9422
+ _context.n = 6;
9423
+ return calculateFee(options, tradeRouter, txBuilderFactory, assetClient, currencyFromInfo, currencyToInfo, currencyFromInfo.decimals, this.chain, toDestTransactionFee);
9424
+ case 6:
8710
9425
  tradeFee = _context.v;
8711
9426
  amountWithoutFee = origin ? amount - tradeFee : amount;
8712
9427
  if (!(amountWithoutFee <= 0n)) {
8713
- _context.n = 6;
9428
+ _context.n = 7;
8714
9429
  break;
8715
9430
  }
8716
9431
  throw new AmountTooLowError();
8717
- case 6:
9432
+ case 7:
8718
9433
  amountNormalized = formatUnits$1(amountWithoutFee, currencyFromInfo.decimals);
8719
9434
  Logger.log('Original amount', amount);
8720
9435
  Logger.log('Amount modified', amountWithoutFee);
8721
- _context.n = 7;
9436
+ _context.n = 8;
8722
9437
  return tradeRouter.getBestSell(currencyFromInfo.id, currencyToInfo.id, amountNormalized);
8723
- case 7:
9438
+ case 8:
8724
9439
  trade = _context.v;
8725
- _context.n = 8;
9440
+ _context.n = 9;
8726
9441
  return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(sender).build();
8727
- case 8:
9442
+ case 9:
8728
9443
  substrateTx = _context.v;
8729
9444
  tx = substrateTx.get();
8730
- amountOut = BigInt(trade.amountOut.decimalPlaces(0).toString());
8731
- _context.n = 9;
8732
- return getAssetInfo(tradeRouter, {
9445
+ amountOut = trade.amountOut;
9446
+ _context.n = 10;
9447
+ return getAssetInfo(assetClient, {
8733
9448
  symbol: getNativeAssetSymbol(this.chain)
8734
9449
  });
8735
- case 9:
9450
+ case 10:
8736
9451
  nativeCurrencyInfo = _context.v;
8737
9452
  if (!(nativeCurrencyInfo === undefined)) {
8738
- _context.n = 10;
8739
- break;
8740
- }
8741
- throw new InvalidCurrencyError('Native currency not found');
8742
- case 10:
8743
- nativeCurrencyDecimals = getAssetDecimals(this.chain, nativeCurrencyInfo.symbol);
8744
- if (!(nativeCurrencyDecimals === null)) {
8745
9453
  _context.n = 11;
8746
9454
  break;
8747
9455
  }
8748
- throw new UnableToComputeError('Native currency decimals not found');
9456
+ throw new InvalidCurrencyError('Native currency not found');
8749
9457
  case 11:
9458
+ _findNativeAssetInfoO = findNativeAssetInfoOrThrow(this.chain), nativeCurrencyDecimals = _findNativeAssetInfoO.decimals;
8750
9459
  _context.n = 12;
8751
- return tradeRouter.getBestSpotPrice(currencyToInfo.id, nativeCurrencyInfo.id);
9460
+ return tradeRouter.getSpotPrice(currencyToInfo.id, nativeCurrencyInfo.id);
8752
9461
  case 12:
8753
9462
  priceInfo = _context.v;
8754
9463
  if (currencyToInfo.id === nativeCurrencyInfo.id) {
8755
9464
  priceInfo = {
8756
- amount: BigNumber(parseUnits$1('1', nativeCurrencyDecimals)),
9465
+ amount: parseUnits$1('1', nativeCurrencyDecimals),
8757
9466
  decimals: nativeCurrencyDecimals
8758
9467
  };
8759
9468
  }
@@ -8763,7 +9472,7 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
8763
9472
  }
8764
9473
  throw new UnableToComputeError('Price not found');
8765
9474
  case 13:
8766
- currencyToPrice = BigInt(priceInfo.amount.decimalPlaces(0).toString());
9475
+ currencyToPrice = priceInfo.amount;
8767
9476
  feeInCurrencyTo = toDestTransactionFee * pow10n(priceInfo.decimals + currencyToInfo.decimals) * BigInt(FEE_BUFFER_PCT) / (currencyToPrice * pow10n(nativeCurrencyDecimals) * 100n);
8768
9477
  Logger.log('Amount out fee', feeInCurrencyTo, nativeCurrencyInfo.symbol);
8769
9478
  amountOutModified = amountOut - feeInCurrencyTo;
@@ -8791,40 +9500,45 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
8791
9500
  key: "getAmountOut",
8792
9501
  value: function () {
8793
9502
  var _getAmountOut = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
8794
- var apiPjs, assetFrom, assetTo, amount, origin, _options$slippagePct, slippagePct, _createSdkContext2, tradeRouter, currencyFromInfo, currencyToInfo, pctDestFee, amountWithoutFee, amountNormalized, trade, amountOut, slippageMultiplier;
9503
+ var apiPapi, assetFrom, assetTo, amount, origin, _options$slippagePct, slippagePct, _yield$createSdkConte2, tradeRouter, assetClient, currencyFromInfo, currencyToInfo, pctDestFee, amountWithoutFee, amountNormalized, trade, amountOut, slippageMultiplier;
8795
9504
  return _regenerator().w(function (_context2) {
8796
9505
  while (1) switch (_context2.n) {
8797
9506
  case 0:
8798
- apiPjs = options.apiPjs, assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, origin = options.origin, _options$slippagePct = options.slippagePct, slippagePct = _options$slippagePct === void 0 ? '0' : _options$slippagePct;
8799
- _createSdkContext2 = createSdkContext(apiPjs), tradeRouter = _createSdkContext2.api.router;
9507
+ 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;
8800
9508
  _context2.n = 1;
8801
- return getAssetInfo(tradeRouter, assetFrom);
9509
+ return createSdkContext(apiPapi);
8802
9510
  case 1:
8803
- currencyFromInfo = _context2.v;
9511
+ _yield$createSdkConte2 = _context2.v;
9512
+ tradeRouter = _yield$createSdkConte2.api.router;
9513
+ assetClient = _yield$createSdkConte2.client.asset;
8804
9514
  _context2.n = 2;
8805
- return getAssetInfo(tradeRouter, assetTo);
9515
+ return getAssetInfo(assetClient, assetFrom);
8806
9516
  case 2:
9517
+ currencyFromInfo = _context2.v;
9518
+ _context2.n = 3;
9519
+ return getAssetInfo(assetClient, assetTo);
9520
+ case 3:
8807
9521
  currencyToInfo = _context2.v;
8808
9522
  if (!(currencyFromInfo === undefined)) {
8809
- _context2.n = 3;
9523
+ _context2.n = 4;
8810
9524
  break;
8811
9525
  }
8812
9526
  throw new InvalidCurrencyError("Currency from doesn't exist");
8813
- case 3:
9527
+ case 4:
8814
9528
  if (!(currencyToInfo === undefined)) {
8815
- _context2.n = 4;
9529
+ _context2.n = 5;
8816
9530
  break;
8817
9531
  }
8818
9532
  throw new InvalidCurrencyError("Currency to doesn't exist");
8819
- case 4:
9533
+ case 5:
8820
9534
  pctDestFee = origin ? DEST_FEE_BUFFER_PCT : 0;
8821
9535
  amountWithoutFee = padValueBy(amount, pctDestFee);
8822
9536
  amountNormalized = formatUnits$1(amountWithoutFee, currencyFromInfo.decimals);
8823
- _context2.n = 5;
9537
+ _context2.n = 6;
8824
9538
  return tradeRouter.getBestSell(currencyFromInfo.id, currencyToInfo.id, amountNormalized);
8825
- case 5:
9539
+ case 6:
8826
9540
  trade = _context2.v;
8827
- amountOut = BigInt(trade.amountOut.decimalPlaces(0).toString());
9541
+ amountOut = trade.amountOut;
8828
9542
  slippageMultiplier = Number(slippagePct);
8829
9543
  return _context2.a(2, padValueBy(amountOut, -slippageMultiplier));
8830
9544
  }
@@ -8839,14 +9553,18 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
8839
9553
  key: "getDexConfig",
8840
9554
  value: function () {
8841
9555
  var _getDexConfig = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(api) {
8842
- var _createSdkContext3, tradeRouter, assets, sdkAssets, transformedAssets;
9556
+ var sdk, assets, sdkAssets, transformedAssets;
8843
9557
  return _regenerator().w(function (_context3) {
8844
- while (1) switch (_context3.n) {
9558
+ while (1) switch (_context3.p = _context3.n) {
8845
9559
  case 0:
8846
- _createSdkContext3 = createSdkContext(api), tradeRouter = _createSdkContext3.api.router;
8847
9560
  _context3.n = 1;
8848
- return tradeRouter.getAllAssets();
9561
+ return createSdkContext(api);
8849
9562
  case 1:
9563
+ sdk = _context3.v;
9564
+ _context3.p = 2;
9565
+ _context3.n = 3;
9566
+ return sdk.client.asset.getSupported();
9567
+ case 3:
8850
9568
  assets = _context3.v;
8851
9569
  sdkAssets = getAssets(this.chain);
8852
9570
  transformedAssets = assets.map(function (_ref) {
@@ -8854,7 +9572,7 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
8854
9572
  var symbol = _ref.symbol,
8855
9573
  id = _ref.id;
8856
9574
  var asset = (_sdkAssets$find = sdkAssets.find(function (a) {
8857
- return !a.isNative && a.assetId === id;
9575
+ return !a.isNative && a.assetId === id.toString();
8858
9576
  })) !== null && _sdkAssets$find !== void 0 ? _sdkAssets$find : sdkAssets.find(function (a) {
8859
9577
  return a.symbol.toLowerCase() === symbol.toLowerCase();
8860
9578
  });
@@ -8870,8 +9588,14 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
8870
9588
  }),
8871
9589
  pairs: []
8872
9590
  });
9591
+ case 4:
9592
+ _context3.p = 4;
9593
+ sdk.destroy();
9594
+ return _context3.f(4);
9595
+ case 5:
9596
+ return _context3.a(2);
8873
9597
  }
8874
- }, _callee3, this);
9598
+ }, _callee3, this, [[2,, 4, 5]]);
8875
9599
  }));
8876
9600
  function getDexConfig(_x4) {
8877
9601
  return _getDexConfig.apply(this, arguments);
@@ -8998,18 +9722,11 @@ var getExchangePairs = function getExchangePairs(exchange) {
8998
9722
  });
8999
9723
  };
9000
9724
 
9001
- /**
9002
- * Retrieves the list of assets supported for transfer from the origin chain to the exchange chain.
9003
- *
9004
- * @param from - The origin chain.
9005
- * @param exchange - The exchange chain or 'Auto select'.
9006
- * @returns An array of supported assets.
9007
- */
9008
- var getSupportedAssetsFrom = function getSupportedAssetsFrom(from, exchangeInput) {
9725
+ var getSupportedAssetsFromImpl = function getSupportedAssetsFromImpl(from, exchangeInput, ctx) {
9009
9726
  var exchange = normalizeExchange(exchangeInput);
9010
9727
  if (exchange === undefined) {
9011
9728
  if (!from) return [];
9012
- return getAssets(from);
9729
+ return getAssetsImpl(from, ctx);
9013
9730
  }
9014
9731
  var exchangeAssets = Array.isArray(exchange) ? exchange.flatMap(function (exchange) {
9015
9732
  return getExchangeAssets(exchange);
@@ -9017,30 +9734,32 @@ var getSupportedAssetsFrom = function getSupportedAssetsFrom(from, exchangeInput
9017
9734
  if (!from || !Array.isArray(exchange) && from === createExchangeInstance(exchange).chain) {
9018
9735
  return exchangeAssets;
9019
9736
  }
9020
- var fromAssets = getAssets(from);
9737
+ var fromAssets = getAssetsImpl(from, ctx);
9021
9738
  return fromAssets.filter(function (fromAsset) {
9022
9739
  return exchangeAssets.some(function (exchangeAsset) {
9023
9740
  return isAssetEqual(fromAsset, exchangeAsset);
9024
9741
  });
9025
9742
  });
9026
9743
  };
9027
-
9028
9744
  /**
9029
- * Retrieves the list of assets supported for transfer to the destination chain.
9745
+ * Retrieves the list of assets supported for transfer from the origin chain to the exchange chain.
9030
9746
  *
9031
- * @param origin - The origin chain.
9747
+ * @param from - The origin chain.
9032
9748
  * @param exchange - The exchange chain or 'Auto select'.
9033
- * @param to - The destination chain.
9034
9749
  * @returns An array of supported assets.
9035
9750
  */
9036
- var getSupportedAssetsTo = function getSupportedAssetsTo(exchangeInput, to) {
9751
+ var getSupportedAssetsFrom = function getSupportedAssetsFrom(from, exchangeInput) {
9752
+ return getSupportedAssetsFromImpl(from, exchangeInput);
9753
+ };
9754
+
9755
+ var getSupportedAssetsToImpl = function getSupportedAssetsToImpl(exchangeInput, to, ctx) {
9037
9756
  var exchange = normalizeExchange(exchangeInput);
9038
9757
  if (exchange === undefined) {
9039
9758
  var allExchangeAssets = EXCHANGE_CHAINS.map(function (exchangeChain) {
9040
9759
  return getExchangeAssets(exchangeChain);
9041
9760
  }).flat();
9042
9761
  if (to) {
9043
- var toAssets = getAssets(to);
9762
+ var toAssets = getAssetsImpl(to, ctx);
9044
9763
  var filteredExchangeAssets = allExchangeAssets.filter(function (asset) {
9045
9764
  return toAssets.some(function (toAsset) {
9046
9765
  return isAssetEqual(asset, toAsset);
@@ -9059,7 +9778,7 @@ var getSupportedAssetsTo = function getSupportedAssetsTo(exchangeInput, to) {
9059
9778
  return getExchangeAssets(exchange);
9060
9779
  }) : getExchangeAssets(exchange);
9061
9780
  if (to) {
9062
- var _toAssets = getAssets(to);
9781
+ var _toAssets = getAssetsImpl(to, ctx);
9063
9782
  var _filteredExchangeAssets = exchangeAssets.filter(function (asset) {
9064
9783
  return _toAssets.some(function (toAsset) {
9065
9784
  return isAssetEqual(asset, toAsset);
@@ -9074,24 +9793,28 @@ var getSupportedAssetsTo = function getSupportedAssetsTo(exchangeInput, to) {
9074
9793
  }
9075
9794
  return exchangeAssets;
9076
9795
  };
9077
-
9078
9796
  /**
9079
- * Retrieves the list of assets that can be used to pay for fees on the origin chain.
9797
+ * Retrieves the list of assets supported for transfer to the destination chain.
9080
9798
  *
9081
- * @param from - The origin chain.
9799
+ * @param origin - The origin chain.
9082
9800
  * @param exchange - The exchange chain or 'Auto select'.
9083
- * @returns An array of fee-eligible assets.
9801
+ * @param to - The destination chain.
9802
+ * @returns An array of supported assets.
9084
9803
  */
9085
- var getSupportedFeeAssets = function getSupportedFeeAssets(from, exchangeInput) {
9804
+ var getSupportedAssetsTo = function getSupportedAssetsTo(exchangeInput, to) {
9805
+ return getSupportedAssetsToImpl(exchangeInput, to);
9806
+ };
9807
+
9808
+ var getSupportedFeeAssetsImpl = function getSupportedFeeAssetsImpl(from, exchangeInput, ctx) {
9086
9809
  var exchange = normalizeExchange(exchangeInput);
9087
- var supportedAssets = getSupportedAssetsFrom(from, exchange);
9810
+ var supportedAssets = getSupportedAssetsFromImpl(from, exchange, ctx);
9088
9811
  var chains = from ? [from] : (exchange === undefined ? EXCHANGE_CHAINS : Array.isArray(exchange) ? exchange : [exchange]).map(function (ex) {
9089
9812
  return createExchangeInstance(ex).chain;
9090
9813
  }).filter(function (chain, i, arr) {
9091
9814
  return arr.indexOf(chain) === i;
9092
9815
  });
9093
9816
  var chainAssets = chains.flatMap(function (chain) {
9094
- return getAssets(chain);
9817
+ return getAssetsImpl(chain, ctx);
9095
9818
  });
9096
9819
  return supportedAssets.filter(function (asset) {
9097
9820
  return chainAssets.some(function (chainAsset) {
@@ -9099,6 +9822,16 @@ var getSupportedFeeAssets = function getSupportedFeeAssets(from, exchangeInput)
9099
9822
  });
9100
9823
  });
9101
9824
  };
9825
+ /**
9826
+ * Retrieves the list of assets that can be used to pay for fees on the origin chain.
9827
+ *
9828
+ * @param from - The origin chain.
9829
+ * @param exchange - The exchange chain or 'Auto select'.
9830
+ * @returns An array of fee-eligible assets.
9831
+ */
9832
+ var getSupportedFeeAssets = function getSupportedFeeAssets(from, exchangeInput) {
9833
+ return getSupportedFeeAssetsImpl(from, exchangeInput);
9834
+ };
9102
9835
 
9103
9836
  var asArray = function asArray(ex) {
9104
9837
  return ex === undefined ? EXCHANGE_CHAINS : Array.isArray(ex) ? ex : [ex];
@@ -9327,65 +10060,116 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
9327
10060
  };
9328
10061
  }();
9329
10062
 
10063
+ var createToExchangeBuilder = function createToExchangeBuilder(_ref) {
10064
+ var origin = _ref.origin,
10065
+ exchange = _ref.exchange,
10066
+ sender = _ref.sender,
10067
+ evmSenderAddress = _ref.evmSenderAddress,
10068
+ amount = _ref.amount,
10069
+ api = _ref.api;
10070
+ return Builder(api.clone()).from(origin.chain).to(exchange.chain).currency({
10071
+ location: origin.assetFrom.location,
10072
+ amount: amount
10073
+ }).sender(isChainEvm(origin.chain) ? evmSenderAddress : sender).recipient(sender);
10074
+ };
10075
+ var buildToExchangeExtrinsic = function buildToExchangeExtrinsic(options) {
10076
+ return createToExchangeBuilder(options).build();
10077
+ };
10078
+ var getToExchangeFee = function getToExchangeFee(options, disableFallback) {
10079
+ return createToExchangeBuilder(options).getXcmFee({
10080
+ disableFallback: disableFallback
10081
+ });
10082
+ };
10083
+ var getToExchangeOriginFee = function getToExchangeOriginFee(options, disableFallback) {
10084
+ return createToExchangeBuilder(options).getOriginXcmFee({
10085
+ disableFallback: disableFallback
10086
+ });
10087
+ };
10088
+ var createFromExchangeBuilder = function createFromExchangeBuilder(_ref2) {
10089
+ var exchange = _ref2.exchange,
10090
+ destination = _ref2.destination,
10091
+ amount = _ref2.amount,
10092
+ sender = _ref2.sender,
10093
+ api = _ref2.api;
10094
+ var apiForChain = api.clone();
10095
+ return Builder(apiForChain).from(exchange.chain).to(destination.chain).currency({
10096
+ location: exchange.assetTo.location,
10097
+ amount: amount
10098
+ }).sender(sender).recipient(destination.address);
10099
+ };
10100
+ var buildFromExchangeExtrinsic = function buildFromExchangeExtrinsic(options) {
10101
+ return createFromExchangeBuilder(options).build();
10102
+ };
10103
+ var getFromExchangeFee = function getFromExchangeFee(options, disableFallback) {
10104
+ return createFromExchangeBuilder(options).getXcmFee({
10105
+ disableFallback: disableFallback
10106
+ });
10107
+ };
10108
+ var determineFeeCalcAddress = function determineFeeCalcAddress(sender, recipient) {
10109
+ if (!ethers.isAddress(sender)) {
10110
+ // Use wallet address for fee calculation
10111
+ return sender;
10112
+ }
10113
+ if (recipient && !ethers.isAddress(recipient)) {
10114
+ // Use recipient address for fee calculation
10115
+ return recipient;
10116
+ }
10117
+ // If both addresses are ethereum addresses, use fallback address for fee calculation
10118
+ return FALLBACK_FEE_CALC_ADDRESS;
10119
+ };
10120
+
9330
10121
  var selectBestExchange = /*#__PURE__*/function () {
9331
10122
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi, isForFeeEstimation) {
9332
- var api;
10123
+ var api, exchangeConfig;
9333
10124
  return _regenerator().w(function (_context2) {
9334
10125
  while (1) switch (_context2.n) {
9335
10126
  case 0:
9336
10127
  api = options.api;
10128
+ exchangeConfig = convertBuilderConfig(api.config);
9337
10129
  return _context2.a(2, selectBestExchangeCommon(options, originApi, /*#__PURE__*/function () {
9338
10130
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, options, parsedAmount) {
9339
- var modifiedOptions, toDestTxFee, _yield$dex$handleMult, amountOut, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10;
10131
+ var exchangeInfo, modifiedOptions, toDestTxFee, _yield$dex$handleMult, amountOut, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
9340
10132
  return _regenerator().w(function (_context) {
9341
10133
  while (1) switch (_context.n) {
9342
10134
  case 0:
9343
10135
  _t = _objectSpread2;
9344
- _t2 = _objectSpread2({}, options);
10136
+ _t2 = _objectSpread2;
9345
10137
  _t3 = {};
9346
- _t4 = BigInt(parsedAmount);
9347
10138
  _context.n = 1;
9348
- return dex.createApiInstance();
10139
+ return buildExchangeApiVariant(dex, exchangeConfig);
9349
10140
  case 1:
9350
- _t5 = _context.v;
10141
+ _t4 = _t2(_t3, _context.v);
10142
+ _t5 = {};
9351
10143
  _context.n = 2;
9352
- return dex.createApiInstancePapi();
10144
+ return api.createApiForChain(dex.chain);
9353
10145
  case 2:
9354
10146
  _t6 = _context.v;
9355
- _context.n = 3;
9356
- return api.createApiForChain(dex.chain);
9357
- case 3:
9358
- _t7 = _context.v;
9359
- _t8 = dex.chain;
9360
- _t9 = assetFromExchange;
9361
- _t0 = assetTo;
9362
- _t1 = {
9363
- apiPjs: _t5,
9364
- apiPapi: _t6,
9365
- api: _t7,
9366
- chain: _t8,
9367
- assetFrom: _t9,
9368
- assetTo: _t0
9369
- };
9370
- _t10 = determineFeeCalcAddress(options.sender, options.recipient);
9371
- modifiedOptions = _t(_t2, _t3, {
9372
- amount: _t4,
9373
- exchange: _t1,
9374
- feeCalcAddress: _t10
10147
+ _t7 = dex.chain;
10148
+ _t8 = assetFromExchange;
10149
+ _t9 = assetTo;
10150
+ exchangeInfo = _t(_t4, _t5, {
10151
+ api: _t6,
10152
+ chain: _t7,
10153
+ assetFrom: _t8,
10154
+ assetTo: _t9
9375
10155
  });
9376
- _context.n = 4;
10156
+ modifiedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
10157
+ amount: BigInt(parsedAmount),
10158
+ exchange: exchangeInfo,
10159
+ feeCalcAddress: determineFeeCalcAddress(options.sender, options.recipient)
10160
+ });
10161
+ _context.n = 3;
9377
10162
  return calculateFromExchangeFee(modifiedOptions);
9378
- case 4:
10163
+ case 3:
9379
10164
  toDestTxFee = _context.v;
9380
- _context.n = 5;
9381
- return dex.handleMultiSwap(_objectSpread2(_objectSpread2({}, modifiedOptions), {}, {
10165
+ _context.n = 4;
10166
+ return dex.handleMultiSwap(_objectSpread2(_objectSpread2(_objectSpread2({}, modifiedOptions), pickExchangeApiVariant(modifiedOptions.exchange)), {}, {
9382
10167
  api: modifiedOptions.exchange.api,
9383
- apiPjs: modifiedOptions.exchange.apiPjs,
9384
10168
  assetFrom: modifiedOptions.exchange.assetFrom,
9385
10169
  assetTo: modifiedOptions.exchange.assetTo,
9386
10170
  isForFeeEstimation: isForFeeEstimation
9387
10171
  }), toDestTxFee);
9388
- case 5:
10172
+ case 4:
9389
10173
  _yield$dex$handleMult = _context.v;
9390
10174
  amountOut = _yield$dex$handleMult.amountOut;
9391
10175
  return _context.a(2, amountOut);
@@ -9454,59 +10238,6 @@ var resolveAssets = function resolveAssets(dex, _ref) {
9454
10238
  };
9455
10239
  };
9456
10240
 
9457
- var createToExchangeBuilder = function createToExchangeBuilder(_ref) {
9458
- var origin = _ref.origin,
9459
- exchange = _ref.exchange,
9460
- sender = _ref.sender,
9461
- evmSenderAddress = _ref.evmSenderAddress,
9462
- amount = _ref.amount,
9463
- api = _ref.api;
9464
- return Builder(api.clone()).from(origin.chain).to(exchange.chain).currency({
9465
- location: origin.assetFrom.location,
9466
- amount: amount
9467
- }).sender(isChainEvm(origin.chain) ? evmSenderAddress : sender).recipient(sender);
9468
- };
9469
- var buildToExchangeExtrinsic = function buildToExchangeExtrinsic(options) {
9470
- return createToExchangeBuilder(options).build();
9471
- };
9472
- var getToExchangeFee = function getToExchangeFee(options, disableFallback) {
9473
- return createToExchangeBuilder(options).getXcmFee({
9474
- disableFallback: disableFallback
9475
- });
9476
- };
9477
- var createFromExchangeBuilder = function createFromExchangeBuilder(_ref2) {
9478
- var exchange = _ref2.exchange,
9479
- destination = _ref2.destination,
9480
- amount = _ref2.amount,
9481
- sender = _ref2.sender,
9482
- api = _ref2.api;
9483
- var apiForChain = api.clone();
9484
- return Builder(apiForChain).from(exchange.chain).to(destination.chain).currency({
9485
- location: exchange.assetTo.location,
9486
- amount: amount
9487
- }).sender(sender).recipient(destination.address);
9488
- };
9489
- var buildFromExchangeExtrinsic = function buildFromExchangeExtrinsic(options) {
9490
- return createFromExchangeBuilder(options).build();
9491
- };
9492
- var getFromExchangeFee = function getFromExchangeFee(options, disableFallback) {
9493
- return createFromExchangeBuilder(options).getXcmFee({
9494
- disableFallback: disableFallback
9495
- });
9496
- };
9497
- var determineFeeCalcAddress = function determineFeeCalcAddress(sender, recipient) {
9498
- if (!ethers.isAddress(sender)) {
9499
- // Use wallet address for fee calculation
9500
- return sender;
9501
- }
9502
- if (recipient && !ethers.isAddress(recipient)) {
9503
- // Use recipient address for fee calculation
9504
- return recipient;
9505
- }
9506
- // If both addresses are ethereum addresses, use fallback address for fee calculation
9507
- return FALLBACK_FEE_CALC_ADDRESS;
9508
- };
9509
-
9510
10241
  var prepareTransformedOptions = /*#__PURE__*/function () {
9511
10242
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
9512
10243
  var _assetFromOrigin$deci;
@@ -9545,11 +10276,7 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
9545
10276
  _t0,
9546
10277
  _t1,
9547
10278
  _t10,
9548
- _t11,
9549
- _t12,
9550
- _t13,
9551
- _t14,
9552
- _t15;
10279
+ _t11;
9553
10280
  return _regenerator().w(function (_context) {
9554
10281
  while (1) switch (_context.n) {
9555
10282
  case 0:
@@ -9608,39 +10335,30 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
9608
10335
  assetFrom: assetFromOrigin,
9609
10336
  feeAssetInfo: feeAssetFromOrigin
9610
10337
  } : undefined;
10338
+ _t8 = _objectSpread2;
10339
+ _t9 = _objectSpread2;
10340
+ _t0 = {};
9611
10341
  _context.n = 9;
9612
- return dex.createApiInstance(exchangeConfig);
10342
+ return buildExchangeApiVariant(dex, exchangeConfig);
9613
10343
  case 9:
9614
- _t8 = _context.v;
9615
- _context.n = 10;
9616
- return dex.createApiInstancePapi(exchangeConfig);
9617
- case 10:
9618
- _t9 = _context.v;
9619
- _t0 = exchangeApi;
9620
- _t1 = dex.chain;
9621
- _t10 = assetFromExchange;
9622
- _t11 = assetTo;
9623
- _t12 = feeAssetFromExchange;
9624
- _t13 = {
9625
- apiPjs: _t8,
9626
- apiPapi: _t9,
9627
- api: _t0,
9628
- chain: _t1,
9629
- assetFrom: _t10,
9630
- assetTo: _t11,
9631
- feeAssetInfo: _t12
9632
- };
9633
- _t14 = destinationSpecified && recipient ? {
10344
+ _t1 = _t8(_t9(_t0, _context.v), {}, {
10345
+ api: exchangeApi,
10346
+ chain: dex.chain,
10347
+ assetFrom: assetFromExchange,
10348
+ assetTo: assetTo,
10349
+ feeAssetInfo: feeAssetFromExchange
10350
+ });
10351
+ _t10 = destinationSpecified && recipient ? {
9634
10352
  chain: to,
9635
10353
  address: recipient
9636
10354
  } : undefined;
9637
- _t15 = determineFeeCalcAddress(sender, recipient);
10355
+ _t11 = determineFeeCalcAddress(sender, recipient);
9638
10356
  transformed = _t3(_t4, _t5, {
9639
10357
  amount: _t6,
9640
10358
  origin: _t7,
9641
- exchange: _t13,
9642
- destination: _t14,
9643
- feeCalcAddress: _t15
10359
+ exchange: _t1,
10360
+ destination: _t10,
10361
+ feeCalcAddress: _t11
9644
10362
  });
9645
10363
  return _context.a(2, {
9646
10364
  dex: dex,
@@ -9654,6 +10372,199 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
9654
10372
  };
9655
10373
  }();
9656
10374
 
10375
+ var callDexAmountOut = function callDexAmountOut(dex, options) {
10376
+ var _overrides$amount, _overrides$assetTo;
10377
+ var overrides = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
10378
+ return dex.getAmountOut(_objectSpread2(_objectSpread2(_objectSpread2({}, options), pickExchangeApiVariant(options.exchange)), {}, {
10379
+ amount: (_overrides$amount = overrides.amount) !== null && _overrides$amount !== void 0 ? _overrides$amount : options.amount,
10380
+ api: options.exchange.api,
10381
+ assetFrom: options.exchange.assetFrom,
10382
+ assetTo: (_overrides$assetTo = overrides.assetTo) !== null && _overrides$assetTo !== void 0 ? _overrides$assetTo : options.exchange.assetTo
10383
+ }, overrides.slippagePct !== undefined && {
10384
+ slippagePct: overrides.slippagePct
10385
+ }));
10386
+ };
10387
+ var buildSwapExecuteTx = /*#__PURE__*/function () {
10388
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options) {
10389
+ var _overrides$amount2, _origin$assetFrom, _origin$feeAssetInfo;
10390
+ var overrides,
10391
+ api,
10392
+ origin,
10393
+ exchange,
10394
+ destination,
10395
+ currencyTo,
10396
+ amount,
10397
+ sender,
10398
+ recipient,
10399
+ evmSenderAddress,
10400
+ amt,
10401
+ minAmountOutSlippage,
10402
+ amountOut,
10403
+ tx,
10404
+ _args = arguments;
10405
+ return _regenerator().w(function (_context) {
10406
+ while (1) switch (_context.n) {
10407
+ case 0:
10408
+ overrides = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
10409
+ api = options.api, origin = options.origin, exchange = options.exchange, destination = options.destination, currencyTo = options.currencyTo, amount = options.amount, sender = options.sender, recipient = options.recipient, evmSenderAddress = options.evmSenderAddress;
10410
+ amt = (_overrides$amount2 = overrides.amount) !== null && _overrides$amount2 !== void 0 ? _overrides$amount2 : amount;
10411
+ minAmountOutSlippage = overrides.feeEstimation ? '1' : undefined;
10412
+ _context.n = 1;
10413
+ return callDexAmountOut(dex, options, {
10414
+ amount: amt
10415
+ });
10416
+ case 1:
10417
+ amountOut = _context.v;
10418
+ _context.n = 2;
10419
+ return handleSwapExecuteTransfer({
10420
+ api: api,
10421
+ chain: origin === null || origin === void 0 ? void 0 : origin.chain,
10422
+ exchangeChain: exchange.chain,
10423
+ destChain: destination === null || destination === void 0 ? void 0 : destination.chain,
10424
+ assetInfoFrom: _objectSpread2(_objectSpread2({}, (_origin$assetFrom = origin === null || origin === void 0 ? void 0 : origin.assetFrom) !== null && _origin$assetFrom !== void 0 ? _origin$assetFrom : exchange.assetFrom), {}, {
10425
+ amount: amt
10426
+ }),
10427
+ assetInfoTo: _objectSpread2(_objectSpread2({}, exchange.assetTo), {}, {
10428
+ amount: amountOut
10429
+ }),
10430
+ currencyTo: currencyTo,
10431
+ feeAssetInfo: (_origin$feeAssetInfo = origin === null || origin === void 0 ? void 0 : origin.feeAssetInfo) !== null && _origin$feeAssetInfo !== void 0 ? _origin$feeAssetInfo : exchange.feeAssetInfo,
10432
+ sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
10433
+ recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
10434
+ calculateMinAmountOut: function calculateMinAmountOut(amountIn, assetTo) {
10435
+ return callDexAmountOut(dex, options, {
10436
+ amount: amountIn,
10437
+ assetTo: assetTo,
10438
+ slippagePct: minAmountOutSlippage
10439
+ });
10440
+ }
10441
+ });
10442
+ case 2:
10443
+ tx = _context.v;
10444
+ return _context.a(2, {
10445
+ tx: tx,
10446
+ amountOut: amountOut
10447
+ });
10448
+ }
10449
+ }, _callee);
10450
+ }));
10451
+ return function buildSwapExecuteTx(_x, _x2) {
10452
+ return _ref.apply(this, arguments);
10453
+ };
10454
+ }();
10455
+ var createSwapExecuteBuildTx = function createSwapExecuteBuildTx(dex, options) {
10456
+ return /*#__PURE__*/function () {
10457
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(overrideAmount) {
10458
+ var amt, _yield$buildSwapExecu, tx;
10459
+ return _regenerator().w(function (_context2) {
10460
+ while (1) switch (_context2.n) {
10461
+ case 0:
10462
+ amt = overrideAmount !== undefined ? applyDecimalAbstraction(overrideAmount, options.exchange.assetFrom.decimals, true) : options.amount;
10463
+ _context2.n = 1;
10464
+ return buildSwapExecuteTx(dex, options, {
10465
+ amount: amt,
10466
+ feeEstimation: true
10467
+ });
10468
+ case 1:
10469
+ _yield$buildSwapExecu = _context2.v;
10470
+ tx = _yield$buildSwapExecu.tx;
10471
+ return _context2.a(2, tx);
10472
+ }
10473
+ }, _callee2);
10474
+ }));
10475
+ return function (_x3) {
10476
+ return _ref2.apply(this, arguments);
10477
+ };
10478
+ }();
10479
+ };
10480
+ var canUseExecuteTransfer = function canUseExecuteTransfer(dex, options) {
10481
+ return Boolean(options.origin || options.destination) && (dex.chain.includes('AssetHub') || dex.chain === 'Hydration');
10482
+ };
10483
+ var isFilteredError = function isFilteredError(error) {
10484
+ return error instanceof DryRunFailedError && error.dryRunType === 'origin' && error.reason === 'Filtered';
10485
+ };
10486
+ var getSwapExecuteXcmFee = /*#__PURE__*/function () {
10487
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(dex, options, disableFallback) {
10488
+ var _origin$chain, _destination$chain;
10489
+ var api, origin, exchange, currencyFrom, currencyTo, feeAsset, destination, amount, sender, recipient, evmSenderAddress, buildTx, amountOut, result;
10490
+ return _regenerator().w(function (_context3) {
10491
+ while (1) switch (_context3.n) {
10492
+ case 0:
10493
+ api = options.api, origin = options.origin, exchange = options.exchange, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, feeAsset = options.feeAsset, destination = options.destination, amount = options.amount, sender = options.sender, recipient = options.recipient, evmSenderAddress = options.evmSenderAddress;
10494
+ assertCurrencyCore(currencyTo);
10495
+ buildTx = createSwapExecuteBuildTx(dex, options);
10496
+ _context3.n = 1;
10497
+ return callDexAmountOut(dex, options);
10498
+ case 1:
10499
+ amountOut = _context3.v;
10500
+ _context3.n = 2;
10501
+ return getXcmFee({
10502
+ api: api,
10503
+ buildTx: buildTx,
10504
+ origin: (_origin$chain = origin === null || origin === void 0 ? void 0 : origin.chain) !== null && _origin$chain !== void 0 ? _origin$chain : exchange.chain,
10505
+ destination: (_destination$chain = destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _destination$chain !== void 0 ? _destination$chain : exchange.chain,
10506
+ sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
10507
+ recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
10508
+ currency: _objectSpread2(_objectSpread2({}, currencyFrom), {}, {
10509
+ amount: amount
10510
+ }),
10511
+ feeAsset: feeAsset,
10512
+ disableFallback: disableFallback,
10513
+ swapConfig: {
10514
+ currencyTo: currencyTo,
10515
+ exchangeChain: exchange.chain,
10516
+ amountOut: amountOut
10517
+ }
10518
+ });
10519
+ case 2:
10520
+ result = _context3.v;
10521
+ if (!(result.failureReason === 'NoDeal' && exchange.chain === 'Hydration')) {
10522
+ _context3.n = 3;
10523
+ break;
10524
+ }
10525
+ throw new RoutingResolutionError('An error occured, either this route is not registered for swap on exchange chain, or the amount out was not able to be calculated.');
10526
+ case 3:
10527
+ return _context3.a(2, {
10528
+ result: result,
10529
+ amountOut: amountOut
10530
+ });
10531
+ }
10532
+ }, _callee3);
10533
+ }));
10534
+ return function getSwapExecuteXcmFee(_x4, _x5, _x6) {
10535
+ return _ref3.apply(this, arguments);
10536
+ };
10537
+ }();
10538
+ var getSwapExecuteOriginXcmFee = /*#__PURE__*/function () {
10539
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(dex, options, disableFallback) {
10540
+ var _origin$chain2, _destination$chain2;
10541
+ var api, origin, exchange, currencyFrom, feeAsset, destination, amount, sender, evmSenderAddress, buildTx;
10542
+ return _regenerator().w(function (_context4) {
10543
+ while (1) switch (_context4.n) {
10544
+ case 0:
10545
+ api = options.api, origin = options.origin, exchange = options.exchange, currencyFrom = options.currencyFrom, feeAsset = options.feeAsset, destination = options.destination, amount = options.amount, sender = options.sender, evmSenderAddress = options.evmSenderAddress;
10546
+ buildTx = createSwapExecuteBuildTx(dex, options);
10547
+ assertCurrencyCore(currencyFrom);
10548
+ return _context4.a(2, getOriginXcmFee$1({
10549
+ api: api,
10550
+ buildTx: buildTx,
10551
+ origin: (_origin$chain2 = origin === null || origin === void 0 ? void 0 : origin.chain) !== null && _origin$chain2 !== void 0 ? _origin$chain2 : exchange.chain,
10552
+ destination: (_destination$chain2 = destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _destination$chain2 !== void 0 ? _destination$chain2 : exchange.chain,
10553
+ sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
10554
+ currency: _objectSpread2(_objectSpread2({}, currencyFrom), {}, {
10555
+ amount: amount
10556
+ }),
10557
+ feeAsset: feeAsset,
10558
+ disableFallback: disableFallback
10559
+ }));
10560
+ }
10561
+ }, _callee4);
10562
+ }));
10563
+ return function getSwapExecuteOriginXcmFee(_x7, _x8, _x9) {
10564
+ return _ref4.apply(this, arguments);
10565
+ };
10566
+ }();
10567
+
9657
10568
  var validateDestinationAddress = function validateDestinationAddress(address, destination) {
9658
10569
  if (typeof address === 'string') {
9659
10570
  var isDestinationEvm = isChainEvm(destination);
@@ -9749,9 +10660,8 @@ var createSwapTx = /*#__PURE__*/function () {
9749
10660
  case 1:
9750
10661
  toDestTxFee = _context2.v;
9751
10662
  _context2.n = 2;
9752
- return exchange.handleMultiSwap(_objectSpread2(_objectSpread2({}, options), {}, {
10663
+ return exchange.handleMultiSwap(_objectSpread2(_objectSpread2(_objectSpread2({}, options), pickExchangeApiVariant(options.exchange)), {}, {
9753
10664
  api: options.exchange.api,
9754
- apiPjs: options.exchange.apiPjs,
9755
10665
  assetFrom: options.exchange.assetFrom,
9756
10666
  assetTo: options.exchange.assetTo,
9757
10667
  isForFeeEstimation: isForFeeEstimation
@@ -9772,100 +10682,69 @@ var createSwapTx = /*#__PURE__*/function () {
9772
10682
  }, _callee2);
9773
10683
  }));
9774
10684
  return function createSwapTx(_x2, _x3) {
9775
- return _ref2.apply(this, arguments);
9776
- };
9777
- }();
9778
-
9779
- var prepareExtrinsics = /*#__PURE__*/function () {
9780
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options) {
9781
- var api, origin, exchange, destination, currencyTo, amount, evmSenderAddress, sender, recipient, _origin$assetFrom, _origin$feeAssetInfo, _amountOut, tx, toExchangeTx, _yield$createSwapTx, swapTxs, amountOut, toDestTx, _t, _t2, _t3;
9782
- return _regenerator().w(function (_context) {
9783
- while (1) switch (_context.p = _context.n) {
9784
- case 0:
9785
- api = options.api, origin = options.origin, exchange = options.exchange, destination = options.destination, currencyTo = options.currencyTo, amount = options.amount, evmSenderAddress = options.evmSenderAddress, sender = options.sender, recipient = options.recipient;
9786
- if (!((origin || destination) && (dex.chain.includes('AssetHub') || dex.chain === 'Hydration'))) {
9787
- _context.n = 5;
9788
- break;
9789
- }
9790
- _context.p = 1;
9791
- _context.n = 2;
9792
- return dex.getAmountOut(_objectSpread2(_objectSpread2({}, options), {}, {
9793
- api: exchange.api,
9794
- apiPjs: exchange.apiPjs,
9795
- assetFrom: exchange.assetFrom,
9796
- assetTo: exchange.assetTo
9797
- }));
9798
- case 2:
9799
- _amountOut = _context.v;
9800
- _context.n = 3;
9801
- return handleSwapExecuteTransfer({
9802
- api: api,
9803
- chain: origin === null || origin === void 0 ? void 0 : origin.chain,
9804
- exchangeChain: exchange.chain,
9805
- destChain: destination === null || destination === void 0 ? void 0 : destination.chain,
9806
- assetInfoFrom: _objectSpread2(_objectSpread2({}, (_origin$assetFrom = origin === null || origin === void 0 ? void 0 : origin.assetFrom) !== null && _origin$assetFrom !== void 0 ? _origin$assetFrom : exchange.assetFrom), {}, {
9807
- amount: BigInt(amount)
9808
- }),
9809
- assetInfoTo: _objectSpread2(_objectSpread2({}, exchange.assetTo), {}, {
9810
- amount: _amountOut
9811
- }),
9812
- sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
9813
- recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
9814
- currencyTo: currencyTo,
9815
- feeAssetInfo: (_origin$feeAssetInfo = origin === null || origin === void 0 ? void 0 : origin.feeAssetInfo) !== null && _origin$feeAssetInfo !== void 0 ? _origin$feeAssetInfo : exchange.feeAssetInfo,
9816
- calculateMinAmountOut: function calculateMinAmountOut(amountIn, assetTo) {
9817
- return dex.getAmountOut(_objectSpread2(_objectSpread2({}, options), {}, {
9818
- amount: amountIn,
9819
- api: options.exchange.api,
9820
- apiPjs: options.exchange.apiPjs,
9821
- assetFrom: options.exchange.assetFrom,
9822
- assetTo: assetTo !== null && assetTo !== void 0 ? assetTo : options.exchange.assetTo
9823
- }));
9824
- }
9825
- });
9826
- case 3:
9827
- tx = _context.v;
10685
+ return _ref2.apply(this, arguments);
10686
+ };
10687
+ }();
10688
+
10689
+ var prepareExtrinsics = /*#__PURE__*/function () {
10690
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options) {
10691
+ var api, origin, exchange, destination, sender, _yield$buildSwapExecu, tx, _amountOut, toExchangeTx, _yield$createSwapTx, swapTxs, amountOut, toDestTx, _t, _t2, _t3;
10692
+ return _regenerator().w(function (_context) {
10693
+ while (1) switch (_context.p = _context.n) {
10694
+ case 0:
10695
+ api = options.api, origin = options.origin, exchange = options.exchange, destination = options.destination, sender = options.sender;
10696
+ if (!canUseExecuteTransfer(dex, options)) {
10697
+ _context.n = 4;
10698
+ break;
10699
+ }
10700
+ _context.p = 1;
10701
+ _context.n = 2;
10702
+ return buildSwapExecuteTx(dex, options);
10703
+ case 2:
10704
+ _yield$buildSwapExecu = _context.v;
10705
+ tx = _yield$buildSwapExecu.tx;
10706
+ _amountOut = _yield$buildSwapExecu.amountOut;
9828
10707
  return _context.a(2, {
9829
10708
  swapTxs: [tx],
9830
10709
  isExecute: true,
9831
10710
  amountOut: _amountOut
9832
10711
  });
9833
- case 4:
9834
- _context.p = 4;
10712
+ case 3:
10713
+ _context.p = 3;
9835
10714
  _t = _context.v;
9836
- if (_t instanceof DryRunFailedError && _t.dryRunType === 'origin' && _t.reason === 'Filtered') {
9837
- _context.n = 5;
10715
+ if (isFilteredError(_t)) {
10716
+ _context.n = 4;
9838
10717
  break;
9839
10718
  }
9840
10719
  throw _t;
9841
- case 5:
10720
+ case 4:
9842
10721
  if (!(origin && origin.chain !== exchange.chain)) {
9843
- _context.n = 7;
10722
+ _context.n = 6;
9844
10723
  break;
9845
10724
  }
9846
- _context.n = 6;
10725
+ _context.n = 5;
9847
10726
  return buildToExchangeExtrinsic(_objectSpread2(_objectSpread2({}, options), {}, {
9848
10727
  origin: origin
9849
10728
  }));
9850
- case 6:
10729
+ case 5:
9851
10730
  _t2 = _context.v;
9852
- _context.n = 8;
10731
+ _context.n = 7;
9853
10732
  break;
9854
- case 7:
10733
+ case 6:
9855
10734
  _t2 = undefined;
9856
- case 8:
10735
+ case 7:
9857
10736
  toExchangeTx = _t2;
9858
- _context.n = 9;
10737
+ _context.n = 8;
9859
10738
  return createSwapTx(dex, options);
9860
- case 9:
10739
+ case 8:
9861
10740
  _yield$createSwapTx = _context.v;
9862
10741
  swapTxs = _yield$createSwapTx.txs;
9863
10742
  amountOut = _yield$createSwapTx.amountOut;
9864
10743
  if (!(destination && destination.chain !== exchange.chain)) {
9865
- _context.n = 11;
10744
+ _context.n = 10;
9866
10745
  break;
9867
10746
  }
9868
- _context.n = 10;
10747
+ _context.n = 9;
9869
10748
  return buildFromExchangeExtrinsic({
9870
10749
  exchange: exchange,
9871
10750
  destination: destination,
@@ -9873,13 +10752,13 @@ var prepareExtrinsics = /*#__PURE__*/function () {
9873
10752
  sender: sender,
9874
10753
  api: api
9875
10754
  });
9876
- case 10:
10755
+ case 9:
9877
10756
  _t3 = _context.v;
9878
- _context.n = 12;
10757
+ _context.n = 11;
9879
10758
  break;
9880
- case 11:
10759
+ case 10:
9881
10760
  _t3 = undefined;
9882
- case 12:
10761
+ case 11:
9883
10762
  toDestTx = _t3;
9884
10763
  return _context.a(2, {
9885
10764
  toExchangeTx: toExchangeTx,
@@ -9888,7 +10767,7 @@ var prepareExtrinsics = /*#__PURE__*/function () {
9888
10767
  amountOut: BigInt(amountOut)
9889
10768
  });
9890
10769
  }
9891
- }, _callee, null, [[1, 4]]);
10770
+ }, _callee, null, [[1, 3]]);
9892
10771
  }));
9893
10772
  return function prepareExtrinsics(_x, _x2) {
9894
10773
  return _ref.apply(this, arguments);
@@ -9962,7 +10841,7 @@ var buildTransactions = /*#__PURE__*/function () {
9962
10841
 
9963
10842
  var buildApiTransactions = /*#__PURE__*/function () {
9964
10843
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions) {
9965
- var _yield$prepareTransfo, options, dex;
10844
+ var _yield$prepareTransfo, options, dex, routerPlan;
9966
10845
  return _regenerator().w(function (_context) {
9967
10846
  while (1) switch (_context.n) {
9968
10847
  case 0:
@@ -9973,7 +10852,14 @@ var buildApiTransactions = /*#__PURE__*/function () {
9973
10852
  _yield$prepareTransfo = _context.v;
9974
10853
  options = _yield$prepareTransfo.options;
9975
10854
  dex = _yield$prepareTransfo.dex;
9976
- return _context.a(2, buildTransactions(dex, options));
10855
+ _context.n = 2;
10856
+ return buildTransactions(dex, options);
10857
+ case 2:
10858
+ routerPlan = _context.v;
10859
+ _context.n = 3;
10860
+ return maybePerformXcmFormatCheck(initialOptions.api, options, routerPlan);
10861
+ case 3:
10862
+ return _context.a(2, routerPlan);
9977
10863
  }
9978
10864
  }, _callee);
9979
10865
  }));
@@ -9982,143 +10868,78 @@ var buildApiTransactions = /*#__PURE__*/function () {
9982
10868
  };
9983
10869
  }();
9984
10870
 
9985
- var assignIsExchange = function assignIsExchange(result, options) {
9986
- var origin = options.origin,
9987
- exchange = options.exchange,
9988
- destination = options.destination;
9989
- if (!origin) {
9990
- result.origin.isExchange = true;
9991
- }
9992
- if (!destination && result.destination) {
9993
- result.destination.isExchange = true;
9994
- }
9995
- result.hops = result.hops.map(function (hop) {
9996
- var isExchange = hop.chain === exchange.chain;
9997
- return _objectSpread2(_objectSpread2({}, hop), {}, {
9998
- result: _objectSpread2(_objectSpread2({}, hop.result), {}, {
9999
- isExchange: isExchange
10000
- }),
10001
- isExchange: isExchange
10002
- });
10003
- });
10004
- return result;
10005
- };
10006
- var dryRunTransaction = /*#__PURE__*/function () {
10007
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, transaction, destChain, bypassOptions) {
10008
- var _ref2;
10009
- var api, exchange, sender, evmSenderAddress, destination, currencyFrom, currencyTo, amount, tx, chain, senderResolved, resolvedDest;
10871
+ var getSwapOriginFee = /*#__PURE__*/function () {
10872
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options, disableFallback) {
10873
+ var origin, exchange, _yield$getSwapFee, result, _t;
10010
10874
  return _regenerator().w(function (_context) {
10011
- while (1) switch (_context.n) {
10012
- case 0:
10013
- api = options.api, exchange = options.exchange, sender = options.sender, evmSenderAddress = options.evmSenderAddress, destination = options.destination, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, amount = options.amount;
10014
- tx = transaction.tx, chain = transaction.chain;
10015
- senderResolved = evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender;
10016
- resolvedDest = (_ref2 = destChain !== null && destChain !== void 0 ? destChain : destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _ref2 !== void 0 ? _ref2 : exchange.chain;
10017
- return _context.a(2, dryRun({
10018
- api: api.clone(),
10019
- tx: tx,
10020
- origin: chain,
10021
- destination: resolvedDest,
10022
- sender: senderResolved,
10023
- swapConfig: {
10024
- currencyTo: currencyTo,
10025
- exchangeChain: exchange.chain
10026
- },
10027
- currency: _objectSpread2(_objectSpread2({}, currencyFrom), {}, {
10028
- amount: BigInt(amount)
10029
- }),
10030
- bypassOptions: bypassOptions
10031
- }));
10032
- }
10033
- }, _callee);
10034
- }));
10035
- return function dryRunTransaction(_x, _x2, _x3, _x4) {
10036
- return _ref.apply(this, arguments);
10037
- };
10038
- }();
10039
- var mergeDryRunResults = function mergeDryRunResults(options, originResult, exchangeResult) {
10040
- var exchange = options.exchange,
10041
- destination = options.destination;
10042
- var result = {
10043
- origin: originResult.origin,
10044
- destination: destination ? exchangeResult.destination : exchangeResult.origin,
10045
- hops: [].concat(_toConsumableArray(originResult.hops), _toConsumableArray(destination ? [{
10046
- chain: exchange.chain,
10047
- result: exchangeResult.origin
10048
- }] : []), _toConsumableArray(exchangeResult.hops))
10049
- };
10050
- return _objectSpread2(_objectSpread2({}, getFailureInfo(result)), result);
10051
- };
10052
- var dryRun2Transactions = /*#__PURE__*/function () {
10053
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, transactions) {
10054
- var exchange, _transactions, firstTx, secondTx, firstRes, _getFailureInfo, failureReason, bypassOptions, secondRes;
10055
- return _regenerator().w(function (_context2) {
10056
- while (1) switch (_context2.n) {
10875
+ while (1) switch (_context.p = _context.n) {
10057
10876
  case 0:
10058
- exchange = options.exchange;
10059
- _transactions = _slicedToArray(transactions, 2), firstTx = _transactions[0], secondTx = _transactions[1];
10060
- _context2.n = 1;
10061
- return dryRunTransaction(options, firstTx, exchange.chain);
10062
- case 1:
10063
- firstRes = _context2.v;
10064
- _getFailureInfo = getFailureInfo(firstRes), failureReason = _getFailureInfo.failureReason;
10065
- bypassOptions = !failureReason ? {
10066
- sentAssetMintMode: 'preview',
10067
- mintFeeAssets: false
10068
- } : undefined;
10069
- _context2.n = 2;
10070
- return dryRunTransaction(options, secondTx, undefined, bypassOptions);
10877
+ origin = options.origin, exchange = options.exchange;
10878
+ if (!canUseExecuteTransfer(dex, options)) {
10879
+ _context.n = 4;
10880
+ break;
10881
+ }
10882
+ _context.p = 1;
10883
+ _context.n = 2;
10884
+ return getSwapExecuteOriginXcmFee(dex, options, disableFallback);
10071
10885
  case 2:
10072
- secondRes = _context2.v;
10073
- return _context2.a(2, mergeDryRunResults(options, firstRes, secondRes));
10886
+ return _context.a(2, _context.v);
10887
+ case 3:
10888
+ _context.p = 3;
10889
+ _t = _context.v;
10890
+ if (isFilteredError(_t)) {
10891
+ _context.n = 4;
10892
+ break;
10893
+ }
10894
+ throw _t;
10895
+ case 4:
10896
+ if (!(origin && origin.chain !== exchange.chain)) {
10897
+ _context.n = 5;
10898
+ break;
10899
+ }
10900
+ return _context.a(2, getToExchangeOriginFee(_objectSpread2(_objectSpread2({}, options), {}, {
10901
+ origin: origin
10902
+ }), disableFallback));
10903
+ case 5:
10904
+ _context.n = 6;
10905
+ return getSwapFee(dex, options, disableFallback);
10906
+ case 6:
10907
+ _yield$getSwapFee = _context.v;
10908
+ result = _yield$getSwapFee.result;
10909
+ return _context.a(2, result);
10074
10910
  }
10075
- }, _callee2);
10911
+ }, _callee, null, [[1, 3]]);
10076
10912
  }));
10077
- return function dryRun2Transactions(_x5, _x6) {
10078
- return _ref3.apply(this, arguments);
10913
+ return function getSwapOriginFee(_x, _x2, _x3) {
10914
+ return _ref.apply(this, arguments);
10079
10915
  };
10080
10916
  }();
10081
- var dryRunTransactions = function dryRunTransactions(transactions, options) {
10082
- if (transactions.length === 1) {
10083
- return dryRunTransaction(options, transactions[0]);
10084
- }
10085
- if (transactions.length === 2) {
10086
- return dryRun2Transactions(options, transactions);
10087
- }
10088
- throw new UnsupportedOperationError('Router dry run supports up to two transactions per flow.');
10089
- };
10090
- var dryRunRouter = /*#__PURE__*/function () {
10091
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(initialOptions) {
10092
- var _yield$prepareTransfo, options, dex, routerPlan, result;
10093
- return _regenerator().w(function (_context3) {
10094
- while (1) switch (_context3.n) {
10917
+
10918
+ var getOriginXcmFee = /*#__PURE__*/function () {
10919
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions, disableFallback) {
10920
+ var _yield$prepareTransfo, options, dex;
10921
+ return _regenerator().w(function (_context) {
10922
+ while (1) switch (_context.n) {
10095
10923
  case 0:
10096
10924
  validateTransferOptions(initialOptions);
10097
- _context3.n = 1;
10098
- return prepareTransformedOptions(initialOptions);
10925
+ _context.n = 1;
10926
+ return prepareTransformedOptions(initialOptions, true);
10099
10927
  case 1:
10100
- _yield$prepareTransfo = _context3.v;
10928
+ _yield$prepareTransfo = _context.v;
10101
10929
  options = _yield$prepareTransfo.options;
10102
10930
  dex = _yield$prepareTransfo.dex;
10103
- _context3.n = 2;
10104
- return buildTransactions(dex, options);
10105
- case 2:
10106
- routerPlan = _context3.v;
10107
- _context3.n = 3;
10108
- return dryRunTransactions(routerPlan, options);
10109
- case 3:
10110
- result = _context3.v;
10111
- return _context3.a(2, assignIsExchange(result, options));
10931
+ return _context.a(2, getSwapOriginFee(dex, options, disableFallback));
10112
10932
  }
10113
- }, _callee3);
10933
+ }, _callee);
10114
10934
  }));
10115
- return function dryRunRouter(_x7) {
10116
- return _ref4.apply(this, arguments);
10935
+ return function getOriginXcmFee(_x, _x2) {
10936
+ return _ref.apply(this, arguments);
10117
10937
  };
10118
10938
  }();
10119
10939
 
10120
10940
  var getSwapFee = /*#__PURE__*/function () {
10121
10941
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(exchange, options, disableFallback) {
10942
+ var _result$fee;
10122
10943
  var sender, _options$exchange, assetFrom, api, amount, txs, amountOut, isForFeeEstimation, swapResult, buildTx, result, finalFee, _t;
10123
10944
  return _regenerator().w(function (_context2) {
10124
10945
  while (1) switch (_context2.p = _context2.n) {
@@ -10169,7 +10990,7 @@ var getSwapFee = /*#__PURE__*/function () {
10169
10990
  };
10170
10991
  }();
10171
10992
  _context2.n = 6;
10172
- return getOriginXcmFee({
10993
+ return getOriginXcmFee$1({
10173
10994
  api: api,
10174
10995
  buildTx: buildTx,
10175
10996
  origin: exchange.chain,
@@ -10183,7 +11004,7 @@ var getSwapFee = /*#__PURE__*/function () {
10183
11004
  });
10184
11005
  case 6:
10185
11006
  result = _context2.v;
10186
- finalFee = result.fee * BigInt(txs.length);
11007
+ finalFee = ((_result$fee = result.fee) !== null && _result$fee !== void 0 ? _result$fee : 0n) * BigInt(txs.length);
10187
11008
  return _context2.a(2, {
10188
11009
  result: _objectSpread2(_objectSpread2({}, result), {}, {
10189
11010
  fee: finalFee
@@ -10199,166 +11020,76 @@ var getSwapFee = /*#__PURE__*/function () {
10199
11020
  }();
10200
11021
 
10201
11022
  var getRouterFees = /*#__PURE__*/function () {
10202
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(dex, options, disableFallback) {
11023
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options, disableFallback) {
10203
11024
  var _sendingChain$hops, _receivingChain$origi, _receivingChain$hops, _sendingChain$origin, _receivingChain$desti, _sendingChain$failure, _sendingChain$failure2;
10204
- var api, origin, exchange, currencyFrom, currencyTo, feeAsset, destination, amount, sender, recipient, evmSenderAddress, _origin$chain, _destination$chain, buildTx, mainAmountOut, executeResult, transformedHops, sendingChain, _yield$getSwapFee, swapChain, amountOut, receivingChain, mergedHops, finalOrigin, finalDestination, _t, _t2, _t3;
10205
- return _regenerator().w(function (_context2) {
10206
- while (1) switch (_context2.p = _context2.n) {
11025
+ var api, origin, exchange, destination, sender, _yield$getSwapExecute, result, transformedHops, sendingChain, _yield$getSwapFee, swapChain, amountOut, receivingChain, mergedHops, finalOrigin, finalDestination, _t, _t2, _t3;
11026
+ return _regenerator().w(function (_context) {
11027
+ while (1) switch (_context.p = _context.n) {
10207
11028
  case 0:
10208
- api = options.api, origin = options.origin, exchange = options.exchange, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, feeAsset = options.feeAsset, destination = options.destination, amount = options.amount, sender = options.sender, recipient = options.recipient, evmSenderAddress = options.evmSenderAddress;
10209
- if (!((origin || destination) && (dex.chain.includes('AssetHub') || dex.chain === 'Hydration'))) {
10210
- _context2.n = 6;
10211
- break;
10212
- }
10213
- _context2.p = 1;
10214
- buildTx = /*#__PURE__*/function () {
10215
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(overrideAmount) {
10216
- var _origin$assetFrom, _origin$feeAssetInfo;
10217
- var amt, amountOut, tx;
10218
- return _regenerator().w(function (_context) {
10219
- while (1) switch (_context.n) {
10220
- case 0:
10221
- amt = overrideAmount !== undefined ? applyDecimalAbstraction(overrideAmount, exchange.assetFrom.decimals, true) : amount;
10222
- _context.n = 1;
10223
- return dex.getAmountOut(_objectSpread2(_objectSpread2({}, options), {}, {
10224
- amount: amt,
10225
- api: exchange.api,
10226
- apiPjs: exchange.apiPjs,
10227
- assetFrom: exchange.assetFrom,
10228
- assetTo: exchange.assetTo
10229
- }));
10230
- case 1:
10231
- amountOut = _context.v;
10232
- _context.n = 2;
10233
- return handleSwapExecuteTransfer({
10234
- api: api,
10235
- chain: origin === null || origin === void 0 ? void 0 : origin.chain,
10236
- exchangeChain: exchange.chain,
10237
- destChain: destination === null || destination === void 0 ? void 0 : destination.chain,
10238
- assetInfoFrom: _objectSpread2(_objectSpread2({}, (_origin$assetFrom = origin === null || origin === void 0 ? void 0 : origin.assetFrom) !== null && _origin$assetFrom !== void 0 ? _origin$assetFrom : exchange.assetFrom), {}, {
10239
- amount: BigInt(amt)
10240
- }),
10241
- assetInfoTo: _objectSpread2(_objectSpread2({}, exchange.assetTo), {}, {
10242
- amount: amountOut
10243
- }),
10244
- currencyTo: currencyTo,
10245
- feeAssetInfo: (_origin$feeAssetInfo = origin === null || origin === void 0 ? void 0 : origin.feeAssetInfo) !== null && _origin$feeAssetInfo !== void 0 ? _origin$feeAssetInfo : exchange.feeAssetInfo,
10246
- sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
10247
- recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
10248
- calculateMinAmountOut: function calculateMinAmountOut(amountIn, assetTo) {
10249
- return dex.getAmountOut(_objectSpread2(_objectSpread2({}, options), {}, {
10250
- amount: amountIn,
10251
- apiPjs: options.exchange.apiPjs,
10252
- api: options.exchange.api,
10253
- assetFrom: options.exchange.assetFrom,
10254
- assetTo: assetTo !== null && assetTo !== void 0 ? assetTo : options.exchange.assetTo,
10255
- slippagePct: '1'
10256
- }));
10257
- }
10258
- });
10259
- case 2:
10260
- tx = _context.v;
10261
- return _context.a(2, tx);
10262
- }
10263
- }, _callee);
10264
- }));
10265
- return function buildTx(_x4) {
10266
- return _ref2.apply(this, arguments);
10267
- };
10268
- }();
10269
- _context2.n = 2;
10270
- return dex.getAmountOut(_objectSpread2(_objectSpread2({}, options), {}, {
10271
- amount: amount,
10272
- api: exchange.api,
10273
- apiPjs: exchange.apiPjs,
10274
- assetFrom: exchange.assetFrom,
10275
- assetTo: exchange.assetTo
10276
- }));
10277
- case 2:
10278
- mainAmountOut = _context2.v;
10279
- _context2.n = 3;
10280
- return getXcmFee({
10281
- api: api,
10282
- buildTx: buildTx,
10283
- origin: (_origin$chain = origin === null || origin === void 0 ? void 0 : origin.chain) !== null && _origin$chain !== void 0 ? _origin$chain : exchange.chain,
10284
- destination: (_destination$chain = destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _destination$chain !== void 0 ? _destination$chain : exchange.chain,
10285
- sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
10286
- recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
10287
- currency: _objectSpread2(_objectSpread2({}, currencyFrom), {}, {
10288
- amount: BigInt(amount)
10289
- }),
10290
- feeAsset: feeAsset,
10291
- disableFallback: disableFallback,
10292
- swapConfig: {
10293
- currencyTo: currencyTo,
10294
- exchangeChain: exchange.chain,
10295
- amountOut: mainAmountOut
10296
- }
10297
- });
10298
- case 3:
10299
- executeResult = _context2.v;
10300
- if (!(executeResult.failureReason === 'NoDeal' && exchange.chain === 'Hydration')) {
10301
- _context2.n = 4;
10302
- break;
10303
- }
10304
- throw new RoutingResolutionError('An error occured, either this route is not registered for swap on exchange chain, or the amount out was not able to be calculated.');
10305
- case 4:
10306
- transformedHops = executeResult.hops.map(function (hop) {
10307
- if (hop.chain === exchange.chain) {
10308
- return {
10309
- chain: hop.chain,
10310
- result: _objectSpread2(_objectSpread2({}, hop.result), {}, {
10311
- isExchange: true
10312
- })
10313
- };
10314
- }
10315
- return hop;
11029
+ api = options.api, origin = options.origin, exchange = options.exchange, destination = options.destination, sender = options.sender;
11030
+ if (!canUseExecuteTransfer(dex, options)) {
11031
+ _context.n = 4;
11032
+ break;
11033
+ }
11034
+ _context.p = 1;
11035
+ _context.n = 2;
11036
+ return getSwapExecuteXcmFee(dex, options, disableFallback);
11037
+ case 2:
11038
+ _yield$getSwapExecute = _context.v;
11039
+ result = _yield$getSwapExecute.result;
11040
+ transformedHops = result.hops.map(function (hop) {
11041
+ return hop.chain === exchange.chain ? {
11042
+ chain: hop.chain,
11043
+ result: _objectSpread2(_objectSpread2({}, hop.result), {}, {
11044
+ isExchange: true
11045
+ })
11046
+ } : hop;
10316
11047
  });
10317
- return _context2.a(2, _objectSpread2(_objectSpread2({}, executeResult), {}, {
10318
- origin: _objectSpread2(_objectSpread2({}, executeResult.origin), !origin && {
11048
+ return _context.a(2, _objectSpread2(_objectSpread2({}, result), {}, {
11049
+ origin: _objectSpread2(_objectSpread2({}, result.origin), !origin && {
10319
11050
  isExchange: true
10320
11051
  }),
10321
- destination: _objectSpread2(_objectSpread2({}, executeResult.destination), !destination && {
11052
+ destination: _objectSpread2(_objectSpread2({}, result.destination), !destination && {
10322
11053
  isExchange: true
10323
11054
  }),
10324
11055
  hops: transformedHops
10325
11056
  }));
10326
- case 5:
10327
- _context2.p = 5;
10328
- _t = _context2.v;
10329
- if (_t instanceof DryRunFailedError && _t.dryRunType === 'origin' && _t.reason === 'Filtered') {
10330
- _context2.n = 6;
11057
+ case 3:
11058
+ _context.p = 3;
11059
+ _t = _context.v;
11060
+ if (isFilteredError(_t)) {
11061
+ _context.n = 4;
10331
11062
  break;
10332
11063
  }
10333
11064
  throw _t;
10334
- case 6:
11065
+ case 4:
10335
11066
  if (!(origin && origin.chain !== exchange.chain)) {
10336
- _context2.n = 8;
11067
+ _context.n = 6;
10337
11068
  break;
10338
11069
  }
10339
- _context2.n = 7;
11070
+ _context.n = 5;
10340
11071
  return getToExchangeFee(_objectSpread2(_objectSpread2({}, options), {}, {
10341
11072
  origin: origin
10342
11073
  }), disableFallback);
10343
- case 7:
10344
- _t2 = _context2.v;
10345
- _context2.n = 9;
11074
+ case 5:
11075
+ _t2 = _context.v;
11076
+ _context.n = 7;
10346
11077
  break;
10347
- case 8:
11078
+ case 6:
10348
11079
  _t2 = undefined;
10349
- case 9:
11080
+ case 7:
10350
11081
  sendingChain = _t2;
10351
- _context2.n = 10;
11082
+ _context.n = 8;
10352
11083
  return getSwapFee(dex, options);
10353
- case 10:
10354
- _yield$getSwapFee = _context2.v;
11084
+ case 8:
11085
+ _yield$getSwapFee = _context.v;
10355
11086
  swapChain = _yield$getSwapFee.result;
10356
11087
  amountOut = _yield$getSwapFee.amountOut;
10357
11088
  if (!(destination && destination.chain !== exchange.chain)) {
10358
- _context2.n = 12;
11089
+ _context.n = 10;
10359
11090
  break;
10360
11091
  }
10361
- _context2.n = 11;
11092
+ _context.n = 9;
10362
11093
  return getFromExchangeFee({
10363
11094
  exchange: exchange,
10364
11095
  destination: destination,
@@ -10366,13 +11097,13 @@ var getRouterFees = /*#__PURE__*/function () {
10366
11097
  sender: sender,
10367
11098
  api: api
10368
11099
  }, disableFallback);
10369
- case 11:
10370
- _t3 = _context2.v;
10371
- _context2.n = 13;
11100
+ case 9:
11101
+ _t3 = _context.v;
11102
+ _context.n = 11;
10372
11103
  break;
10373
- case 12:
11104
+ case 10:
10374
11105
  _t3 = undefined;
10375
- case 13:
11106
+ case 11:
10376
11107
  receivingChain = _t3;
10377
11108
  mergedHops = [].concat(_toConsumableArray((_sendingChain$hops = sendingChain === null || sendingChain === void 0 ? void 0 : sendingChain.hops) !== null && _sendingChain$hops !== void 0 ? _sendingChain$hops : []), _toConsumableArray(sendingChain && receivingChain ? [{
10378
11109
  chain: exchange.chain,
@@ -10389,7 +11120,7 @@ var getRouterFees = /*#__PURE__*/function () {
10389
11120
  }), !origin && !destination && {
10390
11121
  fee: 0n
10391
11122
  });
10392
- return _context2.a(2, {
11123
+ return _context.a(2, {
10393
11124
  failureReason: (_sendingChain$failure = sendingChain === null || sendingChain === void 0 ? void 0 : sendingChain.failureReason) !== null && _sendingChain$failure !== void 0 ? _sendingChain$failure : receivingChain === null || receivingChain === void 0 ? void 0 : receivingChain.failureReason,
10394
11125
  failureChain: (_sendingChain$failure2 = sendingChain === null || sendingChain === void 0 ? void 0 : sendingChain.failureChain) !== null && _sendingChain$failure2 !== void 0 ? _sendingChain$failure2 : receivingChain === null || receivingChain === void 0 ? void 0 : receivingChain.failureChain,
10395
11126
  origin: finalOrigin,
@@ -10397,7 +11128,7 @@ var getRouterFees = /*#__PURE__*/function () {
10397
11128
  hops: mergedHops
10398
11129
  });
10399
11130
  }
10400
- }, _callee2, null, [[1, 5]]);
11131
+ }, _callee, null, [[1, 3]]);
10401
11132
  }));
10402
11133
  return function getRouterFees(_x, _x2, _x3) {
10403
11134
  return _ref.apply(this, arguments);
@@ -10428,12 +11159,14 @@ var getXcmFees = /*#__PURE__*/function () {
10428
11159
 
10429
11160
  var selectBestExchangeAmountOut = /*#__PURE__*/function () {
10430
11161
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi) {
11162
+ var exchangeConfig;
10431
11163
  return _regenerator().w(function (_context2) {
10432
11164
  while (1) switch (_context2.n) {
10433
11165
  case 0:
11166
+ exchangeConfig = convertBuilderConfig(options.api.config);
10434
11167
  return _context2.a(2, selectBestExchangeCommon(options, originApi, /*#__PURE__*/function () {
10435
11168
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, _options, parsedAmount) {
10436
- var exchangeApi, exchangePjsApi;
11169
+ var exchangeApi, _t, _t2, _t3, _t4;
10437
11170
  return _regenerator().w(function (_context) {
10438
11171
  while (1) switch (_context.n) {
10439
11172
  case 0:
@@ -10441,17 +11174,19 @@ var selectBestExchangeAmountOut = /*#__PURE__*/function () {
10441
11174
  return options.api.createApiForChain(dex.chain);
10442
11175
  case 1:
10443
11176
  exchangeApi = _context.v;
11177
+ _t = dex;
11178
+ _t2 = _objectSpread2;
11179
+ _t3 = _objectSpread2;
11180
+ _t4 = {};
10444
11181
  _context.n = 2;
10445
- return dex.createApiInstance();
11182
+ return buildExchangeApiVariant(dex, exchangeConfig);
10446
11183
  case 2:
10447
- exchangePjsApi = _context.v;
10448
- return _context.a(2, dex.getAmountOut({
11184
+ return _context.a(2, _t.getAmountOut.call(_t, _t2(_t3(_t4, _context.v), {}, {
10449
11185
  api: exchangeApi,
10450
- apiPjs: exchangePjsApi,
10451
11186
  assetFrom: assetFromExchange,
10452
11187
  assetTo: assetTo,
10453
11188
  amount: BigInt(parsedAmount)
10454
- }));
11189
+ })));
10455
11190
  }
10456
11191
  }, _callee);
10457
11192
  }));
@@ -10470,7 +11205,7 @@ var selectBestExchangeAmountOut = /*#__PURE__*/function () {
10470
11205
  var getBestAmountOut = /*#__PURE__*/function () {
10471
11206
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
10472
11207
  var _assetFromOrigin$deci;
10473
- var api, exchange, amount, from, originApi, isExchangeAutoSelect, dex, _resolveAssets, assetFromOrigin, assetFrom, assetTo, res, config, exchangeConfig, pjsApi, exchangeApi, _t, _t2, _t3, _t4;
11208
+ var api, exchange, amount, from, originApi, isExchangeAutoSelect, dex, _resolveAssets, assetFromOrigin, assetFrom, assetTo, res, config, exchangeConfig, exchangeApi, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8;
10474
11209
  return _regenerator().w(function (_context) {
10475
11210
  while (1) switch (_context.n) {
10476
11211
  case 0:
@@ -10522,27 +11257,29 @@ var getBestAmountOut = /*#__PURE__*/function () {
10522
11257
  config = api.config;
10523
11258
  exchangeConfig = convertBuilderConfig(config);
10524
11259
  _context.n = 9;
10525
- return dex.createApiInstance(exchangeConfig);
10526
- case 9:
10527
- pjsApi = _context.v;
10528
- _context.n = 10;
10529
11260
  return api.createApiForChain(dex.chain);
10530
- case 10:
11261
+ case 9:
10531
11262
  exchangeApi = _context.v;
10532
11263
  _t3 = dex.chain;
11264
+ _t4 = dex;
11265
+ _t5 = _objectSpread2;
11266
+ _t6 = _objectSpread2;
11267
+ _t7 = {};
11268
+ _context.n = 10;
11269
+ return buildExchangeApiVariant(dex, exchangeConfig);
11270
+ case 10:
10533
11271
  _context.n = 11;
10534
- return dex.getAmountOut({
11272
+ return _t4.getAmountOut.call(_t4, _t5(_t6(_t7, _context.v), {}, {
10535
11273
  api: exchangeApi,
10536
- apiPjs: pjsApi,
10537
11274
  assetFrom: assetFrom,
10538
11275
  assetTo: assetTo,
10539
11276
  amount: applyDecimalAbstraction(amount, (_assetFromOrigin$deci = assetFromOrigin === null || assetFromOrigin === void 0 ? void 0 : assetFromOrigin.decimals) !== null && _assetFromOrigin$deci !== void 0 ? _assetFromOrigin$deci : assetFrom.decimals, (exchangeConfig === null || exchangeConfig === void 0 ? void 0 : exchangeConfig.abstractDecimals) !== false)
10540
- });
11277
+ }));
10541
11278
  case 11:
10542
- _t4 = _context.v;
11279
+ _t8 = _context.v;
10543
11280
  return _context.a(2, {
10544
11281
  exchange: _t3,
10545
- amountOut: _t4
11282
+ amountOut: _t8
10546
11283
  });
10547
11284
  }
10548
11285
  }, _callee);
@@ -10813,6 +11550,9 @@ var transfer = /*#__PURE__*/function () {
10813
11550
  return buildTransactions(dex, options);
10814
11551
  case 5:
10815
11552
  routerPlan = _context.v;
11553
+ _context.n = 6;
11554
+ return maybePerformXcmFormatCheck(api, options, routerPlan);
11555
+ case 6:
10816
11556
  return _context.a(2, executeRouterPlan(routerPlan, {
10817
11557
  signer: signer,
10818
11558
  sender: sender,
@@ -10830,6 +11570,329 @@ var transfer = /*#__PURE__*/function () {
10830
11570
  };
10831
11571
  }();
10832
11572
 
11573
+ var buildExecuteSwapHops = /*#__PURE__*/function () {
11574
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
11575
+ var api, hops, originChain, exchangeChain, currencyFrom, currencyTo, sender, exchangeHopIdx;
11576
+ return _regenerator().w(function (_context2) {
11577
+ while (1) switch (_context2.n) {
11578
+ case 0:
11579
+ api = _ref.api, hops = _ref.hops, originChain = _ref.originChain, exchangeChain = _ref.exchangeChain, currencyFrom = _ref.currencyFrom, currencyTo = _ref.currencyTo, sender = _ref.sender;
11580
+ exchangeHopIdx = hops.findIndex(function (h) {
11581
+ return h.chain === exchangeChain;
11582
+ });
11583
+ return _context2.a(2, Promise.all(hops.map(/*#__PURE__*/function () {
11584
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(hop, idx) {
11585
+ var _hop$result$fee;
11586
+ var isSwapHop, isAfterSwap, result;
11587
+ return _regenerator().w(function (_context) {
11588
+ while (1) switch (_context.n) {
11589
+ case 0:
11590
+ isSwapHop = hop.chain === exchangeChain;
11591
+ isAfterSwap = exchangeHopIdx >= 0 && idx > exchangeHopIdx;
11592
+ _context.n = 1;
11593
+ return buildHopInfo({
11594
+ api: api,
11595
+ chain: hop.chain,
11596
+ fee: (_hop$result$fee = hop.result.fee) !== null && _hop$result$fee !== void 0 ? _hop$result$fee : 0n,
11597
+ originChain: originChain,
11598
+ currency: isAfterSwap ? currencyTo : currencyFrom,
11599
+ asset: hop.result.asset,
11600
+ sender: sender
11601
+ });
11602
+ case 1:
11603
+ result = _context.v;
11604
+ return _context.a(2, {
11605
+ chain: hop.chain,
11606
+ result: _objectSpread2(_objectSpread2({}, result), isSwapHop && {
11607
+ isExchange: true
11608
+ })
11609
+ });
11610
+ }
11611
+ }, _callee);
11612
+ }));
11613
+ return function (_x2, _x3) {
11614
+ return _ref3.apply(this, arguments);
11615
+ };
11616
+ }())));
11617
+ }
11618
+ }, _callee2);
11619
+ }));
11620
+ return function buildExecuteSwapHops(_x) {
11621
+ return _ref2.apply(this, arguments);
11622
+ };
11623
+ }();
11624
+
11625
+ var getExecuteSwapInfo = /*#__PURE__*/function () {
11626
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options) {
11627
+ var _origin$chain, _destination$chain;
11628
+ var api, origin, exchange, currencyFrom, currencyTo, destination, amount, sender, recipient, evmSenderAddress, _yield$getSwapExecute, xcmFeeResult, amountOut, originChain, destChain, senderAddress, recipientAddress, originAsset, originInfo, builtHops, exchangeHopIdx, postSwapHops, _aggregateHopFees, totalHopFee, bridgeFee, destinationInfo;
11629
+ return _regenerator().w(function (_context) {
11630
+ while (1) switch (_context.n) {
11631
+ case 0:
11632
+ api = options.api, origin = options.origin, exchange = options.exchange, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, destination = options.destination, amount = options.amount, sender = options.sender, recipient = options.recipient, evmSenderAddress = options.evmSenderAddress;
11633
+ assertCurrencyCore(currencyFrom);
11634
+ assertCurrencyCore(currencyTo);
11635
+ _context.n = 1;
11636
+ return getSwapExecuteXcmFee(dex, options, false);
11637
+ case 1:
11638
+ _yield$getSwapExecute = _context.v;
11639
+ xcmFeeResult = _yield$getSwapExecute.result;
11640
+ amountOut = _yield$getSwapExecute.amountOut;
11641
+ originChain = (_origin$chain = origin === null || origin === void 0 ? void 0 : origin.chain) !== null && _origin$chain !== void 0 ? _origin$chain : exchange.chain;
11642
+ destChain = (_destination$chain = destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _destination$chain !== void 0 ? _destination$chain : exchange.chain;
11643
+ senderAddress = evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender;
11644
+ recipientAddress = recipient !== null && recipient !== void 0 ? recipient : sender;
11645
+ originAsset = origin ? findAssetInfoOrThrow(originChain, currencyFrom, destChain) : exchange.assetFrom;
11646
+ _context.n = 2;
11647
+ return buildOriginInfo({
11648
+ api: api,
11649
+ origin: originChain,
11650
+ sender: senderAddress,
11651
+ currency: currencyFrom,
11652
+ originAsset: originAsset,
11653
+ amount: BigInt(amount),
11654
+ originFee: xcmFeeResult.origin.fee,
11655
+ originFeeAsset: xcmFeeResult.origin.asset,
11656
+ isFeeAssetAh: false
11657
+ });
11658
+ case 2:
11659
+ originInfo = _context.v;
11660
+ _context.n = 3;
11661
+ return buildExecuteSwapHops({
11662
+ api: api,
11663
+ hops: xcmFeeResult.hops,
11664
+ originChain: originChain,
11665
+ exchangeChain: exchange.chain,
11666
+ currencyFrom: currencyFrom,
11667
+ currencyTo: currencyTo,
11668
+ sender: senderAddress
11669
+ });
11670
+ case 3:
11671
+ builtHops = _context.v;
11672
+ exchangeHopIdx = xcmFeeResult.hops.findIndex(function (h) {
11673
+ return h.chain === exchange.chain;
11674
+ });
11675
+ postSwapHops = exchangeHopIdx >= 0 ? xcmFeeResult.hops.slice(exchangeHopIdx + 1) : xcmFeeResult.hops;
11676
+ _aggregateHopFees = aggregateHopFees(postSwapHops, exchange.assetTo), totalHopFee = _aggregateHopFees.totalHopFee, bridgeFee = _aggregateHopFees.bridgeFee;
11677
+ _context.n = 4;
11678
+ return buildDestInfo({
11679
+ api: api,
11680
+ origin: originChain,
11681
+ destination: destChain,
11682
+ recipient: recipientAddress,
11683
+ currency: _objectSpread2(_objectSpread2({}, currencyTo), {}, {
11684
+ amount: amountOut
11685
+ }),
11686
+ originFee: xcmFeeResult.origin.fee,
11687
+ isFeeAssetAh: false,
11688
+ destFeeDetail: xcmFeeResult.destination,
11689
+ totalHopFee: totalHopFee,
11690
+ bridgeFee: bridgeFee
11691
+ });
11692
+ case 4:
11693
+ destinationInfo = _context.v;
11694
+ return _context.a(2, {
11695
+ chain: {
11696
+ origin: originChain,
11697
+ destination: destChain,
11698
+ ecosystem: getRelayChainSymbol(originChain)
11699
+ },
11700
+ origin: _objectSpread2(_objectSpread2({}, originInfo), !origin && {
11701
+ isExchange: true
11702
+ }),
11703
+ hops: builtHops,
11704
+ destination: _objectSpread2(_objectSpread2({}, destinationInfo), !destination && {
11705
+ isExchange: true
11706
+ })
11707
+ });
11708
+ }
11709
+ }, _callee);
11710
+ }));
11711
+ return function getExecuteSwapInfo(_x, _x2) {
11712
+ return _ref.apply(this, arguments);
11713
+ };
11714
+ }();
11715
+
11716
+ var buildExchangeOriginInfo = function buildExchangeOriginInfo(exchange, sender, amount, swapFee) {
11717
+ return buildOriginInfo({
11718
+ api: exchange.api,
11719
+ origin: exchange.chain,
11720
+ sender: sender,
11721
+ currency: {
11722
+ location: exchange.assetFrom.location
11723
+ },
11724
+ originAsset: exchange.assetFrom,
11725
+ amount: amount,
11726
+ originFee: swapFee.fee,
11727
+ originFeeAsset: swapFee.asset,
11728
+ isFeeAssetAh: false
11729
+ });
11730
+ };
11731
+ var buildExchangeDestInfo = function buildExchangeDestInfo(exchange, recipient, amountOut, currencyTo) {
11732
+ return buildDestInfo({
11733
+ api: exchange.api,
11734
+ origin: exchange.chain,
11735
+ destination: exchange.chain,
11736
+ recipient: recipient,
11737
+ currency: _objectSpread2(_objectSpread2({}, currencyTo), {}, {
11738
+ amount: amountOut
11739
+ }),
11740
+ originFee: 0n,
11741
+ isFeeAssetAh: false,
11742
+ destFeeDetail: {
11743
+ fee: 0n,
11744
+ asset: exchange.assetTo,
11745
+ feeType: 'noFeeRequired'
11746
+ },
11747
+ totalHopFee: 0n
11748
+ });
11749
+ };
11750
+ var getSwapInfo = /*#__PURE__*/function () {
11751
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions) {
11752
+ var _origin$chain, _destination$chain, _sendingInfo$hops, _receivingInfo$hops, _sendingInfo$origin, _receivingInfo$destin;
11753
+ var _yield$prepareTransfo, options, dex, api, origin, exchange, currencyTo, destination, amount, sender, evmSenderAddress, senderAddress, sendingInfo, _yield$getSwapFee, swapChain, amountOut, receivingInfo, originChain, destChain, exchangeHopEntry, hops, finalOrigin, finalDestination, _t, _t2, _t3, _t4, _t5;
11754
+ return _regenerator().w(function (_context) {
11755
+ while (1) switch (_context.p = _context.n) {
11756
+ case 0:
11757
+ validateTransferOptions(initialOptions);
11758
+ _context.n = 1;
11759
+ return prepareTransformedOptions(initialOptions, true);
11760
+ case 1:
11761
+ _yield$prepareTransfo = _context.v;
11762
+ options = _yield$prepareTransfo.options;
11763
+ dex = _yield$prepareTransfo.dex;
11764
+ if (!canUseExecuteTransfer(dex, options)) {
11765
+ _context.n = 5;
11766
+ break;
11767
+ }
11768
+ _context.p = 2;
11769
+ _context.n = 3;
11770
+ return getExecuteSwapInfo(dex, options);
11771
+ case 3:
11772
+ return _context.a(2, _context.v);
11773
+ case 4:
11774
+ _context.p = 4;
11775
+ _t = _context.v;
11776
+ if (isFilteredError(_t)) {
11777
+ _context.n = 5;
11778
+ break;
11779
+ }
11780
+ throw _t;
11781
+ case 5:
11782
+ api = options.api, origin = options.origin, exchange = options.exchange, currencyTo = options.currencyTo, destination = options.destination, amount = options.amount, sender = options.sender, evmSenderAddress = options.evmSenderAddress;
11783
+ assertCurrencyCore(currencyTo);
11784
+ senderAddress = evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender;
11785
+ if (!(origin && origin.chain !== exchange.chain)) {
11786
+ _context.n = 7;
11787
+ break;
11788
+ }
11789
+ _context.n = 6;
11790
+ return createToExchangeBuilder({
11791
+ origin: origin,
11792
+ exchange: exchange,
11793
+ sender: sender,
11794
+ evmSenderAddress: evmSenderAddress,
11795
+ amount: amount,
11796
+ api: api
11797
+ }).getTransferInfo();
11798
+ case 6:
11799
+ _t2 = _context.v;
11800
+ _context.n = 8;
11801
+ break;
11802
+ case 7:
11803
+ _t2 = undefined;
11804
+ case 8:
11805
+ sendingInfo = _t2;
11806
+ _context.n = 9;
11807
+ return getSwapFee(dex, options);
11808
+ case 9:
11809
+ _yield$getSwapFee = _context.v;
11810
+ swapChain = _yield$getSwapFee.result;
11811
+ amountOut = _yield$getSwapFee.amountOut;
11812
+ if (!(destination && destination.chain !== exchange.chain)) {
11813
+ _context.n = 11;
11814
+ break;
11815
+ }
11816
+ _context.n = 10;
11817
+ return createFromExchangeBuilder({
11818
+ exchange: exchange,
11819
+ destination: destination,
11820
+ amount: amountOut,
11821
+ sender: sender,
11822
+ api: api
11823
+ }).getTransferInfo();
11824
+ case 10:
11825
+ _t3 = _context.v;
11826
+ _context.n = 12;
11827
+ break;
11828
+ case 11:
11829
+ _t3 = undefined;
11830
+ case 12:
11831
+ receivingInfo = _t3;
11832
+ originChain = (_origin$chain = origin === null || origin === void 0 ? void 0 : origin.chain) !== null && _origin$chain !== void 0 ? _origin$chain : exchange.chain;
11833
+ destChain = (_destination$chain = destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _destination$chain !== void 0 ? _destination$chain : exchange.chain;
11834
+ exchangeHopEntry = sendingInfo && receivingInfo ? {
11835
+ chain: exchange.chain,
11836
+ result: {
11837
+ asset: exchange.assetTo,
11838
+ xcmFee: {
11839
+ fee: swapChain.fee + receivingInfo.origin.xcmFee.fee,
11840
+ asset: swapChain.asset
11841
+ },
11842
+ isExchange: true
11843
+ }
11844
+ } : undefined;
11845
+ hops = [].concat(_toConsumableArray((_sendingInfo$hops = sendingInfo === null || sendingInfo === void 0 ? void 0 : sendingInfo.hops) !== null && _sendingInfo$hops !== void 0 ? _sendingInfo$hops : []), _toConsumableArray(exchangeHopEntry ? [exchangeHopEntry] : []), _toConsumableArray((_receivingInfo$hops = receivingInfo === null || receivingInfo === void 0 ? void 0 : receivingInfo.hops) !== null && _receivingInfo$hops !== void 0 ? _receivingInfo$hops : []));
11846
+ if (!((_sendingInfo$origin = sendingInfo === null || sendingInfo === void 0 ? void 0 : sendingInfo.origin) !== null && _sendingInfo$origin !== void 0)) {
11847
+ _context.n = 13;
11848
+ break;
11849
+ }
11850
+ _t4 = _sendingInfo$origin;
11851
+ _context.n = 15;
11852
+ break;
11853
+ case 13:
11854
+ _context.n = 14;
11855
+ return buildExchangeOriginInfo(exchange, senderAddress, amount, swapChain);
11856
+ case 14:
11857
+ _t4 = _context.v;
11858
+ case 15:
11859
+ finalOrigin = _t4;
11860
+ if (!((_receivingInfo$destin = receivingInfo === null || receivingInfo === void 0 ? void 0 : receivingInfo.destination) !== null && _receivingInfo$destin !== void 0)) {
11861
+ _context.n = 16;
11862
+ break;
11863
+ }
11864
+ _t5 = _receivingInfo$destin;
11865
+ _context.n = 18;
11866
+ break;
11867
+ case 16:
11868
+ _context.n = 17;
11869
+ return buildExchangeDestInfo(exchange, sender, amountOut, currencyTo);
11870
+ case 17:
11871
+ _t5 = _context.v;
11872
+ case 18:
11873
+ finalDestination = _t5;
11874
+ return _context.a(2, {
11875
+ chain: {
11876
+ origin: originChain,
11877
+ destination: destChain,
11878
+ ecosystem: getRelayChainSymbol(originChain)
11879
+ },
11880
+ origin: _objectSpread2(_objectSpread2({}, finalOrigin), !sendingInfo && {
11881
+ isExchange: true
11882
+ }),
11883
+ hops: hops,
11884
+ destination: _objectSpread2(_objectSpread2({}, finalDestination), !receivingInfo && {
11885
+ isExchange: true
11886
+ })
11887
+ });
11888
+ }
11889
+ }, _callee, null, [[2, 4]]);
11890
+ }));
11891
+ return function getSwapInfo(_x) {
11892
+ return _ref.apply(this, arguments);
11893
+ };
11894
+ }();
11895
+
10833
11896
  var SwapBuilderCore = /*#__PURE__*/function () {
10834
11897
  function SwapBuilderCore(api, options) {
10835
11898
  _classCallCheck(this, SwapBuilderCore);
@@ -10956,18 +12019,57 @@ var SwapBuilderCore = /*#__PURE__*/function () {
10956
12019
  return getXcmFees$1;
10957
12020
  }()
10958
12021
  }, {
10959
- key: "getTransferableAmount",
12022
+ key: "getOriginXcmFee",
10960
12023
  value: function () {
10961
- var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
12024
+ var _getOriginXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
12025
+ var _options$disableFallb2;
12026
+ var disableFallback;
10962
12027
  return _regenerator().w(function (_context2) {
10963
12028
  while (1) switch (_context2.n) {
10964
12029
  case 0:
10965
- return _context2.a(2, getTransferableAmount(_objectSpread2(_objectSpread2({}, this._options), {}, {
12030
+ disableFallback = (_options$disableFallb2 = options === null || options === void 0 ? void 0 : options.disableFallback) !== null && _options$disableFallb2 !== void 0 ? _options$disableFallb2 : false;
12031
+ return _context2.a(2, getOriginXcmFee(_objectSpread2(_objectSpread2({}, this._options), {}, {
10966
12032
  api: this._api
10967
- })));
12033
+ }), disableFallback));
10968
12034
  }
10969
12035
  }, _callee2, this);
10970
12036
  }));
12037
+ function getOriginXcmFee$1(_x2) {
12038
+ return _getOriginXcmFee2.apply(this, arguments);
12039
+ }
12040
+ return getOriginXcmFee$1;
12041
+ }()
12042
+ }, {
12043
+ key: "getSwapInfo",
12044
+ value: function () {
12045
+ var _getSwapInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
12046
+ return _regenerator().w(function (_context3) {
12047
+ while (1) switch (_context3.n) {
12048
+ case 0:
12049
+ return _context3.a(2, getSwapInfo(_objectSpread2(_objectSpread2({}, this._options), {}, {
12050
+ api: this._api
12051
+ })));
12052
+ }
12053
+ }, _callee3, this);
12054
+ }));
12055
+ function getSwapInfo$1() {
12056
+ return _getSwapInfo2.apply(this, arguments);
12057
+ }
12058
+ return getSwapInfo$1;
12059
+ }()
12060
+ }, {
12061
+ key: "getTransferableAmount",
12062
+ value: function () {
12063
+ var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
12064
+ return _regenerator().w(function (_context4) {
12065
+ while (1) switch (_context4.n) {
12066
+ case 0:
12067
+ return _context4.a(2, getTransferableAmount(_objectSpread2(_objectSpread2({}, this._options), {}, {
12068
+ api: this._api
12069
+ })));
12070
+ }
12071
+ }, _callee4, this);
12072
+ }));
10971
12073
  function getTransferableAmount$1() {
10972
12074
  return _getTransferableAmount2.apply(this, arguments);
10973
12075
  }
@@ -10976,15 +12078,15 @@ var SwapBuilderCore = /*#__PURE__*/function () {
10976
12078
  }, {
10977
12079
  key: "getMinTransferableAmount",
10978
12080
  value: function () {
10979
- var _getMinTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
10980
- return _regenerator().w(function (_context3) {
10981
- while (1) switch (_context3.n) {
12081
+ var _getMinTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
12082
+ return _regenerator().w(function (_context5) {
12083
+ while (1) switch (_context5.n) {
10982
12084
  case 0:
10983
- return _context3.a(2, getMinTransferableAmount(_objectSpread2(_objectSpread2({}, this._options), {}, {
12085
+ return _context5.a(2, getMinTransferableAmount(_objectSpread2(_objectSpread2({}, this._options), {}, {
10984
12086
  api: this._api
10985
12087
  })));
10986
12088
  }
10987
- }, _callee3, this);
12089
+ }, _callee5, this);
10988
12090
  }));
10989
12091
  function getMinTransferableAmount$1() {
10990
12092
  return _getMinTransferableAmount2.apply(this, arguments);
@@ -11012,6 +12114,13 @@ var SwapBuilderCore = /*#__PURE__*/function () {
11012
12114
  api: this._api
11013
12115
  }));
11014
12116
  }
12117
+ }, {
12118
+ key: "dryRunPreview",
12119
+ value: function dryRunPreview(previewOptions) {
12120
+ return dryRunRouterPreview(_objectSpread2(_objectSpread2({}, this._options), {}, {
12121
+ api: this._api
12122
+ }), previewOptions);
12123
+ }
11015
12124
  }, {
11016
12125
  key: "getBestAmountOut",
11017
12126
  value: function getBestAmountOut$1() {
@@ -11029,4 +12138,4 @@ registerSwapExtension({
11029
12138
  SwapBuilder: SwapBuilder
11030
12139
  });
11031
12140
 
11032
- export { DEST_FEE_BUFFER_PCT, FALLBACK_FEE_CALC_ADDRESS, FALLBACK_FEE_CALC_EVM_ADDRESS, FEE_BUFFER_PCT, SwapBuilder, SwapBuilderCore, getExchangeAssets, getExchangeConfig, getExchangePairs, getSupportedAssetsFrom, getSupportedAssetsTo, getSupportedFeeAssets };
12141
+ export { DEST_FEE_BUFFER_PCT, FALLBACK_FEE_CALC_ADDRESS, FALLBACK_FEE_CALC_EVM_ADDRESS, FEE_BUFFER_PCT, SwapBuilder, SwapBuilderCore, getExchangeAssets, getExchangeConfig, getExchangePairs, getSupportedAssetsFrom, getSupportedAssetsFromImpl, getSupportedAssetsTo, getSupportedAssetsToImpl, getSupportedFeeAssets, getSupportedFeeAssetsImpl };