@paraspell/swap 12.9.7 → 12.10.0-rc.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 +95 -219
  2. package/dist/index.mjs +368 -415
  3. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { UnsupportedOperationError, createChainClient as createChainClient$1, getNativeAssets, RoutingResolutionError, findAssetInfoById, getOtherAssets, getChainProviders, parseUnits, getNativeAssetSymbol, padValueBy, formatUnits as formatUnits$1, AmountTooLowError, getBalance, localizeLocation, getAssets, transform, Parents, isSymbolMatch, getParaId, UnableToComputeError, getAssetDecimals, InvalidCurrencyError, findAssetInfoOrThrow, isOverrideLocationSpecifier, isSymbolSpecifier, findBestMatches, findAssetInfoBySymbol, findAssetInfoByLoc, deepEqual, normalizeExchange, EXCHANGE_CHAINS, reverseTransformLocation, isAssetEqual, isExternalChain, isSystemAsset, TransferToAhNotSupported, ScenarioNotSupportedError, applyDecimalAbstraction, findAssetInfo, getRelayChainOf, hasSupportForAsset, Builder, isChainEvm, InvalidAddressError, MissingParameterError, DryRunFailedError, handleSwapExecuteTransfer, dryRun, getFailureInfo, getOriginXcmFee, getXcmFee, getExistentialDepositOrThrow, registerSwapExtension } from '@paraspell/sdk';
2
- export { EXCHANGE_CHAINS } from '@paraspell/sdk';
3
- import { InvalidTxError, Binary } from 'polkadot-api';
1
+ import { createChainClient as createChainClient$1, getBalance, transform, registerSwapExtension } from '@paraspell/sdk';
2
+ import { getNativeAssets, RoutingResolutionError, findAssetInfoById, getOtherAssets, getChainProviders, parseUnits, getNativeAssetSymbol, padValueBy, formatUnits as formatUnits$1, AmountTooLowError, 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, getBalance as getBalance$1 } from '@paraspell/sdk-core';
3
+ import 'polkadot-api';
4
4
  import { Wallet } from '@acala-network/sdk';
5
5
  import { FixedPointNumber } from '@acala-network/sdk-core';
6
6
  import { AcalaDex as AcalaDex$1, AggregateDex } from '@acala-network/sdk-swap';
@@ -399,77 +399,54 @@ var pow10n = function pow10n(d) {
399
399
  return result;
400
400
  };
401
401
 
402
- var submitTransaction = /*#__PURE__*/function () {
403
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(tx, signer, onSign) {
404
- return _regenerator().w(function (_context) {
405
- while (1) switch (_context.n) {
406
- case 0:
407
- return _context.a(2, new Promise(function (resolve, reject) {
408
- tx.signSubmitAndWatch(signer).subscribe({
409
- next: function next(event) {
410
- if (event.type === 'signed') {
411
- onSign === null || onSign === void 0 || onSign();
412
- }
413
- if (event.type === 'finalized') {
414
- if (!event.ok) {
415
- var _event$dispatchError;
416
- var errorMsg = (_event$dispatchError = event.dispatchError) !== null && _event$dispatchError !== void 0 && _event$dispatchError.value ? JSON.stringify(event.dispatchError.value) : 'Transaction failed';
417
- reject(new UnsupportedOperationError(errorMsg));
418
- } else {
419
- resolve(event);
420
- }
421
- }
422
- },
423
- error: function error(_error) {
424
- if (_error instanceof InvalidTxError) {
425
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
426
- var typedErr = _error.error;
427
- reject(new UnsupportedOperationError("Invalid transaction: ".concat(JSON.stringify(typedErr))));
428
- } else {
429
- reject(_error instanceof Error ? _error : new UnsupportedOperationError(String(_error)));
430
- }
431
- }
432
- });
433
- }));
434
- }
435
- }, _callee);
436
- }));
437
- return function submitTransaction(_x, _x2, _x3) {
438
- return _ref.apply(this, arguments);
439
- };
440
- }();
441
-
442
- var convertTxToPapi = /*#__PURE__*/function () {
443
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(tx, papiApi) {
444
- var pjsHex, stripHeaderBytes, tryTxFromCallData, hex2, hex3;
402
+ var stripHeaderBytes = function stripHeaderBytes(hex, byteCount) {
403
+ return '0x' + hex.slice(2 + byteCount * 2);
404
+ };
405
+ var convertTxToTarget = /*#__PURE__*/function () {
406
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(tx, api) {
407
+ var isPjsTx, hex, hex2, hex3, _t;
445
408
  return _regenerator().w(function (_context) {
446
409
  while (1) switch (_context.p = _context.n) {
447
410
  case 0:
448
- pjsHex = tx.toHex();
449
- stripHeaderBytes = function stripHeaderBytes(hex, byteCount) {
450
- return '0x' + hex.slice(2 + byteCount * 2);
451
- };
452
- tryTxFromCallData = function tryTxFromCallData(hex) {
453
- return papiApi.getUnsafeApi().txFromCallData(Binary.fromHex(hex));
454
- };
455
- _context.p = 1;
456
- hex2 = stripHeaderBytes(pjsHex, 2);
411
+ isPjsTx = isPjsExtrinsic(tx);
412
+ if (!isPjsTx) {
413
+ _context.n = 1;
414
+ break;
415
+ }
416
+ _t = tx.toHex();
417
+ _context.n = 3;
418
+ break;
419
+ case 1:
457
420
  _context.n = 2;
458
- return tryTxFromCallData(hex2);
421
+ return tx.getEncodedData();
459
422
  case 2:
460
- return _context.a(2, _context.v);
423
+ _t = _context.v.asHex();
461
424
  case 3:
462
- _context.p = 3;
425
+ hex = _t;
426
+ if (!(isPjsTx && api.getType() === 'PAPI')) {
427
+ _context.n = 8;
428
+ break;
429
+ }
430
+ _context.p = 4;
431
+ hex2 = stripHeaderBytes(hex, 2);
432
+ _context.n = 5;
433
+ return api.txFromHex(hex2);
434
+ case 5:
435
+ return _context.a(2, _context.v);
436
+ case 6:
437
+ _context.p = 6;
463
438
  _context.v;
464
- hex3 = stripHeaderBytes(pjsHex, 3); // let any further error bubble up
465
- _context.n = 4;
466
- return tryTxFromCallData(hex3);
467
- case 4:
439
+ hex3 = stripHeaderBytes(hex, 3);
440
+ _context.n = 7;
441
+ return api.txFromHex(hex3);
442
+ case 7:
468
443
  return _context.a(2, _context.v);
444
+ case 8:
445
+ return _context.a(2, api.txFromHex(hex));
469
446
  }
470
- }, _callee, null, [[1, 3]]);
447
+ }, _callee, null, [[4, 6]]);
471
448
  }));
472
- return function convertTxToPapi(_x, _x2) {
449
+ return function convertTxToTarget(_x, _x2) {
473
450
  return _ref.apply(this, arguments);
474
451
  };
475
452
  }();
@@ -7465,11 +7442,11 @@ var AcalaExchange = /*#__PURE__*/function (_ExchangeChain) {
7465
7442
  key: "swapCurrency",
7466
7443
  value: function () {
7467
7444
  var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, options, toDestTransactionFee) {
7468
- var papiApi, assetFrom, assetTo, amount, senderAddress, origin, isForFeeEstimation, wallet, fromToken, toToken, acalaDex, dex, swapFee, totalNativeCurrencyFee, balance, pctDestFee, amountWithoutFee, tradeResult, tx, amountOutRes, amountOut, nativeAssetSymbol, amountOutWithFee;
7445
+ var papiApi, assetFrom, assetTo, amount, sender, origin, isForFeeEstimation, wallet, fromToken, toToken, acalaDex, dex, swapFee, totalNativeCurrencyFee, balance, pctDestFee, amountWithoutFee, tradeResult, tx, amountOutRes, amountOut, nativeAssetSymbol, amountOutWithFee;
7469
7446
  return _regenerator().w(function (_context) {
7470
7447
  while (1) switch (_context.n) {
7471
7448
  case 0:
7472
- papiApi = options.papiApi, assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, senderAddress = options.senderAddress, origin = options.origin, isForFeeEstimation = options.isForFeeEstimation;
7449
+ papiApi = options.papiApi, assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, sender = options.sender, origin = options.origin, isForFeeEstimation = options.isForFeeEstimation;
7473
7450
  wallet = new Wallet(api);
7474
7451
  _context.n = 1;
7475
7452
  return wallet.isReady;
@@ -7494,7 +7471,7 @@ var AcalaExchange = /*#__PURE__*/function (_ExchangeChain) {
7494
7471
  _context.n = 3;
7495
7472
  return getBalance({
7496
7473
  api: papiApi,
7497
- address: senderAddress,
7474
+ address: sender,
7498
7475
  chain: this.chain
7499
7476
  });
7500
7477
  case 3:
@@ -7794,11 +7771,11 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
7794
7771
  key: "swapCurrency",
7795
7772
  value: function () {
7796
7773
  var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_api, options, toDestTxFee) {
7797
- var assetFrom, assetTo, amount, senderAddress, slippagePct, origin, papiApi, pctDestFee, amountWithoutFee, _yield$getQuotedAmoun, amountOut, usedFromML, usedToML, slippageMultiplier, minAmountOut, tx, toDestFeeCurrencyTo, finalAmountOut, _t;
7774
+ var assetFrom, assetTo, amount, sender, slippagePct, origin, papiApi, pctDestFee, amountWithoutFee, _yield$getQuotedAmoun, amountOut, usedFromML, usedToML, slippageMultiplier, minAmountOut, tx, toDestFeeCurrencyTo, finalAmountOut, _t;
7798
7775
  return _regenerator().w(function (_context) {
7799
7776
  while (1) switch (_context.n) {
7800
7777
  case 0:
7801
- assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, senderAddress = options.senderAddress, slippagePct = options.slippagePct, origin = options.origin, papiApi = options.papiApi;
7778
+ assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, sender = options.sender, slippagePct = options.slippagePct, origin = options.origin, papiApi = options.papiApi;
7802
7779
  pctDestFee = origin ? DEST_FEE_BUFFER_PCT : 0;
7803
7780
  amountWithoutFee = padValueBy(amount, pctDestFee);
7804
7781
  _context.n = 1;
@@ -7814,7 +7791,7 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
7814
7791
  path: [transform(usedFromML), transform(usedToML)],
7815
7792
  amount_in: amountWithoutFee,
7816
7793
  amount_out_min: minAmountOut,
7817
- send_to: senderAddress,
7794
+ send_to: sender,
7818
7795
  keep_alive: !!assetFrom.isNative
7819
7796
  });
7820
7797
  if (!(assetTo.symbol == getNativeAssetSymbol(this.chain))) {
@@ -7915,7 +7892,7 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
7915
7892
  optionsHop2 = {
7916
7893
  papiApi: options.papiApi,
7917
7894
  slippagePct: options.slippagePct,
7918
- senderAddress: options.senderAddress,
7895
+ sender: options.sender,
7919
7896
  origin: undefined,
7920
7897
  assetFrom: nativeAsset,
7921
7898
  assetTo: assetTo,
@@ -8385,11 +8362,11 @@ var BifrostExchange = /*#__PURE__*/function (_ExchangeChain) {
8385
8362
  key: "swapCurrency",
8386
8363
  value: function () {
8387
8364
  var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, options, toDestTxFee) {
8388
- var assetFrom, assetTo, amount, senderAddress, slippagePct, origin, chainId, tokenMap, tokenWrappedFrom, tokenWrappedTo, tokenFrom, tokenTo, currencyCombinations, pairs, pctDestFee, amountWithoutFee, amountInFinal, trade, allowedSlippage, blockNumber, deadline, _SwapRouter$swapCallP, extrinsic, amountOut, nativeSymbol, amountOutWithFee;
8365
+ var assetFrom, assetTo, amount, sender, slippagePct, origin, chainId, tokenMap, tokenWrappedFrom, tokenWrappedTo, tokenFrom, tokenTo, currencyCombinations, pairs, pctDestFee, amountWithoutFee, amountInFinal, trade, allowedSlippage, blockNumber, deadline, _SwapRouter$swapCallP, extrinsic, amountOut, nativeSymbol, amountOutWithFee;
8389
8366
  return _regenerator().w(function (_context) {
8390
8367
  while (1) switch (_context.n) {
8391
8368
  case 0:
8392
- assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, senderAddress = options.senderAddress, slippagePct = options.slippagePct, origin = options.origin;
8369
+ assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, sender = options.sender, slippagePct = options.slippagePct, origin = options.origin;
8393
8370
  chainId = getParaId(this.chain);
8394
8371
  tokenMap = getTokenMap(this.chain, chainId);
8395
8372
  tokenWrappedFrom = findToken(tokenMap, assetFrom.symbol);
@@ -8435,7 +8412,7 @@ var BifrostExchange = /*#__PURE__*/function (_ExchangeChain) {
8435
8412
  _SwapRouter$swapCallP = SwapRouter.swapCallParameters(trade, {
8436
8413
  api: api,
8437
8414
  allowedSlippage: allowedSlippage,
8438
- recipient: senderAddress,
8415
+ recipient: sender,
8439
8416
  deadline: deadline
8440
8417
  }), extrinsic = _SwapRouter$swapCallP.extrinsic;
8441
8418
  if (!(extrinsic === null)) {
@@ -8565,11 +8542,11 @@ var getAssetInfo = /*#__PURE__*/function () {
8565
8542
 
8566
8543
  var calculateFee = /*#__PURE__*/function () {
8567
8544
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, currencyFromDecimals, chain, toDestTransactionFee) {
8568
- var amount, slippagePct, feeCalcAddress, senderAddress, trade, nativeCurrencyInfo, nativeCurrencyDecimals, substrateTx, tx, swapFee, feeNative, currencyFromPriceInfo, currencyFromPrice, feeInCurrencyFrom, finalFee;
8545
+ var amount, slippagePct, feeCalcAddress, sender, trade, nativeCurrencyInfo, nativeCurrencyDecimals, substrateTx, tx, swapFee, feeNative, currencyFromPriceInfo, currencyFromPrice, feeInCurrencyFrom, finalFee;
8569
8546
  return _regenerator().w(function (_context) {
8570
8547
  while (1) switch (_context.n) {
8571
8548
  case 0:
8572
- amount = _ref.amount, slippagePct = _ref.slippagePct, feeCalcAddress = _ref.feeCalcAddress, senderAddress = _ref.senderAddress;
8549
+ amount = _ref.amount, slippagePct = _ref.slippagePct, feeCalcAddress = _ref.feeCalcAddress, sender = _ref.sender;
8573
8550
  _context.n = 1;
8574
8551
  return tradeRouter.getBestSell(currencyFromInfo.id, currencyToInfo.id, amount.toString());
8575
8552
  case 1:
@@ -8594,7 +8571,7 @@ var calculateFee = /*#__PURE__*/function () {
8594
8571
  throw new UnableToComputeError('Native currency decimals not found');
8595
8572
  case 4:
8596
8573
  _context.n = 5;
8597
- return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(senderAddress).build();
8574
+ return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(sender).build();
8598
8575
  case 5:
8599
8576
  substrateTx = _context.v;
8600
8577
  tx = substrateTx.get();
@@ -8647,11 +8624,11 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
8647
8624
  key: "swapCurrency",
8648
8625
  value: function () {
8649
8626
  var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, options, toDestTransactionFee) {
8650
- var origin, assetFrom, assetTo, senderAddress, slippagePct, amount, _createSdkContext, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, tradeFee, amountWithoutFee, amountNormalized, trade, substrateTx, tx, amountOut, nativeCurrencyInfo, nativeCurrencyDecimals, priceInfo, currencyToPrice, feeInCurrencyTo, amountOutModified;
8627
+ var origin, assetFrom, assetTo, sender, slippagePct, amount, _createSdkContext, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, tradeFee, amountWithoutFee, amountNormalized, trade, substrateTx, tx, amountOut, nativeCurrencyInfo, nativeCurrencyDecimals, priceInfo, currencyToPrice, feeInCurrencyTo, amountOutModified;
8651
8628
  return _regenerator().w(function (_context) {
8652
8629
  while (1) switch (_context.n) {
8653
8630
  case 0:
8654
- origin = options.origin, assetFrom = options.assetFrom, assetTo = options.assetTo, senderAddress = options.senderAddress, slippagePct = options.slippagePct, amount = options.amount;
8631
+ origin = options.origin, assetFrom = options.assetFrom, assetTo = options.assetTo, sender = options.sender, slippagePct = options.slippagePct, amount = options.amount;
8655
8632
  _createSdkContext = createSdkContext(api), tradeRouter = _createSdkContext.api.router, txBuilderFactory = _createSdkContext.tx;
8656
8633
  _context.n = 1;
8657
8634
  return getAssetInfo(tradeRouter, assetFrom);
@@ -8692,7 +8669,7 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
8692
8669
  case 7:
8693
8670
  trade = _context.v;
8694
8671
  _context.n = 8;
8695
- return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(senderAddress).build();
8672
+ return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(sender).build();
8696
8673
  case 8:
8697
8674
  substrateTx = _context.v;
8698
8675
  tx = substrateTx.get();
@@ -8873,7 +8850,7 @@ var getExchangeConfig = function getExchangeConfig(exchange) {
8873
8850
  var assets = stored.assets.map(function (location) {
8874
8851
  return findAssetInfoOrThrow(chain, {
8875
8852
  location: location
8876
- }, null);
8853
+ });
8877
8854
  });
8878
8855
  return {
8879
8856
  isOmni: stored.isOmni,
@@ -8905,7 +8882,7 @@ var getExchangeAsset = function getExchangeAsset(exchange, currency) {
8905
8882
  throw new RoutingResolutionError("Multiple assets found for symbol ".concat(currency.symbol, ". Please specify the asset by location."));
8906
8883
  }
8907
8884
  }
8908
- asset = findAssetInfoBySymbol(null, otherAssets, nativeAssets, currency.symbol);
8885
+ asset = findAssetInfoBySymbol(otherAssets, nativeAssets, currency.symbol);
8909
8886
  } else if ('location' in currency && !isOverrideLocationSpecifier(currency.location)) {
8910
8887
  asset = findAssetInfoByLoc(assets, currency.location);
8911
8888
  } else if ('id' in currency) {
@@ -9054,7 +9031,7 @@ var getSupportedAssetsTo = function getSupportedAssetsTo(exchangeInput, to) {
9054
9031
  var getSupportedFeeAssets = function getSupportedFeeAssets(from, exchangeInput) {
9055
9032
  var exchange = normalizeExchange(exchangeInput);
9056
9033
  var supportedAssets = getSupportedAssetsFrom(from, exchange);
9057
- var chains = from ? [from] : (exchange === undefined ? _toConsumableArray(EXCHANGE_CHAINS) : Array.isArray(exchange) ? exchange : [exchange]).map(function (ex) {
9034
+ var chains = from ? [from] : (exchange === undefined ? EXCHANGE_CHAINS : Array.isArray(exchange) ? exchange : [exchange]).map(function (ex) {
9058
9035
  return createExchangeInstance(ex).chain;
9059
9036
  }).filter(function (chain, i, arr) {
9060
9037
  return arr.indexOf(chain) === i;
@@ -9100,13 +9077,13 @@ var supportsExchangePair = function supportsExchangePair(exchange, assetA, asset
9100
9077
  };
9101
9078
 
9102
9079
  var canBuildToExchangeTx = /*#__PURE__*/function () {
9103
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, exchangeChain, originApi, assetFromOrigin, builderOptions) {
9104
- var from, amount, _t2;
9080
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, exchangeChain, originApi, assetFromOrigin) {
9081
+ var from, amount, api, _t2;
9105
9082
  return _regenerator().w(function (_context) {
9106
9083
  while (1) switch (_context.p = _context.n) {
9107
9084
  case 0:
9108
9085
  // Try building the to exchange extrinsic to see if it will succeed for this exchange
9109
- from = options.from, amount = options.amount;
9086
+ from = options.from, amount = options.amount, api = options.api;
9110
9087
  _context.p = 1;
9111
9088
  if (!(from && from !== exchangeChain && originApi && assetFromOrigin)) {
9112
9089
  _context.n = 3;
@@ -9115,7 +9092,7 @@ var canBuildToExchangeTx = /*#__PURE__*/function () {
9115
9092
  _context.n = 2;
9116
9093
  return buildToExchangeExtrinsic({
9117
9094
  amount: BigInt(amount),
9118
- senderAddress: FALLBACK_FEE_CALC_ADDRESS,
9095
+ sender: FALLBACK_FEE_CALC_ADDRESS,
9119
9096
  evmSenderAddress: FALLBACK_FEE_CALC_EVM_ADDRESS,
9120
9097
  origin: {
9121
9098
  api: originApi,
@@ -9125,7 +9102,7 @@ var canBuildToExchangeTx = /*#__PURE__*/function () {
9125
9102
  exchange: {
9126
9103
  baseChain: exchangeChain
9127
9104
  },
9128
- builderOptions: builderOptions
9105
+ api: api
9129
9106
  });
9130
9107
  case 2:
9131
9108
  _context.v;
@@ -9153,19 +9130,19 @@ var canBuildToExchangeTx = /*#__PURE__*/function () {
9153
9130
  }
9154
9131
  }, _callee, null, [[1, 5]]);
9155
9132
  }));
9156
- return function canBuildToExchangeTx(_x, _x2, _x3, _x4, _x5) {
9133
+ return function canBuildToExchangeTx(_x, _x2, _x3, _x4) {
9157
9134
  return _ref.apply(this, arguments);
9158
9135
  };
9159
9136
  }();
9160
9137
 
9161
9138
  var selectBestExchangeCommon = /*#__PURE__*/function () {
9162
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, originApi, computeAmountOut, builderOptions) {
9163
- var from, exchange, to, currencyFrom, currencyTo, assetFromOrigin, filteredExchangeChains, bestExchange, maxAmountOut, errors, triedAnyExchange, _iterator, _step, exchangeChain, dex, originSpecified, destinationSpecified, assetFromExchange, assetTo, res, parsedAmount, amountOut, _t, _t2;
9139
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, originApi, computeAmountOut) {
9140
+ var api, from, exchange, to, currencyFrom, currencyTo, assetFromOrigin, filteredExchangeChains, bestExchange, maxAmountOut, errors, triedAnyExchange, _iterator, _step, exchangeChain, dex, originSpecified, destinationSpecified, assetFromExchange, assetTo, res, apiConfig, parsedAmount, amountOut, _t, _t2;
9164
9141
  return _regenerator().w(function (_context) {
9165
9142
  while (1) switch (_context.p = _context.n) {
9166
9143
  case 0:
9167
- from = options.from, exchange = options.exchange, to = options.to, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo;
9168
- assetFromOrigin = from ? findAssetInfo(from, currencyFrom, null) : undefined;
9144
+ api = options.api, from = options.from, exchange = options.exchange, to = options.to, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo;
9145
+ assetFromOrigin = from ? findAssetInfo(from, currencyFrom) : undefined;
9169
9146
  if (!(from && !assetFromOrigin)) {
9170
9147
  _context.n = 1;
9171
9148
  break;
@@ -9224,7 +9201,7 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
9224
9201
  triedAnyExchange = true;
9225
9202
  Logger.log("Checking ".concat(exchangeChain, "..."));
9226
9203
  _context.n = 9;
9227
- return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin, builderOptions);
9204
+ return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin);
9228
9205
  case 9:
9229
9206
  res = _context.v;
9230
9207
  if (res.success) {
@@ -9234,12 +9211,11 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
9234
9211
  errors.set(dex.chain, res.error);
9235
9212
  return _context.a(3, 14);
9236
9213
  case 10:
9237
- parsedAmount = applyDecimalAbstraction(options.amount, assetFromExchange === null || assetFromExchange === void 0 ? void 0 : assetFromExchange.decimals, !!(builderOptions !== null && builderOptions !== void 0 && builderOptions.abstractDecimals)).toString();
9214
+ apiConfig = api.getConfig();
9215
+ parsedAmount = applyDecimalAbstraction(options.amount, assetFromExchange === null || assetFromExchange === void 0 ? void 0 : assetFromExchange.decimals, !(isConfig(apiConfig) && apiConfig.abstractDecimals === false)).toString();
9238
9216
  _context.p = 11;
9239
9217
  _context.n = 12;
9240
- return computeAmountOut(dex, assetFromExchange, assetTo, _objectSpread2(_objectSpread2({}, options), {}, {
9241
- amount: parsedAmount
9242
- }));
9218
+ return computeAmountOut(dex, assetFromExchange, assetTo, options, parsedAmount);
9243
9219
  case 12:
9244
9220
  amountOut = _context.v;
9245
9221
  if (amountOut > maxAmountOut) {
@@ -9292,26 +9268,28 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
9292
9268
  }
9293
9269
  }, _callee, null, [[11, 13], [3, 16, 17, 18]]);
9294
9270
  }));
9295
- return function selectBestExchangeCommon(_x, _x2, _x3, _x4) {
9271
+ return function selectBestExchangeCommon(_x, _x2, _x3) {
9296
9272
  return _ref.apply(this, arguments);
9297
9273
  };
9298
9274
  }();
9299
9275
 
9300
9276
  var selectBestExchange = /*#__PURE__*/function () {
9301
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi, builderOptions, isForFeeEstimation) {
9277
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi, isForFeeEstimation) {
9278
+ var api;
9302
9279
  return _regenerator().w(function (_context2) {
9303
9280
  while (1) switch (_context2.n) {
9304
9281
  case 0:
9282
+ api = options.api;
9305
9283
  return _context2.a(2, selectBestExchangeCommon(options, originApi, /*#__PURE__*/function () {
9306
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, options) {
9307
- var modifiedOptions, toDestTxFee, _yield$dex$handleMult, amountOut, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10;
9284
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, options, parsedAmount) {
9285
+ var modifiedOptions, toDestTxFee, _yield$dex$handleMult, amountOut, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10, _t11;
9308
9286
  return _regenerator().w(function (_context) {
9309
9287
  while (1) switch (_context.n) {
9310
9288
  case 0:
9311
9289
  _t = _objectSpread2;
9312
9290
  _t2 = _objectSpread2({}, options);
9313
9291
  _t3 = {};
9314
- _t4 = BigInt(options.amount);
9292
+ _t4 = BigInt(parsedAmount);
9315
9293
  _context.n = 1;
9316
9294
  return dex.createApiInstance();
9317
9295
  case 1:
@@ -9320,50 +9298,55 @@ var selectBestExchange = /*#__PURE__*/function () {
9320
9298
  return dex.createApiInstancePapi();
9321
9299
  case 2:
9322
9300
  _t6 = _context.v;
9323
- _t7 = dex.chain;
9324
- _t8 = dex.exchangeChain;
9325
- _t9 = assetFromExchange;
9326
- _t0 = assetTo;
9327
- _t1 = {
9328
- api: _t5,
9301
+ _context.n = 3;
9302
+ return api.createApiForChain(dex.chain);
9303
+ case 3:
9304
+ _t7 = _context.v;
9305
+ _t8 = dex.chain;
9306
+ _t9 = dex.exchangeChain;
9307
+ _t0 = assetFromExchange;
9308
+ _t1 = assetTo;
9309
+ _t10 = {
9310
+ apiPjs: _t5,
9329
9311
  apiPapi: _t6,
9330
- baseChain: _t7,
9331
- exchangeChain: _t8,
9332
- assetFrom: _t9,
9333
- assetTo: _t0
9312
+ api: _t7,
9313
+ baseChain: _t8,
9314
+ exchangeChain: _t9,
9315
+ assetFrom: _t0,
9316
+ assetTo: _t1
9334
9317
  };
9335
- _t10 = determineFeeCalcAddress(options.senderAddress, options.recipientAddress);
9318
+ _t11 = determineFeeCalcAddress(options.sender, options.recipient);
9336
9319
  modifiedOptions = _t(_t2, _t3, {
9337
9320
  amount: _t4,
9338
- exchange: _t1,
9339
- feeCalcAddress: _t10
9321
+ exchange: _t10,
9322
+ feeCalcAddress: _t11
9340
9323
  });
9341
- _context.n = 3;
9324
+ _context.n = 4;
9342
9325
  return calculateFromExchangeFee(modifiedOptions);
9343
- case 3:
9326
+ case 4:
9344
9327
  toDestTxFee = _context.v;
9345
- _context.n = 4;
9346
- return dex.handleMultiSwap(modifiedOptions.exchange.api, _objectSpread2(_objectSpread2({}, modifiedOptions), {}, {
9328
+ _context.n = 5;
9329
+ return dex.handleMultiSwap(modifiedOptions.exchange.apiPjs, _objectSpread2(_objectSpread2({}, modifiedOptions), {}, {
9347
9330
  papiApi: modifiedOptions.exchange.apiPapi,
9348
9331
  assetFrom: modifiedOptions.exchange.assetFrom,
9349
9332
  assetTo: modifiedOptions.exchange.assetTo,
9350
9333
  isForFeeEstimation: isForFeeEstimation
9351
9334
  }), toDestTxFee);
9352
- case 4:
9335
+ case 5:
9353
9336
  _yield$dex$handleMult = _context.v;
9354
9337
  amountOut = _yield$dex$handleMult.amountOut;
9355
9338
  return _context.a(2, amountOut);
9356
9339
  }
9357
9340
  }, _callee);
9358
9341
  }));
9359
- return function (_x5, _x6, _x7, _x8) {
9342
+ return function (_x4, _x5, _x6, _x7, _x8) {
9360
9343
  return _ref2.apply(this, arguments);
9361
9344
  };
9362
- }(), builderOptions));
9345
+ }()));
9363
9346
  }
9364
9347
  }, _callee2);
9365
9348
  }));
9366
- return function selectBestExchange(_x, _x2, _x3, _x4) {
9349
+ return function selectBestExchange(_x, _x2, _x3) {
9367
9350
  return _ref.apply(this, arguments);
9368
9351
  };
9369
9352
  }();
@@ -9383,7 +9366,7 @@ var resolveAssets = function resolveAssets(dex, _ref) {
9383
9366
  }
9384
9367
  var assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.exchangeChain, assetFromOrigin) : getExchangeAsset(dex.exchangeChain, currencyFrom);
9385
9368
  if (!assetFromExchange) {
9386
- if (!originSpecified && findAssetInfo(dex.chain, currencyFrom, null)) {
9369
+ if (!originSpecified && findAssetInfo(dex.chain, currencyFrom)) {
9387
9370
  throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " exists in ").concat(dex.chain, " but is not swappable on ").concat(dex.exchangeChain, "."));
9388
9371
  }
9389
9372
  throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " not found in ").concat(dex.exchangeChain, "."));
@@ -9423,14 +9406,14 @@ var createToExchangeBuilder = function createToExchangeBuilder(_ref) {
9423
9406
  from = _ref$origin.chain,
9424
9407
  assetFrom = _ref$origin.assetFrom,
9425
9408
  baseChain = _ref.exchange.baseChain,
9426
- senderAddress = _ref.senderAddress,
9409
+ sender = _ref.sender,
9427
9410
  evmSenderAddress = _ref.evmSenderAddress,
9428
9411
  amount = _ref.amount,
9429
- builderOptions = _ref.builderOptions;
9430
- return Builder(builderOptions).from(from).to(baseChain).currency({
9412
+ api = _ref.api;
9413
+ return Builder(api.clone()).from(from).to(baseChain).currency({
9431
9414
  location: assetFrom.location,
9432
9415
  amount: amount
9433
- }).address(senderAddress).senderAddress(isChainEvm(from) ? evmSenderAddress : senderAddress);
9416
+ }).sender(isChainEvm(from) ? evmSenderAddress : sender).recipient(sender);
9434
9417
  };
9435
9418
  var buildToExchangeExtrinsic = function buildToExchangeExtrinsic(options) {
9436
9419
  return createToExchangeBuilder(options).build();
@@ -9442,21 +9425,19 @@ var getToExchangeFee = function getToExchangeFee(options, disableFallback) {
9442
9425
  };
9443
9426
  var createFromExchangeBuilder = function createFromExchangeBuilder(_ref2) {
9444
9427
  var _ref2$exchange = _ref2.exchange,
9445
- apiPapi = _ref2$exchange.apiPapi,
9446
9428
  baseChain = _ref2$exchange.baseChain,
9447
9429
  assetTo = _ref2$exchange.assetTo,
9448
9430
  _ref2$destination = _ref2.destination,
9449
9431
  chain = _ref2$destination.chain,
9450
9432
  address = _ref2$destination.address,
9451
9433
  amount = _ref2.amount,
9452
- senderAddress = _ref2.senderAddress,
9453
- builderOptions = _ref2.builderOptions;
9454
- return Builder(_objectSpread2(_objectSpread2({}, builderOptions), {}, {
9455
- apiOverrides: _objectSpread2(_objectSpread2({}, builderOptions === null || builderOptions === void 0 ? void 0 : builderOptions.apiOverrides), {}, _defineProperty({}, baseChain, apiPapi))
9456
- })).from(baseChain).to(chain).currency({
9434
+ sender = _ref2.sender,
9435
+ api = _ref2.api;
9436
+ var apiForChain = api.clone();
9437
+ return Builder(apiForChain).from(baseChain).to(chain).currency({
9457
9438
  location: assetTo.location,
9458
9439
  amount: amount
9459
- }).address(address).senderAddress(senderAddress);
9440
+ }).sender(sender).recipient(address);
9460
9441
  };
9461
9442
  var buildFromExchangeExtrinsic = function buildFromExchangeExtrinsic(options) {
9462
9443
  return createFromExchangeBuilder(options).build();
@@ -9466,28 +9447,29 @@ var getFromExchangeFee = function getFromExchangeFee(options, disableFallback) {
9466
9447
  disableFallback: disableFallback
9467
9448
  });
9468
9449
  };
9469
- var determineFeeCalcAddress = function determineFeeCalcAddress(senderAddress, recipientAddress) {
9470
- if (!ethers.isAddress(senderAddress)) {
9450
+ var determineFeeCalcAddress = function determineFeeCalcAddress(sender, recipient) {
9451
+ if (!ethers.isAddress(sender)) {
9471
9452
  // Use wallet address for fee calculation
9472
- return senderAddress;
9453
+ return sender;
9473
9454
  }
9474
- if (recipientAddress && !ethers.isAddress(recipientAddress)) {
9455
+ if (recipient && !ethers.isAddress(recipient)) {
9475
9456
  // Use recipient address for fee calculation
9476
- return recipientAddress;
9457
+ return recipient;
9477
9458
  }
9478
9459
  // If both addresses are ethereum addresses, use fallback address for fee calculation
9479
9460
  return FALLBACK_FEE_CALC_ADDRESS;
9480
9461
  };
9481
9462
 
9482
9463
  var prepareTransformedOptions = /*#__PURE__*/function () {
9483
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, builderOptions) {
9464
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
9484
9465
  var _assetFromOrigin$deci;
9485
9466
  var isForFeeEstimation,
9467
+ api,
9486
9468
  from,
9487
9469
  to,
9488
9470
  exchange,
9489
- senderAddress,
9490
- recipientAddress,
9471
+ sender,
9472
+ recipient,
9491
9473
  amount,
9492
9474
  originApi,
9493
9475
  dex,
@@ -9499,6 +9481,9 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
9499
9481
  feeAssetFromExchange,
9500
9482
  originSpecified,
9501
9483
  destinationSpecified,
9484
+ exchangeApi,
9485
+ config,
9486
+ exchangeConfig,
9502
9487
  transformed,
9503
9488
  _args = arguments,
9504
9489
  _t,
@@ -9522,14 +9507,14 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
9522
9507
  return _regenerator().w(function (_context) {
9523
9508
  while (1) switch (_context.n) {
9524
9509
  case 0:
9525
- isForFeeEstimation = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
9526
- from = options.from, to = options.to, exchange = options.exchange, senderAddress = options.senderAddress, recipientAddress = options.recipientAddress, amount = options.amount;
9510
+ isForFeeEstimation = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
9511
+ api = options.api, from = options.from, to = options.to, exchange = options.exchange, sender = options.sender, recipient = options.recipient, amount = options.amount;
9527
9512
  if (!from) {
9528
9513
  _context.n = 2;
9529
9514
  break;
9530
9515
  }
9531
9516
  _context.n = 1;
9532
- return createChainClient$1(from, builderOptions);
9517
+ return api.createApiForChain(from);
9533
9518
  case 1:
9534
9519
  _t = _context.v;
9535
9520
  _context.n = 3;
@@ -9547,7 +9532,7 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
9547
9532
  break;
9548
9533
  case 4:
9549
9534
  _context.n = 5;
9550
- return selectBestExchange(options, originApi, builderOptions, isForFeeEstimation);
9535
+ return selectBestExchange(options, originApi === null || originApi === void 0 ? void 0 : originApi.getApi(), isForFeeEstimation);
9551
9536
  case 5:
9552
9537
  _t2 = _context.v;
9553
9538
  case 6:
@@ -9561,51 +9546,57 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
9561
9546
  case 7:
9562
9547
  originSpecified = from && originApi && from !== dex.chain;
9563
9548
  destinationSpecified = to && to !== dex.chain;
9549
+ _context.n = 8;
9550
+ return api.createApiForChain(dex.chain);
9551
+ case 8:
9552
+ exchangeApi = _context.v;
9553
+ config = api.getConfig();
9554
+ exchangeConfig = convertBuilderConfig(config);
9564
9555
  _t3 = _objectSpread2;
9565
9556
  _t4 = _objectSpread2({}, options);
9566
9557
  _t5 = {};
9567
- _t6 = applyDecimalAbstraction(amount, (_assetFromOrigin$deci = assetFromOrigin === null || assetFromOrigin === void 0 ? void 0 : assetFromOrigin.decimals) !== null && _assetFromOrigin$deci !== void 0 ? _assetFromOrigin$deci : assetFromExchange.decimals, !!(builderOptions !== null && builderOptions !== void 0 && builderOptions.abstractDecimals));
9568
- _t7 = originSpecified && assetFromOrigin ? {
9569
- api: originApi,
9558
+ _t6 = applyDecimalAbstraction(amount, (_assetFromOrigin$deci = assetFromOrigin === null || assetFromOrigin === void 0 ? void 0 : assetFromOrigin.decimals) !== null && _assetFromOrigin$deci !== void 0 ? _assetFromOrigin$deci : assetFromExchange.decimals, (exchangeConfig === null || exchangeConfig === void 0 ? void 0 : exchangeConfig.abstractDecimals) !== false);
9559
+ _t7 = originSpecified && assetFromOrigin && originApi ? {
9560
+ api: originApi.getApi(),
9570
9561
  chain: from,
9571
9562
  assetFrom: assetFromOrigin,
9572
9563
  feeAssetInfo: feeAssetFromOrigin
9573
9564
  } : undefined;
9574
- _context.n = 8;
9575
- return dex.createApiInstance(builderOptions);
9576
- case 8:
9577
- _t8 = _context.v;
9578
9565
  _context.n = 9;
9579
- return dex.createApiInstancePapi(builderOptions);
9566
+ return dex.createApiInstance(exchangeConfig);
9580
9567
  case 9:
9568
+ _t8 = _context.v;
9569
+ _context.n = 10;
9570
+ return dex.createApiInstancePapi(exchangeConfig);
9571
+ case 10:
9581
9572
  _t9 = _context.v;
9582
- _t0 = dex.chain;
9583
- _t1 = dex.exchangeChain;
9584
- _t10 = assetFromExchange;
9585
- _t11 = assetTo;
9586
- _t12 = feeAssetFromExchange;
9587
- _t13 = {
9588
- api: _t8,
9573
+ _t0 = exchangeApi;
9574
+ _t1 = dex.chain;
9575
+ _t10 = dex.exchangeChain;
9576
+ _t11 = assetFromExchange;
9577
+ _t12 = assetTo;
9578
+ _t13 = feeAssetFromExchange;
9579
+ _t14 = {
9580
+ apiPjs: _t8,
9589
9581
  apiPapi: _t9,
9590
- baseChain: _t0,
9591
- exchangeChain: _t1,
9592
- assetFrom: _t10,
9593
- assetTo: _t11,
9594
- feeAssetInfo: _t12
9582
+ api: _t0,
9583
+ baseChain: _t1,
9584
+ exchangeChain: _t10,
9585
+ assetFrom: _t11,
9586
+ assetTo: _t12,
9587
+ feeAssetInfo: _t13
9595
9588
  };
9596
- _t14 = destinationSpecified && recipientAddress ? {
9589
+ _t15 = destinationSpecified && recipient ? {
9597
9590
  chain: to,
9598
- address: recipientAddress
9591
+ address: recipient
9599
9592
  } : undefined;
9600
- _t15 = determineFeeCalcAddress(senderAddress, recipientAddress);
9601
- _t16 = builderOptions;
9593
+ _t16 = determineFeeCalcAddress(sender, recipient);
9602
9594
  transformed = _t3(_t4, _t5, {
9603
9595
  amount: _t6,
9604
9596
  origin: _t7,
9605
- exchange: _t13,
9606
- destination: _t14,
9607
- feeCalcAddress: _t15,
9608
- builderOptions: _t16
9597
+ exchange: _t14,
9598
+ destination: _t15,
9599
+ feeCalcAddress: _t16
9609
9600
  });
9610
9601
  return _context.a(2, {
9611
9602
  dex: dex,
@@ -9614,7 +9605,7 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
9614
9605
  }
9615
9606
  }, _callee);
9616
9607
  }));
9617
- return function prepareTransformedOptions(_x, _x2) {
9608
+ return function prepareTransformedOptions(_x) {
9618
9609
  return _ref.apply(this, arguments);
9619
9610
  };
9620
9611
  }();
@@ -9639,20 +9630,20 @@ var validateTransferOptions = function validateTransferOptions(options) {
9639
9630
  var from = options.from,
9640
9631
  exchange = options.exchange,
9641
9632
  evmSenderAddress = options.evmSenderAddress,
9642
- senderAddress = options.senderAddress,
9643
- recipientAddress = options.recipientAddress,
9633
+ sender = options.sender,
9634
+ recipient = options.recipient,
9644
9635
  to = options.to;
9645
9636
  if (exchange === undefined && from === undefined) {
9646
9637
  throw new MissingParameterError('from', 'Origin chain is required when exchange is auto');
9647
9638
  }
9648
- if (to && !recipientAddress) {
9649
- throw new MissingParameterError('recipientAddress', 'Recipient address is required');
9639
+ if (to && !recipient) {
9640
+ throw new MissingParameterError('recipient', 'Recipient address is required');
9650
9641
  }
9651
- if (to && recipientAddress) validateDestinationAddress(recipientAddress, to);
9642
+ if (to && recipient) validateDestinationAddress(recipient, to);
9652
9643
  if (evmSenderAddress !== undefined && !ethers.isAddress(evmSenderAddress)) {
9653
9644
  throw new InvalidAddressError('Evm injector address is not a valid Ethereum address');
9654
9645
  }
9655
- if (ethers.isAddress(senderAddress)) {
9646
+ if (ethers.isAddress(sender)) {
9656
9647
  throw new InvalidAddressError('Injector address cannot be an Ethereum address. Please use an Evm injector address instead.');
9657
9648
  }
9658
9649
  if (from && isChainEvm(from) && !evmSenderAddress) {
@@ -9663,11 +9654,11 @@ var validateTransferOptions = function validateTransferOptions(options) {
9663
9654
  var FEE_ESTIMATION_UNITS = '100';
9664
9655
  var calculateFromExchangeFee = /*#__PURE__*/function () {
9665
9656
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
9666
- var exchange, destination, feeCalcAddress, senderAddress, builderOptions, dummyAmount, tx;
9657
+ var exchange, destination, feeCalcAddress, sender, api, dummyAmount, tx, _yield$exchange$api$g, partialFee;
9667
9658
  return _regenerator().w(function (_context) {
9668
9659
  while (1) switch (_context.n) {
9669
9660
  case 0:
9670
- exchange = options.exchange, destination = options.destination, feeCalcAddress = options.feeCalcAddress, senderAddress = options.senderAddress, builderOptions = options.builderOptions;
9661
+ exchange = options.exchange, destination = options.destination, feeCalcAddress = options.feeCalcAddress, sender = options.sender, api = options.api;
9671
9662
  if (!(!destination || destination.chain === exchange.baseChain)) {
9672
9663
  _context.n = 1;
9673
9664
  break;
@@ -9680,12 +9671,17 @@ var calculateFromExchangeFee = /*#__PURE__*/function () {
9680
9671
  exchange: exchange,
9681
9672
  destination: destination,
9682
9673
  amount: dummyAmount,
9683
- senderAddress: senderAddress,
9684
- builderOptions: builderOptions
9674
+ sender: sender,
9675
+ api: api
9685
9676
  });
9686
9677
  case 2:
9687
9678
  tx = _context.v;
9688
- return _context.a(2, tx.getEstimatedFees(feeCalcAddress));
9679
+ _context.n = 3;
9680
+ return exchange.api.getPaymentInfo(tx, feeCalcAddress);
9681
+ case 3:
9682
+ _yield$exchange$api$g = _context.v;
9683
+ partialFee = _yield$exchange$api$g.partialFee;
9684
+ return _context.a(2, partialFee);
9689
9685
  }
9690
9686
  }, _callee);
9691
9687
  }));
@@ -9709,7 +9705,7 @@ var createSwapTx = /*#__PURE__*/function () {
9709
9705
  case 1:
9710
9706
  toDestTxFee = _context2.v;
9711
9707
  _context2.n = 2;
9712
- return exchange.handleMultiSwap(options.exchange.api, _objectSpread2(_objectSpread2({}, options), {}, {
9708
+ return exchange.handleMultiSwap(options.exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
9713
9709
  papiApi: options.exchange.apiPapi,
9714
9710
  assetFrom: options.exchange.assetFrom,
9715
9711
  assetTo: options.exchange.assetTo,
@@ -9719,7 +9715,7 @@ var createSwapTx = /*#__PURE__*/function () {
9719
9715
  swapResult = _context2.v;
9720
9716
  _context2.n = 3;
9721
9717
  return Promise.all(swapResult.txs.map(function (tx) {
9722
- return isPjsExtrinsic(tx) ? convertTxToPapi(tx, options.exchange.apiPapi) : Promise.resolve(tx);
9718
+ return convertTxToTarget(tx, options.exchange.api);
9723
9719
  }));
9724
9720
  case 3:
9725
9721
  txs = _context2.v;
@@ -9737,18 +9733,18 @@ var createSwapTx = /*#__PURE__*/function () {
9737
9733
 
9738
9734
  var prepareExtrinsics = /*#__PURE__*/function () {
9739
9735
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options) {
9740
- var origin, exchange, destination, currencyTo, amount, evmSenderAddress, senderAddress, recipientAddress, builderOptions, _origin$assetFrom, _origin$feeAssetInfo, _amountOut, tx, toExchangeTx, _yield$createSwapTx, swapTxs, amountOut, toDestTx, _t, _t2, _t3;
9736
+ 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;
9741
9737
  return _regenerator().w(function (_context) {
9742
9738
  while (1) switch (_context.p = _context.n) {
9743
9739
  case 0:
9744
- origin = options.origin, exchange = options.exchange, destination = options.destination, currencyTo = options.currencyTo, amount = options.amount, evmSenderAddress = options.evmSenderAddress, senderAddress = options.senderAddress, recipientAddress = options.recipientAddress, builderOptions = options.builderOptions;
9740
+ 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;
9745
9741
  if (!((origin || destination) && (dex.chain.includes('AssetHub') || dex.chain === 'Hydration'))) {
9746
9742
  _context.n = 5;
9747
9743
  break;
9748
9744
  }
9749
9745
  _context.p = 1;
9750
9746
  _context.n = 2;
9751
- return dex.getAmountOut(exchange.api, _objectSpread2(_objectSpread2({}, options), {}, {
9747
+ return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
9752
9748
  papiApi: exchange.apiPapi,
9753
9749
  assetFrom: exchange.assetFrom,
9754
9750
  assetTo: exchange.assetTo
@@ -9757,6 +9753,7 @@ var prepareExtrinsics = /*#__PURE__*/function () {
9757
9753
  _amountOut = _context.v;
9758
9754
  _context.n = 3;
9759
9755
  return handleSwapExecuteTransfer({
9756
+ api: api,
9760
9757
  chain: origin === null || origin === void 0 ? void 0 : origin.chain,
9761
9758
  exchangeChain: exchange.baseChain,
9762
9759
  destChain: destination === null || destination === void 0 ? void 0 : destination.chain,
@@ -9766,19 +9763,19 @@ var prepareExtrinsics = /*#__PURE__*/function () {
9766
9763
  assetInfoTo: _objectSpread2(_objectSpread2({}, exchange.assetTo), {}, {
9767
9764
  amount: _amountOut
9768
9765
  }),
9769
- senderAddress: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : senderAddress,
9766
+ sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
9767
+ recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
9770
9768
  currencyTo: currencyTo,
9771
9769
  feeAssetInfo: (_origin$feeAssetInfo = origin === null || origin === void 0 ? void 0 : origin.feeAssetInfo) !== null && _origin$feeAssetInfo !== void 0 ? _origin$feeAssetInfo : exchange.feeAssetInfo,
9772
- recipientAddress: recipientAddress !== null && recipientAddress !== void 0 ? recipientAddress : senderAddress,
9773
9770
  calculateMinAmountOut: function calculateMinAmountOut(amountIn, assetTo) {
9774
- return dex.getAmountOut(exchange.api, _objectSpread2(_objectSpread2({}, options), {}, {
9771
+ return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
9775
9772
  amount: amountIn,
9776
9773
  papiApi: options.exchange.apiPapi,
9777
9774
  assetFrom: options.exchange.assetFrom,
9778
9775
  assetTo: assetTo !== null && assetTo !== void 0 ? assetTo : options.exchange.assetTo
9779
9776
  }));
9780
9777
  }
9781
- }, builderOptions);
9778
+ });
9782
9779
  case 3:
9783
9780
  tx = _context.v;
9784
9781
  return _context.a(2, {
@@ -9826,8 +9823,8 @@ var prepareExtrinsics = /*#__PURE__*/function () {
9826
9823
  exchange: exchange,
9827
9824
  destination: destination,
9828
9825
  amount: amountOut,
9829
- senderAddress: senderAddress,
9830
- builderOptions: builderOptions
9826
+ sender: sender,
9827
+ api: api
9831
9828
  });
9832
9829
  case 10:
9833
9830
  _t3 = _context.v;
@@ -9878,13 +9875,9 @@ var buildTransactions = /*#__PURE__*/function () {
9878
9875
  });
9879
9876
  }
9880
9877
  if (toDestTx) {
9881
- batchedTx = exchange.apiPapi.getUnsafeApi().tx.Utility.batch_all({
9882
- calls: [].concat(_toConsumableArray(swapTxs.map(function (tx) {
9883
- return tx.decodedCall;
9884
- })), [toDestTx.decodedCall])
9885
- });
9878
+ batchedTx = exchange.api.callBatchMethod([].concat(_toConsumableArray(swapTxs), [toDestTx]), BatchMode.BATCH_ALL);
9886
9879
  transactions.push({
9887
- api: exchange.apiPapi,
9880
+ api: exchange.api.getApi(),
9888
9881
  chain: dex.chain,
9889
9882
  destinationChain: destination === null || destination === void 0 ? void 0 : destination.chain,
9890
9883
  tx: batchedTx,
@@ -9894,20 +9887,16 @@ var buildTransactions = /*#__PURE__*/function () {
9894
9887
  } else {
9895
9888
  if (swapTxs.length === 1) {
9896
9889
  transactions.push({
9897
- api: isExecute ? (_origin$api = origin === null || origin === void 0 ? void 0 : origin.api) !== null && _origin$api !== void 0 ? _origin$api : exchange.apiPapi : exchange.apiPapi,
9890
+ api: isExecute ? (_origin$api = origin === null || origin === void 0 ? void 0 : origin.api) !== null && _origin$api !== void 0 ? _origin$api : exchange.api.getApi() : exchange.api.getApi(),
9898
9891
  chain: isExecute ? (_origin$chain = origin === null || origin === void 0 ? void 0 : origin.chain) !== null && _origin$chain !== void 0 ? _origin$chain : dex.chain : dex.chain,
9899
9892
  tx: swapTxs[0],
9900
9893
  amountOut: amountOut,
9901
9894
  type: 'SWAP'
9902
9895
  });
9903
9896
  } else {
9904
- batchedSwapTx = exchange.apiPapi.getUnsafeApi().tx.Utility.batch_all({
9905
- calls: swapTxs.map(function (tx) {
9906
- return tx.decodedCall;
9907
- })
9908
- });
9897
+ batchedSwapTx = exchange.api.callBatchMethod(swapTxs, BatchMode.BATCH_ALL);
9909
9898
  transactions.push({
9910
- api: exchange.apiPapi,
9899
+ api: exchange.api.getApi(),
9911
9900
  chain: dex.chain,
9912
9901
  tx: batchedSwapTx,
9913
9902
  amountOut: amountOut,
@@ -9925,14 +9914,14 @@ var buildTransactions = /*#__PURE__*/function () {
9925
9914
  }();
9926
9915
 
9927
9916
  var buildApiTransactions = /*#__PURE__*/function () {
9928
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions, builderOptions) {
9917
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions) {
9929
9918
  var _yield$prepareTransfo, options, dex;
9930
9919
  return _regenerator().w(function (_context) {
9931
9920
  while (1) switch (_context.n) {
9932
9921
  case 0:
9933
9922
  validateTransferOptions(initialOptions);
9934
9923
  _context.n = 1;
9935
- return prepareTransformedOptions(initialOptions, builderOptions);
9924
+ return prepareTransformedOptions(initialOptions);
9936
9925
  case 1:
9937
9926
  _yield$prepareTransfo = _context.v;
9938
9927
  options = _yield$prepareTransfo.options;
@@ -9941,7 +9930,7 @@ var buildApiTransactions = /*#__PURE__*/function () {
9941
9930
  }
9942
9931
  }, _callee);
9943
9932
  }));
9944
- return function buildApiTransactions(_x, _x2) {
9933
+ return function buildApiTransactions(_x) {
9945
9934
  return _ref.apply(this, arguments);
9946
9935
  };
9947
9936
  }();
@@ -9970,22 +9959,20 @@ var assignIsExchange = function assignIsExchange(result, options) {
9970
9959
  var dryRunTransaction = /*#__PURE__*/function () {
9971
9960
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, transaction, destChain, bypassOptions) {
9972
9961
  var _ref2;
9973
- var exchange, senderAddress, evmSenderAddress, recipientAddress, destination, currencyFrom, currencyTo, amount, api, tx, chain, address, senderAddressResolved, resolvedDest;
9962
+ var api, exchange, sender, evmSenderAddress, destination, currencyFrom, currencyTo, amount, tx, chain, senderResolved, resolvedDest;
9974
9963
  return _regenerator().w(function (_context) {
9975
9964
  while (1) switch (_context.n) {
9976
9965
  case 0:
9977
- exchange = options.exchange, senderAddress = options.senderAddress, evmSenderAddress = options.evmSenderAddress, recipientAddress = options.recipientAddress, destination = options.destination, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, amount = options.amount;
9978
- api = transaction.api, tx = transaction.tx, chain = transaction.chain;
9979
- address = recipientAddress !== null && recipientAddress !== void 0 ? recipientAddress : senderAddress;
9980
- senderAddressResolved = evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : senderAddress;
9966
+ api = options.api, exchange = options.exchange, sender = options.sender, evmSenderAddress = options.evmSenderAddress, destination = options.destination, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, amount = options.amount;
9967
+ tx = transaction.tx, chain = transaction.chain;
9968
+ senderResolved = evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender;
9981
9969
  resolvedDest = (_ref2 = destChain !== null && destChain !== void 0 ? destChain : destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _ref2 !== void 0 ? _ref2 : exchange.baseChain;
9982
9970
  return _context.a(2, dryRun({
9983
- api: api,
9971
+ api: api.clone(),
9984
9972
  tx: tx,
9985
9973
  origin: chain,
9986
9974
  destination: resolvedDest,
9987
- senderAddress: senderAddressResolved,
9988
- address: address,
9975
+ sender: senderResolved,
9989
9976
  swapConfig: {
9990
9977
  currencyTo: currencyTo,
9991
9978
  exchangeChain: exchange.baseChain
@@ -10054,14 +10041,14 @@ var dryRunTransactions = function dryRunTransactions(transactions, options) {
10054
10041
  throw new UnsupportedOperationError('Router dry run supports up to two transactions per flow.');
10055
10042
  };
10056
10043
  var dryRunRouter = /*#__PURE__*/function () {
10057
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(initialOptions, builderOptions) {
10044
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(initialOptions) {
10058
10045
  var _yield$prepareTransfo, options, dex, routerPlan, result;
10059
10046
  return _regenerator().w(function (_context3) {
10060
10047
  while (1) switch (_context3.n) {
10061
10048
  case 0:
10062
10049
  validateTransferOptions(initialOptions);
10063
10050
  _context3.n = 1;
10064
- return prepareTransformedOptions(initialOptions, builderOptions);
10051
+ return prepareTransformedOptions(initialOptions);
10065
10052
  case 1:
10066
10053
  _yield$prepareTransfo = _context3.v;
10067
10054
  options = _yield$prepareTransfo.options;
@@ -10078,18 +10065,18 @@ var dryRunRouter = /*#__PURE__*/function () {
10078
10065
  }
10079
10066
  }, _callee3);
10080
10067
  }));
10081
- return function dryRunRouter(_x7, _x8) {
10068
+ return function dryRunRouter(_x7) {
10082
10069
  return _ref4.apply(this, arguments);
10083
10070
  };
10084
10071
  }();
10085
10072
 
10086
10073
  var getSwapFee = /*#__PURE__*/function () {
10087
10074
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(exchange, options, disableFallback) {
10088
- var senderAddress, assetFrom, amount, txs, amountOut, isForFeeEstimation, swapResult, buildTx, result, finalFee, _t;
10075
+ var sender, _options$exchange, assetFrom, api, amount, txs, amountOut, isForFeeEstimation, swapResult, buildTx, result, finalFee, _t;
10089
10076
  return _regenerator().w(function (_context2) {
10090
10077
  while (1) switch (_context2.p = _context2.n) {
10091
10078
  case 0:
10092
- senderAddress = options.senderAddress, assetFrom = options.exchange.assetFrom, amount = options.amount;
10079
+ sender = options.sender, _options$exchange = options.exchange, assetFrom = _options$exchange.assetFrom, api = _options$exchange.api, amount = options.amount;
10093
10080
  isForFeeEstimation = true;
10094
10081
  _context2.p = 1;
10095
10082
  _context2.n = 2;
@@ -10136,11 +10123,11 @@ var getSwapFee = /*#__PURE__*/function () {
10136
10123
  }();
10137
10124
  _context2.n = 6;
10138
10125
  return getOriginXcmFee({
10139
- api: options.exchange.apiPapi,
10126
+ api: api,
10140
10127
  buildTx: buildTx,
10141
10128
  origin: exchange.chain,
10142
10129
  destination: exchange.chain,
10143
- senderAddress: senderAddress,
10130
+ sender: sender,
10144
10131
  currency: {
10145
10132
  location: assetFrom.location,
10146
10133
  amount: amount
@@ -10167,11 +10154,11 @@ var getSwapFee = /*#__PURE__*/function () {
10167
10154
  var getRouterFees = /*#__PURE__*/function () {
10168
10155
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(dex, options, disableFallback) {
10169
10156
  var _sendingChain$hops, _receivingChain$origi, _receivingChain$hops, _sendingChain$origin, _receivingChain$desti, _sendingChain$failure, _sendingChain$failure2;
10170
- var origin, exchange, currencyFrom, currencyTo, feeAsset, destination, amount, recipientAddress, evmSenderAddress, senderAddress, builderOptions, _origin$chain, _destination$chain, buildTx, mainAmountOut, executeResult, transformedHops, sendingChain, _yield$getSwapFee, swapChain, amountOut, receivingChain, mergedHops, finalOrigin, finalDestination, _t, _t2, _t3;
10157
+ 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;
10171
10158
  return _regenerator().w(function (_context2) {
10172
10159
  while (1) switch (_context2.p = _context2.n) {
10173
10160
  case 0:
10174
- origin = options.origin, exchange = options.exchange, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, feeAsset = options.feeAsset, destination = options.destination, amount = options.amount, recipientAddress = options.recipientAddress, evmSenderAddress = options.evmSenderAddress, senderAddress = options.senderAddress, builderOptions = options.builderOptions;
10161
+ 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;
10175
10162
  if (!((origin || destination) && (dex.chain.includes('AssetHub') || dex.chain === 'Hydration'))) {
10176
10163
  _context2.n = 6;
10177
10164
  break;
@@ -10186,7 +10173,7 @@ var getRouterFees = /*#__PURE__*/function () {
10186
10173
  case 0:
10187
10174
  amt = overrideAmount !== undefined ? applyDecimalAbstraction(overrideAmount, exchange.assetFrom.decimals, true) : amount;
10188
10175
  _context.n = 1;
10189
- return dex.getAmountOut(exchange.api, _objectSpread2(_objectSpread2({}, options), {}, {
10176
+ return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
10190
10177
  amount: amt,
10191
10178
  papiApi: exchange.apiPapi,
10192
10179
  assetFrom: exchange.assetFrom,
@@ -10196,6 +10183,7 @@ var getRouterFees = /*#__PURE__*/function () {
10196
10183
  amountOut = _context.v;
10197
10184
  _context.n = 2;
10198
10185
  return handleSwapExecuteTransfer({
10186
+ api: api,
10199
10187
  chain: origin === null || origin === void 0 ? void 0 : origin.chain,
10200
10188
  exchangeChain: exchange.baseChain,
10201
10189
  destChain: destination === null || destination === void 0 ? void 0 : destination.chain,
@@ -10207,10 +10195,10 @@ var getRouterFees = /*#__PURE__*/function () {
10207
10195
  }),
10208
10196
  currencyTo: currencyTo,
10209
10197
  feeAssetInfo: (_origin$feeAssetInfo = origin === null || origin === void 0 ? void 0 : origin.feeAssetInfo) !== null && _origin$feeAssetInfo !== void 0 ? _origin$feeAssetInfo : exchange.feeAssetInfo,
10210
- senderAddress: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : senderAddress,
10211
- recipientAddress: recipientAddress !== null && recipientAddress !== void 0 ? recipientAddress : senderAddress,
10198
+ sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
10199
+ recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
10212
10200
  calculateMinAmountOut: function calculateMinAmountOut(amountIn, assetTo) {
10213
- return dex.getAmountOut(exchange.api, _objectSpread2(_objectSpread2({}, options), {}, {
10201
+ return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
10214
10202
  amount: amountIn,
10215
10203
  papiApi: options.exchange.apiPapi,
10216
10204
  assetFrom: options.exchange.assetFrom,
@@ -10218,7 +10206,7 @@ var getRouterFees = /*#__PURE__*/function () {
10218
10206
  slippagePct: '1'
10219
10207
  }));
10220
10208
  }
10221
- }, builderOptions);
10209
+ });
10222
10210
  case 2:
10223
10211
  tx = _context.v;
10224
10212
  return _context.a(2, tx);
@@ -10230,7 +10218,7 @@ var getRouterFees = /*#__PURE__*/function () {
10230
10218
  };
10231
10219
  }();
10232
10220
  _context2.n = 2;
10233
- return dex.getAmountOut(exchange.api, _objectSpread2(_objectSpread2({}, options), {}, {
10221
+ return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
10234
10222
  amount: amount,
10235
10223
  papiApi: exchange.apiPapi,
10236
10224
  assetFrom: exchange.assetFrom,
@@ -10240,11 +10228,12 @@ var getRouterFees = /*#__PURE__*/function () {
10240
10228
  mainAmountOut = _context2.v;
10241
10229
  _context2.n = 3;
10242
10230
  return getXcmFee({
10231
+ api: api,
10243
10232
  buildTx: buildTx,
10244
10233
  origin: (_origin$chain = origin === null || origin === void 0 ? void 0 : origin.chain) !== null && _origin$chain !== void 0 ? _origin$chain : exchange.baseChain,
10245
10234
  destination: (_destination$chain = destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _destination$chain !== void 0 ? _destination$chain : exchange.baseChain,
10246
- senderAddress: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : senderAddress,
10247
- address: recipientAddress !== null && recipientAddress !== void 0 ? recipientAddress : senderAddress,
10235
+ sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
10236
+ recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
10248
10237
  currency: _objectSpread2(_objectSpread2({}, currencyFrom), {}, {
10249
10238
  amount: BigInt(amount)
10250
10239
  }),
@@ -10255,7 +10244,7 @@ var getRouterFees = /*#__PURE__*/function () {
10255
10244
  exchangeChain: exchange.baseChain,
10256
10245
  amountOut: mainAmountOut
10257
10246
  }
10258
- }, builderOptions);
10247
+ });
10259
10248
  case 3:
10260
10249
  executeResult = _context2.v;
10261
10250
  if (!(executeResult.failureReason === 'NoDeal' && exchange.exchangeChain === 'HydrationDex')) {
@@ -10266,9 +10255,12 @@ var getRouterFees = /*#__PURE__*/function () {
10266
10255
  case 4:
10267
10256
  transformedHops = executeResult.hops.map(function (hop) {
10268
10257
  if (hop.chain === exchange.baseChain) {
10269
- return _objectSpread2(_objectSpread2({}, hop), {}, {
10270
- isExchange: true
10271
- });
10258
+ return {
10259
+ chain: hop.chain,
10260
+ result: _objectSpread2(_objectSpread2({}, hop.result), {}, {
10261
+ isExchange: true
10262
+ })
10263
+ };
10272
10264
  }
10273
10265
  return hop;
10274
10266
  });
@@ -10321,8 +10313,8 @@ var getRouterFees = /*#__PURE__*/function () {
10321
10313
  exchange: exchange,
10322
10314
  destination: destination,
10323
10315
  amount: amountOut,
10324
- senderAddress: senderAddress,
10325
- builderOptions: builderOptions
10316
+ sender: sender,
10317
+ api: api
10326
10318
  }, disableFallback);
10327
10319
  case 11:
10328
10320
  _t3 = _context2.v;
@@ -10337,8 +10329,7 @@ var getRouterFees = /*#__PURE__*/function () {
10337
10329
  result: _objectSpread2(_objectSpread2({}, swapChain), {}, {
10338
10330
  fee: swapChain.fee + ((_receivingChain$origi = receivingChain === null || receivingChain === void 0 ? void 0 : receivingChain.origin.fee) !== null && _receivingChain$origi !== void 0 ? _receivingChain$origi : 0n),
10339
10331
  isExchange: true
10340
- }),
10341
- isExchange: true
10332
+ })
10342
10333
  }] : []), _toConsumableArray((_receivingChain$hops = receivingChain === null || receivingChain === void 0 ? void 0 : receivingChain.hops) !== null && _receivingChain$hops !== void 0 ? _receivingChain$hops : []));
10343
10334
  finalOrigin = (_sendingChain$origin = sendingChain === null || sendingChain === void 0 ? void 0 : sendingChain.origin) !== null && _sendingChain$origin !== void 0 ? _sendingChain$origin : _objectSpread2(_objectSpread2({}, swapChain), !origin && {
10344
10335
  isExchange: true
@@ -10364,14 +10355,14 @@ var getRouterFees = /*#__PURE__*/function () {
10364
10355
  }();
10365
10356
 
10366
10357
  var getXcmFees = /*#__PURE__*/function () {
10367
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions, disableFallback, builderOptions) {
10358
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions, disableFallback) {
10368
10359
  var _yield$prepareTransfo, options, dex;
10369
10360
  return _regenerator().w(function (_context) {
10370
10361
  while (1) switch (_context.n) {
10371
10362
  case 0:
10372
10363
  validateTransferOptions(initialOptions);
10373
10364
  _context.n = 1;
10374
- return prepareTransformedOptions(initialOptions, builderOptions, true);
10365
+ return prepareTransformedOptions(initialOptions, true);
10375
10366
  case 1:
10376
10367
  _yield$prepareTransfo = _context.v;
10377
10368
  options = _yield$prepareTransfo.options;
@@ -10380,65 +10371,65 @@ var getXcmFees = /*#__PURE__*/function () {
10380
10371
  }
10381
10372
  }, _callee);
10382
10373
  }));
10383
- return function getXcmFees(_x, _x2, _x3) {
10374
+ return function getXcmFees(_x, _x2) {
10384
10375
  return _ref.apply(this, arguments);
10385
10376
  };
10386
10377
  }();
10387
10378
 
10388
10379
  var selectBestExchangeAmountOut = /*#__PURE__*/function () {
10389
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi, builderOptions) {
10380
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi) {
10390
10381
  return _regenerator().w(function (_context2) {
10391
10382
  while (1) switch (_context2.n) {
10392
10383
  case 0:
10393
10384
  return _context2.a(2, selectBestExchangeCommon(options, originApi, /*#__PURE__*/function () {
10394
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, options) {
10395
- var api, papiApi;
10385
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, _options, parsedAmount) {
10386
+ var pjsApi, papiApi;
10396
10387
  return _regenerator().w(function (_context) {
10397
10388
  while (1) switch (_context.n) {
10398
10389
  case 0:
10399
10390
  _context.n = 1;
10400
10391
  return dex.createApiInstance();
10401
10392
  case 1:
10402
- api = _context.v;
10393
+ pjsApi = _context.v;
10403
10394
  _context.n = 2;
10404
10395
  return dex.createApiInstancePapi();
10405
10396
  case 2:
10406
10397
  papiApi = _context.v;
10407
- return _context.a(2, dex.getAmountOut(api, {
10398
+ return _context.a(2, dex.getAmountOut(pjsApi, {
10408
10399
  papiApi: papiApi,
10409
10400
  assetFrom: assetFromExchange,
10410
10401
  assetTo: assetTo,
10411
- amount: BigInt(options.amount)
10402
+ amount: BigInt(parsedAmount)
10412
10403
  }));
10413
10404
  }
10414
10405
  }, _callee);
10415
10406
  }));
10416
- return function (_x4, _x5, _x6, _x7) {
10407
+ return function (_x3, _x4, _x5, _x6, _x7) {
10417
10408
  return _ref2.apply(this, arguments);
10418
10409
  };
10419
- }(), builderOptions));
10410
+ }()));
10420
10411
  }
10421
10412
  }, _callee2);
10422
10413
  }));
10423
- return function selectBestExchangeAmountOut(_x, _x2, _x3) {
10414
+ return function selectBestExchangeAmountOut(_x, _x2) {
10424
10415
  return _ref.apply(this, arguments);
10425
10416
  };
10426
10417
  }();
10427
10418
 
10428
10419
  var getBestAmountOut = /*#__PURE__*/function () {
10429
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, builderOptions) {
10420
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
10430
10421
  var _assetFromOrigin$deci;
10431
- var exchange, amount, from, originApi, isExchangeAutoSelect, dex, _resolveAssets, assetFromOrigin, assetFrom, assetTo, res, api, papiApi, _t, _t2, _t3, _t4;
10422
+ var api, exchange, amount, from, originApi, isExchangeAutoSelect, dex, _resolveAssets, assetFromOrigin, assetFrom, assetTo, res, config, exchangeConfig, pjsApi, papiApi, _t, _t2, _t3, _t4;
10432
10423
  return _regenerator().w(function (_context) {
10433
10424
  while (1) switch (_context.n) {
10434
10425
  case 0:
10435
- exchange = options.exchange, amount = options.amount, from = options.from;
10426
+ api = options.api, exchange = options.exchange, amount = options.amount, from = options.from;
10436
10427
  if (!from) {
10437
10428
  _context.n = 2;
10438
10429
  break;
10439
10430
  }
10440
10431
  _context.n = 1;
10441
- return createChainClient$1(from, builderOptions);
10432
+ return createChainClient$2(api, from);
10442
10433
  case 1:
10443
10434
  _t = _context.v;
10444
10435
  _context.n = 3;
@@ -10453,7 +10444,7 @@ var getBestAmountOut = /*#__PURE__*/function () {
10453
10444
  break;
10454
10445
  }
10455
10446
  _context.n = 4;
10456
- return selectBestExchangeAmountOut(options, originApi, builderOptions);
10447
+ return selectBestExchangeAmountOut(options, originApi);
10457
10448
  case 4:
10458
10449
  _t2 = _context.v;
10459
10450
  _context.n = 6;
@@ -10468,7 +10459,7 @@ var getBestAmountOut = /*#__PURE__*/function () {
10468
10459
  break;
10469
10460
  }
10470
10461
  _context.n = 7;
10471
- return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin, builderOptions);
10462
+ return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin);
10472
10463
  case 7:
10473
10464
  res = _context.v;
10474
10465
  if (res.success) {
@@ -10477,21 +10468,23 @@ var getBestAmountOut = /*#__PURE__*/function () {
10477
10468
  }
10478
10469
  throw res.error;
10479
10470
  case 8:
10471
+ config = api.getConfig();
10472
+ exchangeConfig = convertBuilderConfig(config);
10480
10473
  _context.n = 9;
10481
- return dex.createApiInstance(builderOptions);
10474
+ return dex.createApiInstance(exchangeConfig);
10482
10475
  case 9:
10483
- api = _context.v;
10476
+ pjsApi = _context.v;
10484
10477
  _context.n = 10;
10485
- return dex.createApiInstancePapi(builderOptions);
10478
+ return dex.createApiInstancePapi(exchangeConfig);
10486
10479
  case 10:
10487
10480
  papiApi = _context.v;
10488
10481
  _t3 = dex.exchangeChain;
10489
10482
  _context.n = 11;
10490
- return dex.getAmountOut(api, {
10483
+ return dex.getAmountOut(pjsApi, {
10491
10484
  papiApi: papiApi,
10492
10485
  assetFrom: assetFrom,
10493
10486
  assetTo: assetTo,
10494
- amount: applyDecimalAbstraction(amount, (_assetFromOrigin$deci = assetFromOrigin === null || assetFromOrigin === void 0 ? void 0 : assetFromOrigin.decimals) !== null && _assetFromOrigin$deci !== void 0 ? _assetFromOrigin$deci : assetFrom.decimals, !!(builderOptions !== null && builderOptions !== void 0 && builderOptions.abstractDecimals))
10487
+ 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)
10495
10488
  });
10496
10489
  case 11:
10497
10490
  _t4 = _context.v;
@@ -10502,7 +10495,7 @@ var getBestAmountOut = /*#__PURE__*/function () {
10502
10495
  }
10503
10496
  }, _callee);
10504
10497
  }));
10505
- return function getBestAmountOut(_x, _x2) {
10498
+ return function getBestAmountOut(_x) {
10506
10499
  return _ref.apply(this, arguments);
10507
10500
  };
10508
10501
  }();
@@ -10541,19 +10534,19 @@ var computeExchangeMinAmount = /*#__PURE__*/function () {
10541
10534
  };
10542
10535
  }();
10543
10536
  var getMinTransferableAmount = /*#__PURE__*/function () {
10544
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(initialOptions, builderOptions) {
10545
- var _yield$prepareTransfo, dex, options, origin, exchange, senderAddress, evmSenderAddress, amount, builder;
10537
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(initialOptions) {
10538
+ var _yield$prepareTransfo, dex, options, origin, exchange, sender, evmSenderAddress, amount, api, builder;
10546
10539
  return _regenerator().w(function (_context2) {
10547
10540
  while (1) switch (_context2.n) {
10548
10541
  case 0:
10549
10542
  validateTransferOptions(initialOptions);
10550
10543
  _context2.n = 1;
10551
- return prepareTransformedOptions(initialOptions, builderOptions);
10544
+ return prepareTransformedOptions(initialOptions);
10552
10545
  case 1:
10553
10546
  _yield$prepareTransfo = _context2.v;
10554
10547
  dex = _yield$prepareTransfo.dex;
10555
10548
  options = _yield$prepareTransfo.options;
10556
- origin = options.origin, exchange = options.exchange, senderAddress = options.senderAddress, evmSenderAddress = options.evmSenderAddress, amount = options.amount;
10549
+ origin = options.origin, exchange = options.exchange, sender = options.sender, evmSenderAddress = options.evmSenderAddress, amount = options.amount, api = options.api;
10557
10550
  if (!origin) {
10558
10551
  _context2.n = 2;
10559
10552
  break;
@@ -10561,10 +10554,10 @@ var getMinTransferableAmount = /*#__PURE__*/function () {
10561
10554
  builder = createToExchangeBuilder({
10562
10555
  origin: origin,
10563
10556
  exchange: exchange,
10564
- senderAddress: senderAddress,
10557
+ sender: sender,
10565
10558
  evmSenderAddress: evmSenderAddress,
10566
10559
  amount: amount,
10567
- builderOptions: builderOptions
10560
+ api: api
10568
10561
  });
10569
10562
  return _context2.a(2, builder.getMinTransferableAmount());
10570
10563
  case 2:
@@ -10572,26 +10565,26 @@ var getMinTransferableAmount = /*#__PURE__*/function () {
10572
10565
  }
10573
10566
  }, _callee2);
10574
10567
  }));
10575
- return function getMinTransferableAmount(_x3, _x4) {
10568
+ return function getMinTransferableAmount(_x3) {
10576
10569
  return _ref2.apply(this, arguments);
10577
10570
  };
10578
10571
  }();
10579
10572
 
10580
10573
  var computeLocalTransferableAmount = /*#__PURE__*/function () {
10581
10574
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options) {
10582
- var exchange, senderAddress, currency, balance, existentialDeposit, swapFee, nativeSymbol, _result$fee, _yield$getSwapFee, result, transferable;
10575
+ var exchange, sender, currency, balance, existentialDeposit, swapFee, nativeSymbol, _result$fee, _yield$getSwapFee, result, transferable;
10583
10576
  return _regenerator().w(function (_context) {
10584
10577
  while (1) switch (_context.n) {
10585
10578
  case 0:
10586
- exchange = options.exchange, senderAddress = options.senderAddress;
10579
+ exchange = options.exchange, sender = options.sender;
10587
10580
  currency = {
10588
10581
  location: exchange.assetFrom.location
10589
10582
  };
10590
10583
  _context.n = 1;
10591
- return getBalance({
10592
- api: exchange.apiPapi,
10584
+ return getBalance$1({
10585
+ api: exchange.api,
10593
10586
  chain: exchange.baseChain,
10594
- address: senderAddress,
10587
+ address: sender,
10595
10588
  currency: currency
10596
10589
  });
10597
10590
  case 1:
@@ -10620,14 +10613,14 @@ var computeLocalTransferableAmount = /*#__PURE__*/function () {
10620
10613
  };
10621
10614
  }();
10622
10615
  var getTransferableAmount = /*#__PURE__*/function () {
10623
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(initialOptions, builderOptions) {
10616
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(initialOptions) {
10624
10617
  var _yield$prepareTransfo, dex, options, transformedOptions, builder;
10625
10618
  return _regenerator().w(function (_context2) {
10626
10619
  while (1) switch (_context2.n) {
10627
10620
  case 0:
10628
10621
  validateTransferOptions(initialOptions);
10629
10622
  _context2.n = 1;
10630
- return prepareTransformedOptions(initialOptions, builderOptions);
10623
+ return prepareTransformedOptions(initialOptions);
10631
10624
  case 1:
10632
10625
  _yield$prepareTransfo = _context2.v;
10633
10626
  dex = _yield$prepareTransfo.dex;
@@ -10640,10 +10633,10 @@ var getTransferableAmount = /*#__PURE__*/function () {
10640
10633
  builder = createToExchangeBuilder({
10641
10634
  origin: transformedOptions.origin,
10642
10635
  exchange: transformedOptions.exchange,
10643
- senderAddress: transformedOptions.senderAddress,
10636
+ sender: transformedOptions.sender,
10644
10637
  evmSenderAddress: transformedOptions.evmSenderAddress,
10645
10638
  amount: transformedOptions.amount,
10646
- builderOptions: builderOptions
10639
+ api: transformedOptions.api
10647
10640
  });
10648
10641
  return _context2.a(2, builder.getTransferableAmount());
10649
10642
  case 2:
@@ -10651,24 +10644,25 @@ var getTransferableAmount = /*#__PURE__*/function () {
10651
10644
  }
10652
10645
  }, _callee2);
10653
10646
  }));
10654
- return function getTransferableAmount(_x3, _x4) {
10647
+ return function getTransferableAmount(_x3) {
10655
10648
  return _ref2.apply(this, arguments);
10656
10649
  };
10657
10650
  }();
10658
10651
 
10659
10652
  var executeRouterPlan = /*#__PURE__*/function () {
10660
10653
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(plan, _ref) {
10661
- var signer, evmSigner, onStatusChange, _iterator, _step, _step$value, currentStep, _step$value$, tx, type, chain, destinationChain, _t;
10654
+ var signer, evmSigner, onStatusChange, api, txHashes, _iterator, _step, _step$value, currentStep, _step$value$, tx, type, chain, destinationChain, _t, _t2, _t3;
10662
10655
  return _regenerator().w(function (_context) {
10663
10656
  while (1) switch (_context.p = _context.n) {
10664
10657
  case 0:
10665
- signer = _ref.signer, evmSigner = _ref.evmSigner, onStatusChange = _ref.onStatusChange;
10658
+ signer = _ref.signer, evmSigner = _ref.evmSigner, onStatusChange = _ref.onStatusChange, api = _ref.api;
10659
+ txHashes = [];
10666
10660
  _iterator = _createForOfIteratorHelper(plan.entries());
10667
10661
  _context.p = 1;
10668
10662
  _iterator.s();
10669
10663
  case 2:
10670
10664
  if ((_step = _iterator.n()).done) {
10671
- _context.n = 6;
10665
+ _context.n = 7;
10672
10666
  break;
10673
10667
  }
10674
10668
  _step$value = _slicedToArray(_step.value, 2), currentStep = _step$value[0], _step$value$ = _step$value[1], tx = _step$value$.tx, type = _step$value$.type, chain = _step$value$.chain, destinationChain = _step$value$.destinationChain;
@@ -10683,79 +10677,56 @@ var executeRouterPlan = /*#__PURE__*/function () {
10683
10677
  _context.n = 4;
10684
10678
  break;
10685
10679
  }
10680
+ _t = txHashes;
10686
10681
  _context.n = 3;
10687
- return submitTransaction(tx, evmSigner);
10682
+ return api.signAndSubmitFinalized(tx, evmSigner);
10688
10683
  case 3:
10689
- _context.n = 5;
10684
+ _t.push.call(_t, _context.v);
10685
+ _context.n = 6;
10690
10686
  break;
10691
10687
  case 4:
10688
+ _t2 = txHashes;
10692
10689
  _context.n = 5;
10693
- return submitTransaction(tx, signer);
10690
+ return api.signAndSubmitFinalized(tx, signer);
10694
10691
  case 5:
10695
- _context.n = 2;
10696
- break;
10692
+ _t2.push.call(_t2, _context.v);
10697
10693
  case 6:
10698
- _context.n = 8;
10694
+ _context.n = 2;
10699
10695
  break;
10700
10696
  case 7:
10701
- _context.p = 7;
10702
- _t = _context.v;
10703
- _iterator.e(_t);
10697
+ _context.n = 9;
10698
+ break;
10704
10699
  case 8:
10705
10700
  _context.p = 8;
10706
- _iterator.f();
10707
- return _context.f(8);
10701
+ _t3 = _context.v;
10702
+ _iterator.e(_t3);
10708
10703
  case 9:
10704
+ _context.p = 9;
10705
+ _iterator.f();
10706
+ return _context.f(9);
10707
+ case 10:
10709
10708
  onStatusChange === null || onStatusChange === void 0 || onStatusChange({
10710
10709
  type: 'COMPLETED',
10711
10710
  currentStep: plan.length - 1,
10712
10711
  routerPlan: plan
10713
10712
  });
10714
- case 10:
10715
- return _context.a(2);
10713
+ return _context.a(2, txHashes);
10716
10714
  }
10717
- }, _callee, null, [[1, 7, 8, 9]]);
10715
+ }, _callee, null, [[1, 8, 9, 10]]);
10718
10716
  }));
10719
10717
  return function executeRouterPlan(_x, _x2) {
10720
10718
  return _ref2.apply(this, arguments);
10721
10719
  };
10722
10720
  }();
10723
10721
 
10724
- /**
10725
- * This function allows users to send one type of token and receive a different one on the destination chain
10726
- * in a one operation. It integrates with multiple exchanges like Acala, Basilisk, Bifrost, HydraDX, Interlay,
10727
- * Karura, and Kintsugi, covering over 500 asset pools.
10728
- *
10729
- * **Example Usage:**
10730
- * ```typescript
10731
- * await transfer({
10732
- * from: 'Polkadot',
10733
- * to: 'Astar',
10734
- * currencyFrom: { symbol: 'DOT' },
10735
- * currencyTo: { symbol: 'ASTR' },
10736
- * amount: '1000000',
10737
- * slippagePct: '1',
10738
- * senderAddress: 'your_injector_address',
10739
- * recipientAddress: 'recipient_address',
10740
- * signer: 'your_signer',
10741
- * onStatusChange: (status) => {
10742
- * console.log(status);
10743
- * },
10744
- * });
10745
- * ```
10746
- *
10747
- * @param initialOptions - An object containing transfer details such as origin, destination, currencies, amount, addresses, and signers.
10748
- * @returns A Promise that resolves when the transfer is complete.
10749
- * @throws An error if required parameters are missing or invalid.
10750
- */
10751
10722
  var transfer = /*#__PURE__*/function () {
10752
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions, builderOptions) {
10723
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions) {
10753
10724
  var _options$destination;
10754
- var from, exchangeChain, signer, evmSigner, senderAddress, evmSenderAddress, onStatusChange, _yield$prepareTransfo, dex, options, routerPlan;
10725
+ var api, from, exchangeChain, signer, evmSigner, sender, evmSenderAddress, onStatusChange, _yield$prepareTransfo, dex, options, routerPlan;
10755
10726
  return _regenerator().w(function (_context) {
10756
10727
  while (1) switch (_context.n) {
10757
10728
  case 0:
10758
- from = initialOptions.from, exchangeChain = initialOptions.exchange, signer = initialOptions.signer, evmSigner = initialOptions.evmSigner, senderAddress = initialOptions.senderAddress, evmSenderAddress = initialOptions.evmSenderAddress, onStatusChange = initialOptions.onStatusChange;
10729
+ api = initialOptions.api, from = initialOptions.from, exchangeChain = initialOptions.exchange, signer = initialOptions.signer, evmSigner = initialOptions.evmSigner, sender = initialOptions.sender, evmSenderAddress = initialOptions.evmSenderAddress, onStatusChange = initialOptions.onStatusChange;
10759
10730
  validateTransferOptions(initialOptions);
10760
10731
  if (!(evmSigner !== undefined && evmSenderAddress === undefined)) {
10761
10732
  _context.n = 1;
@@ -10781,7 +10752,7 @@ var transfer = /*#__PURE__*/function () {
10781
10752
  });
10782
10753
  }
10783
10754
  _context.n = 4;
10784
- return prepareTransformedOptions(initialOptions, builderOptions);
10755
+ return prepareTransformedOptions(initialOptions);
10785
10756
  case 4:
10786
10757
  _yield$prepareTransfo = _context.v;
10787
10758
  dex = _yield$prepareTransfo.dex;
@@ -10790,34 +10761,27 @@ var transfer = /*#__PURE__*/function () {
10790
10761
  return buildTransactions(dex, options);
10791
10762
  case 5:
10792
10763
  routerPlan = _context.v;
10793
- _context.n = 6;
10794
- return executeRouterPlan(routerPlan, {
10764
+ return _context.a(2, executeRouterPlan(routerPlan, {
10795
10765
  signer: signer,
10796
- senderAddress: senderAddress,
10766
+ sender: sender,
10797
10767
  destination: (_options$destination = options.destination) === null || _options$destination === void 0 ? void 0 : _options$destination.chain,
10798
10768
  evmSigner: evmSigner,
10799
10769
  evmSenderAddress: evmSenderAddress,
10800
- onStatusChange: onStatusChange
10801
- });
10802
- case 6:
10803
- return _context.a(2);
10770
+ onStatusChange: onStatusChange,
10771
+ api: api
10772
+ }));
10804
10773
  }
10805
10774
  }, _callee);
10806
10775
  }));
10807
- return function transfer(_x, _x2) {
10776
+ return function transfer(_x) {
10808
10777
  return _ref.apply(this, arguments);
10809
10778
  };
10810
10779
  }();
10811
10780
 
10812
- /**
10813
- * Builder class for constructing and executing cross-chain transfers using the XCM Router.
10814
- *
10815
- * @deprecated Use `@paraspell/sdk` with the "swap" extension installed instead.
10816
- */
10817
10781
  var RouterBuilderCore = /*#__PURE__*/function () {
10818
- function RouterBuilderCore(builderOptions, options) {
10782
+ function RouterBuilderCore(api, options) {
10819
10783
  _classCallCheck(this, RouterBuilderCore);
10820
- this._builderOptions = builderOptions;
10784
+ this._api = api;
10821
10785
  this._options = options !== null && options !== void 0 ? options : {};
10822
10786
  }
10823
10787
  /**
@@ -10829,7 +10793,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10829
10793
  return _createClass(RouterBuilderCore, [{
10830
10794
  key: "from",
10831
10795
  value: function from(chain) {
10832
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10796
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10833
10797
  from: chain
10834
10798
  }));
10835
10799
  }
@@ -10842,7 +10806,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10842
10806
  }, {
10843
10807
  key: "exchange",
10844
10808
  value: function exchange(chain) {
10845
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10809
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10846
10810
  exchange: normalizeExchange(chain)
10847
10811
  }));
10848
10812
  }
@@ -10855,7 +10819,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10855
10819
  }, {
10856
10820
  key: "to",
10857
10821
  value: function to(chain) {
10858
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10822
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10859
10823
  to: chain
10860
10824
  }));
10861
10825
  }
@@ -10868,7 +10832,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10868
10832
  }, {
10869
10833
  key: "currencyFrom",
10870
10834
  value: function currencyFrom(currency) {
10871
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10835
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10872
10836
  currencyFrom: currency
10873
10837
  }));
10874
10838
  }
@@ -10881,7 +10845,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10881
10845
  }, {
10882
10846
  key: "currencyTo",
10883
10847
  value: function currencyTo(currency) {
10884
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10848
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10885
10849
  currencyTo: currency
10886
10850
  }));
10887
10851
  }
@@ -10894,7 +10858,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10894
10858
  }, {
10895
10859
  key: "feeAsset",
10896
10860
  value: function feeAsset(currency) {
10897
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10861
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10898
10862
  feeAsset: currency
10899
10863
  }));
10900
10864
  }
@@ -10907,21 +10871,21 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10907
10871
  }, {
10908
10872
  key: "amount",
10909
10873
  value: function amount(_amount) {
10910
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10874
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10911
10875
  amount: _amount.toString()
10912
10876
  }));
10913
10877
  }
10914
10878
  /**
10915
10879
  * Specifies the recipient address on the destination chain.
10916
10880
  *
10917
- * @param recipientAddress - The recipient address.
10881
+ * @param recipient - The recipient address.
10918
10882
  * @returns The current builder instance.
10919
10883
  */
10920
10884
  }, {
10921
- key: "recipientAddress",
10922
- value: function recipientAddress(address) {
10923
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10924
- recipientAddress: address
10885
+ key: "recipient",
10886
+ value: function recipient(address) {
10887
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10888
+ recipient: address
10925
10889
  }));
10926
10890
  }
10927
10891
  /**
@@ -10931,22 +10895,22 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10931
10895
  * @returns The current builder instance.
10932
10896
  */
10933
10897
  }, {
10934
- key: "senderAddress",
10935
- value: function senderAddress(address) {
10936
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10937
- senderAddress: address
10898
+ key: "sender",
10899
+ value: function sender(address) {
10900
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10901
+ sender: address
10938
10902
  }));
10939
10903
  }
10940
10904
  /**
10941
- * Specifies the Polkadot signer for the transaction.
10905
+ * Specifies the signer for the transaction.
10942
10906
  *
10943
- * @param signer - The Polkadot signer instance.
10907
+ * @param signer - The signer instance.
10944
10908
  * @returns The current builder instance.
10945
10909
  */
10946
10910
  }, {
10947
10911
  key: "signer",
10948
10912
  value: function signer(_signer) {
10949
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10913
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10950
10914
  signer: _signer
10951
10915
  }));
10952
10916
  }
@@ -10959,7 +10923,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10959
10923
  }, {
10960
10924
  key: "evmSenderAddress",
10961
10925
  value: function evmSenderAddress(address) {
10962
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10926
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10963
10927
  evmSenderAddress: address
10964
10928
  }));
10965
10929
  }
@@ -10972,7 +10936,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10972
10936
  }, {
10973
10937
  key: "evmSigner",
10974
10938
  value: function evmSigner(signer) {
10975
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10939
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10976
10940
  evmSigner: signer
10977
10941
  }));
10978
10942
  }
@@ -10985,7 +10949,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10985
10949
  }, {
10986
10950
  key: "slippagePct",
10987
10951
  value: function slippagePct(pct) {
10988
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10952
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10989
10953
  slippagePct: pct
10990
10954
  }));
10991
10955
  }
@@ -10998,7 +10962,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10998
10962
  }, {
10999
10963
  key: "onStatusChange",
11000
10964
  value: function onStatusChange(callback) {
11001
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10965
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
11002
10966
  onStatusChange: callback
11003
10967
  }));
11004
10968
  }
@@ -11017,7 +10981,9 @@ var RouterBuilderCore = /*#__PURE__*/function () {
11017
10981
  while (1) switch (_context.n) {
11018
10982
  case 0:
11019
10983
  disableFallback = (_options$disableFallb = options === null || options === void 0 ? void 0 : options.disableFallback) !== null && _options$disableFallb !== void 0 ? _options$disableFallb : false;
11020
- return _context.a(2, getXcmFees(this._options, disableFallback, this._builderOptions));
10984
+ return _context.a(2, getXcmFees(_objectSpread2(_objectSpread2({}, this._options), {}, {
10985
+ api: this._api
10986
+ }), disableFallback));
11021
10987
  }
11022
10988
  }, _callee, this);
11023
10989
  }));
@@ -11033,7 +10999,9 @@ var RouterBuilderCore = /*#__PURE__*/function () {
11033
10999
  return _regenerator().w(function (_context2) {
11034
11000
  while (1) switch (_context2.n) {
11035
11001
  case 0:
11036
- return _context2.a(2, getTransferableAmount(this._options, this._builderOptions));
11002
+ return _context2.a(2, getTransferableAmount(_objectSpread2(_objectSpread2({}, this._options), {}, {
11003
+ api: this._api
11004
+ })));
11037
11005
  }
11038
11006
  }, _callee2, this);
11039
11007
  }));
@@ -11049,7 +11017,9 @@ var RouterBuilderCore = /*#__PURE__*/function () {
11049
11017
  return _regenerator().w(function (_context3) {
11050
11018
  while (1) switch (_context3.n) {
11051
11019
  case 0:
11052
- return _context3.a(2, getMinTransferableAmount(this._options, this._builderOptions));
11020
+ return _context3.a(2, getMinTransferableAmount(_objectSpread2(_objectSpread2({}, this._options), {}, {
11021
+ api: this._api
11022
+ })));
11053
11023
  }
11054
11024
  }, _callee3, this);
11055
11025
  }));
@@ -11061,65 +11031,48 @@ var RouterBuilderCore = /*#__PURE__*/function () {
11061
11031
  /**
11062
11032
  * Executes the transfer with the provided parameters.
11063
11033
  *
11034
+ * @returns An array of finalized transaction hashes (hex) in execution order.
11064
11035
  * @throws Error if required parameters are missing.
11065
11036
  */
11066
11037
  }, {
11067
- key: "build",
11068
- value: function build() {
11069
- return transfer(this._options, this._builderOptions);
11038
+ key: "signAndSubmit",
11039
+ value: function signAndSubmit() {
11040
+ return transfer(_objectSpread2(_objectSpread2({}, this._options), {}, {
11041
+ api: this._api
11042
+ }));
11070
11043
  }
11071
11044
  /**
11072
11045
  * Builds the transactions for the transfer with the provided parameters.
11073
11046
  */
11074
11047
  }, {
11075
- key: "buildTransactions",
11076
- value: function buildTransactions() {
11077
- return buildApiTransactions(this._options, this._builderOptions);
11048
+ key: "build",
11049
+ value: function build() {
11050
+ return buildApiTransactions(_objectSpread2(_objectSpread2({}, this._options), {}, {
11051
+ api: this._api
11052
+ }));
11078
11053
  }
11079
11054
  }, {
11080
11055
  key: "dryRun",
11081
11056
  value: function dryRun() {
11082
- return dryRunRouter(this._options, this._builderOptions);
11057
+ return dryRunRouter(_objectSpread2(_objectSpread2({}, this._options), {}, {
11058
+ api: this._api
11059
+ }));
11083
11060
  }
11084
11061
  }, {
11085
11062
  key: "getBestAmountOut",
11086
11063
  value: function getBestAmountOut$1() {
11087
- return getBestAmountOut(this._options, this._builderOptions);
11064
+ return getBestAmountOut(_objectSpread2(_objectSpread2({}, this._options), {}, {
11065
+ api: this._api
11066
+ }));
11088
11067
  }
11089
11068
  }]);
11090
11069
  }();
11091
- /**
11092
- * Creates a new `RouterBuilder` instance for constructing and executing cross-chain transfers using the XCM Router.
11093
- *
11094
- * @deprecated Use `@paraspell/sdk` with the "swap" extension installed instead.
11095
- *
11096
- * **Example usage:**
11097
- * ```typescript
11098
- * await RouterBuilder(options)
11099
- * .from('Polkadot')
11100
- * .exchange('HydrationDex')
11101
- * .to('Astar')
11102
- * .currencyFrom({ symbol: 'DOT' })
11103
- * .currencyTo({ symbol: 'ASTR' })
11104
- * .amount(1000000n)
11105
- * .slippagePct('1')
11106
- * .senderAddress('sender_address')
11107
- * .recipientAddress('recipient_address')
11108
- * .signer(yourSigner)
11109
- * .onStatusChange((status) => {
11110
- * console.log(status);
11111
- * })
11112
- * .build();
11113
- * ```
11114
- *
11115
- * @returns A new `RouterBuilder`.
11116
- */
11117
- var RouterBuilder = function RouterBuilder(options) {
11118
- return new RouterBuilderCore(options);
11070
+ var RouterBuilder = function RouterBuilder(api) {
11071
+ return new RouterBuilderCore(api);
11119
11072
  };
11120
11073
 
11121
11074
  registerSwapExtension({
11122
11075
  RouterBuilder: RouterBuilder
11123
11076
  });
11124
11077
 
11125
- export { DEST_FEE_BUFFER_PCT, FALLBACK_FEE_CALC_ADDRESS, FALLBACK_FEE_CALC_EVM_ADDRESS, FEE_BUFFER_PCT, RouterBuilder, RouterBuilderCore, buildApiTransactions, buildTransactions, createExchangeInstance, getExchangeAssets, getExchangeConfig, getExchangePairs, getSupportedAssetsFrom, getSupportedAssetsTo, getSupportedFeeAssets, transfer };
11078
+ export { DEST_FEE_BUFFER_PCT, FALLBACK_FEE_CALC_ADDRESS, FALLBACK_FEE_CALC_EVM_ADDRESS, FEE_BUFFER_PCT, RouterBuilder, RouterBuilderCore, getExchangeAssets, getExchangeConfig, getExchangePairs, getSupportedAssetsFrom, getSupportedAssetsTo, getSupportedFeeAssets };