@paraspell/swap 12.9.5 → 13.0.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 +370 -414
  3. package/package.json +19 -19
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
  }();
@@ -7533,11 +7510,11 @@ var AcalaExchange = /*#__PURE__*/function (_ExchangeChain) {
7533
7510
  key: "swapCurrency",
7534
7511
  value: function () {
7535
7512
  var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, options, toDestTransactionFee) {
7536
- var papiApi, assetFrom, assetTo, amount, senderAddress, origin, isForFeeEstimation, wallet, fromToken, toToken, acalaDex, dex, swapFee, totalNativeCurrencyFee, balance, pctDestFee, amountWithoutFee, tradeResult, tx, amountOutRes, amountOut, nativeAssetSymbol, amountOutWithFee;
7513
+ var papiApi, assetFrom, assetTo, amount, sender, origin, isForFeeEstimation, wallet, fromToken, toToken, acalaDex, dex, swapFee, totalNativeCurrencyFee, balance, pctDestFee, amountWithoutFee, tradeResult, tx, amountOutRes, amountOut, nativeAssetSymbol, amountOutWithFee;
7537
7514
  return _regenerator().w(function (_context) {
7538
7515
  while (1) switch (_context.n) {
7539
7516
  case 0:
7540
- papiApi = options.papiApi, assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, senderAddress = options.senderAddress, origin = options.origin, isForFeeEstimation = options.isForFeeEstimation;
7517
+ papiApi = options.papiApi, assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, sender = options.sender, origin = options.origin, isForFeeEstimation = options.isForFeeEstimation;
7541
7518
  wallet = new Wallet(api);
7542
7519
  _context.n = 1;
7543
7520
  return wallet.isReady;
@@ -7562,7 +7539,7 @@ var AcalaExchange = /*#__PURE__*/function (_ExchangeChain) {
7562
7539
  _context.n = 3;
7563
7540
  return getBalance({
7564
7541
  api: papiApi,
7565
- address: senderAddress,
7542
+ address: sender,
7566
7543
  chain: this.chain
7567
7544
  });
7568
7545
  case 3:
@@ -7862,11 +7839,11 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
7862
7839
  key: "swapCurrency",
7863
7840
  value: function () {
7864
7841
  var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_api, options, toDestTxFee) {
7865
- var assetFrom, assetTo, amount, senderAddress, slippagePct, origin, papiApi, pctDestFee, amountWithoutFee, _yield$getQuotedAmoun, amountOut, usedFromML, usedToML, slippageMultiplier, minAmountOut, tx, toDestFeeCurrencyTo, finalAmountOut, _t;
7842
+ var assetFrom, assetTo, amount, sender, slippagePct, origin, papiApi, pctDestFee, amountWithoutFee, _yield$getQuotedAmoun, amountOut, usedFromML, usedToML, slippageMultiplier, minAmountOut, tx, toDestFeeCurrencyTo, finalAmountOut, _t;
7866
7843
  return _regenerator().w(function (_context) {
7867
7844
  while (1) switch (_context.n) {
7868
7845
  case 0:
7869
- assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, senderAddress = options.senderAddress, slippagePct = options.slippagePct, origin = options.origin, papiApi = options.papiApi;
7846
+ assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, sender = options.sender, slippagePct = options.slippagePct, origin = options.origin, papiApi = options.papiApi;
7870
7847
  pctDestFee = origin ? DEST_FEE_BUFFER_PCT : 0;
7871
7848
  amountWithoutFee = padValueBy(amount, pctDestFee);
7872
7849
  _context.n = 1;
@@ -7882,7 +7859,7 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
7882
7859
  path: [transform(usedFromML), transform(usedToML)],
7883
7860
  amount_in: amountWithoutFee,
7884
7861
  amount_out_min: minAmountOut,
7885
- send_to: senderAddress,
7862
+ send_to: sender,
7886
7863
  keep_alive: !!assetFrom.isNative
7887
7864
  });
7888
7865
  if (!(assetTo.symbol == getNativeAssetSymbol(this.chain))) {
@@ -7983,7 +7960,7 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
7983
7960
  optionsHop2 = {
7984
7961
  papiApi: options.papiApi,
7985
7962
  slippagePct: options.slippagePct,
7986
- senderAddress: options.senderAddress,
7963
+ sender: options.sender,
7987
7964
  origin: undefined,
7988
7965
  assetFrom: nativeAsset,
7989
7966
  assetTo: assetTo,
@@ -8453,11 +8430,11 @@ var BifrostExchange = /*#__PURE__*/function (_ExchangeChain) {
8453
8430
  key: "swapCurrency",
8454
8431
  value: function () {
8455
8432
  var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, options, toDestTxFee) {
8456
- 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;
8433
+ 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;
8457
8434
  return _regenerator().w(function (_context) {
8458
8435
  while (1) switch (_context.n) {
8459
8436
  case 0:
8460
- assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, senderAddress = options.senderAddress, slippagePct = options.slippagePct, origin = options.origin;
8437
+ assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, sender = options.sender, slippagePct = options.slippagePct, origin = options.origin;
8461
8438
  chainId = getParaId(this.chain);
8462
8439
  tokenMap = getTokenMap(this.chain, chainId);
8463
8440
  tokenWrappedFrom = findToken(tokenMap, assetFrom.symbol);
@@ -8503,7 +8480,7 @@ var BifrostExchange = /*#__PURE__*/function (_ExchangeChain) {
8503
8480
  _SwapRouter$swapCallP = SwapRouter.swapCallParameters(trade, {
8504
8481
  api: api,
8505
8482
  allowedSlippage: allowedSlippage,
8506
- recipient: senderAddress,
8483
+ recipient: sender,
8507
8484
  deadline: deadline
8508
8485
  }), extrinsic = _SwapRouter$swapCallP.extrinsic;
8509
8486
  if (!(extrinsic === null)) {
@@ -8633,11 +8610,11 @@ var getAssetInfo = /*#__PURE__*/function () {
8633
8610
 
8634
8611
  var calculateFee = /*#__PURE__*/function () {
8635
8612
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, currencyFromDecimals, chain, toDestTransactionFee) {
8636
- var amount, slippagePct, feeCalcAddress, senderAddress, trade, nativeCurrencyInfo, nativeCurrencyDecimals, substrateTx, tx, swapFee, feeNative, currencyFromPriceInfo, currencyFromPrice, feeInCurrencyFrom, finalFee;
8613
+ var amount, slippagePct, feeCalcAddress, sender, trade, nativeCurrencyInfo, nativeCurrencyDecimals, substrateTx, tx, swapFee, feeNative, currencyFromPriceInfo, currencyFromPrice, feeInCurrencyFrom, finalFee;
8637
8614
  return _regenerator().w(function (_context) {
8638
8615
  while (1) switch (_context.n) {
8639
8616
  case 0:
8640
- amount = _ref.amount, slippagePct = _ref.slippagePct, feeCalcAddress = _ref.feeCalcAddress, senderAddress = _ref.senderAddress;
8617
+ amount = _ref.amount, slippagePct = _ref.slippagePct, feeCalcAddress = _ref.feeCalcAddress, sender = _ref.sender;
8641
8618
  _context.n = 1;
8642
8619
  return tradeRouter.getBestSell(currencyFromInfo.id, currencyToInfo.id, amount.toString());
8643
8620
  case 1:
@@ -8662,7 +8639,7 @@ var calculateFee = /*#__PURE__*/function () {
8662
8639
  throw new UnableToComputeError('Native currency decimals not found');
8663
8640
  case 4:
8664
8641
  _context.n = 5;
8665
- return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(senderAddress).build();
8642
+ return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(sender).build();
8666
8643
  case 5:
8667
8644
  substrateTx = _context.v;
8668
8645
  tx = substrateTx.get();
@@ -8715,11 +8692,11 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
8715
8692
  key: "swapCurrency",
8716
8693
  value: function () {
8717
8694
  var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, options, toDestTransactionFee) {
8718
- 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;
8695
+ 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;
8719
8696
  return _regenerator().w(function (_context) {
8720
8697
  while (1) switch (_context.n) {
8721
8698
  case 0:
8722
- origin = options.origin, assetFrom = options.assetFrom, assetTo = options.assetTo, senderAddress = options.senderAddress, slippagePct = options.slippagePct, amount = options.amount;
8699
+ origin = options.origin, assetFrom = options.assetFrom, assetTo = options.assetTo, sender = options.sender, slippagePct = options.slippagePct, amount = options.amount;
8723
8700
  _createSdkContext = createSdkContext(api), tradeRouter = _createSdkContext.api.router, txBuilderFactory = _createSdkContext.tx;
8724
8701
  _context.n = 1;
8725
8702
  return getAssetInfo(tradeRouter, assetFrom);
@@ -8760,7 +8737,7 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
8760
8737
  case 7:
8761
8738
  trade = _context.v;
8762
8739
  _context.n = 8;
8763
- return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(senderAddress).build();
8740
+ return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(sender).build();
8764
8741
  case 8:
8765
8742
  substrateTx = _context.v;
8766
8743
  tx = substrateTx.get();
@@ -8941,7 +8918,7 @@ var getExchangeConfig = function getExchangeConfig(exchange) {
8941
8918
  var assets = stored.assets.map(function (location) {
8942
8919
  return findAssetInfoOrThrow(chain, {
8943
8920
  location: location
8944
- }, null);
8921
+ });
8945
8922
  });
8946
8923
  return {
8947
8924
  isOmni: stored.isOmni,
@@ -8973,7 +8950,7 @@ var getExchangeAsset = function getExchangeAsset(exchange, currency) {
8973
8950
  throw new RoutingResolutionError("Multiple assets found for symbol ".concat(currency.symbol, ". Please specify the asset by location."));
8974
8951
  }
8975
8952
  }
8976
- asset = findAssetInfoBySymbol(null, otherAssets, nativeAssets, currency.symbol);
8953
+ asset = findAssetInfoBySymbol(otherAssets, nativeAssets, currency.symbol);
8977
8954
  } else if ('location' in currency && !isOverrideLocationSpecifier(currency.location)) {
8978
8955
  asset = findAssetInfoByLoc(assets, currency.location);
8979
8956
  } else if ('id' in currency) {
@@ -9122,7 +9099,7 @@ var getSupportedAssetsTo = function getSupportedAssetsTo(exchangeInput, to) {
9122
9099
  var getSupportedFeeAssets = function getSupportedFeeAssets(from, exchangeInput) {
9123
9100
  var exchange = normalizeExchange(exchangeInput);
9124
9101
  var supportedAssets = getSupportedAssetsFrom(from, exchange);
9125
- var chains = from ? [from] : (exchange === undefined ? _toConsumableArray(EXCHANGE_CHAINS) : Array.isArray(exchange) ? exchange : [exchange]).map(function (ex) {
9102
+ var chains = from ? [from] : (exchange === undefined ? EXCHANGE_CHAINS : Array.isArray(exchange) ? exchange : [exchange]).map(function (ex) {
9126
9103
  return createExchangeInstance(ex).chain;
9127
9104
  }).filter(function (chain, i, arr) {
9128
9105
  return arr.indexOf(chain) === i;
@@ -9168,13 +9145,13 @@ var supportsExchangePair = function supportsExchangePair(exchange, assetA, asset
9168
9145
  };
9169
9146
 
9170
9147
  var canBuildToExchangeTx = /*#__PURE__*/function () {
9171
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, exchangeChain, originApi, assetFromOrigin, builderOptions) {
9172
- var from, amount, _t2;
9148
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, exchangeChain, originApi, assetFromOrigin) {
9149
+ var from, amount, api, _t2;
9173
9150
  return _regenerator().w(function (_context) {
9174
9151
  while (1) switch (_context.p = _context.n) {
9175
9152
  case 0:
9176
9153
  // Try building the to exchange extrinsic to see if it will succeed for this exchange
9177
- from = options.from, amount = options.amount;
9154
+ from = options.from, amount = options.amount, api = options.api;
9178
9155
  _context.p = 1;
9179
9156
  if (!(from && from !== exchangeChain && originApi && assetFromOrigin)) {
9180
9157
  _context.n = 3;
@@ -9183,7 +9160,7 @@ var canBuildToExchangeTx = /*#__PURE__*/function () {
9183
9160
  _context.n = 2;
9184
9161
  return buildToExchangeExtrinsic({
9185
9162
  amount: BigInt(amount),
9186
- senderAddress: FALLBACK_FEE_CALC_ADDRESS,
9163
+ sender: FALLBACK_FEE_CALC_ADDRESS,
9187
9164
  evmSenderAddress: FALLBACK_FEE_CALC_EVM_ADDRESS,
9188
9165
  origin: {
9189
9166
  api: originApi,
@@ -9193,7 +9170,7 @@ var canBuildToExchangeTx = /*#__PURE__*/function () {
9193
9170
  exchange: {
9194
9171
  baseChain: exchangeChain
9195
9172
  },
9196
- builderOptions: builderOptions
9173
+ api: api
9197
9174
  });
9198
9175
  case 2:
9199
9176
  _context.v;
@@ -9221,19 +9198,19 @@ var canBuildToExchangeTx = /*#__PURE__*/function () {
9221
9198
  }
9222
9199
  }, _callee, null, [[1, 5]]);
9223
9200
  }));
9224
- return function canBuildToExchangeTx(_x, _x2, _x3, _x4, _x5) {
9201
+ return function canBuildToExchangeTx(_x, _x2, _x3, _x4) {
9225
9202
  return _ref.apply(this, arguments);
9226
9203
  };
9227
9204
  }();
9228
9205
 
9229
9206
  var selectBestExchangeCommon = /*#__PURE__*/function () {
9230
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, originApi, computeAmountOut, builderOptions) {
9231
- 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;
9207
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, originApi, computeAmountOut) {
9208
+ 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;
9232
9209
  return _regenerator().w(function (_context) {
9233
9210
  while (1) switch (_context.p = _context.n) {
9234
9211
  case 0:
9235
- from = options.from, exchange = options.exchange, to = options.to, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo;
9236
- assetFromOrigin = from ? findAssetInfo(from, currencyFrom, null) : undefined;
9212
+ api = options.api, from = options.from, exchange = options.exchange, to = options.to, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo;
9213
+ assetFromOrigin = from ? findAssetInfo(from, currencyFrom) : undefined;
9237
9214
  if (!(from && !assetFromOrigin)) {
9238
9215
  _context.n = 1;
9239
9216
  break;
@@ -9292,7 +9269,7 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
9292
9269
  triedAnyExchange = true;
9293
9270
  Logger.log("Checking ".concat(exchangeChain, "..."));
9294
9271
  _context.n = 9;
9295
- return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin, builderOptions);
9272
+ return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin);
9296
9273
  case 9:
9297
9274
  res = _context.v;
9298
9275
  if (res.success) {
@@ -9302,12 +9279,11 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
9302
9279
  errors.set(dex.chain, res.error);
9303
9280
  return _context.a(3, 14);
9304
9281
  case 10:
9305
- parsedAmount = applyDecimalAbstraction(options.amount, assetFromExchange === null || assetFromExchange === void 0 ? void 0 : assetFromExchange.decimals, !!(builderOptions !== null && builderOptions !== void 0 && builderOptions.abstractDecimals)).toString();
9282
+ apiConfig = api.getConfig();
9283
+ parsedAmount = applyDecimalAbstraction(options.amount, assetFromExchange === null || assetFromExchange === void 0 ? void 0 : assetFromExchange.decimals, !(isConfig(apiConfig) && apiConfig.abstractDecimals === false)).toString();
9306
9284
  _context.p = 11;
9307
9285
  _context.n = 12;
9308
- return computeAmountOut(dex, assetFromExchange, assetTo, _objectSpread2(_objectSpread2({}, options), {}, {
9309
- amount: parsedAmount
9310
- }));
9286
+ return computeAmountOut(dex, assetFromExchange, assetTo, options, parsedAmount);
9311
9287
  case 12:
9312
9288
  amountOut = _context.v;
9313
9289
  if (amountOut > maxAmountOut) {
@@ -9360,26 +9336,28 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
9360
9336
  }
9361
9337
  }, _callee, null, [[11, 13], [3, 16, 17, 18]]);
9362
9338
  }));
9363
- return function selectBestExchangeCommon(_x, _x2, _x3, _x4) {
9339
+ return function selectBestExchangeCommon(_x, _x2, _x3) {
9364
9340
  return _ref.apply(this, arguments);
9365
9341
  };
9366
9342
  }();
9367
9343
 
9368
9344
  var selectBestExchange = /*#__PURE__*/function () {
9369
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi, builderOptions, isForFeeEstimation) {
9345
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi, isForFeeEstimation) {
9346
+ var api;
9370
9347
  return _regenerator().w(function (_context2) {
9371
9348
  while (1) switch (_context2.n) {
9372
9349
  case 0:
9350
+ api = options.api;
9373
9351
  return _context2.a(2, selectBestExchangeCommon(options, originApi, /*#__PURE__*/function () {
9374
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, options) {
9375
- var modifiedOptions, toDestTxFee, _yield$dex$handleMult, amountOut, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10;
9352
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, options, parsedAmount) {
9353
+ var modifiedOptions, toDestTxFee, _yield$dex$handleMult, amountOut, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10, _t11;
9376
9354
  return _regenerator().w(function (_context) {
9377
9355
  while (1) switch (_context.n) {
9378
9356
  case 0:
9379
9357
  _t = _objectSpread2;
9380
9358
  _t2 = _objectSpread2({}, options);
9381
9359
  _t3 = {};
9382
- _t4 = BigInt(options.amount);
9360
+ _t4 = BigInt(parsedAmount);
9383
9361
  _context.n = 1;
9384
9362
  return dex.createApiInstance();
9385
9363
  case 1:
@@ -9388,50 +9366,55 @@ var selectBestExchange = /*#__PURE__*/function () {
9388
9366
  return dex.createApiInstancePapi();
9389
9367
  case 2:
9390
9368
  _t6 = _context.v;
9391
- _t7 = dex.chain;
9392
- _t8 = dex.exchangeChain;
9393
- _t9 = assetFromExchange;
9394
- _t0 = assetTo;
9395
- _t1 = {
9396
- api: _t5,
9369
+ _context.n = 3;
9370
+ return api.createApiForChain(dex.chain);
9371
+ case 3:
9372
+ _t7 = _context.v;
9373
+ _t8 = dex.chain;
9374
+ _t9 = dex.exchangeChain;
9375
+ _t0 = assetFromExchange;
9376
+ _t1 = assetTo;
9377
+ _t10 = {
9378
+ apiPjs: _t5,
9397
9379
  apiPapi: _t6,
9398
- baseChain: _t7,
9399
- exchangeChain: _t8,
9400
- assetFrom: _t9,
9401
- assetTo: _t0
9380
+ api: _t7,
9381
+ baseChain: _t8,
9382
+ exchangeChain: _t9,
9383
+ assetFrom: _t0,
9384
+ assetTo: _t1
9402
9385
  };
9403
- _t10 = determineFeeCalcAddress(options.senderAddress, options.recipientAddress);
9386
+ _t11 = determineFeeCalcAddress(options.sender, options.recipient);
9404
9387
  modifiedOptions = _t(_t2, _t3, {
9405
9388
  amount: _t4,
9406
- exchange: _t1,
9407
- feeCalcAddress: _t10
9389
+ exchange: _t10,
9390
+ feeCalcAddress: _t11
9408
9391
  });
9409
- _context.n = 3;
9392
+ _context.n = 4;
9410
9393
  return calculateFromExchangeFee(modifiedOptions);
9411
- case 3:
9394
+ case 4:
9412
9395
  toDestTxFee = _context.v;
9413
- _context.n = 4;
9414
- return dex.handleMultiSwap(modifiedOptions.exchange.api, _objectSpread2(_objectSpread2({}, modifiedOptions), {}, {
9396
+ _context.n = 5;
9397
+ return dex.handleMultiSwap(modifiedOptions.exchange.apiPjs, _objectSpread2(_objectSpread2({}, modifiedOptions), {}, {
9415
9398
  papiApi: modifiedOptions.exchange.apiPapi,
9416
9399
  assetFrom: modifiedOptions.exchange.assetFrom,
9417
9400
  assetTo: modifiedOptions.exchange.assetTo,
9418
9401
  isForFeeEstimation: isForFeeEstimation
9419
9402
  }), toDestTxFee);
9420
- case 4:
9403
+ case 5:
9421
9404
  _yield$dex$handleMult = _context.v;
9422
9405
  amountOut = _yield$dex$handleMult.amountOut;
9423
9406
  return _context.a(2, amountOut);
9424
9407
  }
9425
9408
  }, _callee);
9426
9409
  }));
9427
- return function (_x5, _x6, _x7, _x8) {
9410
+ return function (_x4, _x5, _x6, _x7, _x8) {
9428
9411
  return _ref2.apply(this, arguments);
9429
9412
  };
9430
- }(), builderOptions));
9413
+ }()));
9431
9414
  }
9432
9415
  }, _callee2);
9433
9416
  }));
9434
- return function selectBestExchange(_x, _x2, _x3, _x4) {
9417
+ return function selectBestExchange(_x, _x2, _x3) {
9435
9418
  return _ref.apply(this, arguments);
9436
9419
  };
9437
9420
  }();
@@ -9451,7 +9434,7 @@ var resolveAssets = function resolveAssets(dex, _ref) {
9451
9434
  }
9452
9435
  var assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.exchangeChain, assetFromOrigin) : getExchangeAsset(dex.exchangeChain, currencyFrom);
9453
9436
  if (!assetFromExchange) {
9454
- if (!originSpecified && findAssetInfo(dex.chain, currencyFrom, null)) {
9437
+ if (!originSpecified && findAssetInfo(dex.chain, currencyFrom)) {
9455
9438
  throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " exists in ").concat(dex.chain, " but is not swappable on ").concat(dex.exchangeChain, "."));
9456
9439
  }
9457
9440
  throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " not found in ").concat(dex.exchangeChain, "."));
@@ -9491,14 +9474,14 @@ var createToExchangeBuilder = function createToExchangeBuilder(_ref) {
9491
9474
  from = _ref$origin.chain,
9492
9475
  assetFrom = _ref$origin.assetFrom,
9493
9476
  baseChain = _ref.exchange.baseChain,
9494
- senderAddress = _ref.senderAddress,
9477
+ sender = _ref.sender,
9495
9478
  evmSenderAddress = _ref.evmSenderAddress,
9496
9479
  amount = _ref.amount,
9497
- builderOptions = _ref.builderOptions;
9498
- return Builder(builderOptions).from(from).to(baseChain).currency({
9480
+ api = _ref.api;
9481
+ return Builder(api).from(from).to(baseChain).currency({
9499
9482
  location: assetFrom.location,
9500
9483
  amount: amount
9501
- }).address(senderAddress).senderAddress(isChainEvm(from) ? evmSenderAddress : senderAddress);
9484
+ }).sender(isChainEvm(from) ? evmSenderAddress : sender).recipient(sender);
9502
9485
  };
9503
9486
  var buildToExchangeExtrinsic = function buildToExchangeExtrinsic(options) {
9504
9487
  return createToExchangeBuilder(options).build();
@@ -9510,21 +9493,19 @@ var getToExchangeFee = function getToExchangeFee(options, disableFallback) {
9510
9493
  };
9511
9494
  var createFromExchangeBuilder = function createFromExchangeBuilder(_ref2) {
9512
9495
  var _ref2$exchange = _ref2.exchange,
9513
- apiPapi = _ref2$exchange.apiPapi,
9514
9496
  baseChain = _ref2$exchange.baseChain,
9515
9497
  assetTo = _ref2$exchange.assetTo,
9516
9498
  _ref2$destination = _ref2.destination,
9517
9499
  chain = _ref2$destination.chain,
9518
9500
  address = _ref2$destination.address,
9519
9501
  amount = _ref2.amount,
9520
- senderAddress = _ref2.senderAddress,
9521
- builderOptions = _ref2.builderOptions;
9522
- return Builder(_objectSpread2(_objectSpread2({}, builderOptions), {}, {
9523
- apiOverrides: _objectSpread2(_objectSpread2({}, builderOptions === null || builderOptions === void 0 ? void 0 : builderOptions.apiOverrides), {}, _defineProperty({}, baseChain, apiPapi))
9524
- })).from(baseChain).to(chain).currency({
9502
+ sender = _ref2.sender,
9503
+ api = _ref2.api;
9504
+ var apiForChain = api.clone();
9505
+ return Builder(apiForChain).from(baseChain).to(chain).currency({
9525
9506
  location: assetTo.location,
9526
9507
  amount: amount
9527
- }).address(address).senderAddress(senderAddress);
9508
+ }).sender(sender).recipient(address);
9528
9509
  };
9529
9510
  var buildFromExchangeExtrinsic = function buildFromExchangeExtrinsic(options) {
9530
9511
  return createFromExchangeBuilder(options).build();
@@ -9534,28 +9515,29 @@ var getFromExchangeFee = function getFromExchangeFee(options, disableFallback) {
9534
9515
  disableFallback: disableFallback
9535
9516
  });
9536
9517
  };
9537
- var determineFeeCalcAddress = function determineFeeCalcAddress(senderAddress, recipientAddress) {
9538
- if (!ethers.isAddress(senderAddress)) {
9518
+ var determineFeeCalcAddress = function determineFeeCalcAddress(sender, recipient) {
9519
+ if (!ethers.isAddress(sender)) {
9539
9520
  // Use wallet address for fee calculation
9540
- return senderAddress;
9521
+ return sender;
9541
9522
  }
9542
- if (recipientAddress && !ethers.isAddress(recipientAddress)) {
9523
+ if (recipient && !ethers.isAddress(recipient)) {
9543
9524
  // Use recipient address for fee calculation
9544
- return recipientAddress;
9525
+ return recipient;
9545
9526
  }
9546
9527
  // If both addresses are ethereum addresses, use fallback address for fee calculation
9547
9528
  return FALLBACK_FEE_CALC_ADDRESS;
9548
9529
  };
9549
9530
 
9550
9531
  var prepareTransformedOptions = /*#__PURE__*/function () {
9551
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, builderOptions) {
9532
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
9552
9533
  var _assetFromOrigin$deci;
9553
9534
  var isForFeeEstimation,
9535
+ api,
9554
9536
  from,
9555
9537
  to,
9556
9538
  exchange,
9557
- senderAddress,
9558
- recipientAddress,
9539
+ sender,
9540
+ recipient,
9559
9541
  amount,
9560
9542
  originApi,
9561
9543
  dex,
@@ -9567,6 +9549,9 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
9567
9549
  feeAssetFromExchange,
9568
9550
  originSpecified,
9569
9551
  destinationSpecified,
9552
+ exchangeApi,
9553
+ config,
9554
+ exchangeConfig,
9570
9555
  transformed,
9571
9556
  _args = arguments,
9572
9557
  _t,
@@ -9590,14 +9575,14 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
9590
9575
  return _regenerator().w(function (_context) {
9591
9576
  while (1) switch (_context.n) {
9592
9577
  case 0:
9593
- isForFeeEstimation = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
9594
- from = options.from, to = options.to, exchange = options.exchange, senderAddress = options.senderAddress, recipientAddress = options.recipientAddress, amount = options.amount;
9578
+ isForFeeEstimation = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
9579
+ api = options.api, from = options.from, to = options.to, exchange = options.exchange, sender = options.sender, recipient = options.recipient, amount = options.amount;
9595
9580
  if (!from) {
9596
9581
  _context.n = 2;
9597
9582
  break;
9598
9583
  }
9599
9584
  _context.n = 1;
9600
- return createChainClient$1(from, builderOptions);
9585
+ return api.createApiForChain(from);
9601
9586
  case 1:
9602
9587
  _t = _context.v;
9603
9588
  _context.n = 3;
@@ -9615,7 +9600,7 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
9615
9600
  break;
9616
9601
  case 4:
9617
9602
  _context.n = 5;
9618
- return selectBestExchange(options, originApi, builderOptions, isForFeeEstimation);
9603
+ return selectBestExchange(options, originApi === null || originApi === void 0 ? void 0 : originApi.getApi(), isForFeeEstimation);
9619
9604
  case 5:
9620
9605
  _t2 = _context.v;
9621
9606
  case 6:
@@ -9629,51 +9614,57 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
9629
9614
  case 7:
9630
9615
  originSpecified = from && originApi && from !== dex.chain;
9631
9616
  destinationSpecified = to && to !== dex.chain;
9617
+ _context.n = 8;
9618
+ return api.createApiForChain(dex.chain);
9619
+ case 8:
9620
+ exchangeApi = _context.v;
9621
+ config = api.getConfig();
9622
+ exchangeConfig = convertBuilderConfig(config);
9632
9623
  _t3 = _objectSpread2;
9633
9624
  _t4 = _objectSpread2({}, options);
9634
9625
  _t5 = {};
9635
- _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));
9636
- _t7 = originSpecified && assetFromOrigin ? {
9637
- api: originApi,
9626
+ _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);
9627
+ _t7 = originSpecified && assetFromOrigin && originApi ? {
9628
+ api: originApi.getApi(),
9638
9629
  chain: from,
9639
9630
  assetFrom: assetFromOrigin,
9640
9631
  feeAssetInfo: feeAssetFromOrigin
9641
9632
  } : undefined;
9642
- _context.n = 8;
9643
- return dex.createApiInstance(builderOptions);
9644
- case 8:
9645
- _t8 = _context.v;
9646
9633
  _context.n = 9;
9647
- return dex.createApiInstancePapi(builderOptions);
9634
+ return dex.createApiInstance(exchangeConfig);
9648
9635
  case 9:
9636
+ _t8 = _context.v;
9637
+ _context.n = 10;
9638
+ return dex.createApiInstancePapi(exchangeConfig);
9639
+ case 10:
9649
9640
  _t9 = _context.v;
9650
- _t0 = dex.chain;
9651
- _t1 = dex.exchangeChain;
9652
- _t10 = assetFromExchange;
9653
- _t11 = assetTo;
9654
- _t12 = feeAssetFromExchange;
9655
- _t13 = {
9656
- api: _t8,
9641
+ _t0 = exchangeApi;
9642
+ _t1 = dex.chain;
9643
+ _t10 = dex.exchangeChain;
9644
+ _t11 = assetFromExchange;
9645
+ _t12 = assetTo;
9646
+ _t13 = feeAssetFromExchange;
9647
+ _t14 = {
9648
+ apiPjs: _t8,
9657
9649
  apiPapi: _t9,
9658
- baseChain: _t0,
9659
- exchangeChain: _t1,
9660
- assetFrom: _t10,
9661
- assetTo: _t11,
9662
- feeAssetInfo: _t12
9650
+ api: _t0,
9651
+ baseChain: _t1,
9652
+ exchangeChain: _t10,
9653
+ assetFrom: _t11,
9654
+ assetTo: _t12,
9655
+ feeAssetInfo: _t13
9663
9656
  };
9664
- _t14 = destinationSpecified && recipientAddress ? {
9657
+ _t15 = destinationSpecified && recipient ? {
9665
9658
  chain: to,
9666
- address: recipientAddress
9659
+ address: recipient
9667
9660
  } : undefined;
9668
- _t15 = determineFeeCalcAddress(senderAddress, recipientAddress);
9669
- _t16 = builderOptions;
9661
+ _t16 = determineFeeCalcAddress(sender, recipient);
9670
9662
  transformed = _t3(_t4, _t5, {
9671
9663
  amount: _t6,
9672
9664
  origin: _t7,
9673
- exchange: _t13,
9674
- destination: _t14,
9675
- feeCalcAddress: _t15,
9676
- builderOptions: _t16
9665
+ exchange: _t14,
9666
+ destination: _t15,
9667
+ feeCalcAddress: _t16
9677
9668
  });
9678
9669
  return _context.a(2, {
9679
9670
  dex: dex,
@@ -9682,7 +9673,7 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
9682
9673
  }
9683
9674
  }, _callee);
9684
9675
  }));
9685
- return function prepareTransformedOptions(_x, _x2) {
9676
+ return function prepareTransformedOptions(_x) {
9686
9677
  return _ref.apply(this, arguments);
9687
9678
  };
9688
9679
  }();
@@ -9707,20 +9698,20 @@ var validateTransferOptions = function validateTransferOptions(options) {
9707
9698
  var from = options.from,
9708
9699
  exchange = options.exchange,
9709
9700
  evmSenderAddress = options.evmSenderAddress,
9710
- senderAddress = options.senderAddress,
9711
- recipientAddress = options.recipientAddress,
9701
+ sender = options.sender,
9702
+ recipient = options.recipient,
9712
9703
  to = options.to;
9713
9704
  if (exchange === undefined && from === undefined) {
9714
9705
  throw new MissingParameterError('from', 'Origin chain is required when exchange is auto');
9715
9706
  }
9716
- if (to && !recipientAddress) {
9717
- throw new MissingParameterError('recipientAddress', 'Recipient address is required');
9707
+ if (to && !recipient) {
9708
+ throw new MissingParameterError('recipient', 'Recipient address is required');
9718
9709
  }
9719
- if (to && recipientAddress) validateDestinationAddress(recipientAddress, to);
9710
+ if (to && recipient) validateDestinationAddress(recipient, to);
9720
9711
  if (evmSenderAddress !== undefined && !ethers.isAddress(evmSenderAddress)) {
9721
9712
  throw new InvalidAddressError('Evm injector address is not a valid Ethereum address');
9722
9713
  }
9723
- if (ethers.isAddress(senderAddress)) {
9714
+ if (ethers.isAddress(sender)) {
9724
9715
  throw new InvalidAddressError('Injector address cannot be an Ethereum address. Please use an Evm injector address instead.');
9725
9716
  }
9726
9717
  if (from && isChainEvm(from) && !evmSenderAddress) {
@@ -9731,11 +9722,11 @@ var validateTransferOptions = function validateTransferOptions(options) {
9731
9722
  var FEE_ESTIMATION_UNITS = '100';
9732
9723
  var calculateFromExchangeFee = /*#__PURE__*/function () {
9733
9724
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
9734
- var exchange, destination, feeCalcAddress, senderAddress, builderOptions, dummyAmount, tx;
9725
+ var api, exchange, destination, feeCalcAddress, sender, dummyAmount, tx, _yield$api$getPayment, partialFee;
9735
9726
  return _regenerator().w(function (_context) {
9736
9727
  while (1) switch (_context.n) {
9737
9728
  case 0:
9738
- exchange = options.exchange, destination = options.destination, feeCalcAddress = options.feeCalcAddress, senderAddress = options.senderAddress, builderOptions = options.builderOptions;
9729
+ api = options.api, exchange = options.exchange, destination = options.destination, feeCalcAddress = options.feeCalcAddress, sender = options.sender;
9739
9730
  if (!(!destination || destination.chain === exchange.baseChain)) {
9740
9731
  _context.n = 1;
9741
9732
  break;
@@ -9748,12 +9739,17 @@ var calculateFromExchangeFee = /*#__PURE__*/function () {
9748
9739
  exchange: exchange,
9749
9740
  destination: destination,
9750
9741
  amount: dummyAmount,
9751
- senderAddress: senderAddress,
9752
- builderOptions: builderOptions
9742
+ sender: sender,
9743
+ api: api
9753
9744
  });
9754
9745
  case 2:
9755
9746
  tx = _context.v;
9756
- return _context.a(2, tx.getEstimatedFees(feeCalcAddress));
9747
+ _context.n = 3;
9748
+ return api.getPaymentInfo(tx, feeCalcAddress);
9749
+ case 3:
9750
+ _yield$api$getPayment = _context.v;
9751
+ partialFee = _yield$api$getPayment.partialFee;
9752
+ return _context.a(2, partialFee);
9757
9753
  }
9758
9754
  }, _callee);
9759
9755
  }));
@@ -9764,6 +9760,7 @@ var calculateFromExchangeFee = /*#__PURE__*/function () {
9764
9760
  var createSwapTx = /*#__PURE__*/function () {
9765
9761
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(exchange, options) {
9766
9762
  var isForFeeEstimation,
9763
+ api,
9767
9764
  toDestTxFee,
9768
9765
  swapResult,
9769
9766
  txs,
@@ -9772,12 +9769,13 @@ var createSwapTx = /*#__PURE__*/function () {
9772
9769
  while (1) switch (_context2.n) {
9773
9770
  case 0:
9774
9771
  isForFeeEstimation = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : false;
9772
+ api = options.api;
9775
9773
  _context2.n = 1;
9776
9774
  return calculateFromExchangeFee(options);
9777
9775
  case 1:
9778
9776
  toDestTxFee = _context2.v;
9779
9777
  _context2.n = 2;
9780
- return exchange.handleMultiSwap(options.exchange.api, _objectSpread2(_objectSpread2({}, options), {}, {
9778
+ return exchange.handleMultiSwap(options.exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
9781
9779
  papiApi: options.exchange.apiPapi,
9782
9780
  assetFrom: options.exchange.assetFrom,
9783
9781
  assetTo: options.exchange.assetTo,
@@ -9787,7 +9785,7 @@ var createSwapTx = /*#__PURE__*/function () {
9787
9785
  swapResult = _context2.v;
9788
9786
  _context2.n = 3;
9789
9787
  return Promise.all(swapResult.txs.map(function (tx) {
9790
- return isPjsExtrinsic(tx) ? convertTxToPapi(tx, options.exchange.apiPapi) : Promise.resolve(tx);
9788
+ return convertTxToTarget(tx, api);
9791
9789
  }));
9792
9790
  case 3:
9793
9791
  txs = _context2.v;
@@ -9805,18 +9803,18 @@ var createSwapTx = /*#__PURE__*/function () {
9805
9803
 
9806
9804
  var prepareExtrinsics = /*#__PURE__*/function () {
9807
9805
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options) {
9808
- 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;
9806
+ 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;
9809
9807
  return _regenerator().w(function (_context) {
9810
9808
  while (1) switch (_context.p = _context.n) {
9811
9809
  case 0:
9812
- 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;
9810
+ 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;
9813
9811
  if (!((origin || destination) && (dex.chain.includes('AssetHub') || dex.chain === 'Hydration'))) {
9814
9812
  _context.n = 5;
9815
9813
  break;
9816
9814
  }
9817
9815
  _context.p = 1;
9818
9816
  _context.n = 2;
9819
- return dex.getAmountOut(exchange.api, _objectSpread2(_objectSpread2({}, options), {}, {
9817
+ return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
9820
9818
  papiApi: exchange.apiPapi,
9821
9819
  assetFrom: exchange.assetFrom,
9822
9820
  assetTo: exchange.assetTo
@@ -9825,6 +9823,7 @@ var prepareExtrinsics = /*#__PURE__*/function () {
9825
9823
  _amountOut = _context.v;
9826
9824
  _context.n = 3;
9827
9825
  return handleSwapExecuteTransfer({
9826
+ api: api,
9828
9827
  chain: origin === null || origin === void 0 ? void 0 : origin.chain,
9829
9828
  exchangeChain: exchange.baseChain,
9830
9829
  destChain: destination === null || destination === void 0 ? void 0 : destination.chain,
@@ -9834,19 +9833,19 @@ var prepareExtrinsics = /*#__PURE__*/function () {
9834
9833
  assetInfoTo: _objectSpread2(_objectSpread2({}, exchange.assetTo), {}, {
9835
9834
  amount: _amountOut
9836
9835
  }),
9837
- senderAddress: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : senderAddress,
9836
+ sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
9837
+ recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
9838
9838
  currencyTo: currencyTo,
9839
9839
  feeAssetInfo: (_origin$feeAssetInfo = origin === null || origin === void 0 ? void 0 : origin.feeAssetInfo) !== null && _origin$feeAssetInfo !== void 0 ? _origin$feeAssetInfo : exchange.feeAssetInfo,
9840
- recipientAddress: recipientAddress !== null && recipientAddress !== void 0 ? recipientAddress : senderAddress,
9841
9840
  calculateMinAmountOut: function calculateMinAmountOut(amountIn, assetTo) {
9842
- return dex.getAmountOut(exchange.api, _objectSpread2(_objectSpread2({}, options), {}, {
9841
+ return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
9843
9842
  amount: amountIn,
9844
9843
  papiApi: options.exchange.apiPapi,
9845
9844
  assetFrom: options.exchange.assetFrom,
9846
9845
  assetTo: assetTo !== null && assetTo !== void 0 ? assetTo : options.exchange.assetTo
9847
9846
  }));
9848
9847
  }
9849
- }, builderOptions);
9848
+ });
9850
9849
  case 3:
9851
9850
  tx = _context.v;
9852
9851
  return _context.a(2, {
@@ -9894,8 +9893,8 @@ var prepareExtrinsics = /*#__PURE__*/function () {
9894
9893
  exchange: exchange,
9895
9894
  destination: destination,
9896
9895
  amount: amountOut,
9897
- senderAddress: senderAddress,
9898
- builderOptions: builderOptions
9896
+ sender: sender,
9897
+ api: api
9899
9898
  });
9900
9899
  case 10:
9901
9900
  _t3 = _context.v;
@@ -9946,13 +9945,9 @@ var buildTransactions = /*#__PURE__*/function () {
9946
9945
  });
9947
9946
  }
9948
9947
  if (toDestTx) {
9949
- batchedTx = exchange.apiPapi.getUnsafeApi().tx.Utility.batch_all({
9950
- calls: [].concat(_toConsumableArray(swapTxs.map(function (tx) {
9951
- return tx.decodedCall;
9952
- })), [toDestTx.decodedCall])
9953
- });
9948
+ batchedTx = exchange.api.callBatchMethod([].concat(_toConsumableArray(swapTxs), [toDestTx]), BatchMode.BATCH_ALL);
9954
9949
  transactions.push({
9955
- api: exchange.apiPapi,
9950
+ api: exchange.api.getApi(),
9956
9951
  chain: dex.chain,
9957
9952
  destinationChain: destination === null || destination === void 0 ? void 0 : destination.chain,
9958
9953
  tx: batchedTx,
@@ -9962,20 +9957,16 @@ var buildTransactions = /*#__PURE__*/function () {
9962
9957
  } else {
9963
9958
  if (swapTxs.length === 1) {
9964
9959
  transactions.push({
9965
- api: isExecute ? (_origin$api = origin === null || origin === void 0 ? void 0 : origin.api) !== null && _origin$api !== void 0 ? _origin$api : exchange.apiPapi : exchange.apiPapi,
9960
+ 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(),
9966
9961
  chain: isExecute ? (_origin$chain = origin === null || origin === void 0 ? void 0 : origin.chain) !== null && _origin$chain !== void 0 ? _origin$chain : dex.chain : dex.chain,
9967
9962
  tx: swapTxs[0],
9968
9963
  amountOut: amountOut,
9969
9964
  type: 'SWAP'
9970
9965
  });
9971
9966
  } else {
9972
- batchedSwapTx = exchange.apiPapi.getUnsafeApi().tx.Utility.batch_all({
9973
- calls: swapTxs.map(function (tx) {
9974
- return tx.decodedCall;
9975
- })
9976
- });
9967
+ batchedSwapTx = exchange.api.callBatchMethod(swapTxs, BatchMode.BATCH_ALL);
9977
9968
  transactions.push({
9978
- api: exchange.apiPapi,
9969
+ api: exchange.api.getApi(),
9979
9970
  chain: dex.chain,
9980
9971
  tx: batchedSwapTx,
9981
9972
  amountOut: amountOut,
@@ -9993,14 +9984,14 @@ var buildTransactions = /*#__PURE__*/function () {
9993
9984
  }();
9994
9985
 
9995
9986
  var buildApiTransactions = /*#__PURE__*/function () {
9996
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions, builderOptions) {
9987
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions) {
9997
9988
  var _yield$prepareTransfo, options, dex;
9998
9989
  return _regenerator().w(function (_context) {
9999
9990
  while (1) switch (_context.n) {
10000
9991
  case 0:
10001
9992
  validateTransferOptions(initialOptions);
10002
9993
  _context.n = 1;
10003
- return prepareTransformedOptions(initialOptions, builderOptions);
9994
+ return prepareTransformedOptions(initialOptions);
10004
9995
  case 1:
10005
9996
  _yield$prepareTransfo = _context.v;
10006
9997
  options = _yield$prepareTransfo.options;
@@ -10009,7 +10000,7 @@ var buildApiTransactions = /*#__PURE__*/function () {
10009
10000
  }
10010
10001
  }, _callee);
10011
10002
  }));
10012
- return function buildApiTransactions(_x, _x2) {
10003
+ return function buildApiTransactions(_x) {
10013
10004
  return _ref.apply(this, arguments);
10014
10005
  };
10015
10006
  }();
@@ -10038,22 +10029,20 @@ var assignIsExchange = function assignIsExchange(result, options) {
10038
10029
  var dryRunTransaction = /*#__PURE__*/function () {
10039
10030
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, transaction, destChain, bypassOptions) {
10040
10031
  var _ref2;
10041
- var exchange, senderAddress, evmSenderAddress, recipientAddress, destination, currencyFrom, currencyTo, amount, api, tx, chain, address, senderAddressResolved, resolvedDest;
10032
+ var api, exchange, sender, evmSenderAddress, destination, currencyFrom, currencyTo, amount, tx, chain, senderResolved, resolvedDest;
10042
10033
  return _regenerator().w(function (_context) {
10043
10034
  while (1) switch (_context.n) {
10044
10035
  case 0:
10045
- exchange = options.exchange, senderAddress = options.senderAddress, evmSenderAddress = options.evmSenderAddress, recipientAddress = options.recipientAddress, destination = options.destination, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, amount = options.amount;
10046
- api = transaction.api, tx = transaction.tx, chain = transaction.chain;
10047
- address = recipientAddress !== null && recipientAddress !== void 0 ? recipientAddress : senderAddress;
10048
- senderAddressResolved = evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : senderAddress;
10036
+ api = options.api, exchange = options.exchange, sender = options.sender, evmSenderAddress = options.evmSenderAddress, destination = options.destination, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, amount = options.amount;
10037
+ tx = transaction.tx, chain = transaction.chain;
10038
+ senderResolved = evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender;
10049
10039
  resolvedDest = (_ref2 = destChain !== null && destChain !== void 0 ? destChain : destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _ref2 !== void 0 ? _ref2 : exchange.baseChain;
10050
10040
  return _context.a(2, dryRun({
10051
10041
  api: api,
10052
10042
  tx: tx,
10053
10043
  origin: chain,
10054
10044
  destination: resolvedDest,
10055
- senderAddress: senderAddressResolved,
10056
- address: address,
10045
+ sender: senderResolved,
10057
10046
  swapConfig: {
10058
10047
  currencyTo: currencyTo,
10059
10048
  exchangeChain: exchange.baseChain
@@ -10122,14 +10111,14 @@ var dryRunTransactions = function dryRunTransactions(transactions, options) {
10122
10111
  throw new UnsupportedOperationError('Router dry run supports up to two transactions per flow.');
10123
10112
  };
10124
10113
  var dryRunRouter = /*#__PURE__*/function () {
10125
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(initialOptions, builderOptions) {
10114
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(initialOptions) {
10126
10115
  var _yield$prepareTransfo, options, dex, routerPlan, result;
10127
10116
  return _regenerator().w(function (_context3) {
10128
10117
  while (1) switch (_context3.n) {
10129
10118
  case 0:
10130
10119
  validateTransferOptions(initialOptions);
10131
10120
  _context3.n = 1;
10132
- return prepareTransformedOptions(initialOptions, builderOptions);
10121
+ return prepareTransformedOptions(initialOptions);
10133
10122
  case 1:
10134
10123
  _yield$prepareTransfo = _context3.v;
10135
10124
  options = _yield$prepareTransfo.options;
@@ -10146,18 +10135,18 @@ var dryRunRouter = /*#__PURE__*/function () {
10146
10135
  }
10147
10136
  }, _callee3);
10148
10137
  }));
10149
- return function dryRunRouter(_x7, _x8) {
10138
+ return function dryRunRouter(_x7) {
10150
10139
  return _ref4.apply(this, arguments);
10151
10140
  };
10152
10141
  }();
10153
10142
 
10154
10143
  var getSwapFee = /*#__PURE__*/function () {
10155
10144
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(exchange, options, disableFallback) {
10156
- var senderAddress, assetFrom, amount, txs, amountOut, isForFeeEstimation, swapResult, buildTx, result, finalFee, _t;
10145
+ var api, sender, assetFrom, amount, txs, amountOut, isForFeeEstimation, swapResult, buildTx, result, finalFee, _t;
10157
10146
  return _regenerator().w(function (_context2) {
10158
10147
  while (1) switch (_context2.p = _context2.n) {
10159
10148
  case 0:
10160
- senderAddress = options.senderAddress, assetFrom = options.exchange.assetFrom, amount = options.amount;
10149
+ api = options.api, sender = options.sender, assetFrom = options.exchange.assetFrom, amount = options.amount;
10161
10150
  isForFeeEstimation = true;
10162
10151
  _context2.p = 1;
10163
10152
  _context2.n = 2;
@@ -10204,11 +10193,11 @@ var getSwapFee = /*#__PURE__*/function () {
10204
10193
  }();
10205
10194
  _context2.n = 6;
10206
10195
  return getOriginXcmFee({
10207
- api: options.exchange.apiPapi,
10196
+ api: api,
10208
10197
  buildTx: buildTx,
10209
10198
  origin: exchange.chain,
10210
10199
  destination: exchange.chain,
10211
- senderAddress: senderAddress,
10200
+ sender: sender,
10212
10201
  currency: {
10213
10202
  location: assetFrom.location,
10214
10203
  amount: amount
@@ -10235,11 +10224,11 @@ var getSwapFee = /*#__PURE__*/function () {
10235
10224
  var getRouterFees = /*#__PURE__*/function () {
10236
10225
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(dex, options, disableFallback) {
10237
10226
  var _sendingChain$hops, _receivingChain$origi, _receivingChain$hops, _sendingChain$origin, _receivingChain$desti, _sendingChain$failure, _sendingChain$failure2;
10238
- 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;
10227
+ 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;
10239
10228
  return _regenerator().w(function (_context2) {
10240
10229
  while (1) switch (_context2.p = _context2.n) {
10241
10230
  case 0:
10242
- 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;
10231
+ 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;
10243
10232
  if (!((origin || destination) && (dex.chain.includes('AssetHub') || dex.chain === 'Hydration'))) {
10244
10233
  _context2.n = 6;
10245
10234
  break;
@@ -10254,7 +10243,7 @@ var getRouterFees = /*#__PURE__*/function () {
10254
10243
  case 0:
10255
10244
  amt = overrideAmount !== undefined ? applyDecimalAbstraction(overrideAmount, exchange.assetFrom.decimals, true) : amount;
10256
10245
  _context.n = 1;
10257
- return dex.getAmountOut(exchange.api, _objectSpread2(_objectSpread2({}, options), {}, {
10246
+ return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
10258
10247
  amount: amt,
10259
10248
  papiApi: exchange.apiPapi,
10260
10249
  assetFrom: exchange.assetFrom,
@@ -10264,6 +10253,7 @@ var getRouterFees = /*#__PURE__*/function () {
10264
10253
  amountOut = _context.v;
10265
10254
  _context.n = 2;
10266
10255
  return handleSwapExecuteTransfer({
10256
+ api: api,
10267
10257
  chain: origin === null || origin === void 0 ? void 0 : origin.chain,
10268
10258
  exchangeChain: exchange.baseChain,
10269
10259
  destChain: destination === null || destination === void 0 ? void 0 : destination.chain,
@@ -10275,10 +10265,10 @@ var getRouterFees = /*#__PURE__*/function () {
10275
10265
  }),
10276
10266
  currencyTo: currencyTo,
10277
10267
  feeAssetInfo: (_origin$feeAssetInfo = origin === null || origin === void 0 ? void 0 : origin.feeAssetInfo) !== null && _origin$feeAssetInfo !== void 0 ? _origin$feeAssetInfo : exchange.feeAssetInfo,
10278
- senderAddress: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : senderAddress,
10279
- recipientAddress: recipientAddress !== null && recipientAddress !== void 0 ? recipientAddress : senderAddress,
10268
+ sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
10269
+ recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
10280
10270
  calculateMinAmountOut: function calculateMinAmountOut(amountIn, assetTo) {
10281
- return dex.getAmountOut(exchange.api, _objectSpread2(_objectSpread2({}, options), {}, {
10271
+ return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
10282
10272
  amount: amountIn,
10283
10273
  papiApi: options.exchange.apiPapi,
10284
10274
  assetFrom: options.exchange.assetFrom,
@@ -10286,7 +10276,7 @@ var getRouterFees = /*#__PURE__*/function () {
10286
10276
  slippagePct: '1'
10287
10277
  }));
10288
10278
  }
10289
- }, builderOptions);
10279
+ });
10290
10280
  case 2:
10291
10281
  tx = _context.v;
10292
10282
  return _context.a(2, tx);
@@ -10298,7 +10288,7 @@ var getRouterFees = /*#__PURE__*/function () {
10298
10288
  };
10299
10289
  }();
10300
10290
  _context2.n = 2;
10301
- return dex.getAmountOut(exchange.api, _objectSpread2(_objectSpread2({}, options), {}, {
10291
+ return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
10302
10292
  amount: amount,
10303
10293
  papiApi: exchange.apiPapi,
10304
10294
  assetFrom: exchange.assetFrom,
@@ -10308,11 +10298,12 @@ var getRouterFees = /*#__PURE__*/function () {
10308
10298
  mainAmountOut = _context2.v;
10309
10299
  _context2.n = 3;
10310
10300
  return getXcmFee({
10301
+ api: api,
10311
10302
  buildTx: buildTx,
10312
10303
  origin: (_origin$chain = origin === null || origin === void 0 ? void 0 : origin.chain) !== null && _origin$chain !== void 0 ? _origin$chain : exchange.baseChain,
10313
10304
  destination: (_destination$chain = destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _destination$chain !== void 0 ? _destination$chain : exchange.baseChain,
10314
- senderAddress: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : senderAddress,
10315
- address: recipientAddress !== null && recipientAddress !== void 0 ? recipientAddress : senderAddress,
10305
+ sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
10306
+ recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
10316
10307
  currency: _objectSpread2(_objectSpread2({}, currencyFrom), {}, {
10317
10308
  amount: BigInt(amount)
10318
10309
  }),
@@ -10323,7 +10314,7 @@ var getRouterFees = /*#__PURE__*/function () {
10323
10314
  exchangeChain: exchange.baseChain,
10324
10315
  amountOut: mainAmountOut
10325
10316
  }
10326
- }, builderOptions);
10317
+ });
10327
10318
  case 3:
10328
10319
  executeResult = _context2.v;
10329
10320
  if (!(executeResult.failureReason === 'NoDeal' && exchange.exchangeChain === 'HydrationDex')) {
@@ -10334,9 +10325,12 @@ var getRouterFees = /*#__PURE__*/function () {
10334
10325
  case 4:
10335
10326
  transformedHops = executeResult.hops.map(function (hop) {
10336
10327
  if (hop.chain === exchange.baseChain) {
10337
- return _objectSpread2(_objectSpread2({}, hop), {}, {
10338
- isExchange: true
10339
- });
10328
+ return {
10329
+ chain: hop.chain,
10330
+ result: _objectSpread2(_objectSpread2({}, hop.result), {}, {
10331
+ isExchange: true
10332
+ })
10333
+ };
10340
10334
  }
10341
10335
  return hop;
10342
10336
  });
@@ -10389,8 +10383,8 @@ var getRouterFees = /*#__PURE__*/function () {
10389
10383
  exchange: exchange,
10390
10384
  destination: destination,
10391
10385
  amount: amountOut,
10392
- senderAddress: senderAddress,
10393
- builderOptions: builderOptions
10386
+ sender: sender,
10387
+ api: api
10394
10388
  }, disableFallback);
10395
10389
  case 11:
10396
10390
  _t3 = _context2.v;
@@ -10405,8 +10399,7 @@ var getRouterFees = /*#__PURE__*/function () {
10405
10399
  result: _objectSpread2(_objectSpread2({}, swapChain), {}, {
10406
10400
  fee: swapChain.fee + ((_receivingChain$origi = receivingChain === null || receivingChain === void 0 ? void 0 : receivingChain.origin.fee) !== null && _receivingChain$origi !== void 0 ? _receivingChain$origi : 0n),
10407
10401
  isExchange: true
10408
- }),
10409
- isExchange: true
10402
+ })
10410
10403
  }] : []), _toConsumableArray((_receivingChain$hops = receivingChain === null || receivingChain === void 0 ? void 0 : receivingChain.hops) !== null && _receivingChain$hops !== void 0 ? _receivingChain$hops : []));
10411
10404
  finalOrigin = (_sendingChain$origin = sendingChain === null || sendingChain === void 0 ? void 0 : sendingChain.origin) !== null && _sendingChain$origin !== void 0 ? _sendingChain$origin : _objectSpread2(_objectSpread2({}, swapChain), !origin && {
10412
10405
  isExchange: true
@@ -10432,14 +10425,14 @@ var getRouterFees = /*#__PURE__*/function () {
10432
10425
  }();
10433
10426
 
10434
10427
  var getXcmFees = /*#__PURE__*/function () {
10435
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions, disableFallback, builderOptions) {
10428
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions, disableFallback) {
10436
10429
  var _yield$prepareTransfo, options, dex;
10437
10430
  return _regenerator().w(function (_context) {
10438
10431
  while (1) switch (_context.n) {
10439
10432
  case 0:
10440
10433
  validateTransferOptions(initialOptions);
10441
10434
  _context.n = 1;
10442
- return prepareTransformedOptions(initialOptions, builderOptions, true);
10435
+ return prepareTransformedOptions(initialOptions, true);
10443
10436
  case 1:
10444
10437
  _yield$prepareTransfo = _context.v;
10445
10438
  options = _yield$prepareTransfo.options;
@@ -10448,65 +10441,65 @@ var getXcmFees = /*#__PURE__*/function () {
10448
10441
  }
10449
10442
  }, _callee);
10450
10443
  }));
10451
- return function getXcmFees(_x, _x2, _x3) {
10444
+ return function getXcmFees(_x, _x2) {
10452
10445
  return _ref.apply(this, arguments);
10453
10446
  };
10454
10447
  }();
10455
10448
 
10456
10449
  var selectBestExchangeAmountOut = /*#__PURE__*/function () {
10457
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi, builderOptions) {
10450
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi) {
10458
10451
  return _regenerator().w(function (_context2) {
10459
10452
  while (1) switch (_context2.n) {
10460
10453
  case 0:
10461
10454
  return _context2.a(2, selectBestExchangeCommon(options, originApi, /*#__PURE__*/function () {
10462
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, options) {
10463
- var api, papiApi;
10455
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, _options, parsedAmount) {
10456
+ var pjsApi, papiApi;
10464
10457
  return _regenerator().w(function (_context) {
10465
10458
  while (1) switch (_context.n) {
10466
10459
  case 0:
10467
10460
  _context.n = 1;
10468
10461
  return dex.createApiInstance();
10469
10462
  case 1:
10470
- api = _context.v;
10463
+ pjsApi = _context.v;
10471
10464
  _context.n = 2;
10472
10465
  return dex.createApiInstancePapi();
10473
10466
  case 2:
10474
10467
  papiApi = _context.v;
10475
- return _context.a(2, dex.getAmountOut(api, {
10468
+ return _context.a(2, dex.getAmountOut(pjsApi, {
10476
10469
  papiApi: papiApi,
10477
10470
  assetFrom: assetFromExchange,
10478
10471
  assetTo: assetTo,
10479
- amount: BigInt(options.amount)
10472
+ amount: BigInt(parsedAmount)
10480
10473
  }));
10481
10474
  }
10482
10475
  }, _callee);
10483
10476
  }));
10484
- return function (_x4, _x5, _x6, _x7) {
10477
+ return function (_x3, _x4, _x5, _x6, _x7) {
10485
10478
  return _ref2.apply(this, arguments);
10486
10479
  };
10487
- }(), builderOptions));
10480
+ }()));
10488
10481
  }
10489
10482
  }, _callee2);
10490
10483
  }));
10491
- return function selectBestExchangeAmountOut(_x, _x2, _x3) {
10484
+ return function selectBestExchangeAmountOut(_x, _x2) {
10492
10485
  return _ref.apply(this, arguments);
10493
10486
  };
10494
10487
  }();
10495
10488
 
10496
10489
  var getBestAmountOut = /*#__PURE__*/function () {
10497
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, builderOptions) {
10490
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
10498
10491
  var _assetFromOrigin$deci;
10499
- var exchange, amount, from, originApi, isExchangeAutoSelect, dex, _resolveAssets, assetFromOrigin, assetFrom, assetTo, res, api, papiApi, _t, _t2, _t3, _t4;
10492
+ var api, exchange, amount, from, originApi, isExchangeAutoSelect, dex, _resolveAssets, assetFromOrigin, assetFrom, assetTo, res, config, exchangeConfig, pjsApi, papiApi, _t, _t2, _t3, _t4;
10500
10493
  return _regenerator().w(function (_context) {
10501
10494
  while (1) switch (_context.n) {
10502
10495
  case 0:
10503
- exchange = options.exchange, amount = options.amount, from = options.from;
10496
+ api = options.api, exchange = options.exchange, amount = options.amount, from = options.from;
10504
10497
  if (!from) {
10505
10498
  _context.n = 2;
10506
10499
  break;
10507
10500
  }
10508
10501
  _context.n = 1;
10509
- return createChainClient$1(from, builderOptions);
10502
+ return createChainClient$2(api, from);
10510
10503
  case 1:
10511
10504
  _t = _context.v;
10512
10505
  _context.n = 3;
@@ -10521,7 +10514,7 @@ var getBestAmountOut = /*#__PURE__*/function () {
10521
10514
  break;
10522
10515
  }
10523
10516
  _context.n = 4;
10524
- return selectBestExchangeAmountOut(options, originApi, builderOptions);
10517
+ return selectBestExchangeAmountOut(options, originApi);
10525
10518
  case 4:
10526
10519
  _t2 = _context.v;
10527
10520
  _context.n = 6;
@@ -10536,7 +10529,7 @@ var getBestAmountOut = /*#__PURE__*/function () {
10536
10529
  break;
10537
10530
  }
10538
10531
  _context.n = 7;
10539
- return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin, builderOptions);
10532
+ return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin);
10540
10533
  case 7:
10541
10534
  res = _context.v;
10542
10535
  if (res.success) {
@@ -10545,21 +10538,23 @@ var getBestAmountOut = /*#__PURE__*/function () {
10545
10538
  }
10546
10539
  throw res.error;
10547
10540
  case 8:
10541
+ config = api.getConfig();
10542
+ exchangeConfig = convertBuilderConfig(config);
10548
10543
  _context.n = 9;
10549
- return dex.createApiInstance(builderOptions);
10544
+ return dex.createApiInstance(exchangeConfig);
10550
10545
  case 9:
10551
- api = _context.v;
10546
+ pjsApi = _context.v;
10552
10547
  _context.n = 10;
10553
- return dex.createApiInstancePapi(builderOptions);
10548
+ return dex.createApiInstancePapi(exchangeConfig);
10554
10549
  case 10:
10555
10550
  papiApi = _context.v;
10556
10551
  _t3 = dex.exchangeChain;
10557
10552
  _context.n = 11;
10558
- return dex.getAmountOut(api, {
10553
+ return dex.getAmountOut(pjsApi, {
10559
10554
  papiApi: papiApi,
10560
10555
  assetFrom: assetFrom,
10561
10556
  assetTo: assetTo,
10562
- 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))
10557
+ 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)
10563
10558
  });
10564
10559
  case 11:
10565
10560
  _t4 = _context.v;
@@ -10570,7 +10565,7 @@ var getBestAmountOut = /*#__PURE__*/function () {
10570
10565
  }
10571
10566
  }, _callee);
10572
10567
  }));
10573
- return function getBestAmountOut(_x, _x2) {
10568
+ return function getBestAmountOut(_x) {
10574
10569
  return _ref.apply(this, arguments);
10575
10570
  };
10576
10571
  }();
@@ -10609,19 +10604,19 @@ var computeExchangeMinAmount = /*#__PURE__*/function () {
10609
10604
  };
10610
10605
  }();
10611
10606
  var getMinTransferableAmount = /*#__PURE__*/function () {
10612
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(initialOptions, builderOptions) {
10613
- var _yield$prepareTransfo, dex, options, origin, exchange, senderAddress, evmSenderAddress, amount, builder;
10607
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(initialOptions) {
10608
+ var _yield$prepareTransfo, dex, options, origin, exchange, sender, evmSenderAddress, amount, api, builder;
10614
10609
  return _regenerator().w(function (_context2) {
10615
10610
  while (1) switch (_context2.n) {
10616
10611
  case 0:
10617
10612
  validateTransferOptions(initialOptions);
10618
10613
  _context2.n = 1;
10619
- return prepareTransformedOptions(initialOptions, builderOptions);
10614
+ return prepareTransformedOptions(initialOptions);
10620
10615
  case 1:
10621
10616
  _yield$prepareTransfo = _context2.v;
10622
10617
  dex = _yield$prepareTransfo.dex;
10623
10618
  options = _yield$prepareTransfo.options;
10624
- origin = options.origin, exchange = options.exchange, senderAddress = options.senderAddress, evmSenderAddress = options.evmSenderAddress, amount = options.amount;
10619
+ origin = options.origin, exchange = options.exchange, sender = options.sender, evmSenderAddress = options.evmSenderAddress, amount = options.amount, api = options.api;
10625
10620
  if (!origin) {
10626
10621
  _context2.n = 2;
10627
10622
  break;
@@ -10629,10 +10624,10 @@ var getMinTransferableAmount = /*#__PURE__*/function () {
10629
10624
  builder = createToExchangeBuilder({
10630
10625
  origin: origin,
10631
10626
  exchange: exchange,
10632
- senderAddress: senderAddress,
10627
+ sender: sender,
10633
10628
  evmSenderAddress: evmSenderAddress,
10634
10629
  amount: amount,
10635
- builderOptions: builderOptions
10630
+ api: api
10636
10631
  });
10637
10632
  return _context2.a(2, builder.getMinTransferableAmount());
10638
10633
  case 2:
@@ -10640,26 +10635,26 @@ var getMinTransferableAmount = /*#__PURE__*/function () {
10640
10635
  }
10641
10636
  }, _callee2);
10642
10637
  }));
10643
- return function getMinTransferableAmount(_x3, _x4) {
10638
+ return function getMinTransferableAmount(_x3) {
10644
10639
  return _ref2.apply(this, arguments);
10645
10640
  };
10646
10641
  }();
10647
10642
 
10648
10643
  var computeLocalTransferableAmount = /*#__PURE__*/function () {
10649
10644
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options) {
10650
- var exchange, senderAddress, currency, balance, existentialDeposit, swapFee, nativeSymbol, _result$fee, _yield$getSwapFee, result, transferable;
10645
+ var exchange, sender, currency, balance, existentialDeposit, swapFee, nativeSymbol, _result$fee, _yield$getSwapFee, result, transferable;
10651
10646
  return _regenerator().w(function (_context) {
10652
10647
  while (1) switch (_context.n) {
10653
10648
  case 0:
10654
- exchange = options.exchange, senderAddress = options.senderAddress;
10649
+ exchange = options.exchange, sender = options.sender;
10655
10650
  currency = {
10656
10651
  location: exchange.assetFrom.location
10657
10652
  };
10658
10653
  _context.n = 1;
10659
- return getBalance({
10660
- api: exchange.apiPapi,
10654
+ return getBalance$1({
10655
+ api: exchange.api,
10661
10656
  chain: exchange.baseChain,
10662
- address: senderAddress,
10657
+ address: sender,
10663
10658
  currency: currency
10664
10659
  });
10665
10660
  case 1:
@@ -10688,14 +10683,14 @@ var computeLocalTransferableAmount = /*#__PURE__*/function () {
10688
10683
  };
10689
10684
  }();
10690
10685
  var getTransferableAmount = /*#__PURE__*/function () {
10691
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(initialOptions, builderOptions) {
10686
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(initialOptions) {
10692
10687
  var _yield$prepareTransfo, dex, options, transformedOptions, builder;
10693
10688
  return _regenerator().w(function (_context2) {
10694
10689
  while (1) switch (_context2.n) {
10695
10690
  case 0:
10696
10691
  validateTransferOptions(initialOptions);
10697
10692
  _context2.n = 1;
10698
- return prepareTransformedOptions(initialOptions, builderOptions);
10693
+ return prepareTransformedOptions(initialOptions);
10699
10694
  case 1:
10700
10695
  _yield$prepareTransfo = _context2.v;
10701
10696
  dex = _yield$prepareTransfo.dex;
@@ -10708,10 +10703,10 @@ var getTransferableAmount = /*#__PURE__*/function () {
10708
10703
  builder = createToExchangeBuilder({
10709
10704
  origin: transformedOptions.origin,
10710
10705
  exchange: transformedOptions.exchange,
10711
- senderAddress: transformedOptions.senderAddress,
10706
+ sender: transformedOptions.sender,
10712
10707
  evmSenderAddress: transformedOptions.evmSenderAddress,
10713
10708
  amount: transformedOptions.amount,
10714
- builderOptions: builderOptions
10709
+ api: transformedOptions.api
10715
10710
  });
10716
10711
  return _context2.a(2, builder.getTransferableAmount());
10717
10712
  case 2:
@@ -10719,24 +10714,25 @@ var getTransferableAmount = /*#__PURE__*/function () {
10719
10714
  }
10720
10715
  }, _callee2);
10721
10716
  }));
10722
- return function getTransferableAmount(_x3, _x4) {
10717
+ return function getTransferableAmount(_x3) {
10723
10718
  return _ref2.apply(this, arguments);
10724
10719
  };
10725
10720
  }();
10726
10721
 
10727
10722
  var executeRouterPlan = /*#__PURE__*/function () {
10728
10723
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(plan, _ref) {
10729
- var signer, evmSigner, onStatusChange, _iterator, _step, _step$value, currentStep, _step$value$, tx, type, chain, destinationChain, _t;
10724
+ var signer, evmSigner, onStatusChange, api, txHashes, _iterator, _step, _step$value, currentStep, _step$value$, tx, type, chain, destinationChain, _t, _t2, _t3;
10730
10725
  return _regenerator().w(function (_context) {
10731
10726
  while (1) switch (_context.p = _context.n) {
10732
10727
  case 0:
10733
- signer = _ref.signer, evmSigner = _ref.evmSigner, onStatusChange = _ref.onStatusChange;
10728
+ signer = _ref.signer, evmSigner = _ref.evmSigner, onStatusChange = _ref.onStatusChange, api = _ref.api;
10729
+ txHashes = [];
10734
10730
  _iterator = _createForOfIteratorHelper(plan.entries());
10735
10731
  _context.p = 1;
10736
10732
  _iterator.s();
10737
10733
  case 2:
10738
10734
  if ((_step = _iterator.n()).done) {
10739
- _context.n = 6;
10735
+ _context.n = 7;
10740
10736
  break;
10741
10737
  }
10742
10738
  _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;
@@ -10751,79 +10747,56 @@ var executeRouterPlan = /*#__PURE__*/function () {
10751
10747
  _context.n = 4;
10752
10748
  break;
10753
10749
  }
10750
+ _t = txHashes;
10754
10751
  _context.n = 3;
10755
- return submitTransaction(tx, evmSigner);
10752
+ return api.signAndSubmitFinalized(tx, evmSigner);
10756
10753
  case 3:
10757
- _context.n = 5;
10754
+ _t.push.call(_t, _context.v);
10755
+ _context.n = 6;
10758
10756
  break;
10759
10757
  case 4:
10758
+ _t2 = txHashes;
10760
10759
  _context.n = 5;
10761
- return submitTransaction(tx, signer);
10760
+ return api.signAndSubmitFinalized(tx, signer);
10762
10761
  case 5:
10763
- _context.n = 2;
10764
- break;
10762
+ _t2.push.call(_t2, _context.v);
10765
10763
  case 6:
10766
- _context.n = 8;
10764
+ _context.n = 2;
10767
10765
  break;
10768
10766
  case 7:
10769
- _context.p = 7;
10770
- _t = _context.v;
10771
- _iterator.e(_t);
10767
+ _context.n = 9;
10768
+ break;
10772
10769
  case 8:
10773
10770
  _context.p = 8;
10774
- _iterator.f();
10775
- return _context.f(8);
10771
+ _t3 = _context.v;
10772
+ _iterator.e(_t3);
10776
10773
  case 9:
10774
+ _context.p = 9;
10775
+ _iterator.f();
10776
+ return _context.f(9);
10777
+ case 10:
10777
10778
  onStatusChange === null || onStatusChange === void 0 || onStatusChange({
10778
10779
  type: 'COMPLETED',
10779
10780
  currentStep: plan.length - 1,
10780
10781
  routerPlan: plan
10781
10782
  });
10782
- case 10:
10783
- return _context.a(2);
10783
+ return _context.a(2, txHashes);
10784
10784
  }
10785
- }, _callee, null, [[1, 7, 8, 9]]);
10785
+ }, _callee, null, [[1, 8, 9, 10]]);
10786
10786
  }));
10787
10787
  return function executeRouterPlan(_x, _x2) {
10788
10788
  return _ref2.apply(this, arguments);
10789
10789
  };
10790
10790
  }();
10791
10791
 
10792
- /**
10793
- * This function allows users to send one type of token and receive a different one on the destination chain
10794
- * in a one operation. It integrates with multiple exchanges like Acala, Basilisk, Bifrost, HydraDX, Interlay,
10795
- * Karura, and Kintsugi, covering over 500 asset pools.
10796
- *
10797
- * **Example Usage:**
10798
- * ```typescript
10799
- * await transfer({
10800
- * from: 'Polkadot',
10801
- * to: 'Astar',
10802
- * currencyFrom: { symbol: 'DOT' },
10803
- * currencyTo: { symbol: 'ASTR' },
10804
- * amount: '1000000',
10805
- * slippagePct: '1',
10806
- * senderAddress: 'your_injector_address',
10807
- * recipientAddress: 'recipient_address',
10808
- * signer: 'your_signer',
10809
- * onStatusChange: (status) => {
10810
- * console.log(status);
10811
- * },
10812
- * });
10813
- * ```
10814
- *
10815
- * @param initialOptions - An object containing transfer details such as origin, destination, currencies, amount, addresses, and signers.
10816
- * @returns A Promise that resolves when the transfer is complete.
10817
- * @throws An error if required parameters are missing or invalid.
10818
- */
10819
10792
  var transfer = /*#__PURE__*/function () {
10820
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions, builderOptions) {
10793
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions) {
10821
10794
  var _options$destination;
10822
- var from, exchangeChain, signer, evmSigner, senderAddress, evmSenderAddress, onStatusChange, _yield$prepareTransfo, dex, options, routerPlan;
10795
+ var api, from, exchangeChain, signer, evmSigner, sender, evmSenderAddress, onStatusChange, _yield$prepareTransfo, dex, options, routerPlan;
10823
10796
  return _regenerator().w(function (_context) {
10824
10797
  while (1) switch (_context.n) {
10825
10798
  case 0:
10826
- from = initialOptions.from, exchangeChain = initialOptions.exchange, signer = initialOptions.signer, evmSigner = initialOptions.evmSigner, senderAddress = initialOptions.senderAddress, evmSenderAddress = initialOptions.evmSenderAddress, onStatusChange = initialOptions.onStatusChange;
10799
+ api = initialOptions.api, from = initialOptions.from, exchangeChain = initialOptions.exchange, signer = initialOptions.signer, evmSigner = initialOptions.evmSigner, sender = initialOptions.sender, evmSenderAddress = initialOptions.evmSenderAddress, onStatusChange = initialOptions.onStatusChange;
10827
10800
  validateTransferOptions(initialOptions);
10828
10801
  if (!(evmSigner !== undefined && evmSenderAddress === undefined)) {
10829
10802
  _context.n = 1;
@@ -10849,7 +10822,7 @@ var transfer = /*#__PURE__*/function () {
10849
10822
  });
10850
10823
  }
10851
10824
  _context.n = 4;
10852
- return prepareTransformedOptions(initialOptions, builderOptions);
10825
+ return prepareTransformedOptions(initialOptions);
10853
10826
  case 4:
10854
10827
  _yield$prepareTransfo = _context.v;
10855
10828
  dex = _yield$prepareTransfo.dex;
@@ -10858,34 +10831,27 @@ var transfer = /*#__PURE__*/function () {
10858
10831
  return buildTransactions(dex, options);
10859
10832
  case 5:
10860
10833
  routerPlan = _context.v;
10861
- _context.n = 6;
10862
- return executeRouterPlan(routerPlan, {
10834
+ return _context.a(2, executeRouterPlan(routerPlan, {
10863
10835
  signer: signer,
10864
- senderAddress: senderAddress,
10836
+ sender: sender,
10865
10837
  destination: (_options$destination = options.destination) === null || _options$destination === void 0 ? void 0 : _options$destination.chain,
10866
10838
  evmSigner: evmSigner,
10867
10839
  evmSenderAddress: evmSenderAddress,
10868
- onStatusChange: onStatusChange
10869
- });
10870
- case 6:
10871
- return _context.a(2);
10840
+ onStatusChange: onStatusChange,
10841
+ api: api
10842
+ }));
10872
10843
  }
10873
10844
  }, _callee);
10874
10845
  }));
10875
- return function transfer(_x, _x2) {
10846
+ return function transfer(_x) {
10876
10847
  return _ref.apply(this, arguments);
10877
10848
  };
10878
10849
  }();
10879
10850
 
10880
- /**
10881
- * Builder class for constructing and executing cross-chain transfers using the XCM Router.
10882
- *
10883
- * @deprecated Use `@paraspell/sdk` with the "swap" extension installed instead.
10884
- */
10885
10851
  var RouterBuilderCore = /*#__PURE__*/function () {
10886
- function RouterBuilderCore(builderOptions, options) {
10852
+ function RouterBuilderCore(api, options) {
10887
10853
  _classCallCheck(this, RouterBuilderCore);
10888
- this._builderOptions = builderOptions;
10854
+ this._api = api;
10889
10855
  this._options = options !== null && options !== void 0 ? options : {};
10890
10856
  }
10891
10857
  /**
@@ -10897,7 +10863,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10897
10863
  return _createClass(RouterBuilderCore, [{
10898
10864
  key: "from",
10899
10865
  value: function from(chain) {
10900
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10866
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10901
10867
  from: chain
10902
10868
  }));
10903
10869
  }
@@ -10910,7 +10876,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10910
10876
  }, {
10911
10877
  key: "exchange",
10912
10878
  value: function exchange(chain) {
10913
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10879
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10914
10880
  exchange: normalizeExchange(chain)
10915
10881
  }));
10916
10882
  }
@@ -10923,7 +10889,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10923
10889
  }, {
10924
10890
  key: "to",
10925
10891
  value: function to(chain) {
10926
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10892
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10927
10893
  to: chain
10928
10894
  }));
10929
10895
  }
@@ -10936,7 +10902,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10936
10902
  }, {
10937
10903
  key: "currencyFrom",
10938
10904
  value: function currencyFrom(currency) {
10939
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10905
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10940
10906
  currencyFrom: currency
10941
10907
  }));
10942
10908
  }
@@ -10949,7 +10915,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10949
10915
  }, {
10950
10916
  key: "currencyTo",
10951
10917
  value: function currencyTo(currency) {
10952
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10918
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10953
10919
  currencyTo: currency
10954
10920
  }));
10955
10921
  }
@@ -10962,7 +10928,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10962
10928
  }, {
10963
10929
  key: "feeAsset",
10964
10930
  value: function feeAsset(currency) {
10965
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10931
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10966
10932
  feeAsset: currency
10967
10933
  }));
10968
10934
  }
@@ -10975,21 +10941,21 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10975
10941
  }, {
10976
10942
  key: "amount",
10977
10943
  value: function amount(_amount) {
10978
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10944
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10979
10945
  amount: _amount.toString()
10980
10946
  }));
10981
10947
  }
10982
10948
  /**
10983
10949
  * Specifies the recipient address on the destination chain.
10984
10950
  *
10985
- * @param recipientAddress - The recipient address.
10951
+ * @param recipient - The recipient address.
10986
10952
  * @returns The current builder instance.
10987
10953
  */
10988
10954
  }, {
10989
- key: "recipientAddress",
10990
- value: function recipientAddress(address) {
10991
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10992
- recipientAddress: address
10955
+ key: "recipient",
10956
+ value: function recipient(address) {
10957
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10958
+ recipient: address
10993
10959
  }));
10994
10960
  }
10995
10961
  /**
@@ -10999,22 +10965,22 @@ var RouterBuilderCore = /*#__PURE__*/function () {
10999
10965
  * @returns The current builder instance.
11000
10966
  */
11001
10967
  }, {
11002
- key: "senderAddress",
11003
- value: function senderAddress(address) {
11004
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
11005
- senderAddress: address
10968
+ key: "sender",
10969
+ value: function sender(address) {
10970
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
10971
+ sender: address
11006
10972
  }));
11007
10973
  }
11008
10974
  /**
11009
- * Specifies the Polkadot signer for the transaction.
10975
+ * Specifies the signer for the transaction.
11010
10976
  *
11011
- * @param signer - The Polkadot signer instance.
10977
+ * @param signer - The signer instance.
11012
10978
  * @returns The current builder instance.
11013
10979
  */
11014
10980
  }, {
11015
10981
  key: "signer",
11016
10982
  value: function signer(_signer) {
11017
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10983
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
11018
10984
  signer: _signer
11019
10985
  }));
11020
10986
  }
@@ -11027,7 +10993,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
11027
10993
  }, {
11028
10994
  key: "evmSenderAddress",
11029
10995
  value: function evmSenderAddress(address) {
11030
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
10996
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
11031
10997
  evmSenderAddress: address
11032
10998
  }));
11033
10999
  }
@@ -11040,7 +11006,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
11040
11006
  }, {
11041
11007
  key: "evmSigner",
11042
11008
  value: function evmSigner(signer) {
11043
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
11009
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
11044
11010
  evmSigner: signer
11045
11011
  }));
11046
11012
  }
@@ -11053,7 +11019,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
11053
11019
  }, {
11054
11020
  key: "slippagePct",
11055
11021
  value: function slippagePct(pct) {
11056
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
11022
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
11057
11023
  slippagePct: pct
11058
11024
  }));
11059
11025
  }
@@ -11066,7 +11032,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
11066
11032
  }, {
11067
11033
  key: "onStatusChange",
11068
11034
  value: function onStatusChange(callback) {
11069
- return new RouterBuilderCore(this._builderOptions, _objectSpread2(_objectSpread2({}, this._options), {}, {
11035
+ return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
11070
11036
  onStatusChange: callback
11071
11037
  }));
11072
11038
  }
@@ -11085,7 +11051,9 @@ var RouterBuilderCore = /*#__PURE__*/function () {
11085
11051
  while (1) switch (_context.n) {
11086
11052
  case 0:
11087
11053
  disableFallback = (_options$disableFallb = options === null || options === void 0 ? void 0 : options.disableFallback) !== null && _options$disableFallb !== void 0 ? _options$disableFallb : false;
11088
- return _context.a(2, getXcmFees(this._options, disableFallback, this._builderOptions));
11054
+ return _context.a(2, getXcmFees(_objectSpread2(_objectSpread2({}, this._options), {}, {
11055
+ api: this._api
11056
+ }), disableFallback));
11089
11057
  }
11090
11058
  }, _callee, this);
11091
11059
  }));
@@ -11101,7 +11069,9 @@ var RouterBuilderCore = /*#__PURE__*/function () {
11101
11069
  return _regenerator().w(function (_context2) {
11102
11070
  while (1) switch (_context2.n) {
11103
11071
  case 0:
11104
- return _context2.a(2, getTransferableAmount(this._options, this._builderOptions));
11072
+ return _context2.a(2, getTransferableAmount(_objectSpread2(_objectSpread2({}, this._options), {}, {
11073
+ api: this._api
11074
+ })));
11105
11075
  }
11106
11076
  }, _callee2, this);
11107
11077
  }));
@@ -11117,7 +11087,9 @@ var RouterBuilderCore = /*#__PURE__*/function () {
11117
11087
  return _regenerator().w(function (_context3) {
11118
11088
  while (1) switch (_context3.n) {
11119
11089
  case 0:
11120
- return _context3.a(2, getMinTransferableAmount(this._options, this._builderOptions));
11090
+ return _context3.a(2, getMinTransferableAmount(_objectSpread2(_objectSpread2({}, this._options), {}, {
11091
+ api: this._api
11092
+ })));
11121
11093
  }
11122
11094
  }, _callee3, this);
11123
11095
  }));
@@ -11129,65 +11101,49 @@ var RouterBuilderCore = /*#__PURE__*/function () {
11129
11101
  /**
11130
11102
  * Executes the transfer with the provided parameters.
11131
11103
  *
11104
+ * @returns An array of finalized transaction hashes (hex) in execution order.
11132
11105
  * @throws Error if required parameters are missing.
11133
11106
  */
11134
11107
  }, {
11135
- key: "build",
11136
- value: function build() {
11137
- return transfer(this._options, this._builderOptions);
11108
+ key: "signAndSubmit",
11109
+ value: function signAndSubmit() {
11110
+ return transfer(_objectSpread2(_objectSpread2({}, this._options), {}, {
11111
+ api: this._api
11112
+ }));
11138
11113
  }
11139
11114
  /**
11140
11115
  * Builds the transactions for the transfer with the provided parameters.
11141
11116
  */
11142
11117
  }, {
11143
- key: "buildTransactions",
11144
- value: function buildTransactions() {
11145
- return buildApiTransactions(this._options, this._builderOptions);
11118
+ key: "build",
11119
+ value: function build() {
11120
+ return buildApiTransactions(_objectSpread2(_objectSpread2({}, this._options), {}, {
11121
+ api: this._api
11122
+ }));
11146
11123
  }
11147
11124
  }, {
11148
11125
  key: "dryRun",
11149
11126
  value: function dryRun() {
11150
- return dryRunRouter(this._options, this._builderOptions);
11127
+ return dryRunRouter(_objectSpread2(_objectSpread2({}, this._options), {}, {
11128
+ api: this._api
11129
+ }));
11151
11130
  }
11152
11131
  }, {
11153
11132
  key: "getBestAmountOut",
11154
11133
  value: function getBestAmountOut$1() {
11155
- return getBestAmountOut(this._options, this._builderOptions);
11134
+ return getBestAmountOut(_objectSpread2(_objectSpread2({}, this._options), {}, {
11135
+ api: this._api
11136
+ }));
11156
11137
  }
11157
11138
  }]);
11158
11139
  }();
11159
- /**
11160
- * Creates a new `RouterBuilder` instance for constructing and executing cross-chain transfers using the XCM Router.
11161
- *
11162
- * @deprecated Use `@paraspell/sdk` with the "swap" extension installed instead.
11163
- *
11164
- * **Example usage:**
11165
- * ```typescript
11166
- * await RouterBuilder(options)
11167
- * .from('Polkadot')
11168
- * .exchange('HydrationDex')
11169
- * .to('Astar')
11170
- * .currencyFrom({ symbol: 'DOT' })
11171
- * .currencyTo({ symbol: 'ASTR' })
11172
- * .amount(1000000n)
11173
- * .slippagePct('1')
11174
- * .senderAddress('sender_address')
11175
- * .recipientAddress('recipient_address')
11176
- * .signer(yourSigner)
11177
- * .onStatusChange((status) => {
11178
- * console.log(status);
11179
- * })
11180
- * .build();
11181
- * ```
11182
- *
11183
- * @returns A new `RouterBuilder`.
11184
- */
11185
- var RouterBuilder = function RouterBuilder(options) {
11186
- return new RouterBuilderCore(options);
11140
+ var RouterBuilder = function RouterBuilder(api) {
11141
+ return new RouterBuilderCore(api);
11187
11142
  };
11188
11143
 
11144
+ // @ts-expect-error - Temporary fix till the release to implement breaking changes
11189
11145
  registerSwapExtension({
11190
11146
  RouterBuilder: RouterBuilder
11191
11147
  });
11192
11148
 
11193
- 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 };
11149
+ 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 };