@paraspell/swap 12.9.7 → 12.10.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +96 -221
- package/dist/index.mjs +434 -497
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import
|
|
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
|
-
import { AcalaDex
|
|
6
|
+
import { AcalaDex, AggregateDex } from '@acala-network/sdk-swap';
|
|
7
7
|
import { firstValueFrom } from 'rxjs';
|
|
8
8
|
import { createChainClient, formatUnits } from '@paraspell/sdk-pjs';
|
|
9
9
|
import { options } from '@acala-network/api';
|
|
@@ -399,82 +399,59 @@ var pow10n = function pow10n(d) {
|
|
|
399
399
|
return result;
|
|
400
400
|
};
|
|
401
401
|
|
|
402
|
-
var
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
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
|
|
421
|
+
return tx.getEncodedData();
|
|
459
422
|
case 2:
|
|
460
|
-
|
|
423
|
+
_t = _context.v.asHex();
|
|
461
424
|
case 3:
|
|
462
|
-
|
|
425
|
+
hex = _t;
|
|
426
|
+
if (!(isPjsTx && api.type === '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(
|
|
465
|
-
_context.n =
|
|
466
|
-
return
|
|
467
|
-
case
|
|
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, [[
|
|
447
|
+
}, _callee, null, [[4, 6]]);
|
|
471
448
|
}));
|
|
472
|
-
return function
|
|
449
|
+
return function convertTxToTarget(_x, _x2) {
|
|
473
450
|
return _ref.apply(this, arguments);
|
|
474
451
|
};
|
|
475
452
|
}();
|
|
476
453
|
|
|
477
|
-
var
|
|
454
|
+
var AssetHubPolkadot = {
|
|
478
455
|
isOmni: true,
|
|
479
456
|
assets: [
|
|
480
457
|
{
|
|
@@ -891,7 +868,7 @@ var AssetHubPolkadotDex = {
|
|
|
891
868
|
pairs: [
|
|
892
869
|
]
|
|
893
870
|
};
|
|
894
|
-
var
|
|
871
|
+
var AssetHubKusama = {
|
|
895
872
|
isOmni: true,
|
|
896
873
|
assets: [
|
|
897
874
|
{
|
|
@@ -1058,7 +1035,7 @@ var AssetHubKusamaDex = {
|
|
|
1058
1035
|
pairs: [
|
|
1059
1036
|
]
|
|
1060
1037
|
};
|
|
1061
|
-
var
|
|
1038
|
+
var AssetHubPaseo = {
|
|
1062
1039
|
isOmni: true,
|
|
1063
1040
|
assets: [
|
|
1064
1041
|
{
|
|
@@ -1190,7 +1167,7 @@ var AssetHubPaseoDex = {
|
|
|
1190
1167
|
pairs: [
|
|
1191
1168
|
]
|
|
1192
1169
|
};
|
|
1193
|
-
var
|
|
1170
|
+
var AssetHubWestend = {
|
|
1194
1171
|
isOmni: true,
|
|
1195
1172
|
assets: [
|
|
1196
1173
|
{
|
|
@@ -1291,7 +1268,7 @@ var AssetHubWestendDex = {
|
|
|
1291
1268
|
pairs: [
|
|
1292
1269
|
]
|
|
1293
1270
|
};
|
|
1294
|
-
var
|
|
1271
|
+
var Hydration = {
|
|
1295
1272
|
isOmni: true,
|
|
1296
1273
|
assets: [
|
|
1297
1274
|
{
|
|
@@ -2343,7 +2320,7 @@ var HydrationDex = {
|
|
|
2343
2320
|
pairs: [
|
|
2344
2321
|
]
|
|
2345
2322
|
};
|
|
2346
|
-
var
|
|
2323
|
+
var Karura = {
|
|
2347
2324
|
isOmni: false,
|
|
2348
2325
|
assets: [
|
|
2349
2326
|
{
|
|
@@ -4701,7 +4678,7 @@ var KaruraDex = {
|
|
|
4701
4678
|
]
|
|
4702
4679
|
]
|
|
4703
4680
|
};
|
|
4704
|
-
var
|
|
4681
|
+
var Acala = {
|
|
4705
4682
|
isOmni: false,
|
|
4706
4683
|
assets: [
|
|
4707
4684
|
{
|
|
@@ -6266,7 +6243,7 @@ var AcalaDex = {
|
|
|
6266
6243
|
]
|
|
6267
6244
|
]
|
|
6268
6245
|
};
|
|
6269
|
-
var
|
|
6246
|
+
var BifrostKusama = {
|
|
6270
6247
|
isOmni: false,
|
|
6271
6248
|
assets: [
|
|
6272
6249
|
{
|
|
@@ -6815,7 +6792,7 @@ var BifrostKusamaDex = {
|
|
|
6815
6792
|
]
|
|
6816
6793
|
]
|
|
6817
6794
|
};
|
|
6818
|
-
var
|
|
6795
|
+
var BifrostPolkadot = {
|
|
6819
6796
|
isOmni: false,
|
|
6820
6797
|
assets: [
|
|
6821
6798
|
{
|
|
@@ -7153,28 +7130,28 @@ var BifrostPolkadotDex = {
|
|
|
7153
7130
|
]
|
|
7154
7131
|
};
|
|
7155
7132
|
var assets = {
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7133
|
+
AssetHubPolkadot: AssetHubPolkadot,
|
|
7134
|
+
AssetHubKusama: AssetHubKusama,
|
|
7135
|
+
AssetHubPaseo: AssetHubPaseo,
|
|
7136
|
+
AssetHubWestend: AssetHubWestend,
|
|
7137
|
+
Hydration: Hydration,
|
|
7138
|
+
Karura: Karura,
|
|
7139
|
+
Acala: Acala,
|
|
7140
|
+
BifrostKusama: BifrostKusama,
|
|
7141
|
+
BifrostPolkadot: BifrostPolkadot
|
|
7165
7142
|
};
|
|
7166
7143
|
|
|
7167
7144
|
var assetsMapJson = /*#__PURE__*/Object.freeze({
|
|
7168
7145
|
__proto__: null,
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7146
|
+
Acala: Acala,
|
|
7147
|
+
AssetHubKusama: AssetHubKusama,
|
|
7148
|
+
AssetHubPaseo: AssetHubPaseo,
|
|
7149
|
+
AssetHubPolkadot: AssetHubPolkadot,
|
|
7150
|
+
AssetHubWestend: AssetHubWestend,
|
|
7151
|
+
BifrostKusama: BifrostKusama,
|
|
7152
|
+
BifrostPolkadot: BifrostPolkadot,
|
|
7153
|
+
Hydration: Hydration,
|
|
7154
|
+
Karura: Karura,
|
|
7178
7155
|
default: assets
|
|
7179
7156
|
});
|
|
7180
7157
|
|
|
@@ -7195,21 +7172,15 @@ var Logger = {
|
|
|
7195
7172
|
};
|
|
7196
7173
|
|
|
7197
7174
|
var ExchangeChain = /*#__PURE__*/function () {
|
|
7198
|
-
function ExchangeChain(chain
|
|
7175
|
+
function ExchangeChain(chain) {
|
|
7199
7176
|
_classCallCheck(this, ExchangeChain);
|
|
7200
7177
|
this._chain = chain;
|
|
7201
|
-
this._exchangeChain = exchangeChain;
|
|
7202
7178
|
}
|
|
7203
7179
|
return _createClass(ExchangeChain, [{
|
|
7204
7180
|
key: "chain",
|
|
7205
7181
|
get: function get() {
|
|
7206
7182
|
return this._chain;
|
|
7207
7183
|
}
|
|
7208
|
-
}, {
|
|
7209
|
-
key: "exchangeChain",
|
|
7210
|
-
get: function get() {
|
|
7211
|
-
return this._exchangeChain;
|
|
7212
|
-
}
|
|
7213
7184
|
}, {
|
|
7214
7185
|
key: "handleMultiSwap",
|
|
7215
7186
|
value: function () {
|
|
@@ -7359,7 +7330,7 @@ var getDexConfig$2 = /*#__PURE__*/function () {
|
|
|
7359
7330
|
seen.add(key);
|
|
7360
7331
|
directPairs.push([a.location, b.location]);
|
|
7361
7332
|
});
|
|
7362
|
-
acalaDex = new AcalaDex
|
|
7333
|
+
acalaDex = new AcalaDex({
|
|
7363
7334
|
api: api,
|
|
7364
7335
|
wallet: wallet
|
|
7365
7336
|
});
|
|
@@ -7465,18 +7436,18 @@ var AcalaExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
7465
7436
|
key: "swapCurrency",
|
|
7466
7437
|
value: function () {
|
|
7467
7438
|
var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, options, toDestTransactionFee) {
|
|
7468
|
-
var papiApi, assetFrom, assetTo, amount,
|
|
7439
|
+
var papiApi, assetFrom, assetTo, amount, sender, origin, isForFeeEstimation, wallet, fromToken, toToken, acalaDex, dex, swapFee, totalNativeCurrencyFee, balance, pctDestFee, amountWithoutFee, tradeResult, tx, amountOutRes, amountOut, nativeAssetSymbol, amountOutWithFee;
|
|
7469
7440
|
return _regenerator().w(function (_context) {
|
|
7470
7441
|
while (1) switch (_context.n) {
|
|
7471
7442
|
case 0:
|
|
7472
|
-
papiApi = options.papiApi, assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount,
|
|
7443
|
+
papiApi = options.papiApi, assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, sender = options.sender, origin = options.origin, isForFeeEstimation = options.isForFeeEstimation;
|
|
7473
7444
|
wallet = new Wallet(api);
|
|
7474
7445
|
_context.n = 1;
|
|
7475
7446
|
return wallet.isReady;
|
|
7476
7447
|
case 1:
|
|
7477
7448
|
fromToken = wallet.getToken(assetFrom.symbol);
|
|
7478
7449
|
toToken = wallet.getToken(assetTo.symbol);
|
|
7479
|
-
acalaDex = new AcalaDex
|
|
7450
|
+
acalaDex = new AcalaDex({
|
|
7480
7451
|
api: api,
|
|
7481
7452
|
wallet: wallet
|
|
7482
7453
|
});
|
|
@@ -7494,7 +7465,7 @@ var AcalaExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
7494
7465
|
_context.n = 3;
|
|
7495
7466
|
return getBalance({
|
|
7496
7467
|
api: papiApi,
|
|
7497
|
-
address:
|
|
7468
|
+
address: sender,
|
|
7498
7469
|
chain: this.chain
|
|
7499
7470
|
});
|
|
7500
7471
|
case 3:
|
|
@@ -7570,7 +7541,7 @@ var AcalaExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
7570
7541
|
case 1:
|
|
7571
7542
|
fromToken = wallet.getToken(assetFrom.symbol);
|
|
7572
7543
|
toToken = wallet.getToken(assetTo.symbol);
|
|
7573
|
-
acalaDex = new AcalaDex
|
|
7544
|
+
acalaDex = new AcalaDex({
|
|
7574
7545
|
api: api,
|
|
7575
7546
|
wallet: wallet
|
|
7576
7547
|
});
|
|
@@ -7794,11 +7765,11 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
7794
7765
|
key: "swapCurrency",
|
|
7795
7766
|
value: function () {
|
|
7796
7767
|
var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_api, options, toDestTxFee) {
|
|
7797
|
-
var assetFrom, assetTo, amount,
|
|
7768
|
+
var assetFrom, assetTo, amount, sender, slippagePct, origin, papiApi, pctDestFee, amountWithoutFee, _yield$getQuotedAmoun, amountOut, usedFromML, usedToML, slippageMultiplier, minAmountOut, tx, toDestFeeCurrencyTo, finalAmountOut, _t;
|
|
7798
7769
|
return _regenerator().w(function (_context) {
|
|
7799
7770
|
while (1) switch (_context.n) {
|
|
7800
7771
|
case 0:
|
|
7801
|
-
assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount,
|
|
7772
|
+
assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, sender = options.sender, slippagePct = options.slippagePct, origin = options.origin, papiApi = options.papiApi;
|
|
7802
7773
|
pctDestFee = origin ? DEST_FEE_BUFFER_PCT : 0;
|
|
7803
7774
|
amountWithoutFee = padValueBy(amount, pctDestFee);
|
|
7804
7775
|
_context.n = 1;
|
|
@@ -7814,7 +7785,7 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
7814
7785
|
path: [transform(usedFromML), transform(usedToML)],
|
|
7815
7786
|
amount_in: amountWithoutFee,
|
|
7816
7787
|
amount_out_min: minAmountOut,
|
|
7817
|
-
send_to:
|
|
7788
|
+
send_to: sender,
|
|
7818
7789
|
keep_alive: !!assetFrom.isNative
|
|
7819
7790
|
});
|
|
7820
7791
|
if (!(assetTo.symbol == getNativeAssetSymbol(this.chain))) {
|
|
@@ -7866,7 +7837,7 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
7866
7837
|
while (1) switch (_context2.n) {
|
|
7867
7838
|
case 0:
|
|
7868
7839
|
assetFrom = options.assetFrom, assetTo = options.assetTo;
|
|
7869
|
-
nativeAsset = getExchangeAsset(this.
|
|
7840
|
+
nativeAsset = getExchangeAsset(this.chain, {
|
|
7870
7841
|
symbol: getNativeAssetSymbol(this.chain)
|
|
7871
7842
|
});
|
|
7872
7843
|
if (nativeAsset) {
|
|
@@ -7915,7 +7886,7 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
7915
7886
|
optionsHop2 = {
|
|
7916
7887
|
papiApi: options.papiApi,
|
|
7917
7888
|
slippagePct: options.slippagePct,
|
|
7918
|
-
|
|
7889
|
+
sender: options.sender,
|
|
7919
7890
|
origin: undefined,
|
|
7920
7891
|
assetFrom: nativeAsset,
|
|
7921
7892
|
assetTo: assetTo,
|
|
@@ -7955,7 +7926,7 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
7955
7926
|
while (1) switch (_context3.n) {
|
|
7956
7927
|
case 0:
|
|
7957
7928
|
assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, origin = options.origin, papiApi = options.papiApi;
|
|
7958
|
-
nativeAsset = getExchangeAsset(this.
|
|
7929
|
+
nativeAsset = getExchangeAsset(this.chain, {
|
|
7959
7930
|
symbol: getNativeAssetSymbol(this.chain)
|
|
7960
7931
|
});
|
|
7961
7932
|
if (nativeAsset) {
|
|
@@ -8385,11 +8356,11 @@ var BifrostExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
8385
8356
|
key: "swapCurrency",
|
|
8386
8357
|
value: function () {
|
|
8387
8358
|
var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, options, toDestTxFee) {
|
|
8388
|
-
var assetFrom, assetTo, amount,
|
|
8359
|
+
var assetFrom, assetTo, amount, sender, slippagePct, origin, chainId, tokenMap, tokenWrappedFrom, tokenWrappedTo, tokenFrom, tokenTo, currencyCombinations, pairs, pctDestFee, amountWithoutFee, amountInFinal, trade, allowedSlippage, blockNumber, deadline, _SwapRouter$swapCallP, extrinsic, amountOut, nativeSymbol, amountOutWithFee;
|
|
8389
8360
|
return _regenerator().w(function (_context) {
|
|
8390
8361
|
while (1) switch (_context.n) {
|
|
8391
8362
|
case 0:
|
|
8392
|
-
assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount,
|
|
8363
|
+
assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, sender = options.sender, slippagePct = options.slippagePct, origin = options.origin;
|
|
8393
8364
|
chainId = getParaId(this.chain);
|
|
8394
8365
|
tokenMap = getTokenMap(this.chain, chainId);
|
|
8395
8366
|
tokenWrappedFrom = findToken(tokenMap, assetFrom.symbol);
|
|
@@ -8435,7 +8406,7 @@ var BifrostExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
8435
8406
|
_SwapRouter$swapCallP = SwapRouter.swapCallParameters(trade, {
|
|
8436
8407
|
api: api,
|
|
8437
8408
|
allowedSlippage: allowedSlippage,
|
|
8438
|
-
recipient:
|
|
8409
|
+
recipient: sender,
|
|
8439
8410
|
deadline: deadline
|
|
8440
8411
|
}), extrinsic = _SwapRouter$swapCallP.extrinsic;
|
|
8441
8412
|
if (!(extrinsic === null)) {
|
|
@@ -8565,11 +8536,11 @@ var getAssetInfo = /*#__PURE__*/function () {
|
|
|
8565
8536
|
|
|
8566
8537
|
var calculateFee = /*#__PURE__*/function () {
|
|
8567
8538
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, currencyFromDecimals, chain, toDestTransactionFee) {
|
|
8568
|
-
var amount, slippagePct, feeCalcAddress,
|
|
8539
|
+
var amount, slippagePct, feeCalcAddress, sender, trade, nativeCurrencyInfo, nativeCurrencyDecimals, substrateTx, tx, swapFee, feeNative, currencyFromPriceInfo, currencyFromPrice, feeInCurrencyFrom, finalFee;
|
|
8569
8540
|
return _regenerator().w(function (_context) {
|
|
8570
8541
|
while (1) switch (_context.n) {
|
|
8571
8542
|
case 0:
|
|
8572
|
-
amount = _ref.amount, slippagePct = _ref.slippagePct, feeCalcAddress = _ref.feeCalcAddress,
|
|
8543
|
+
amount = _ref.amount, slippagePct = _ref.slippagePct, feeCalcAddress = _ref.feeCalcAddress, sender = _ref.sender;
|
|
8573
8544
|
_context.n = 1;
|
|
8574
8545
|
return tradeRouter.getBestSell(currencyFromInfo.id, currencyToInfo.id, amount.toString());
|
|
8575
8546
|
case 1:
|
|
@@ -8594,7 +8565,7 @@ var calculateFee = /*#__PURE__*/function () {
|
|
|
8594
8565
|
throw new UnableToComputeError('Native currency decimals not found');
|
|
8595
8566
|
case 4:
|
|
8596
8567
|
_context.n = 5;
|
|
8597
|
-
return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(
|
|
8568
|
+
return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(sender).build();
|
|
8598
8569
|
case 5:
|
|
8599
8570
|
substrateTx = _context.v;
|
|
8600
8571
|
tx = substrateTx.get();
|
|
@@ -8647,11 +8618,11 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
8647
8618
|
key: "swapCurrency",
|
|
8648
8619
|
value: function () {
|
|
8649
8620
|
var _swapCurrency = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, options, toDestTransactionFee) {
|
|
8650
|
-
var origin, assetFrom, assetTo,
|
|
8621
|
+
var origin, assetFrom, assetTo, sender, slippagePct, amount, _createSdkContext, tradeRouter, txBuilderFactory, currencyFromInfo, currencyToInfo, tradeFee, amountWithoutFee, amountNormalized, trade, substrateTx, tx, amountOut, nativeCurrencyInfo, nativeCurrencyDecimals, priceInfo, currencyToPrice, feeInCurrencyTo, amountOutModified;
|
|
8651
8622
|
return _regenerator().w(function (_context) {
|
|
8652
8623
|
while (1) switch (_context.n) {
|
|
8653
8624
|
case 0:
|
|
8654
|
-
origin = options.origin, assetFrom = options.assetFrom, assetTo = options.assetTo,
|
|
8625
|
+
origin = options.origin, assetFrom = options.assetFrom, assetTo = options.assetTo, sender = options.sender, slippagePct = options.slippagePct, amount = options.amount;
|
|
8655
8626
|
_createSdkContext = createSdkContext(api), tradeRouter = _createSdkContext.api.router, txBuilderFactory = _createSdkContext.tx;
|
|
8656
8627
|
_context.n = 1;
|
|
8657
8628
|
return getAssetInfo(tradeRouter, assetFrom);
|
|
@@ -8692,7 +8663,7 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
8692
8663
|
case 7:
|
|
8693
8664
|
trade = _context.v;
|
|
8694
8665
|
_context.n = 8;
|
|
8695
|
-
return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(
|
|
8666
|
+
return txBuilderFactory.trade(trade).withSlippage(Number(slippagePct)).withBeneficiary(sender).build();
|
|
8696
8667
|
case 8:
|
|
8697
8668
|
substrateTx = _context.v;
|
|
8698
8669
|
tx = substrateTx.get();
|
|
@@ -8852,15 +8823,15 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
8852
8823
|
|
|
8853
8824
|
var record = {
|
|
8854
8825
|
// Reuse classes for Kusama equivalents
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8826
|
+
AssetHubPolkadot: new AssetHubExchange('AssetHubPolkadot'),
|
|
8827
|
+
AssetHubKusama: new AssetHubExchange('AssetHubKusama'),
|
|
8828
|
+
AssetHubPaseo: new AssetHubExchange('AssetHubPaseo'),
|
|
8829
|
+
AssetHubWestend: new AssetHubExchange('AssetHubWestend'),
|
|
8830
|
+
Hydration: new HydrationExchange('Hydration'),
|
|
8831
|
+
Acala: new AcalaExchange('Acala'),
|
|
8832
|
+
Karura: new AcalaExchange('Karura'),
|
|
8833
|
+
BifrostPolkadot: new BifrostExchange('BifrostPolkadot'),
|
|
8834
|
+
BifrostKusama: new BifrostExchange('BifrostKusama')
|
|
8864
8835
|
};
|
|
8865
8836
|
var createExchangeInstance = function createExchangeInstance(chain) {
|
|
8866
8837
|
return record[chain];
|
|
@@ -8873,7 +8844,7 @@ var getExchangeConfig = function getExchangeConfig(exchange) {
|
|
|
8873
8844
|
var assets = stored.assets.map(function (location) {
|
|
8874
8845
|
return findAssetInfoOrThrow(chain, {
|
|
8875
8846
|
location: location
|
|
8876
|
-
}
|
|
8847
|
+
});
|
|
8877
8848
|
});
|
|
8878
8849
|
return {
|
|
8879
8850
|
isOmni: stored.isOmni,
|
|
@@ -8905,7 +8876,7 @@ var getExchangeAsset = function getExchangeAsset(exchange, currency) {
|
|
|
8905
8876
|
throw new RoutingResolutionError("Multiple assets found for symbol ".concat(currency.symbol, ". Please specify the asset by location."));
|
|
8906
8877
|
}
|
|
8907
8878
|
}
|
|
8908
|
-
asset = findAssetInfoBySymbol(
|
|
8879
|
+
asset = findAssetInfoBySymbol(otherAssets, nativeAssets, currency.symbol);
|
|
8909
8880
|
} else if ('location' in currency && !isOverrideLocationSpecifier(currency.location)) {
|
|
8910
8881
|
asset = findAssetInfoByLoc(assets, currency.location);
|
|
8911
8882
|
} else if ('id' in currency) {
|
|
@@ -9054,7 +9025,7 @@ var getSupportedAssetsTo = function getSupportedAssetsTo(exchangeInput, to) {
|
|
|
9054
9025
|
var getSupportedFeeAssets = function getSupportedFeeAssets(from, exchangeInput) {
|
|
9055
9026
|
var exchange = normalizeExchange(exchangeInput);
|
|
9056
9027
|
var supportedAssets = getSupportedAssetsFrom(from, exchange);
|
|
9057
|
-
var chains = from ? [from] : (exchange === undefined ?
|
|
9028
|
+
var chains = from ? [from] : (exchange === undefined ? EXCHANGE_CHAINS : Array.isArray(exchange) ? exchange : [exchange]).map(function (ex) {
|
|
9058
9029
|
return createExchangeInstance(ex).chain;
|
|
9059
9030
|
}).filter(function (chain, i, arr) {
|
|
9060
9031
|
return arr.indexOf(chain) === i;
|
|
@@ -9100,13 +9071,13 @@ var supportsExchangePair = function supportsExchangePair(exchange, assetA, asset
|
|
|
9100
9071
|
};
|
|
9101
9072
|
|
|
9102
9073
|
var canBuildToExchangeTx = /*#__PURE__*/function () {
|
|
9103
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, exchangeChain, originApi, assetFromOrigin
|
|
9104
|
-
var from, amount, _t2;
|
|
9074
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, exchangeChain, originApi, assetFromOrigin) {
|
|
9075
|
+
var from, amount, api, _t2;
|
|
9105
9076
|
return _regenerator().w(function (_context) {
|
|
9106
9077
|
while (1) switch (_context.p = _context.n) {
|
|
9107
9078
|
case 0:
|
|
9108
9079
|
// Try building the to exchange extrinsic to see if it will succeed for this exchange
|
|
9109
|
-
from = options.from, amount = options.amount;
|
|
9080
|
+
from = options.from, amount = options.amount, api = options.api;
|
|
9110
9081
|
_context.p = 1;
|
|
9111
9082
|
if (!(from && from !== exchangeChain && originApi && assetFromOrigin)) {
|
|
9112
9083
|
_context.n = 3;
|
|
@@ -9115,7 +9086,7 @@ var canBuildToExchangeTx = /*#__PURE__*/function () {
|
|
|
9115
9086
|
_context.n = 2;
|
|
9116
9087
|
return buildToExchangeExtrinsic({
|
|
9117
9088
|
amount: BigInt(amount),
|
|
9118
|
-
|
|
9089
|
+
sender: FALLBACK_FEE_CALC_ADDRESS,
|
|
9119
9090
|
evmSenderAddress: FALLBACK_FEE_CALC_EVM_ADDRESS,
|
|
9120
9091
|
origin: {
|
|
9121
9092
|
api: originApi,
|
|
@@ -9123,9 +9094,9 @@ var canBuildToExchangeTx = /*#__PURE__*/function () {
|
|
|
9123
9094
|
assetFrom: assetFromOrigin
|
|
9124
9095
|
},
|
|
9125
9096
|
exchange: {
|
|
9126
|
-
|
|
9097
|
+
chain: exchangeChain
|
|
9127
9098
|
},
|
|
9128
|
-
|
|
9099
|
+
api: api
|
|
9129
9100
|
});
|
|
9130
9101
|
case 2:
|
|
9131
9102
|
_context.v;
|
|
@@ -9153,19 +9124,19 @@ var canBuildToExchangeTx = /*#__PURE__*/function () {
|
|
|
9153
9124
|
}
|
|
9154
9125
|
}, _callee, null, [[1, 5]]);
|
|
9155
9126
|
}));
|
|
9156
|
-
return function canBuildToExchangeTx(_x, _x2, _x3, _x4
|
|
9127
|
+
return function canBuildToExchangeTx(_x, _x2, _x3, _x4) {
|
|
9157
9128
|
return _ref.apply(this, arguments);
|
|
9158
9129
|
};
|
|
9159
9130
|
}();
|
|
9160
9131
|
|
|
9161
9132
|
var selectBestExchangeCommon = /*#__PURE__*/function () {
|
|
9162
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, originApi, computeAmountOut
|
|
9163
|
-
var from, exchange, to, currencyFrom, currencyTo, assetFromOrigin, filteredExchangeChains, bestExchange, maxAmountOut, errors, triedAnyExchange, _iterator, _step, exchangeChain, dex, originSpecified, destinationSpecified, assetFromExchange, assetTo, res, parsedAmount, amountOut, _t, _t2;
|
|
9133
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, originApi, computeAmountOut) {
|
|
9134
|
+
var api, from, exchange, to, currencyFrom, currencyTo, assetFromOrigin, filteredExchangeChains, bestExchange, maxAmountOut, errors, triedAnyExchange, _iterator, _step, exchangeChain, dex, originSpecified, destinationSpecified, assetFromExchange, assetTo, res, config, parsedAmount, amountOut, _t, _t2;
|
|
9164
9135
|
return _regenerator().w(function (_context) {
|
|
9165
9136
|
while (1) switch (_context.p = _context.n) {
|
|
9166
9137
|
case 0:
|
|
9167
|
-
from = options.from, exchange = options.exchange, to = options.to, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo;
|
|
9168
|
-
assetFromOrigin = from ? findAssetInfo(from, currencyFrom
|
|
9138
|
+
api = options.api, from = options.from, exchange = options.exchange, to = options.to, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo;
|
|
9139
|
+
assetFromOrigin = from ? findAssetInfo(from, currencyFrom) : undefined;
|
|
9169
9140
|
if (!(from && !assetFromOrigin)) {
|
|
9170
9141
|
_context.n = 1;
|
|
9171
9142
|
break;
|
|
@@ -9195,14 +9166,14 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
|
|
|
9195
9166
|
dex = createExchangeInstance(exchangeChain);
|
|
9196
9167
|
originSpecified = from && from !== dex.chain;
|
|
9197
9168
|
destinationSpecified = to && to !== dex.chain;
|
|
9198
|
-
assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.
|
|
9169
|
+
assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.chain, assetFromOrigin) : getExchangeAsset(dex.chain, currencyFrom);
|
|
9199
9170
|
if (assetFromExchange) {
|
|
9200
9171
|
_context.n = 5;
|
|
9201
9172
|
break;
|
|
9202
9173
|
}
|
|
9203
9174
|
return _context.a(3, 14);
|
|
9204
9175
|
case 5:
|
|
9205
|
-
assetTo = getExchangeAsset(dex.
|
|
9176
|
+
assetTo = getExchangeAsset(dex.chain, currencyTo, true);
|
|
9206
9177
|
if (assetTo) {
|
|
9207
9178
|
_context.n = 6;
|
|
9208
9179
|
break;
|
|
@@ -9224,7 +9195,7 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
|
|
|
9224
9195
|
triedAnyExchange = true;
|
|
9225
9196
|
Logger.log("Checking ".concat(exchangeChain, "..."));
|
|
9226
9197
|
_context.n = 9;
|
|
9227
|
-
return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin
|
|
9198
|
+
return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin);
|
|
9228
9199
|
case 9:
|
|
9229
9200
|
res = _context.v;
|
|
9230
9201
|
if (res.success) {
|
|
@@ -9234,12 +9205,11 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
|
|
|
9234
9205
|
errors.set(dex.chain, res.error);
|
|
9235
9206
|
return _context.a(3, 14);
|
|
9236
9207
|
case 10:
|
|
9237
|
-
|
|
9208
|
+
config = api.config;
|
|
9209
|
+
parsedAmount = applyDecimalAbstraction(options.amount, assetFromExchange === null || assetFromExchange === void 0 ? void 0 : assetFromExchange.decimals, !(isConfig(config) && config.abstractDecimals === false)).toString();
|
|
9238
9210
|
_context.p = 11;
|
|
9239
9211
|
_context.n = 12;
|
|
9240
|
-
return computeAmountOut(dex, assetFromExchange, assetTo,
|
|
9241
|
-
amount: parsedAmount
|
|
9242
|
-
}));
|
|
9212
|
+
return computeAmountOut(dex, assetFromExchange, assetTo, options, parsedAmount);
|
|
9243
9213
|
case 12:
|
|
9244
9214
|
amountOut = _context.v;
|
|
9245
9215
|
if (amountOut > maxAmountOut) {
|
|
@@ -9292,18 +9262,20 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
|
|
|
9292
9262
|
}
|
|
9293
9263
|
}, _callee, null, [[11, 13], [3, 16, 17, 18]]);
|
|
9294
9264
|
}));
|
|
9295
|
-
return function selectBestExchangeCommon(_x, _x2, _x3
|
|
9265
|
+
return function selectBestExchangeCommon(_x, _x2, _x3) {
|
|
9296
9266
|
return _ref.apply(this, arguments);
|
|
9297
9267
|
};
|
|
9298
9268
|
}();
|
|
9299
9269
|
|
|
9300
9270
|
var selectBestExchange = /*#__PURE__*/function () {
|
|
9301
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi,
|
|
9271
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi, isForFeeEstimation) {
|
|
9272
|
+
var api;
|
|
9302
9273
|
return _regenerator().w(function (_context2) {
|
|
9303
9274
|
while (1) switch (_context2.n) {
|
|
9304
9275
|
case 0:
|
|
9276
|
+
api = options.api;
|
|
9305
9277
|
return _context2.a(2, selectBestExchangeCommon(options, originApi, /*#__PURE__*/function () {
|
|
9306
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, options) {
|
|
9278
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, options, parsedAmount) {
|
|
9307
9279
|
var modifiedOptions, toDestTxFee, _yield$dex$handleMult, amountOut, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10;
|
|
9308
9280
|
return _regenerator().w(function (_context) {
|
|
9309
9281
|
while (1) switch (_context.n) {
|
|
@@ -9311,7 +9283,7 @@ var selectBestExchange = /*#__PURE__*/function () {
|
|
|
9311
9283
|
_t = _objectSpread2;
|
|
9312
9284
|
_t2 = _objectSpread2({}, options);
|
|
9313
9285
|
_t3 = {};
|
|
9314
|
-
_t4 = BigInt(
|
|
9286
|
+
_t4 = BigInt(parsedAmount);
|
|
9315
9287
|
_context.n = 1;
|
|
9316
9288
|
return dex.createApiInstance();
|
|
9317
9289
|
case 1:
|
|
@@ -9320,50 +9292,53 @@ var selectBestExchange = /*#__PURE__*/function () {
|
|
|
9320
9292
|
return dex.createApiInstancePapi();
|
|
9321
9293
|
case 2:
|
|
9322
9294
|
_t6 = _context.v;
|
|
9323
|
-
|
|
9324
|
-
|
|
9295
|
+
_context.n = 3;
|
|
9296
|
+
return api.createApiForChain(dex.chain);
|
|
9297
|
+
case 3:
|
|
9298
|
+
_t7 = _context.v;
|
|
9299
|
+
_t8 = dex.chain;
|
|
9325
9300
|
_t9 = assetFromExchange;
|
|
9326
9301
|
_t0 = assetTo;
|
|
9327
9302
|
_t1 = {
|
|
9328
|
-
|
|
9303
|
+
apiPjs: _t5,
|
|
9329
9304
|
apiPapi: _t6,
|
|
9330
|
-
|
|
9331
|
-
|
|
9305
|
+
api: _t7,
|
|
9306
|
+
chain: _t8,
|
|
9332
9307
|
assetFrom: _t9,
|
|
9333
9308
|
assetTo: _t0
|
|
9334
9309
|
};
|
|
9335
|
-
_t10 = determineFeeCalcAddress(options.
|
|
9310
|
+
_t10 = determineFeeCalcAddress(options.sender, options.recipient);
|
|
9336
9311
|
modifiedOptions = _t(_t2, _t3, {
|
|
9337
9312
|
amount: _t4,
|
|
9338
9313
|
exchange: _t1,
|
|
9339
9314
|
feeCalcAddress: _t10
|
|
9340
9315
|
});
|
|
9341
|
-
_context.n =
|
|
9316
|
+
_context.n = 4;
|
|
9342
9317
|
return calculateFromExchangeFee(modifiedOptions);
|
|
9343
|
-
case
|
|
9318
|
+
case 4:
|
|
9344
9319
|
toDestTxFee = _context.v;
|
|
9345
|
-
_context.n =
|
|
9346
|
-
return dex.handleMultiSwap(modifiedOptions.exchange.
|
|
9320
|
+
_context.n = 5;
|
|
9321
|
+
return dex.handleMultiSwap(modifiedOptions.exchange.apiPjs, _objectSpread2(_objectSpread2({}, modifiedOptions), {}, {
|
|
9347
9322
|
papiApi: modifiedOptions.exchange.apiPapi,
|
|
9348
9323
|
assetFrom: modifiedOptions.exchange.assetFrom,
|
|
9349
9324
|
assetTo: modifiedOptions.exchange.assetTo,
|
|
9350
9325
|
isForFeeEstimation: isForFeeEstimation
|
|
9351
9326
|
}), toDestTxFee);
|
|
9352
|
-
case
|
|
9327
|
+
case 5:
|
|
9353
9328
|
_yield$dex$handleMult = _context.v;
|
|
9354
9329
|
amountOut = _yield$dex$handleMult.amountOut;
|
|
9355
9330
|
return _context.a(2, amountOut);
|
|
9356
9331
|
}
|
|
9357
9332
|
}, _callee);
|
|
9358
9333
|
}));
|
|
9359
|
-
return function (_x5, _x6, _x7, _x8) {
|
|
9334
|
+
return function (_x4, _x5, _x6, _x7, _x8) {
|
|
9360
9335
|
return _ref2.apply(this, arguments);
|
|
9361
9336
|
};
|
|
9362
|
-
}()
|
|
9337
|
+
}()));
|
|
9363
9338
|
}
|
|
9364
9339
|
}, _callee2);
|
|
9365
9340
|
}));
|
|
9366
|
-
return function selectBestExchange(_x, _x2, _x3
|
|
9341
|
+
return function selectBestExchange(_x, _x2, _x3) {
|
|
9367
9342
|
return _ref.apply(this, arguments);
|
|
9368
9343
|
};
|
|
9369
9344
|
}();
|
|
@@ -9381,16 +9356,16 @@ var resolveAssets = function resolveAssets(dex, _ref) {
|
|
|
9381
9356
|
if (originSpecified && !assetFromOrigin) {
|
|
9382
9357
|
throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " not found in ").concat(from, "."));
|
|
9383
9358
|
}
|
|
9384
|
-
var assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.
|
|
9359
|
+
var assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.chain, assetFromOrigin) : getExchangeAsset(dex.chain, currencyFrom);
|
|
9385
9360
|
if (!assetFromExchange) {
|
|
9386
|
-
if (!originSpecified && findAssetInfo(dex.chain, currencyFrom
|
|
9387
|
-
throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " exists in ").concat(dex.chain, " but is not swappable on ").concat(dex.
|
|
9361
|
+
if (!originSpecified && findAssetInfo(dex.chain, currencyFrom)) {
|
|
9362
|
+
throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " exists in ").concat(dex.chain, " but is not swappable on ").concat(dex.chain, "."));
|
|
9388
9363
|
}
|
|
9389
|
-
throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " not found in ").concat(dex.
|
|
9364
|
+
throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " not found in ").concat(dex.chain, "."));
|
|
9390
9365
|
}
|
|
9391
|
-
var assetTo = getExchangeAsset(dex.
|
|
9366
|
+
var assetTo = getExchangeAsset(dex.chain, currencyTo);
|
|
9392
9367
|
if (!assetTo) {
|
|
9393
|
-
throw new RoutingResolutionError("Currency to ".concat(JSON.stringify(currencyTo), " not found in ").concat(dex.
|
|
9368
|
+
throw new RoutingResolutionError("Currency to ".concat(JSON.stringify(currencyTo), " not found in ").concat(dex.chain, "."));
|
|
9394
9369
|
}
|
|
9395
9370
|
if (destinationSpecified && !hasSupportForAsset(to, assetTo.symbol)) {
|
|
9396
9371
|
throw new RoutingResolutionError("Currency to ".concat(JSON.stringify(currencyTo), " not supported by ").concat(to, "."));
|
|
@@ -9399,7 +9374,7 @@ var resolveAssets = function resolveAssets(dex, _ref) {
|
|
|
9399
9374
|
if (feeAsset && originSpecified && !feeAssetFromOrigin) {
|
|
9400
9375
|
throw new RoutingResolutionError("Fee asset ".concat(JSON.stringify(feeAsset), " not found in ").concat(from, "."));
|
|
9401
9376
|
}
|
|
9402
|
-
var feeAssetFromExchange = feeAsset ? feeAssetFromOrigin ? getExchangeAssetByOriginAsset(dex.
|
|
9377
|
+
var feeAssetFromExchange = feeAsset ? feeAssetFromOrigin ? getExchangeAssetByOriginAsset(dex.chain, feeAssetFromOrigin) : (_getExchangeAsset = getExchangeAsset(dex.chain, feeAsset)) !== null && _getExchangeAsset !== void 0 ? _getExchangeAsset : undefined : undefined;
|
|
9403
9378
|
var resolvedFeeAssetLocation = (_feeAssetFromOrigin$l = feeAssetFromOrigin === null || feeAssetFromOrigin === void 0 ? void 0 : feeAssetFromOrigin.location) !== null && _feeAssetFromOrigin$l !== void 0 ? _feeAssetFromOrigin$l : feeAssetFromExchange === null || feeAssetFromExchange === void 0 ? void 0 : feeAssetFromExchange.location;
|
|
9404
9379
|
if (feeAsset && resolvedFeeAssetLocation) {
|
|
9405
9380
|
var sdkAsset = findAssetInfoOrThrow(from !== null && from !== void 0 ? from : dex.chain, {
|
|
@@ -9419,18 +9394,16 @@ var resolveAssets = function resolveAssets(dex, _ref) {
|
|
|
9419
9394
|
};
|
|
9420
9395
|
|
|
9421
9396
|
var createToExchangeBuilder = function createToExchangeBuilder(_ref) {
|
|
9422
|
-
var
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
baseChain = _ref.exchange.baseChain,
|
|
9426
|
-
senderAddress = _ref.senderAddress,
|
|
9397
|
+
var origin = _ref.origin,
|
|
9398
|
+
exchange = _ref.exchange,
|
|
9399
|
+
sender = _ref.sender,
|
|
9427
9400
|
evmSenderAddress = _ref.evmSenderAddress,
|
|
9428
9401
|
amount = _ref.amount,
|
|
9429
|
-
|
|
9430
|
-
return Builder(
|
|
9431
|
-
location: assetFrom.location,
|
|
9402
|
+
api = _ref.api;
|
|
9403
|
+
return Builder(api.clone()).from(origin.chain).to(exchange.chain).currency({
|
|
9404
|
+
location: origin.assetFrom.location,
|
|
9432
9405
|
amount: amount
|
|
9433
|
-
}).
|
|
9406
|
+
}).sender(isChainEvm(origin.chain) ? evmSenderAddress : sender).recipient(sender);
|
|
9434
9407
|
};
|
|
9435
9408
|
var buildToExchangeExtrinsic = function buildToExchangeExtrinsic(options) {
|
|
9436
9409
|
return createToExchangeBuilder(options).build();
|
|
@@ -9441,22 +9414,16 @@ var getToExchangeFee = function getToExchangeFee(options, disableFallback) {
|
|
|
9441
9414
|
});
|
|
9442
9415
|
};
|
|
9443
9416
|
var createFromExchangeBuilder = function createFromExchangeBuilder(_ref2) {
|
|
9444
|
-
var
|
|
9445
|
-
|
|
9446
|
-
baseChain = _ref2$exchange.baseChain,
|
|
9447
|
-
assetTo = _ref2$exchange.assetTo,
|
|
9448
|
-
_ref2$destination = _ref2.destination,
|
|
9449
|
-
chain = _ref2$destination.chain,
|
|
9450
|
-
address = _ref2$destination.address,
|
|
9417
|
+
var exchange = _ref2.exchange,
|
|
9418
|
+
destination = _ref2.destination,
|
|
9451
9419
|
amount = _ref2.amount,
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
location: assetTo.location,
|
|
9420
|
+
sender = _ref2.sender,
|
|
9421
|
+
api = _ref2.api;
|
|
9422
|
+
var apiForChain = api.clone();
|
|
9423
|
+
return Builder(apiForChain).from(exchange.chain).to(destination.chain).currency({
|
|
9424
|
+
location: exchange.assetTo.location,
|
|
9458
9425
|
amount: amount
|
|
9459
|
-
}).
|
|
9426
|
+
}).sender(sender).recipient(destination.address);
|
|
9460
9427
|
};
|
|
9461
9428
|
var buildFromExchangeExtrinsic = function buildFromExchangeExtrinsic(options) {
|
|
9462
9429
|
return createFromExchangeBuilder(options).build();
|
|
@@ -9466,28 +9433,29 @@ var getFromExchangeFee = function getFromExchangeFee(options, disableFallback) {
|
|
|
9466
9433
|
disableFallback: disableFallback
|
|
9467
9434
|
});
|
|
9468
9435
|
};
|
|
9469
|
-
var determineFeeCalcAddress = function determineFeeCalcAddress(
|
|
9470
|
-
if (!ethers.isAddress(
|
|
9436
|
+
var determineFeeCalcAddress = function determineFeeCalcAddress(sender, recipient) {
|
|
9437
|
+
if (!ethers.isAddress(sender)) {
|
|
9471
9438
|
// Use wallet address for fee calculation
|
|
9472
|
-
return
|
|
9439
|
+
return sender;
|
|
9473
9440
|
}
|
|
9474
|
-
if (
|
|
9441
|
+
if (recipient && !ethers.isAddress(recipient)) {
|
|
9475
9442
|
// Use recipient address for fee calculation
|
|
9476
|
-
return
|
|
9443
|
+
return recipient;
|
|
9477
9444
|
}
|
|
9478
9445
|
// If both addresses are ethereum addresses, use fallback address for fee calculation
|
|
9479
9446
|
return FALLBACK_FEE_CALC_ADDRESS;
|
|
9480
9447
|
};
|
|
9481
9448
|
|
|
9482
9449
|
var prepareTransformedOptions = /*#__PURE__*/function () {
|
|
9483
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options
|
|
9450
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
9484
9451
|
var _assetFromOrigin$deci;
|
|
9485
9452
|
var isForFeeEstimation,
|
|
9453
|
+
api,
|
|
9486
9454
|
from,
|
|
9487
9455
|
to,
|
|
9488
9456
|
exchange,
|
|
9489
|
-
|
|
9490
|
-
|
|
9457
|
+
sender,
|
|
9458
|
+
recipient,
|
|
9491
9459
|
amount,
|
|
9492
9460
|
originApi,
|
|
9493
9461
|
dex,
|
|
@@ -9499,6 +9467,9 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
|
|
|
9499
9467
|
feeAssetFromExchange,
|
|
9500
9468
|
originSpecified,
|
|
9501
9469
|
destinationSpecified,
|
|
9470
|
+
exchangeApi,
|
|
9471
|
+
config,
|
|
9472
|
+
exchangeConfig,
|
|
9502
9473
|
transformed,
|
|
9503
9474
|
_args = arguments,
|
|
9504
9475
|
_t,
|
|
@@ -9517,19 +9488,18 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
|
|
|
9517
9488
|
_t12,
|
|
9518
9489
|
_t13,
|
|
9519
9490
|
_t14,
|
|
9520
|
-
_t15
|
|
9521
|
-
_t16;
|
|
9491
|
+
_t15;
|
|
9522
9492
|
return _regenerator().w(function (_context) {
|
|
9523
9493
|
while (1) switch (_context.n) {
|
|
9524
9494
|
case 0:
|
|
9525
|
-
isForFeeEstimation = _args.length >
|
|
9526
|
-
from = options.from, to = options.to, exchange = options.exchange,
|
|
9495
|
+
isForFeeEstimation = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
|
|
9496
|
+
api = options.api, from = options.from, to = options.to, exchange = options.exchange, sender = options.sender, recipient = options.recipient, amount = options.amount;
|
|
9527
9497
|
if (!from) {
|
|
9528
9498
|
_context.n = 2;
|
|
9529
9499
|
break;
|
|
9530
9500
|
}
|
|
9531
9501
|
_context.n = 1;
|
|
9532
|
-
return
|
|
9502
|
+
return api.createApiForChain(from);
|
|
9533
9503
|
case 1:
|
|
9534
9504
|
_t = _context.v;
|
|
9535
9505
|
_context.n = 3;
|
|
@@ -9547,13 +9517,13 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
|
|
|
9547
9517
|
break;
|
|
9548
9518
|
case 4:
|
|
9549
9519
|
_context.n = 5;
|
|
9550
|
-
return selectBestExchange(options, originApi
|
|
9520
|
+
return selectBestExchange(options, originApi === null || originApi === void 0 ? void 0 : originApi.api, isForFeeEstimation);
|
|
9551
9521
|
case 5:
|
|
9552
9522
|
_t2 = _context.v;
|
|
9553
9523
|
case 6:
|
|
9554
9524
|
dex = _t2;
|
|
9555
9525
|
_resolveAssets = resolveAssets(dex, options), assetFromOrigin = _resolveAssets.assetFromOrigin, assetFromExchange = _resolveAssets.assetFromExchange, assetTo = _resolveAssets.assetTo, feeAssetFromOrigin = _resolveAssets.feeAssetFromOrigin, feeAssetFromExchange = _resolveAssets.feeAssetFromExchange;
|
|
9556
|
-
if (supportsExchangePair(dex.
|
|
9526
|
+
if (supportsExchangePair(dex.chain, assetFromExchange, assetTo)) {
|
|
9557
9527
|
_context.n = 7;
|
|
9558
9528
|
break;
|
|
9559
9529
|
}
|
|
@@ -9561,51 +9531,55 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
|
|
|
9561
9531
|
case 7:
|
|
9562
9532
|
originSpecified = from && originApi && from !== dex.chain;
|
|
9563
9533
|
destinationSpecified = to && to !== dex.chain;
|
|
9534
|
+
_context.n = 8;
|
|
9535
|
+
return api.createApiForChain(dex.chain);
|
|
9536
|
+
case 8:
|
|
9537
|
+
exchangeApi = _context.v;
|
|
9538
|
+
config = api.config;
|
|
9539
|
+
exchangeConfig = convertBuilderConfig(config);
|
|
9564
9540
|
_t3 = _objectSpread2;
|
|
9565
9541
|
_t4 = _objectSpread2({}, options);
|
|
9566
9542
|
_t5 = {};
|
|
9567
|
-
_t6 = applyDecimalAbstraction(amount, (_assetFromOrigin$deci = assetFromOrigin === null || assetFromOrigin === void 0 ? void 0 : assetFromOrigin.decimals) !== null && _assetFromOrigin$deci !== void 0 ? _assetFromOrigin$deci : assetFromExchange.decimals,
|
|
9568
|
-
_t7 = originSpecified && assetFromOrigin ? {
|
|
9569
|
-
api: originApi,
|
|
9543
|
+
_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);
|
|
9544
|
+
_t7 = originSpecified && assetFromOrigin && originApi ? {
|
|
9545
|
+
api: originApi.api,
|
|
9570
9546
|
chain: from,
|
|
9571
9547
|
assetFrom: assetFromOrigin,
|
|
9572
9548
|
feeAssetInfo: feeAssetFromOrigin
|
|
9573
9549
|
} : undefined;
|
|
9574
|
-
_context.n = 8;
|
|
9575
|
-
return dex.createApiInstance(builderOptions);
|
|
9576
|
-
case 8:
|
|
9577
|
-
_t8 = _context.v;
|
|
9578
9550
|
_context.n = 9;
|
|
9579
|
-
return dex.
|
|
9551
|
+
return dex.createApiInstance(exchangeConfig);
|
|
9580
9552
|
case 9:
|
|
9553
|
+
_t8 = _context.v;
|
|
9554
|
+
_context.n = 10;
|
|
9555
|
+
return dex.createApiInstancePapi(exchangeConfig);
|
|
9556
|
+
case 10:
|
|
9581
9557
|
_t9 = _context.v;
|
|
9582
|
-
_t0 =
|
|
9583
|
-
_t1 = dex.
|
|
9558
|
+
_t0 = exchangeApi;
|
|
9559
|
+
_t1 = dex.chain;
|
|
9584
9560
|
_t10 = assetFromExchange;
|
|
9585
9561
|
_t11 = assetTo;
|
|
9586
9562
|
_t12 = feeAssetFromExchange;
|
|
9587
9563
|
_t13 = {
|
|
9588
|
-
|
|
9564
|
+
apiPjs: _t8,
|
|
9589
9565
|
apiPapi: _t9,
|
|
9590
|
-
|
|
9591
|
-
|
|
9566
|
+
api: _t0,
|
|
9567
|
+
chain: _t1,
|
|
9592
9568
|
assetFrom: _t10,
|
|
9593
9569
|
assetTo: _t11,
|
|
9594
9570
|
feeAssetInfo: _t12
|
|
9595
9571
|
};
|
|
9596
|
-
_t14 = destinationSpecified &&
|
|
9572
|
+
_t14 = destinationSpecified && recipient ? {
|
|
9597
9573
|
chain: to,
|
|
9598
|
-
address:
|
|
9574
|
+
address: recipient
|
|
9599
9575
|
} : undefined;
|
|
9600
|
-
_t15 = determineFeeCalcAddress(
|
|
9601
|
-
_t16 = builderOptions;
|
|
9576
|
+
_t15 = determineFeeCalcAddress(sender, recipient);
|
|
9602
9577
|
transformed = _t3(_t4, _t5, {
|
|
9603
9578
|
amount: _t6,
|
|
9604
9579
|
origin: _t7,
|
|
9605
9580
|
exchange: _t13,
|
|
9606
9581
|
destination: _t14,
|
|
9607
|
-
feeCalcAddress: _t15
|
|
9608
|
-
builderOptions: _t16
|
|
9582
|
+
feeCalcAddress: _t15
|
|
9609
9583
|
});
|
|
9610
9584
|
return _context.a(2, {
|
|
9611
9585
|
dex: dex,
|
|
@@ -9614,7 +9588,7 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
|
|
|
9614
9588
|
}
|
|
9615
9589
|
}, _callee);
|
|
9616
9590
|
}));
|
|
9617
|
-
return function prepareTransformedOptions(_x
|
|
9591
|
+
return function prepareTransformedOptions(_x) {
|
|
9618
9592
|
return _ref.apply(this, arguments);
|
|
9619
9593
|
};
|
|
9620
9594
|
}();
|
|
@@ -9639,20 +9613,20 @@ var validateTransferOptions = function validateTransferOptions(options) {
|
|
|
9639
9613
|
var from = options.from,
|
|
9640
9614
|
exchange = options.exchange,
|
|
9641
9615
|
evmSenderAddress = options.evmSenderAddress,
|
|
9642
|
-
|
|
9643
|
-
|
|
9616
|
+
sender = options.sender,
|
|
9617
|
+
recipient = options.recipient,
|
|
9644
9618
|
to = options.to;
|
|
9645
9619
|
if (exchange === undefined && from === undefined) {
|
|
9646
9620
|
throw new MissingParameterError('from', 'Origin chain is required when exchange is auto');
|
|
9647
9621
|
}
|
|
9648
|
-
if (to && !
|
|
9649
|
-
throw new MissingParameterError('
|
|
9622
|
+
if (to && !recipient) {
|
|
9623
|
+
throw new MissingParameterError('recipient', 'Recipient address is required');
|
|
9650
9624
|
}
|
|
9651
|
-
if (to &&
|
|
9625
|
+
if (to && recipient) validateDestinationAddress(recipient, to);
|
|
9652
9626
|
if (evmSenderAddress !== undefined && !ethers.isAddress(evmSenderAddress)) {
|
|
9653
9627
|
throw new InvalidAddressError('Evm injector address is not a valid Ethereum address');
|
|
9654
9628
|
}
|
|
9655
|
-
if (ethers.isAddress(
|
|
9629
|
+
if (ethers.isAddress(sender)) {
|
|
9656
9630
|
throw new InvalidAddressError('Injector address cannot be an Ethereum address. Please use an Evm injector address instead.');
|
|
9657
9631
|
}
|
|
9658
9632
|
if (from && isChainEvm(from) && !evmSenderAddress) {
|
|
@@ -9663,12 +9637,12 @@ var validateTransferOptions = function validateTransferOptions(options) {
|
|
|
9663
9637
|
var FEE_ESTIMATION_UNITS = '100';
|
|
9664
9638
|
var calculateFromExchangeFee = /*#__PURE__*/function () {
|
|
9665
9639
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
9666
|
-
var exchange, destination, feeCalcAddress,
|
|
9640
|
+
var exchange, destination, feeCalcAddress, sender, api, dummyAmount, tx, _yield$exchange$api$g, partialFee;
|
|
9667
9641
|
return _regenerator().w(function (_context) {
|
|
9668
9642
|
while (1) switch (_context.n) {
|
|
9669
9643
|
case 0:
|
|
9670
|
-
exchange = options.exchange, destination = options.destination, feeCalcAddress = options.feeCalcAddress,
|
|
9671
|
-
if (!(!destination || destination.chain === exchange.
|
|
9644
|
+
exchange = options.exchange, destination = options.destination, feeCalcAddress = options.feeCalcAddress, sender = options.sender, api = options.api;
|
|
9645
|
+
if (!(!destination || destination.chain === exchange.chain)) {
|
|
9672
9646
|
_context.n = 1;
|
|
9673
9647
|
break;
|
|
9674
9648
|
}
|
|
@@ -9680,12 +9654,17 @@ var calculateFromExchangeFee = /*#__PURE__*/function () {
|
|
|
9680
9654
|
exchange: exchange,
|
|
9681
9655
|
destination: destination,
|
|
9682
9656
|
amount: dummyAmount,
|
|
9683
|
-
|
|
9684
|
-
|
|
9657
|
+
sender: sender,
|
|
9658
|
+
api: api
|
|
9685
9659
|
});
|
|
9686
9660
|
case 2:
|
|
9687
9661
|
tx = _context.v;
|
|
9688
|
-
|
|
9662
|
+
_context.n = 3;
|
|
9663
|
+
return exchange.api.getPaymentInfo(tx, feeCalcAddress);
|
|
9664
|
+
case 3:
|
|
9665
|
+
_yield$exchange$api$g = _context.v;
|
|
9666
|
+
partialFee = _yield$exchange$api$g.partialFee;
|
|
9667
|
+
return _context.a(2, partialFee);
|
|
9689
9668
|
}
|
|
9690
9669
|
}, _callee);
|
|
9691
9670
|
}));
|
|
@@ -9709,7 +9688,7 @@ var createSwapTx = /*#__PURE__*/function () {
|
|
|
9709
9688
|
case 1:
|
|
9710
9689
|
toDestTxFee = _context2.v;
|
|
9711
9690
|
_context2.n = 2;
|
|
9712
|
-
return exchange.handleMultiSwap(options.exchange.
|
|
9691
|
+
return exchange.handleMultiSwap(options.exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
9713
9692
|
papiApi: options.exchange.apiPapi,
|
|
9714
9693
|
assetFrom: options.exchange.assetFrom,
|
|
9715
9694
|
assetTo: options.exchange.assetTo,
|
|
@@ -9719,7 +9698,7 @@ var createSwapTx = /*#__PURE__*/function () {
|
|
|
9719
9698
|
swapResult = _context2.v;
|
|
9720
9699
|
_context2.n = 3;
|
|
9721
9700
|
return Promise.all(swapResult.txs.map(function (tx) {
|
|
9722
|
-
return
|
|
9701
|
+
return convertTxToTarget(tx, options.exchange.api);
|
|
9723
9702
|
}));
|
|
9724
9703
|
case 3:
|
|
9725
9704
|
txs = _context2.v;
|
|
@@ -9737,18 +9716,18 @@ var createSwapTx = /*#__PURE__*/function () {
|
|
|
9737
9716
|
|
|
9738
9717
|
var prepareExtrinsics = /*#__PURE__*/function () {
|
|
9739
9718
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options) {
|
|
9740
|
-
var origin, exchange, destination, currencyTo, amount, evmSenderAddress,
|
|
9719
|
+
var api, origin, exchange, destination, currencyTo, amount, evmSenderAddress, sender, recipient, _origin$assetFrom, _origin$feeAssetInfo, _amountOut, tx, toExchangeTx, _yield$createSwapTx, swapTxs, amountOut, toDestTx, _t, _t2, _t3;
|
|
9741
9720
|
return _regenerator().w(function (_context) {
|
|
9742
9721
|
while (1) switch (_context.p = _context.n) {
|
|
9743
9722
|
case 0:
|
|
9744
|
-
origin = options.origin, exchange = options.exchange, destination = options.destination, currencyTo = options.currencyTo, amount = options.amount, evmSenderAddress = options.evmSenderAddress,
|
|
9723
|
+
api = options.api, origin = options.origin, exchange = options.exchange, destination = options.destination, currencyTo = options.currencyTo, amount = options.amount, evmSenderAddress = options.evmSenderAddress, sender = options.sender, recipient = options.recipient;
|
|
9745
9724
|
if (!((origin || destination) && (dex.chain.includes('AssetHub') || dex.chain === 'Hydration'))) {
|
|
9746
9725
|
_context.n = 5;
|
|
9747
9726
|
break;
|
|
9748
9727
|
}
|
|
9749
9728
|
_context.p = 1;
|
|
9750
9729
|
_context.n = 2;
|
|
9751
|
-
return dex.getAmountOut(exchange.
|
|
9730
|
+
return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
9752
9731
|
papiApi: exchange.apiPapi,
|
|
9753
9732
|
assetFrom: exchange.assetFrom,
|
|
9754
9733
|
assetTo: exchange.assetTo
|
|
@@ -9757,8 +9736,9 @@ var prepareExtrinsics = /*#__PURE__*/function () {
|
|
|
9757
9736
|
_amountOut = _context.v;
|
|
9758
9737
|
_context.n = 3;
|
|
9759
9738
|
return handleSwapExecuteTransfer({
|
|
9739
|
+
api: api,
|
|
9760
9740
|
chain: origin === null || origin === void 0 ? void 0 : origin.chain,
|
|
9761
|
-
exchangeChain: exchange.
|
|
9741
|
+
exchangeChain: exchange.chain,
|
|
9762
9742
|
destChain: destination === null || destination === void 0 ? void 0 : destination.chain,
|
|
9763
9743
|
assetInfoFrom: _objectSpread2(_objectSpread2({}, (_origin$assetFrom = origin === null || origin === void 0 ? void 0 : origin.assetFrom) !== null && _origin$assetFrom !== void 0 ? _origin$assetFrom : exchange.assetFrom), {}, {
|
|
9764
9744
|
amount: BigInt(amount)
|
|
@@ -9766,19 +9746,19 @@ var prepareExtrinsics = /*#__PURE__*/function () {
|
|
|
9766
9746
|
assetInfoTo: _objectSpread2(_objectSpread2({}, exchange.assetTo), {}, {
|
|
9767
9747
|
amount: _amountOut
|
|
9768
9748
|
}),
|
|
9769
|
-
|
|
9749
|
+
sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
|
|
9750
|
+
recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
|
|
9770
9751
|
currencyTo: currencyTo,
|
|
9771
9752
|
feeAssetInfo: (_origin$feeAssetInfo = origin === null || origin === void 0 ? void 0 : origin.feeAssetInfo) !== null && _origin$feeAssetInfo !== void 0 ? _origin$feeAssetInfo : exchange.feeAssetInfo,
|
|
9772
|
-
recipientAddress: recipientAddress !== null && recipientAddress !== void 0 ? recipientAddress : senderAddress,
|
|
9773
9753
|
calculateMinAmountOut: function calculateMinAmountOut(amountIn, assetTo) {
|
|
9774
|
-
return dex.getAmountOut(exchange.
|
|
9754
|
+
return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
9775
9755
|
amount: amountIn,
|
|
9776
9756
|
papiApi: options.exchange.apiPapi,
|
|
9777
9757
|
assetFrom: options.exchange.assetFrom,
|
|
9778
9758
|
assetTo: assetTo !== null && assetTo !== void 0 ? assetTo : options.exchange.assetTo
|
|
9779
9759
|
}));
|
|
9780
9760
|
}
|
|
9781
|
-
}
|
|
9761
|
+
});
|
|
9782
9762
|
case 3:
|
|
9783
9763
|
tx = _context.v;
|
|
9784
9764
|
return _context.a(2, {
|
|
@@ -9795,7 +9775,7 @@ var prepareExtrinsics = /*#__PURE__*/function () {
|
|
|
9795
9775
|
}
|
|
9796
9776
|
throw _t;
|
|
9797
9777
|
case 5:
|
|
9798
|
-
if (!(origin && origin.chain !== exchange.
|
|
9778
|
+
if (!(origin && origin.chain !== exchange.chain)) {
|
|
9799
9779
|
_context.n = 7;
|
|
9800
9780
|
break;
|
|
9801
9781
|
}
|
|
@@ -9817,7 +9797,7 @@ var prepareExtrinsics = /*#__PURE__*/function () {
|
|
|
9817
9797
|
_yield$createSwapTx = _context.v;
|
|
9818
9798
|
swapTxs = _yield$createSwapTx.txs;
|
|
9819
9799
|
amountOut = _yield$createSwapTx.amountOut;
|
|
9820
|
-
if (!(destination && destination.chain !== exchange.
|
|
9800
|
+
if (!(destination && destination.chain !== exchange.chain)) {
|
|
9821
9801
|
_context.n = 11;
|
|
9822
9802
|
break;
|
|
9823
9803
|
}
|
|
@@ -9826,8 +9806,8 @@ var prepareExtrinsics = /*#__PURE__*/function () {
|
|
|
9826
9806
|
exchange: exchange,
|
|
9827
9807
|
destination: destination,
|
|
9828
9808
|
amount: amountOut,
|
|
9829
|
-
|
|
9830
|
-
|
|
9809
|
+
sender: sender,
|
|
9810
|
+
api: api
|
|
9831
9811
|
});
|
|
9832
9812
|
case 10:
|
|
9833
9813
|
_t3 = _context.v;
|
|
@@ -9872,19 +9852,15 @@ var buildTransactions = /*#__PURE__*/function () {
|
|
|
9872
9852
|
transactions.push({
|
|
9873
9853
|
api: origin.api,
|
|
9874
9854
|
chain: origin.chain,
|
|
9875
|
-
destinationChain: exchange.
|
|
9855
|
+
destinationChain: exchange.chain,
|
|
9876
9856
|
tx: toExchangeTx,
|
|
9877
9857
|
type: 'TRANSFER'
|
|
9878
9858
|
});
|
|
9879
9859
|
}
|
|
9880
9860
|
if (toDestTx) {
|
|
9881
|
-
batchedTx = exchange.
|
|
9882
|
-
calls: [].concat(_toConsumableArray(swapTxs.map(function (tx) {
|
|
9883
|
-
return tx.decodedCall;
|
|
9884
|
-
})), [toDestTx.decodedCall])
|
|
9885
|
-
});
|
|
9861
|
+
batchedTx = exchange.api.callBatchMethod([].concat(_toConsumableArray(swapTxs), [toDestTx]), BatchMode.BATCH_ALL);
|
|
9886
9862
|
transactions.push({
|
|
9887
|
-
api: exchange.
|
|
9863
|
+
api: exchange.api.api,
|
|
9888
9864
|
chain: dex.chain,
|
|
9889
9865
|
destinationChain: destination === null || destination === void 0 ? void 0 : destination.chain,
|
|
9890
9866
|
tx: batchedTx,
|
|
@@ -9894,20 +9870,16 @@ var buildTransactions = /*#__PURE__*/function () {
|
|
|
9894
9870
|
} else {
|
|
9895
9871
|
if (swapTxs.length === 1) {
|
|
9896
9872
|
transactions.push({
|
|
9897
|
-
api: isExecute ? (_origin$api = origin === null || origin === void 0 ? void 0 : origin.api) !== null && _origin$api !== void 0 ? _origin$api : exchange.
|
|
9873
|
+
api: isExecute ? (_origin$api = origin === null || origin === void 0 ? void 0 : origin.api) !== null && _origin$api !== void 0 ? _origin$api : exchange.api.api : exchange.api.api,
|
|
9898
9874
|
chain: isExecute ? (_origin$chain = origin === null || origin === void 0 ? void 0 : origin.chain) !== null && _origin$chain !== void 0 ? _origin$chain : dex.chain : dex.chain,
|
|
9899
9875
|
tx: swapTxs[0],
|
|
9900
9876
|
amountOut: amountOut,
|
|
9901
9877
|
type: 'SWAP'
|
|
9902
9878
|
});
|
|
9903
9879
|
} else {
|
|
9904
|
-
batchedSwapTx = exchange.
|
|
9905
|
-
calls: swapTxs.map(function (tx) {
|
|
9906
|
-
return tx.decodedCall;
|
|
9907
|
-
})
|
|
9908
|
-
});
|
|
9880
|
+
batchedSwapTx = exchange.api.callBatchMethod(swapTxs, BatchMode.BATCH_ALL);
|
|
9909
9881
|
transactions.push({
|
|
9910
|
-
api: exchange.
|
|
9882
|
+
api: exchange.api.api,
|
|
9911
9883
|
chain: dex.chain,
|
|
9912
9884
|
tx: batchedSwapTx,
|
|
9913
9885
|
amountOut: amountOut,
|
|
@@ -9925,14 +9897,14 @@ var buildTransactions = /*#__PURE__*/function () {
|
|
|
9925
9897
|
}();
|
|
9926
9898
|
|
|
9927
9899
|
var buildApiTransactions = /*#__PURE__*/function () {
|
|
9928
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions
|
|
9900
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions) {
|
|
9929
9901
|
var _yield$prepareTransfo, options, dex;
|
|
9930
9902
|
return _regenerator().w(function (_context) {
|
|
9931
9903
|
while (1) switch (_context.n) {
|
|
9932
9904
|
case 0:
|
|
9933
9905
|
validateTransferOptions(initialOptions);
|
|
9934
9906
|
_context.n = 1;
|
|
9935
|
-
return prepareTransformedOptions(initialOptions
|
|
9907
|
+
return prepareTransformedOptions(initialOptions);
|
|
9936
9908
|
case 1:
|
|
9937
9909
|
_yield$prepareTransfo = _context.v;
|
|
9938
9910
|
options = _yield$prepareTransfo.options;
|
|
@@ -9941,7 +9913,7 @@ var buildApiTransactions = /*#__PURE__*/function () {
|
|
|
9941
9913
|
}
|
|
9942
9914
|
}, _callee);
|
|
9943
9915
|
}));
|
|
9944
|
-
return function buildApiTransactions(_x
|
|
9916
|
+
return function buildApiTransactions(_x) {
|
|
9945
9917
|
return _ref.apply(this, arguments);
|
|
9946
9918
|
};
|
|
9947
9919
|
}();
|
|
@@ -9957,7 +9929,7 @@ var assignIsExchange = function assignIsExchange(result, options) {
|
|
|
9957
9929
|
result.destination.isExchange = true;
|
|
9958
9930
|
}
|
|
9959
9931
|
result.hops = result.hops.map(function (hop) {
|
|
9960
|
-
var isExchange = hop.chain === exchange.
|
|
9932
|
+
var isExchange = hop.chain === exchange.chain;
|
|
9961
9933
|
return _objectSpread2(_objectSpread2({}, hop), {}, {
|
|
9962
9934
|
result: _objectSpread2(_objectSpread2({}, hop.result), {}, {
|
|
9963
9935
|
isExchange: isExchange
|
|
@@ -9970,25 +9942,23 @@ var assignIsExchange = function assignIsExchange(result, options) {
|
|
|
9970
9942
|
var dryRunTransaction = /*#__PURE__*/function () {
|
|
9971
9943
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, transaction, destChain, bypassOptions) {
|
|
9972
9944
|
var _ref2;
|
|
9973
|
-
var exchange,
|
|
9945
|
+
var api, exchange, sender, evmSenderAddress, destination, currencyFrom, currencyTo, amount, tx, chain, senderResolved, resolvedDest;
|
|
9974
9946
|
return _regenerator().w(function (_context) {
|
|
9975
9947
|
while (1) switch (_context.n) {
|
|
9976
9948
|
case 0:
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
resolvedDest = (_ref2 = destChain !== null && destChain !== void 0 ? destChain : destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _ref2 !== void 0 ? _ref2 : exchange.baseChain;
|
|
9949
|
+
api = options.api, exchange = options.exchange, sender = options.sender, evmSenderAddress = options.evmSenderAddress, destination = options.destination, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, amount = options.amount;
|
|
9950
|
+
tx = transaction.tx, chain = transaction.chain;
|
|
9951
|
+
senderResolved = evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender;
|
|
9952
|
+
resolvedDest = (_ref2 = destChain !== null && destChain !== void 0 ? destChain : destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _ref2 !== void 0 ? _ref2 : exchange.chain;
|
|
9982
9953
|
return _context.a(2, dryRun({
|
|
9983
|
-
api: api,
|
|
9954
|
+
api: api.clone(),
|
|
9984
9955
|
tx: tx,
|
|
9985
9956
|
origin: chain,
|
|
9986
9957
|
destination: resolvedDest,
|
|
9987
|
-
|
|
9988
|
-
address: address,
|
|
9958
|
+
sender: senderResolved,
|
|
9989
9959
|
swapConfig: {
|
|
9990
9960
|
currencyTo: currencyTo,
|
|
9991
|
-
exchangeChain: exchange.
|
|
9961
|
+
exchangeChain: exchange.chain
|
|
9992
9962
|
},
|
|
9993
9963
|
currency: _objectSpread2(_objectSpread2({}, currencyFrom), {}, {
|
|
9994
9964
|
amount: BigInt(amount)
|
|
@@ -10009,7 +9979,7 @@ var mergeDryRunResults = function mergeDryRunResults(options, originResult, exch
|
|
|
10009
9979
|
origin: originResult.origin,
|
|
10010
9980
|
destination: destination ? exchangeResult.destination : exchangeResult.origin,
|
|
10011
9981
|
hops: [].concat(_toConsumableArray(originResult.hops), _toConsumableArray(destination ? [{
|
|
10012
|
-
chain: exchange.
|
|
9982
|
+
chain: exchange.chain,
|
|
10013
9983
|
result: exchangeResult.origin
|
|
10014
9984
|
}] : []), _toConsumableArray(exchangeResult.hops))
|
|
10015
9985
|
};
|
|
@@ -10024,7 +9994,7 @@ var dryRun2Transactions = /*#__PURE__*/function () {
|
|
|
10024
9994
|
exchange = options.exchange;
|
|
10025
9995
|
_transactions = _slicedToArray(transactions, 2), firstTx = _transactions[0], secondTx = _transactions[1];
|
|
10026
9996
|
_context2.n = 1;
|
|
10027
|
-
return dryRunTransaction(options, firstTx, exchange.
|
|
9997
|
+
return dryRunTransaction(options, firstTx, exchange.chain);
|
|
10028
9998
|
case 1:
|
|
10029
9999
|
firstRes = _context2.v;
|
|
10030
10000
|
_getFailureInfo = getFailureInfo(firstRes), failureReason = _getFailureInfo.failureReason;
|
|
@@ -10054,14 +10024,14 @@ var dryRunTransactions = function dryRunTransactions(transactions, options) {
|
|
|
10054
10024
|
throw new UnsupportedOperationError('Router dry run supports up to two transactions per flow.');
|
|
10055
10025
|
};
|
|
10056
10026
|
var dryRunRouter = /*#__PURE__*/function () {
|
|
10057
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(initialOptions
|
|
10027
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(initialOptions) {
|
|
10058
10028
|
var _yield$prepareTransfo, options, dex, routerPlan, result;
|
|
10059
10029
|
return _regenerator().w(function (_context3) {
|
|
10060
10030
|
while (1) switch (_context3.n) {
|
|
10061
10031
|
case 0:
|
|
10062
10032
|
validateTransferOptions(initialOptions);
|
|
10063
10033
|
_context3.n = 1;
|
|
10064
|
-
return prepareTransformedOptions(initialOptions
|
|
10034
|
+
return prepareTransformedOptions(initialOptions);
|
|
10065
10035
|
case 1:
|
|
10066
10036
|
_yield$prepareTransfo = _context3.v;
|
|
10067
10037
|
options = _yield$prepareTransfo.options;
|
|
@@ -10078,18 +10048,18 @@ var dryRunRouter = /*#__PURE__*/function () {
|
|
|
10078
10048
|
}
|
|
10079
10049
|
}, _callee3);
|
|
10080
10050
|
}));
|
|
10081
|
-
return function dryRunRouter(_x7
|
|
10051
|
+
return function dryRunRouter(_x7) {
|
|
10082
10052
|
return _ref4.apply(this, arguments);
|
|
10083
10053
|
};
|
|
10084
10054
|
}();
|
|
10085
10055
|
|
|
10086
10056
|
var getSwapFee = /*#__PURE__*/function () {
|
|
10087
10057
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(exchange, options, disableFallback) {
|
|
10088
|
-
var
|
|
10058
|
+
var sender, _options$exchange, assetFrom, api, amount, txs, amountOut, isForFeeEstimation, swapResult, buildTx, result, finalFee, _t;
|
|
10089
10059
|
return _regenerator().w(function (_context2) {
|
|
10090
10060
|
while (1) switch (_context2.p = _context2.n) {
|
|
10091
10061
|
case 0:
|
|
10092
|
-
|
|
10062
|
+
sender = options.sender, _options$exchange = options.exchange, assetFrom = _options$exchange.assetFrom, api = _options$exchange.api, amount = options.amount;
|
|
10093
10063
|
isForFeeEstimation = true;
|
|
10094
10064
|
_context2.p = 1;
|
|
10095
10065
|
_context2.n = 2;
|
|
@@ -10136,11 +10106,11 @@ var getSwapFee = /*#__PURE__*/function () {
|
|
|
10136
10106
|
}();
|
|
10137
10107
|
_context2.n = 6;
|
|
10138
10108
|
return getOriginXcmFee({
|
|
10139
|
-
api:
|
|
10109
|
+
api: api,
|
|
10140
10110
|
buildTx: buildTx,
|
|
10141
10111
|
origin: exchange.chain,
|
|
10142
10112
|
destination: exchange.chain,
|
|
10143
|
-
|
|
10113
|
+
sender: sender,
|
|
10144
10114
|
currency: {
|
|
10145
10115
|
location: assetFrom.location,
|
|
10146
10116
|
amount: amount
|
|
@@ -10167,11 +10137,11 @@ var getSwapFee = /*#__PURE__*/function () {
|
|
|
10167
10137
|
var getRouterFees = /*#__PURE__*/function () {
|
|
10168
10138
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(dex, options, disableFallback) {
|
|
10169
10139
|
var _sendingChain$hops, _receivingChain$origi, _receivingChain$hops, _sendingChain$origin, _receivingChain$desti, _sendingChain$failure, _sendingChain$failure2;
|
|
10170
|
-
var origin, exchange, currencyFrom, currencyTo, feeAsset, destination, amount,
|
|
10140
|
+
var api, origin, exchange, currencyFrom, currencyTo, feeAsset, destination, amount, sender, recipient, evmSenderAddress, _origin$chain, _destination$chain, buildTx, mainAmountOut, executeResult, transformedHops, sendingChain, _yield$getSwapFee, swapChain, amountOut, receivingChain, mergedHops, finalOrigin, finalDestination, _t, _t2, _t3;
|
|
10171
10141
|
return _regenerator().w(function (_context2) {
|
|
10172
10142
|
while (1) switch (_context2.p = _context2.n) {
|
|
10173
10143
|
case 0:
|
|
10174
|
-
origin = options.origin, exchange = options.exchange, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, feeAsset = options.feeAsset, destination = options.destination, amount = options.amount,
|
|
10144
|
+
api = options.api, origin = options.origin, exchange = options.exchange, currencyFrom = options.currencyFrom, currencyTo = options.currencyTo, feeAsset = options.feeAsset, destination = options.destination, amount = options.amount, sender = options.sender, recipient = options.recipient, evmSenderAddress = options.evmSenderAddress;
|
|
10175
10145
|
if (!((origin || destination) && (dex.chain.includes('AssetHub') || dex.chain === 'Hydration'))) {
|
|
10176
10146
|
_context2.n = 6;
|
|
10177
10147
|
break;
|
|
@@ -10186,7 +10156,7 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10186
10156
|
case 0:
|
|
10187
10157
|
amt = overrideAmount !== undefined ? applyDecimalAbstraction(overrideAmount, exchange.assetFrom.decimals, true) : amount;
|
|
10188
10158
|
_context.n = 1;
|
|
10189
|
-
return dex.getAmountOut(exchange.
|
|
10159
|
+
return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
10190
10160
|
amount: amt,
|
|
10191
10161
|
papiApi: exchange.apiPapi,
|
|
10192
10162
|
assetFrom: exchange.assetFrom,
|
|
@@ -10196,8 +10166,9 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10196
10166
|
amountOut = _context.v;
|
|
10197
10167
|
_context.n = 2;
|
|
10198
10168
|
return handleSwapExecuteTransfer({
|
|
10169
|
+
api: api,
|
|
10199
10170
|
chain: origin === null || origin === void 0 ? void 0 : origin.chain,
|
|
10200
|
-
exchangeChain: exchange.
|
|
10171
|
+
exchangeChain: exchange.chain,
|
|
10201
10172
|
destChain: destination === null || destination === void 0 ? void 0 : destination.chain,
|
|
10202
10173
|
assetInfoFrom: _objectSpread2(_objectSpread2({}, (_origin$assetFrom = origin === null || origin === void 0 ? void 0 : origin.assetFrom) !== null && _origin$assetFrom !== void 0 ? _origin$assetFrom : exchange.assetFrom), {}, {
|
|
10203
10174
|
amount: BigInt(amt)
|
|
@@ -10207,10 +10178,10 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10207
10178
|
}),
|
|
10208
10179
|
currencyTo: currencyTo,
|
|
10209
10180
|
feeAssetInfo: (_origin$feeAssetInfo = origin === null || origin === void 0 ? void 0 : origin.feeAssetInfo) !== null && _origin$feeAssetInfo !== void 0 ? _origin$feeAssetInfo : exchange.feeAssetInfo,
|
|
10210
|
-
|
|
10211
|
-
|
|
10181
|
+
sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
|
|
10182
|
+
recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
|
|
10212
10183
|
calculateMinAmountOut: function calculateMinAmountOut(amountIn, assetTo) {
|
|
10213
|
-
return dex.getAmountOut(exchange.
|
|
10184
|
+
return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
10214
10185
|
amount: amountIn,
|
|
10215
10186
|
papiApi: options.exchange.apiPapi,
|
|
10216
10187
|
assetFrom: options.exchange.assetFrom,
|
|
@@ -10218,7 +10189,7 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10218
10189
|
slippagePct: '1'
|
|
10219
10190
|
}));
|
|
10220
10191
|
}
|
|
10221
|
-
}
|
|
10192
|
+
});
|
|
10222
10193
|
case 2:
|
|
10223
10194
|
tx = _context.v;
|
|
10224
10195
|
return _context.a(2, tx);
|
|
@@ -10230,7 +10201,7 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10230
10201
|
};
|
|
10231
10202
|
}();
|
|
10232
10203
|
_context2.n = 2;
|
|
10233
|
-
return dex.getAmountOut(exchange.
|
|
10204
|
+
return dex.getAmountOut(exchange.apiPjs, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
10234
10205
|
amount: amount,
|
|
10235
10206
|
papiApi: exchange.apiPapi,
|
|
10236
10207
|
assetFrom: exchange.assetFrom,
|
|
@@ -10240,11 +10211,12 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10240
10211
|
mainAmountOut = _context2.v;
|
|
10241
10212
|
_context2.n = 3;
|
|
10242
10213
|
return getXcmFee({
|
|
10214
|
+
api: api,
|
|
10243
10215
|
buildTx: buildTx,
|
|
10244
|
-
origin: (_origin$chain = origin === null || origin === void 0 ? void 0 : origin.chain) !== null && _origin$chain !== void 0 ? _origin$chain : exchange.
|
|
10245
|
-
destination: (_destination$chain = destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _destination$chain !== void 0 ? _destination$chain : exchange.
|
|
10246
|
-
|
|
10247
|
-
|
|
10216
|
+
origin: (_origin$chain = origin === null || origin === void 0 ? void 0 : origin.chain) !== null && _origin$chain !== void 0 ? _origin$chain : exchange.chain,
|
|
10217
|
+
destination: (_destination$chain = destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _destination$chain !== void 0 ? _destination$chain : exchange.chain,
|
|
10218
|
+
sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
|
|
10219
|
+
recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
|
|
10248
10220
|
currency: _objectSpread2(_objectSpread2({}, currencyFrom), {}, {
|
|
10249
10221
|
amount: BigInt(amount)
|
|
10250
10222
|
}),
|
|
@@ -10252,23 +10224,26 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10252
10224
|
disableFallback: disableFallback,
|
|
10253
10225
|
swapConfig: {
|
|
10254
10226
|
currencyTo: currencyTo,
|
|
10255
|
-
exchangeChain: exchange.
|
|
10227
|
+
exchangeChain: exchange.chain,
|
|
10256
10228
|
amountOut: mainAmountOut
|
|
10257
10229
|
}
|
|
10258
|
-
}
|
|
10230
|
+
});
|
|
10259
10231
|
case 3:
|
|
10260
10232
|
executeResult = _context2.v;
|
|
10261
|
-
if (!(executeResult.failureReason === 'NoDeal' && exchange.
|
|
10233
|
+
if (!(executeResult.failureReason === 'NoDeal' && exchange.chain === 'Hydration')) {
|
|
10262
10234
|
_context2.n = 4;
|
|
10263
10235
|
break;
|
|
10264
10236
|
}
|
|
10265
10237
|
throw new RoutingResolutionError('An error occured, either this route is not registered for swap on exchange chain, or the amount out was not able to be calculated.');
|
|
10266
10238
|
case 4:
|
|
10267
10239
|
transformedHops = executeResult.hops.map(function (hop) {
|
|
10268
|
-
if (hop.chain === exchange.
|
|
10269
|
-
return
|
|
10270
|
-
|
|
10271
|
-
|
|
10240
|
+
if (hop.chain === exchange.chain) {
|
|
10241
|
+
return {
|
|
10242
|
+
chain: hop.chain,
|
|
10243
|
+
result: _objectSpread2(_objectSpread2({}, hop.result), {}, {
|
|
10244
|
+
isExchange: true
|
|
10245
|
+
})
|
|
10246
|
+
};
|
|
10272
10247
|
}
|
|
10273
10248
|
return hop;
|
|
10274
10249
|
});
|
|
@@ -10290,7 +10265,7 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10290
10265
|
}
|
|
10291
10266
|
throw _t;
|
|
10292
10267
|
case 6:
|
|
10293
|
-
if (!(origin && origin.chain !== exchange.
|
|
10268
|
+
if (!(origin && origin.chain !== exchange.chain)) {
|
|
10294
10269
|
_context2.n = 8;
|
|
10295
10270
|
break;
|
|
10296
10271
|
}
|
|
@@ -10312,7 +10287,7 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10312
10287
|
_yield$getSwapFee = _context2.v;
|
|
10313
10288
|
swapChain = _yield$getSwapFee.result;
|
|
10314
10289
|
amountOut = _yield$getSwapFee.amountOut;
|
|
10315
|
-
if (!(destination && destination.chain !== exchange.
|
|
10290
|
+
if (!(destination && destination.chain !== exchange.chain)) {
|
|
10316
10291
|
_context2.n = 12;
|
|
10317
10292
|
break;
|
|
10318
10293
|
}
|
|
@@ -10321,8 +10296,8 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10321
10296
|
exchange: exchange,
|
|
10322
10297
|
destination: destination,
|
|
10323
10298
|
amount: amountOut,
|
|
10324
|
-
|
|
10325
|
-
|
|
10299
|
+
sender: sender,
|
|
10300
|
+
api: api
|
|
10326
10301
|
}, disableFallback);
|
|
10327
10302
|
case 11:
|
|
10328
10303
|
_t3 = _context2.v;
|
|
@@ -10333,12 +10308,11 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10333
10308
|
case 13:
|
|
10334
10309
|
receivingChain = _t3;
|
|
10335
10310
|
mergedHops = [].concat(_toConsumableArray((_sendingChain$hops = sendingChain === null || sendingChain === void 0 ? void 0 : sendingChain.hops) !== null && _sendingChain$hops !== void 0 ? _sendingChain$hops : []), _toConsumableArray(sendingChain && receivingChain ? [{
|
|
10336
|
-
chain: exchange.
|
|
10311
|
+
chain: exchange.chain,
|
|
10337
10312
|
result: _objectSpread2(_objectSpread2({}, swapChain), {}, {
|
|
10338
10313
|
fee: swapChain.fee + ((_receivingChain$origi = receivingChain === null || receivingChain === void 0 ? void 0 : receivingChain.origin.fee) !== null && _receivingChain$origi !== void 0 ? _receivingChain$origi : 0n),
|
|
10339
10314
|
isExchange: true
|
|
10340
|
-
})
|
|
10341
|
-
isExchange: true
|
|
10315
|
+
})
|
|
10342
10316
|
}] : []), _toConsumableArray((_receivingChain$hops = receivingChain === null || receivingChain === void 0 ? void 0 : receivingChain.hops) !== null && _receivingChain$hops !== void 0 ? _receivingChain$hops : []));
|
|
10343
10317
|
finalOrigin = (_sendingChain$origin = sendingChain === null || sendingChain === void 0 ? void 0 : sendingChain.origin) !== null && _sendingChain$origin !== void 0 ? _sendingChain$origin : _objectSpread2(_objectSpread2({}, swapChain), !origin && {
|
|
10344
10318
|
isExchange: true
|
|
@@ -10364,14 +10338,14 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10364
10338
|
}();
|
|
10365
10339
|
|
|
10366
10340
|
var getXcmFees = /*#__PURE__*/function () {
|
|
10367
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions, disableFallback
|
|
10341
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions, disableFallback) {
|
|
10368
10342
|
var _yield$prepareTransfo, options, dex;
|
|
10369
10343
|
return _regenerator().w(function (_context) {
|
|
10370
10344
|
while (1) switch (_context.n) {
|
|
10371
10345
|
case 0:
|
|
10372
10346
|
validateTransferOptions(initialOptions);
|
|
10373
10347
|
_context.n = 1;
|
|
10374
|
-
return prepareTransformedOptions(initialOptions,
|
|
10348
|
+
return prepareTransformedOptions(initialOptions, true);
|
|
10375
10349
|
case 1:
|
|
10376
10350
|
_yield$prepareTransfo = _context.v;
|
|
10377
10351
|
options = _yield$prepareTransfo.options;
|
|
@@ -10380,65 +10354,65 @@ var getXcmFees = /*#__PURE__*/function () {
|
|
|
10380
10354
|
}
|
|
10381
10355
|
}, _callee);
|
|
10382
10356
|
}));
|
|
10383
|
-
return function getXcmFees(_x, _x2
|
|
10357
|
+
return function getXcmFees(_x, _x2) {
|
|
10384
10358
|
return _ref.apply(this, arguments);
|
|
10385
10359
|
};
|
|
10386
10360
|
}();
|
|
10387
10361
|
|
|
10388
10362
|
var selectBestExchangeAmountOut = /*#__PURE__*/function () {
|
|
10389
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi
|
|
10363
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, originApi) {
|
|
10390
10364
|
return _regenerator().w(function (_context2) {
|
|
10391
10365
|
while (1) switch (_context2.n) {
|
|
10392
10366
|
case 0:
|
|
10393
10367
|
return _context2.a(2, selectBestExchangeCommon(options, originApi, /*#__PURE__*/function () {
|
|
10394
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo,
|
|
10395
|
-
var
|
|
10368
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, _options, parsedAmount) {
|
|
10369
|
+
var pjsApi, papiApi;
|
|
10396
10370
|
return _regenerator().w(function (_context) {
|
|
10397
10371
|
while (1) switch (_context.n) {
|
|
10398
10372
|
case 0:
|
|
10399
10373
|
_context.n = 1;
|
|
10400
10374
|
return dex.createApiInstance();
|
|
10401
10375
|
case 1:
|
|
10402
|
-
|
|
10376
|
+
pjsApi = _context.v;
|
|
10403
10377
|
_context.n = 2;
|
|
10404
10378
|
return dex.createApiInstancePapi();
|
|
10405
10379
|
case 2:
|
|
10406
10380
|
papiApi = _context.v;
|
|
10407
|
-
return _context.a(2, dex.getAmountOut(
|
|
10381
|
+
return _context.a(2, dex.getAmountOut(pjsApi, {
|
|
10408
10382
|
papiApi: papiApi,
|
|
10409
10383
|
assetFrom: assetFromExchange,
|
|
10410
10384
|
assetTo: assetTo,
|
|
10411
|
-
amount: BigInt(
|
|
10385
|
+
amount: BigInt(parsedAmount)
|
|
10412
10386
|
}));
|
|
10413
10387
|
}
|
|
10414
10388
|
}, _callee);
|
|
10415
10389
|
}));
|
|
10416
|
-
return function (_x4, _x5, _x6, _x7) {
|
|
10390
|
+
return function (_x3, _x4, _x5, _x6, _x7) {
|
|
10417
10391
|
return _ref2.apply(this, arguments);
|
|
10418
10392
|
};
|
|
10419
|
-
}()
|
|
10393
|
+
}()));
|
|
10420
10394
|
}
|
|
10421
10395
|
}, _callee2);
|
|
10422
10396
|
}));
|
|
10423
|
-
return function selectBestExchangeAmountOut(_x, _x2
|
|
10397
|
+
return function selectBestExchangeAmountOut(_x, _x2) {
|
|
10424
10398
|
return _ref.apply(this, arguments);
|
|
10425
10399
|
};
|
|
10426
10400
|
}();
|
|
10427
10401
|
|
|
10428
10402
|
var getBestAmountOut = /*#__PURE__*/function () {
|
|
10429
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options
|
|
10403
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
10430
10404
|
var _assetFromOrigin$deci;
|
|
10431
|
-
var exchange, amount, from, originApi, isExchangeAutoSelect, dex, _resolveAssets, assetFromOrigin, assetFrom, assetTo, res,
|
|
10405
|
+
var api, exchange, amount, from, originApi, isExchangeAutoSelect, dex, _resolveAssets, assetFromOrigin, assetFrom, assetTo, res, config, exchangeConfig, pjsApi, papiApi, _t, _t2, _t3, _t4;
|
|
10432
10406
|
return _regenerator().w(function (_context) {
|
|
10433
10407
|
while (1) switch (_context.n) {
|
|
10434
10408
|
case 0:
|
|
10435
|
-
exchange = options.exchange, amount = options.amount, from = options.from;
|
|
10409
|
+
api = options.api, exchange = options.exchange, amount = options.amount, from = options.from;
|
|
10436
10410
|
if (!from) {
|
|
10437
10411
|
_context.n = 2;
|
|
10438
10412
|
break;
|
|
10439
10413
|
}
|
|
10440
10414
|
_context.n = 1;
|
|
10441
|
-
return createChainClient$
|
|
10415
|
+
return createChainClient$2(api, from);
|
|
10442
10416
|
case 1:
|
|
10443
10417
|
_t = _context.v;
|
|
10444
10418
|
_context.n = 3;
|
|
@@ -10453,7 +10427,7 @@ var getBestAmountOut = /*#__PURE__*/function () {
|
|
|
10453
10427
|
break;
|
|
10454
10428
|
}
|
|
10455
10429
|
_context.n = 4;
|
|
10456
|
-
return selectBestExchangeAmountOut(options, originApi
|
|
10430
|
+
return selectBestExchangeAmountOut(options, originApi);
|
|
10457
10431
|
case 4:
|
|
10458
10432
|
_t2 = _context.v;
|
|
10459
10433
|
_context.n = 6;
|
|
@@ -10468,7 +10442,7 @@ var getBestAmountOut = /*#__PURE__*/function () {
|
|
|
10468
10442
|
break;
|
|
10469
10443
|
}
|
|
10470
10444
|
_context.n = 7;
|
|
10471
|
-
return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin
|
|
10445
|
+
return canBuildToExchangeTx(options, dex.chain, originApi, assetFromOrigin);
|
|
10472
10446
|
case 7:
|
|
10473
10447
|
res = _context.v;
|
|
10474
10448
|
if (res.success) {
|
|
@@ -10477,21 +10451,23 @@ var getBestAmountOut = /*#__PURE__*/function () {
|
|
|
10477
10451
|
}
|
|
10478
10452
|
throw res.error;
|
|
10479
10453
|
case 8:
|
|
10454
|
+
config = api.config;
|
|
10455
|
+
exchangeConfig = convertBuilderConfig(config);
|
|
10480
10456
|
_context.n = 9;
|
|
10481
|
-
return dex.createApiInstance(
|
|
10457
|
+
return dex.createApiInstance(exchangeConfig);
|
|
10482
10458
|
case 9:
|
|
10483
|
-
|
|
10459
|
+
pjsApi = _context.v;
|
|
10484
10460
|
_context.n = 10;
|
|
10485
|
-
return dex.createApiInstancePapi(
|
|
10461
|
+
return dex.createApiInstancePapi(exchangeConfig);
|
|
10486
10462
|
case 10:
|
|
10487
10463
|
papiApi = _context.v;
|
|
10488
|
-
_t3 = dex.
|
|
10464
|
+
_t3 = dex.chain;
|
|
10489
10465
|
_context.n = 11;
|
|
10490
|
-
return dex.getAmountOut(
|
|
10466
|
+
return dex.getAmountOut(pjsApi, {
|
|
10491
10467
|
papiApi: papiApi,
|
|
10492
10468
|
assetFrom: assetFrom,
|
|
10493
10469
|
assetTo: assetTo,
|
|
10494
|
-
amount: applyDecimalAbstraction(amount, (_assetFromOrigin$deci = assetFromOrigin === null || assetFromOrigin === void 0 ? void 0 : assetFromOrigin.decimals) !== null && _assetFromOrigin$deci !== void 0 ? _assetFromOrigin$deci : assetFrom.decimals,
|
|
10470
|
+
amount: applyDecimalAbstraction(amount, (_assetFromOrigin$deci = assetFromOrigin === null || assetFromOrigin === void 0 ? void 0 : assetFromOrigin.decimals) !== null && _assetFromOrigin$deci !== void 0 ? _assetFromOrigin$deci : assetFrom.decimals, (exchangeConfig === null || exchangeConfig === void 0 ? void 0 : exchangeConfig.abstractDecimals) !== false)
|
|
10495
10471
|
});
|
|
10496
10472
|
case 11:
|
|
10497
10473
|
_t4 = _context.v;
|
|
@@ -10502,7 +10478,7 @@ var getBestAmountOut = /*#__PURE__*/function () {
|
|
|
10502
10478
|
}
|
|
10503
10479
|
}, _callee);
|
|
10504
10480
|
}));
|
|
10505
|
-
return function getBestAmountOut(_x
|
|
10481
|
+
return function getBestAmountOut(_x) {
|
|
10506
10482
|
return _ref.apply(this, arguments);
|
|
10507
10483
|
};
|
|
10508
10484
|
}();
|
|
@@ -10515,10 +10491,10 @@ var computeExchangeMinAmount = /*#__PURE__*/function () {
|
|
|
10515
10491
|
while (1) switch (_context.n) {
|
|
10516
10492
|
case 0:
|
|
10517
10493
|
exchange = options.exchange;
|
|
10518
|
-
existentialDeposit = getExistentialDepositOrThrow(exchange.
|
|
10494
|
+
existentialDeposit = getExistentialDepositOrThrow(exchange.chain, {
|
|
10519
10495
|
location: exchange.assetFrom.location
|
|
10520
10496
|
});
|
|
10521
|
-
nativeSymbol = getNativeAssetSymbol(exchange.
|
|
10497
|
+
nativeSymbol = getNativeAssetSymbol(exchange.chain);
|
|
10522
10498
|
isNativeAsset = exchange.assetFrom.symbol === nativeSymbol;
|
|
10523
10499
|
if (isNativeAsset) {
|
|
10524
10500
|
_context.n = 1;
|
|
@@ -10541,19 +10517,19 @@ var computeExchangeMinAmount = /*#__PURE__*/function () {
|
|
|
10541
10517
|
};
|
|
10542
10518
|
}();
|
|
10543
10519
|
var getMinTransferableAmount = /*#__PURE__*/function () {
|
|
10544
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(initialOptions
|
|
10545
|
-
var _yield$prepareTransfo, dex, options, origin, exchange,
|
|
10520
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(initialOptions) {
|
|
10521
|
+
var _yield$prepareTransfo, dex, options, origin, exchange, sender, evmSenderAddress, amount, api, builder;
|
|
10546
10522
|
return _regenerator().w(function (_context2) {
|
|
10547
10523
|
while (1) switch (_context2.n) {
|
|
10548
10524
|
case 0:
|
|
10549
10525
|
validateTransferOptions(initialOptions);
|
|
10550
10526
|
_context2.n = 1;
|
|
10551
|
-
return prepareTransformedOptions(initialOptions
|
|
10527
|
+
return prepareTransformedOptions(initialOptions);
|
|
10552
10528
|
case 1:
|
|
10553
10529
|
_yield$prepareTransfo = _context2.v;
|
|
10554
10530
|
dex = _yield$prepareTransfo.dex;
|
|
10555
10531
|
options = _yield$prepareTransfo.options;
|
|
10556
|
-
origin = options.origin, exchange = options.exchange,
|
|
10532
|
+
origin = options.origin, exchange = options.exchange, sender = options.sender, evmSenderAddress = options.evmSenderAddress, amount = options.amount, api = options.api;
|
|
10557
10533
|
if (!origin) {
|
|
10558
10534
|
_context2.n = 2;
|
|
10559
10535
|
break;
|
|
@@ -10561,10 +10537,10 @@ var getMinTransferableAmount = /*#__PURE__*/function () {
|
|
|
10561
10537
|
builder = createToExchangeBuilder({
|
|
10562
10538
|
origin: origin,
|
|
10563
10539
|
exchange: exchange,
|
|
10564
|
-
|
|
10540
|
+
sender: sender,
|
|
10565
10541
|
evmSenderAddress: evmSenderAddress,
|
|
10566
10542
|
amount: amount,
|
|
10567
|
-
|
|
10543
|
+
api: api
|
|
10568
10544
|
});
|
|
10569
10545
|
return _context2.a(2, builder.getMinTransferableAmount());
|
|
10570
10546
|
case 2:
|
|
@@ -10572,33 +10548,33 @@ var getMinTransferableAmount = /*#__PURE__*/function () {
|
|
|
10572
10548
|
}
|
|
10573
10549
|
}, _callee2);
|
|
10574
10550
|
}));
|
|
10575
|
-
return function getMinTransferableAmount(_x3
|
|
10551
|
+
return function getMinTransferableAmount(_x3) {
|
|
10576
10552
|
return _ref2.apply(this, arguments);
|
|
10577
10553
|
};
|
|
10578
10554
|
}();
|
|
10579
10555
|
|
|
10580
10556
|
var computeLocalTransferableAmount = /*#__PURE__*/function () {
|
|
10581
10557
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options) {
|
|
10582
|
-
var exchange,
|
|
10558
|
+
var exchange, sender, currency, balance, existentialDeposit, swapFee, nativeSymbol, _result$fee, _yield$getSwapFee, result, transferable;
|
|
10583
10559
|
return _regenerator().w(function (_context) {
|
|
10584
10560
|
while (1) switch (_context.n) {
|
|
10585
10561
|
case 0:
|
|
10586
|
-
exchange = options.exchange,
|
|
10562
|
+
exchange = options.exchange, sender = options.sender;
|
|
10587
10563
|
currency = {
|
|
10588
10564
|
location: exchange.assetFrom.location
|
|
10589
10565
|
};
|
|
10590
10566
|
_context.n = 1;
|
|
10591
|
-
return getBalance({
|
|
10592
|
-
api: exchange.
|
|
10593
|
-
chain: exchange.
|
|
10594
|
-
address:
|
|
10567
|
+
return getBalance$1({
|
|
10568
|
+
api: exchange.api,
|
|
10569
|
+
chain: exchange.chain,
|
|
10570
|
+
address: sender,
|
|
10595
10571
|
currency: currency
|
|
10596
10572
|
});
|
|
10597
10573
|
case 1:
|
|
10598
10574
|
balance = _context.v;
|
|
10599
|
-
existentialDeposit = getExistentialDepositOrThrow(exchange.
|
|
10575
|
+
existentialDeposit = getExistentialDepositOrThrow(exchange.chain, currency);
|
|
10600
10576
|
swapFee = 0n;
|
|
10601
|
-
nativeSymbol = getNativeAssetSymbol(exchange.
|
|
10577
|
+
nativeSymbol = getNativeAssetSymbol(exchange.chain);
|
|
10602
10578
|
if (!(exchange.assetFrom.symbol === nativeSymbol)) {
|
|
10603
10579
|
_context.n = 3;
|
|
10604
10580
|
break;
|
|
@@ -10620,30 +10596,30 @@ var computeLocalTransferableAmount = /*#__PURE__*/function () {
|
|
|
10620
10596
|
};
|
|
10621
10597
|
}();
|
|
10622
10598
|
var getTransferableAmount = /*#__PURE__*/function () {
|
|
10623
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(initialOptions
|
|
10599
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(initialOptions) {
|
|
10624
10600
|
var _yield$prepareTransfo, dex, options, transformedOptions, builder;
|
|
10625
10601
|
return _regenerator().w(function (_context2) {
|
|
10626
10602
|
while (1) switch (_context2.n) {
|
|
10627
10603
|
case 0:
|
|
10628
10604
|
validateTransferOptions(initialOptions);
|
|
10629
10605
|
_context2.n = 1;
|
|
10630
|
-
return prepareTransformedOptions(initialOptions
|
|
10606
|
+
return prepareTransformedOptions(initialOptions);
|
|
10631
10607
|
case 1:
|
|
10632
10608
|
_yield$prepareTransfo = _context2.v;
|
|
10633
10609
|
dex = _yield$prepareTransfo.dex;
|
|
10634
10610
|
options = _yield$prepareTransfo.options;
|
|
10635
10611
|
transformedOptions = options;
|
|
10636
|
-
if (!(transformedOptions.origin && transformedOptions.origin.chain !== transformedOptions.exchange.
|
|
10612
|
+
if (!(transformedOptions.origin && transformedOptions.origin.chain !== transformedOptions.exchange.chain)) {
|
|
10637
10613
|
_context2.n = 2;
|
|
10638
10614
|
break;
|
|
10639
10615
|
}
|
|
10640
10616
|
builder = createToExchangeBuilder({
|
|
10641
10617
|
origin: transformedOptions.origin,
|
|
10642
10618
|
exchange: transformedOptions.exchange,
|
|
10643
|
-
|
|
10619
|
+
sender: transformedOptions.sender,
|
|
10644
10620
|
evmSenderAddress: transformedOptions.evmSenderAddress,
|
|
10645
10621
|
amount: transformedOptions.amount,
|
|
10646
|
-
|
|
10622
|
+
api: transformedOptions.api
|
|
10647
10623
|
});
|
|
10648
10624
|
return _context2.a(2, builder.getTransferableAmount());
|
|
10649
10625
|
case 2:
|
|
@@ -10651,24 +10627,25 @@ var getTransferableAmount = /*#__PURE__*/function () {
|
|
|
10651
10627
|
}
|
|
10652
10628
|
}, _callee2);
|
|
10653
10629
|
}));
|
|
10654
|
-
return function getTransferableAmount(_x3
|
|
10630
|
+
return function getTransferableAmount(_x3) {
|
|
10655
10631
|
return _ref2.apply(this, arguments);
|
|
10656
10632
|
};
|
|
10657
10633
|
}();
|
|
10658
10634
|
|
|
10659
10635
|
var executeRouterPlan = /*#__PURE__*/function () {
|
|
10660
10636
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(plan, _ref) {
|
|
10661
|
-
var signer, evmSigner, onStatusChange, _iterator, _step, _step$value, currentStep, _step$value$, tx, type, chain, destinationChain, _t;
|
|
10637
|
+
var signer, evmSigner, onStatusChange, api, txHashes, _iterator, _step, _step$value, currentStep, _step$value$, tx, type, chain, destinationChain, _t, _t2, _t3;
|
|
10662
10638
|
return _regenerator().w(function (_context) {
|
|
10663
10639
|
while (1) switch (_context.p = _context.n) {
|
|
10664
10640
|
case 0:
|
|
10665
|
-
signer = _ref.signer, evmSigner = _ref.evmSigner, onStatusChange = _ref.onStatusChange;
|
|
10641
|
+
signer = _ref.signer, evmSigner = _ref.evmSigner, onStatusChange = _ref.onStatusChange, api = _ref.api;
|
|
10642
|
+
txHashes = [];
|
|
10666
10643
|
_iterator = _createForOfIteratorHelper(plan.entries());
|
|
10667
10644
|
_context.p = 1;
|
|
10668
10645
|
_iterator.s();
|
|
10669
10646
|
case 2:
|
|
10670
10647
|
if ((_step = _iterator.n()).done) {
|
|
10671
|
-
_context.n =
|
|
10648
|
+
_context.n = 7;
|
|
10672
10649
|
break;
|
|
10673
10650
|
}
|
|
10674
10651
|
_step$value = _slicedToArray(_step.value, 2), currentStep = _step$value[0], _step$value$ = _step$value[1], tx = _step$value$.tx, type = _step$value$.type, chain = _step$value$.chain, destinationChain = _step$value$.destinationChain;
|
|
@@ -10683,79 +10660,56 @@ var executeRouterPlan = /*#__PURE__*/function () {
|
|
|
10683
10660
|
_context.n = 4;
|
|
10684
10661
|
break;
|
|
10685
10662
|
}
|
|
10663
|
+
_t = txHashes;
|
|
10686
10664
|
_context.n = 3;
|
|
10687
|
-
return
|
|
10665
|
+
return api.signAndSubmitFinalized(tx, evmSigner);
|
|
10688
10666
|
case 3:
|
|
10689
|
-
_context.
|
|
10667
|
+
_t.push.call(_t, _context.v);
|
|
10668
|
+
_context.n = 6;
|
|
10690
10669
|
break;
|
|
10691
10670
|
case 4:
|
|
10671
|
+
_t2 = txHashes;
|
|
10692
10672
|
_context.n = 5;
|
|
10693
|
-
return
|
|
10673
|
+
return api.signAndSubmitFinalized(tx, signer);
|
|
10694
10674
|
case 5:
|
|
10695
|
-
_context.
|
|
10696
|
-
break;
|
|
10675
|
+
_t2.push.call(_t2, _context.v);
|
|
10697
10676
|
case 6:
|
|
10698
|
-
_context.n =
|
|
10677
|
+
_context.n = 2;
|
|
10699
10678
|
break;
|
|
10700
10679
|
case 7:
|
|
10701
|
-
_context.
|
|
10702
|
-
|
|
10703
|
-
_iterator.e(_t);
|
|
10680
|
+
_context.n = 9;
|
|
10681
|
+
break;
|
|
10704
10682
|
case 8:
|
|
10705
10683
|
_context.p = 8;
|
|
10706
|
-
|
|
10707
|
-
|
|
10684
|
+
_t3 = _context.v;
|
|
10685
|
+
_iterator.e(_t3);
|
|
10708
10686
|
case 9:
|
|
10687
|
+
_context.p = 9;
|
|
10688
|
+
_iterator.f();
|
|
10689
|
+
return _context.f(9);
|
|
10690
|
+
case 10:
|
|
10709
10691
|
onStatusChange === null || onStatusChange === void 0 || onStatusChange({
|
|
10710
10692
|
type: 'COMPLETED',
|
|
10711
10693
|
currentStep: plan.length - 1,
|
|
10712
10694
|
routerPlan: plan
|
|
10713
10695
|
});
|
|
10714
|
-
|
|
10715
|
-
return _context.a(2);
|
|
10696
|
+
return _context.a(2, txHashes);
|
|
10716
10697
|
}
|
|
10717
|
-
}, _callee, null, [[1,
|
|
10698
|
+
}, _callee, null, [[1, 8, 9, 10]]);
|
|
10718
10699
|
}));
|
|
10719
10700
|
return function executeRouterPlan(_x, _x2) {
|
|
10720
10701
|
return _ref2.apply(this, arguments);
|
|
10721
10702
|
};
|
|
10722
10703
|
}();
|
|
10723
10704
|
|
|
10724
|
-
/**
|
|
10725
|
-
* This function allows users to send one type of token and receive a different one on the destination chain
|
|
10726
|
-
* in a one operation. It integrates with multiple exchanges like Acala, Basilisk, Bifrost, HydraDX, Interlay,
|
|
10727
|
-
* Karura, and Kintsugi, covering over 500 asset pools.
|
|
10728
|
-
*
|
|
10729
|
-
* **Example Usage:**
|
|
10730
|
-
* ```typescript
|
|
10731
|
-
* await transfer({
|
|
10732
|
-
* from: 'Polkadot',
|
|
10733
|
-
* to: 'Astar',
|
|
10734
|
-
* currencyFrom: { symbol: 'DOT' },
|
|
10735
|
-
* currencyTo: { symbol: 'ASTR' },
|
|
10736
|
-
* amount: '1000000',
|
|
10737
|
-
* slippagePct: '1',
|
|
10738
|
-
* senderAddress: 'your_injector_address',
|
|
10739
|
-
* recipientAddress: 'recipient_address',
|
|
10740
|
-
* signer: 'your_signer',
|
|
10741
|
-
* onStatusChange: (status) => {
|
|
10742
|
-
* console.log(status);
|
|
10743
|
-
* },
|
|
10744
|
-
* });
|
|
10745
|
-
* ```
|
|
10746
|
-
*
|
|
10747
|
-
* @param initialOptions - An object containing transfer details such as origin, destination, currencies, amount, addresses, and signers.
|
|
10748
|
-
* @returns A Promise that resolves when the transfer is complete.
|
|
10749
|
-
* @throws An error if required parameters are missing or invalid.
|
|
10750
|
-
*/
|
|
10751
10705
|
var transfer = /*#__PURE__*/function () {
|
|
10752
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions
|
|
10706
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions) {
|
|
10753
10707
|
var _options$destination;
|
|
10754
|
-
var from, exchangeChain, signer, evmSigner,
|
|
10708
|
+
var api, from, exchangeChain, signer, evmSigner, sender, evmSenderAddress, onStatusChange, _yield$prepareTransfo, dex, options, routerPlan;
|
|
10755
10709
|
return _regenerator().w(function (_context) {
|
|
10756
10710
|
while (1) switch (_context.n) {
|
|
10757
10711
|
case 0:
|
|
10758
|
-
from = initialOptions.from, exchangeChain = initialOptions.exchange, signer = initialOptions.signer, evmSigner = initialOptions.evmSigner,
|
|
10712
|
+
api = initialOptions.api, from = initialOptions.from, exchangeChain = initialOptions.exchange, signer = initialOptions.signer, evmSigner = initialOptions.evmSigner, sender = initialOptions.sender, evmSenderAddress = initialOptions.evmSenderAddress, onStatusChange = initialOptions.onStatusChange;
|
|
10759
10713
|
validateTransferOptions(initialOptions);
|
|
10760
10714
|
if (!(evmSigner !== undefined && evmSenderAddress === undefined)) {
|
|
10761
10715
|
_context.n = 1;
|
|
@@ -10781,7 +10735,7 @@ var transfer = /*#__PURE__*/function () {
|
|
|
10781
10735
|
});
|
|
10782
10736
|
}
|
|
10783
10737
|
_context.n = 4;
|
|
10784
|
-
return prepareTransformedOptions(initialOptions
|
|
10738
|
+
return prepareTransformedOptions(initialOptions);
|
|
10785
10739
|
case 4:
|
|
10786
10740
|
_yield$prepareTransfo = _context.v;
|
|
10787
10741
|
dex = _yield$prepareTransfo.dex;
|
|
@@ -10790,34 +10744,27 @@ var transfer = /*#__PURE__*/function () {
|
|
|
10790
10744
|
return buildTransactions(dex, options);
|
|
10791
10745
|
case 5:
|
|
10792
10746
|
routerPlan = _context.v;
|
|
10793
|
-
_context.
|
|
10794
|
-
return executeRouterPlan(routerPlan, {
|
|
10747
|
+
return _context.a(2, executeRouterPlan(routerPlan, {
|
|
10795
10748
|
signer: signer,
|
|
10796
|
-
|
|
10749
|
+
sender: sender,
|
|
10797
10750
|
destination: (_options$destination = options.destination) === null || _options$destination === void 0 ? void 0 : _options$destination.chain,
|
|
10798
10751
|
evmSigner: evmSigner,
|
|
10799
10752
|
evmSenderAddress: evmSenderAddress,
|
|
10800
|
-
onStatusChange: onStatusChange
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
return _context.a(2);
|
|
10753
|
+
onStatusChange: onStatusChange,
|
|
10754
|
+
api: api
|
|
10755
|
+
}));
|
|
10804
10756
|
}
|
|
10805
10757
|
}, _callee);
|
|
10806
10758
|
}));
|
|
10807
|
-
return function transfer(_x
|
|
10759
|
+
return function transfer(_x) {
|
|
10808
10760
|
return _ref.apply(this, arguments);
|
|
10809
10761
|
};
|
|
10810
10762
|
}();
|
|
10811
10763
|
|
|
10812
|
-
/**
|
|
10813
|
-
* Builder class for constructing and executing cross-chain transfers using the XCM Router.
|
|
10814
|
-
*
|
|
10815
|
-
* @deprecated Use `@paraspell/sdk` with the "swap" extension installed instead.
|
|
10816
|
-
*/
|
|
10817
10764
|
var RouterBuilderCore = /*#__PURE__*/function () {
|
|
10818
|
-
function RouterBuilderCore(
|
|
10765
|
+
function RouterBuilderCore(api, options) {
|
|
10819
10766
|
_classCallCheck(this, RouterBuilderCore);
|
|
10820
|
-
this.
|
|
10767
|
+
this._api = api;
|
|
10821
10768
|
this._options = options !== null && options !== void 0 ? options : {};
|
|
10822
10769
|
}
|
|
10823
10770
|
/**
|
|
@@ -10829,7 +10776,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
10829
10776
|
return _createClass(RouterBuilderCore, [{
|
|
10830
10777
|
key: "from",
|
|
10831
10778
|
value: function from(chain) {
|
|
10832
|
-
return new RouterBuilderCore(this.
|
|
10779
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10833
10780
|
from: chain
|
|
10834
10781
|
}));
|
|
10835
10782
|
}
|
|
@@ -10842,7 +10789,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
10842
10789
|
}, {
|
|
10843
10790
|
key: "exchange",
|
|
10844
10791
|
value: function exchange(chain) {
|
|
10845
|
-
return new RouterBuilderCore(this.
|
|
10792
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10846
10793
|
exchange: normalizeExchange(chain)
|
|
10847
10794
|
}));
|
|
10848
10795
|
}
|
|
@@ -10855,7 +10802,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
10855
10802
|
}, {
|
|
10856
10803
|
key: "to",
|
|
10857
10804
|
value: function to(chain) {
|
|
10858
|
-
return new RouterBuilderCore(this.
|
|
10805
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10859
10806
|
to: chain
|
|
10860
10807
|
}));
|
|
10861
10808
|
}
|
|
@@ -10868,7 +10815,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
10868
10815
|
}, {
|
|
10869
10816
|
key: "currencyFrom",
|
|
10870
10817
|
value: function currencyFrom(currency) {
|
|
10871
|
-
return new RouterBuilderCore(this.
|
|
10818
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10872
10819
|
currencyFrom: currency
|
|
10873
10820
|
}));
|
|
10874
10821
|
}
|
|
@@ -10881,7 +10828,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
10881
10828
|
}, {
|
|
10882
10829
|
key: "currencyTo",
|
|
10883
10830
|
value: function currencyTo(currency) {
|
|
10884
|
-
return new RouterBuilderCore(this.
|
|
10831
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10885
10832
|
currencyTo: currency
|
|
10886
10833
|
}));
|
|
10887
10834
|
}
|
|
@@ -10894,7 +10841,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
10894
10841
|
}, {
|
|
10895
10842
|
key: "feeAsset",
|
|
10896
10843
|
value: function feeAsset(currency) {
|
|
10897
|
-
return new RouterBuilderCore(this.
|
|
10844
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10898
10845
|
feeAsset: currency
|
|
10899
10846
|
}));
|
|
10900
10847
|
}
|
|
@@ -10907,21 +10854,21 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
10907
10854
|
}, {
|
|
10908
10855
|
key: "amount",
|
|
10909
10856
|
value: function amount(_amount) {
|
|
10910
|
-
return new RouterBuilderCore(this.
|
|
10857
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10911
10858
|
amount: _amount.toString()
|
|
10912
10859
|
}));
|
|
10913
10860
|
}
|
|
10914
10861
|
/**
|
|
10915
10862
|
* Specifies the recipient address on the destination chain.
|
|
10916
10863
|
*
|
|
10917
|
-
* @param
|
|
10864
|
+
* @param recipient - The recipient address.
|
|
10918
10865
|
* @returns The current builder instance.
|
|
10919
10866
|
*/
|
|
10920
10867
|
}, {
|
|
10921
|
-
key: "
|
|
10922
|
-
value: function
|
|
10923
|
-
return new RouterBuilderCore(this.
|
|
10924
|
-
|
|
10868
|
+
key: "recipient",
|
|
10869
|
+
value: function recipient(address) {
|
|
10870
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10871
|
+
recipient: address
|
|
10925
10872
|
}));
|
|
10926
10873
|
}
|
|
10927
10874
|
/**
|
|
@@ -10931,22 +10878,22 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
10931
10878
|
* @returns The current builder instance.
|
|
10932
10879
|
*/
|
|
10933
10880
|
}, {
|
|
10934
|
-
key: "
|
|
10935
|
-
value: function
|
|
10936
|
-
return new RouterBuilderCore(this.
|
|
10937
|
-
|
|
10881
|
+
key: "sender",
|
|
10882
|
+
value: function sender(address) {
|
|
10883
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10884
|
+
sender: address
|
|
10938
10885
|
}));
|
|
10939
10886
|
}
|
|
10940
10887
|
/**
|
|
10941
|
-
* Specifies the
|
|
10888
|
+
* Specifies the signer for the transaction.
|
|
10942
10889
|
*
|
|
10943
|
-
* @param signer - The
|
|
10890
|
+
* @param signer - The signer instance.
|
|
10944
10891
|
* @returns The current builder instance.
|
|
10945
10892
|
*/
|
|
10946
10893
|
}, {
|
|
10947
10894
|
key: "signer",
|
|
10948
10895
|
value: function signer(_signer) {
|
|
10949
|
-
return new RouterBuilderCore(this.
|
|
10896
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10950
10897
|
signer: _signer
|
|
10951
10898
|
}));
|
|
10952
10899
|
}
|
|
@@ -10959,7 +10906,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
10959
10906
|
}, {
|
|
10960
10907
|
key: "evmSenderAddress",
|
|
10961
10908
|
value: function evmSenderAddress(address) {
|
|
10962
|
-
return new RouterBuilderCore(this.
|
|
10909
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10963
10910
|
evmSenderAddress: address
|
|
10964
10911
|
}));
|
|
10965
10912
|
}
|
|
@@ -10972,7 +10919,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
10972
10919
|
}, {
|
|
10973
10920
|
key: "evmSigner",
|
|
10974
10921
|
value: function evmSigner(signer) {
|
|
10975
|
-
return new RouterBuilderCore(this.
|
|
10922
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10976
10923
|
evmSigner: signer
|
|
10977
10924
|
}));
|
|
10978
10925
|
}
|
|
@@ -10985,7 +10932,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
10985
10932
|
}, {
|
|
10986
10933
|
key: "slippagePct",
|
|
10987
10934
|
value: function slippagePct(pct) {
|
|
10988
|
-
return new RouterBuilderCore(this.
|
|
10935
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10989
10936
|
slippagePct: pct
|
|
10990
10937
|
}));
|
|
10991
10938
|
}
|
|
@@ -10998,7 +10945,7 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
10998
10945
|
}, {
|
|
10999
10946
|
key: "onStatusChange",
|
|
11000
10947
|
value: function onStatusChange(callback) {
|
|
11001
|
-
return new RouterBuilderCore(this.
|
|
10948
|
+
return new RouterBuilderCore(this._api, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
11002
10949
|
onStatusChange: callback
|
|
11003
10950
|
}));
|
|
11004
10951
|
}
|
|
@@ -11017,7 +10964,9 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
11017
10964
|
while (1) switch (_context.n) {
|
|
11018
10965
|
case 0:
|
|
11019
10966
|
disableFallback = (_options$disableFallb = options === null || options === void 0 ? void 0 : options.disableFallback) !== null && _options$disableFallb !== void 0 ? _options$disableFallb : false;
|
|
11020
|
-
return _context.a(2, getXcmFees(this._options,
|
|
10967
|
+
return _context.a(2, getXcmFees(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10968
|
+
api: this._api
|
|
10969
|
+
}), disableFallback));
|
|
11021
10970
|
}
|
|
11022
10971
|
}, _callee, this);
|
|
11023
10972
|
}));
|
|
@@ -11033,7 +10982,9 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
11033
10982
|
return _regenerator().w(function (_context2) {
|
|
11034
10983
|
while (1) switch (_context2.n) {
|
|
11035
10984
|
case 0:
|
|
11036
|
-
return _context2.a(2, getTransferableAmount(this._options,
|
|
10985
|
+
return _context2.a(2, getTransferableAmount(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
10986
|
+
api: this._api
|
|
10987
|
+
})));
|
|
11037
10988
|
}
|
|
11038
10989
|
}, _callee2, this);
|
|
11039
10990
|
}));
|
|
@@ -11049,7 +11000,9 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
11049
11000
|
return _regenerator().w(function (_context3) {
|
|
11050
11001
|
while (1) switch (_context3.n) {
|
|
11051
11002
|
case 0:
|
|
11052
|
-
return _context3.a(2, getMinTransferableAmount(this._options,
|
|
11003
|
+
return _context3.a(2, getMinTransferableAmount(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
11004
|
+
api: this._api
|
|
11005
|
+
})));
|
|
11053
11006
|
}
|
|
11054
11007
|
}, _callee3, this);
|
|
11055
11008
|
}));
|
|
@@ -11061,65 +11014,49 @@ var RouterBuilderCore = /*#__PURE__*/function () {
|
|
|
11061
11014
|
/**
|
|
11062
11015
|
* Executes the transfer with the provided parameters.
|
|
11063
11016
|
*
|
|
11017
|
+
* @returns An array of finalized transaction hashes (hex) in execution order.
|
|
11064
11018
|
* @throws Error if required parameters are missing.
|
|
11065
11019
|
*/
|
|
11066
11020
|
}, {
|
|
11067
|
-
key: "
|
|
11068
|
-
value: function
|
|
11069
|
-
return transfer(this._options,
|
|
11021
|
+
key: "signAndSubmit",
|
|
11022
|
+
value: function signAndSubmit() {
|
|
11023
|
+
return transfer(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
11024
|
+
api: this._api
|
|
11025
|
+
}));
|
|
11070
11026
|
}
|
|
11071
11027
|
/**
|
|
11072
11028
|
* Builds the transactions for the transfer with the provided parameters.
|
|
11073
11029
|
*/
|
|
11074
11030
|
}, {
|
|
11075
|
-
key: "
|
|
11076
|
-
value: function
|
|
11077
|
-
return buildApiTransactions(this._options,
|
|
11031
|
+
key: "build",
|
|
11032
|
+
value: function build() {
|
|
11033
|
+
return buildApiTransactions(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
11034
|
+
api: this._api
|
|
11035
|
+
}));
|
|
11078
11036
|
}
|
|
11079
11037
|
}, {
|
|
11080
11038
|
key: "dryRun",
|
|
11081
11039
|
value: function dryRun() {
|
|
11082
|
-
return dryRunRouter(this._options,
|
|
11040
|
+
return dryRunRouter(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
11041
|
+
api: this._api
|
|
11042
|
+
}));
|
|
11083
11043
|
}
|
|
11084
11044
|
}, {
|
|
11085
11045
|
key: "getBestAmountOut",
|
|
11086
11046
|
value: function getBestAmountOut$1() {
|
|
11087
|
-
return getBestAmountOut(this._options,
|
|
11047
|
+
return getBestAmountOut(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
11048
|
+
api: this._api
|
|
11049
|
+
}));
|
|
11088
11050
|
}
|
|
11089
11051
|
}]);
|
|
11090
11052
|
}();
|
|
11091
|
-
|
|
11092
|
-
|
|
11093
|
-
*
|
|
11094
|
-
* @deprecated Use `@paraspell/sdk` with the "swap" extension installed instead.
|
|
11095
|
-
*
|
|
11096
|
-
* **Example usage:**
|
|
11097
|
-
* ```typescript
|
|
11098
|
-
* await RouterBuilder(options)
|
|
11099
|
-
* .from('Polkadot')
|
|
11100
|
-
* .exchange('HydrationDex')
|
|
11101
|
-
* .to('Astar')
|
|
11102
|
-
* .currencyFrom({ symbol: 'DOT' })
|
|
11103
|
-
* .currencyTo({ symbol: 'ASTR' })
|
|
11104
|
-
* .amount(1000000n)
|
|
11105
|
-
* .slippagePct('1')
|
|
11106
|
-
* .senderAddress('sender_address')
|
|
11107
|
-
* .recipientAddress('recipient_address')
|
|
11108
|
-
* .signer(yourSigner)
|
|
11109
|
-
* .onStatusChange((status) => {
|
|
11110
|
-
* console.log(status);
|
|
11111
|
-
* })
|
|
11112
|
-
* .build();
|
|
11113
|
-
* ```
|
|
11114
|
-
*
|
|
11115
|
-
* @returns A new `RouterBuilder`.
|
|
11116
|
-
*/
|
|
11117
|
-
var RouterBuilder = function RouterBuilder(options) {
|
|
11118
|
-
return new RouterBuilderCore(options);
|
|
11053
|
+
var RouterBuilder = function RouterBuilder(api) {
|
|
11054
|
+
return new RouterBuilderCore(api);
|
|
11119
11055
|
};
|
|
11120
11056
|
|
|
11057
|
+
// @ts-expect-error - Temporary. Will be removed once the swap extension is fully integrated into the SDK.
|
|
11121
11058
|
registerSwapExtension({
|
|
11122
11059
|
RouterBuilder: RouterBuilder
|
|
11123
11060
|
});
|
|
11124
11061
|
|
|
11125
|
-
export { DEST_FEE_BUFFER_PCT, FALLBACK_FEE_CALC_ADDRESS, FALLBACK_FEE_CALC_EVM_ADDRESS, FEE_BUFFER_PCT, RouterBuilder, RouterBuilderCore,
|
|
11062
|
+
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 };
|