@paraspell/swap 13.0.0-rc.1 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -10
- package/dist/index.mjs +124 -141
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TSubstrateChain, TExchangeInput, TChain, TCurrencyInput, TAmount, TStatusChangeCallback, TExchangeChain, TAssetInfo,
|
|
1
|
+
import { TSubstrateChain, TExchangeInput, TChain, TCurrencyInput, TAmount, TStatusChangeCallback, TExchangeChain, TAssetInfo, PolkadotApi, TLocation, WithApi, TGetXcmFeeBuilderOptions, TGetXcmFeeResult, TDryRunResult } from '@paraspell/sdk-core';
|
|
2
2
|
import { TPapiApi, TPapiTransaction } from '@paraspell/sdk';
|
|
3
3
|
import { TPjsApi, Extrinsic } from '@paraspell/sdk-pjs';
|
|
4
4
|
|
|
@@ -112,9 +112,8 @@ type TOriginInfo<TApi> = {
|
|
|
112
112
|
type TExchangeInfo<TApi, TRes, TSigner> = {
|
|
113
113
|
apiPjs: TPjsApi;
|
|
114
114
|
apiPapi: TPapiApi;
|
|
115
|
-
api:
|
|
116
|
-
|
|
117
|
-
exchangeChain: TExchangeChain;
|
|
115
|
+
api: PolkadotApi<TApi, TRes, TSigner>;
|
|
116
|
+
chain: TExchangeChain;
|
|
118
117
|
assetFrom: TAssetInfo;
|
|
119
118
|
assetTo: TAssetInfo;
|
|
120
119
|
feeAssetInfo?: TAssetInfo;
|
|
@@ -168,7 +167,7 @@ type TExecuteRouterPlanOptions<TApi, TRes, TSigner> = {
|
|
|
168
167
|
evmSigner?: TSigner;
|
|
169
168
|
evmSenderAddress?: string;
|
|
170
169
|
onStatusChange?: TStatusChangeCallback<TApi, TRes>;
|
|
171
|
-
api:
|
|
170
|
+
api: PolkadotApi<TApi, TRes, TSigner>;
|
|
172
171
|
};
|
|
173
172
|
type TPreparedExtrinsics<TRes> = {
|
|
174
173
|
toExchangeTx?: TRes;
|
|
@@ -183,14 +182,14 @@ type TBuildToExchangeTxOptions<TApi, TRes, TSigner> = {
|
|
|
183
182
|
sender: string;
|
|
184
183
|
evmSenderAddress?: string;
|
|
185
184
|
amount: bigint;
|
|
186
|
-
api:
|
|
185
|
+
api: PolkadotApi<TApi, TRes, TSigner>;
|
|
187
186
|
};
|
|
188
187
|
type TBuildFromExchangeTxOptions<TApi, TRes, TSigner> = {
|
|
189
188
|
exchange: TExchangeInfo<TApi, TRes, TSigner>;
|
|
190
189
|
destination: TDestinationInfo;
|
|
191
190
|
amount: bigint;
|
|
192
191
|
sender: string;
|
|
193
|
-
api:
|
|
192
|
+
api: PolkadotApi<TApi, TRes, TSigner>;
|
|
194
193
|
};
|
|
195
194
|
|
|
196
195
|
declare const getExchangeConfig: (exchange: TExchangeChain) => TDexConfig;
|
|
@@ -227,10 +226,10 @@ declare const getSupportedAssetsTo: (exchangeInput: TExchangeInput, to: TChain |
|
|
|
227
226
|
declare const getSupportedFeeAssets: (from: TChain | undefined, exchangeInput: TExchangeInput) => TAssetInfo[];
|
|
228
227
|
|
|
229
228
|
declare class RouterBuilderCore<TApi, TRes, TSigner, T extends Partial<TTransferBaseOptions<TApi, TRes, TSigner>> = object> {
|
|
230
|
-
readonly _api:
|
|
229
|
+
readonly _api: PolkadotApi<TApi, TRes, TSigner>;
|
|
231
230
|
readonly _options: T;
|
|
232
231
|
readonly _builderOptions?: TTransferBaseOptions<TApi, TRes, TSigner>;
|
|
233
|
-
constructor(api:
|
|
232
|
+
constructor(api: PolkadotApi<TApi, TRes, TSigner>, options?: T);
|
|
234
233
|
/**
|
|
235
234
|
* Specifies the origin chain of the transfer.
|
|
236
235
|
*
|
|
@@ -381,7 +380,7 @@ declare class RouterBuilderCore<TApi, TRes, TSigner, T extends Partial<TTransfer
|
|
|
381
380
|
dryRun(this: RouterBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<TDryRunResult>;
|
|
382
381
|
getBestAmountOut(this: RouterBuilderCore<TApi, TRes, TSigner, TGetBestAmountOutBaseOptions<TApi, TRes, TSigner>>): Promise<TGetBestAmountOutResult>;
|
|
383
382
|
}
|
|
384
|
-
declare const RouterBuilder: <TApi, TRes, TSigner>(api:
|
|
383
|
+
declare const RouterBuilder: <TApi, TRes, TSigner>(api: PolkadotApi<TApi, TRes, TSigner>) => RouterBuilderCore<TApi, TRes, TSigner, object>;
|
|
385
384
|
|
|
386
385
|
declare const FEE_BUFFER_PCT = 10;
|
|
387
386
|
declare const DEST_FEE_BUFFER_PCT = -1;
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { getNativeAssets, RoutingResolutionError, findAssetInfoById, getOtherAss
|
|
|
3
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';
|
|
@@ -423,7 +423,7 @@ var convertTxToTarget = /*#__PURE__*/function () {
|
|
|
423
423
|
_t = _context.v.asHex();
|
|
424
424
|
case 3:
|
|
425
425
|
hex = _t;
|
|
426
|
-
if (!(isPjsTx && api.
|
|
426
|
+
if (!(isPjsTx && api.type === 'PAPI')) {
|
|
427
427
|
_context.n = 8;
|
|
428
428
|
break;
|
|
429
429
|
}
|
|
@@ -451,7 +451,7 @@ var convertTxToTarget = /*#__PURE__*/function () {
|
|
|
451
451
|
};
|
|
452
452
|
}();
|
|
453
453
|
|
|
454
|
-
var
|
|
454
|
+
var AssetHubPolkadot = {
|
|
455
455
|
isOmni: true,
|
|
456
456
|
assets: [
|
|
457
457
|
{
|
|
@@ -868,7 +868,7 @@ var AssetHubPolkadotDex = {
|
|
|
868
868
|
pairs: [
|
|
869
869
|
]
|
|
870
870
|
};
|
|
871
|
-
var
|
|
871
|
+
var AssetHubKusama = {
|
|
872
872
|
isOmni: true,
|
|
873
873
|
assets: [
|
|
874
874
|
{
|
|
@@ -1035,7 +1035,7 @@ var AssetHubKusamaDex = {
|
|
|
1035
1035
|
pairs: [
|
|
1036
1036
|
]
|
|
1037
1037
|
};
|
|
1038
|
-
var
|
|
1038
|
+
var AssetHubPaseo = {
|
|
1039
1039
|
isOmni: true,
|
|
1040
1040
|
assets: [
|
|
1041
1041
|
{
|
|
@@ -1167,7 +1167,7 @@ var AssetHubPaseoDex = {
|
|
|
1167
1167
|
pairs: [
|
|
1168
1168
|
]
|
|
1169
1169
|
};
|
|
1170
|
-
var
|
|
1170
|
+
var AssetHubWestend = {
|
|
1171
1171
|
isOmni: true,
|
|
1172
1172
|
assets: [
|
|
1173
1173
|
{
|
|
@@ -1268,7 +1268,7 @@ var AssetHubWestendDex = {
|
|
|
1268
1268
|
pairs: [
|
|
1269
1269
|
]
|
|
1270
1270
|
};
|
|
1271
|
-
var
|
|
1271
|
+
var Hydration = {
|
|
1272
1272
|
isOmni: true,
|
|
1273
1273
|
assets: [
|
|
1274
1274
|
{
|
|
@@ -2320,7 +2320,7 @@ var HydrationDex = {
|
|
|
2320
2320
|
pairs: [
|
|
2321
2321
|
]
|
|
2322
2322
|
};
|
|
2323
|
-
var
|
|
2323
|
+
var Karura = {
|
|
2324
2324
|
isOmni: false,
|
|
2325
2325
|
assets: [
|
|
2326
2326
|
{
|
|
@@ -4678,7 +4678,7 @@ var KaruraDex = {
|
|
|
4678
4678
|
]
|
|
4679
4679
|
]
|
|
4680
4680
|
};
|
|
4681
|
-
var
|
|
4681
|
+
var Acala = {
|
|
4682
4682
|
isOmni: false,
|
|
4683
4683
|
assets: [
|
|
4684
4684
|
{
|
|
@@ -6243,7 +6243,7 @@ var AcalaDex = {
|
|
|
6243
6243
|
]
|
|
6244
6244
|
]
|
|
6245
6245
|
};
|
|
6246
|
-
var
|
|
6246
|
+
var BifrostKusama = {
|
|
6247
6247
|
isOmni: false,
|
|
6248
6248
|
assets: [
|
|
6249
6249
|
{
|
|
@@ -6792,7 +6792,7 @@ var BifrostKusamaDex = {
|
|
|
6792
6792
|
]
|
|
6793
6793
|
]
|
|
6794
6794
|
};
|
|
6795
|
-
var
|
|
6795
|
+
var BifrostPolkadot = {
|
|
6796
6796
|
isOmni: false,
|
|
6797
6797
|
assets: [
|
|
6798
6798
|
{
|
|
@@ -7130,28 +7130,28 @@ var BifrostPolkadotDex = {
|
|
|
7130
7130
|
]
|
|
7131
7131
|
};
|
|
7132
7132
|
var assets = {
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
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
|
|
7142
7142
|
};
|
|
7143
7143
|
|
|
7144
7144
|
var assetsMapJson = /*#__PURE__*/Object.freeze({
|
|
7145
7145
|
__proto__: null,
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
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,
|
|
7155
7155
|
default: assets
|
|
7156
7156
|
});
|
|
7157
7157
|
|
|
@@ -7172,21 +7172,15 @@ var Logger = {
|
|
|
7172
7172
|
};
|
|
7173
7173
|
|
|
7174
7174
|
var ExchangeChain = /*#__PURE__*/function () {
|
|
7175
|
-
function ExchangeChain(chain
|
|
7175
|
+
function ExchangeChain(chain) {
|
|
7176
7176
|
_classCallCheck(this, ExchangeChain);
|
|
7177
7177
|
this._chain = chain;
|
|
7178
|
-
this._exchangeChain = exchangeChain;
|
|
7179
7178
|
}
|
|
7180
7179
|
return _createClass(ExchangeChain, [{
|
|
7181
7180
|
key: "chain",
|
|
7182
7181
|
get: function get() {
|
|
7183
7182
|
return this._chain;
|
|
7184
7183
|
}
|
|
7185
|
-
}, {
|
|
7186
|
-
key: "exchangeChain",
|
|
7187
|
-
get: function get() {
|
|
7188
|
-
return this._exchangeChain;
|
|
7189
|
-
}
|
|
7190
7184
|
}, {
|
|
7191
7185
|
key: "handleMultiSwap",
|
|
7192
7186
|
value: function () {
|
|
@@ -7336,7 +7330,7 @@ var getDexConfig$2 = /*#__PURE__*/function () {
|
|
|
7336
7330
|
seen.add(key);
|
|
7337
7331
|
directPairs.push([a.location, b.location]);
|
|
7338
7332
|
});
|
|
7339
|
-
acalaDex = new AcalaDex
|
|
7333
|
+
acalaDex = new AcalaDex({
|
|
7340
7334
|
api: api,
|
|
7341
7335
|
wallet: wallet
|
|
7342
7336
|
});
|
|
@@ -7453,7 +7447,7 @@ var AcalaExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
7453
7447
|
case 1:
|
|
7454
7448
|
fromToken = wallet.getToken(assetFrom.symbol);
|
|
7455
7449
|
toToken = wallet.getToken(assetTo.symbol);
|
|
7456
|
-
acalaDex = new AcalaDex
|
|
7450
|
+
acalaDex = new AcalaDex({
|
|
7457
7451
|
api: api,
|
|
7458
7452
|
wallet: wallet
|
|
7459
7453
|
});
|
|
@@ -7547,7 +7541,7 @@ var AcalaExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
7547
7541
|
case 1:
|
|
7548
7542
|
fromToken = wallet.getToken(assetFrom.symbol);
|
|
7549
7543
|
toToken = wallet.getToken(assetTo.symbol);
|
|
7550
|
-
acalaDex = new AcalaDex
|
|
7544
|
+
acalaDex = new AcalaDex({
|
|
7551
7545
|
api: api,
|
|
7552
7546
|
wallet: wallet
|
|
7553
7547
|
});
|
|
@@ -7843,7 +7837,7 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
7843
7837
|
while (1) switch (_context2.n) {
|
|
7844
7838
|
case 0:
|
|
7845
7839
|
assetFrom = options.assetFrom, assetTo = options.assetTo;
|
|
7846
|
-
nativeAsset = getExchangeAsset(this.
|
|
7840
|
+
nativeAsset = getExchangeAsset(this.chain, {
|
|
7847
7841
|
symbol: getNativeAssetSymbol(this.chain)
|
|
7848
7842
|
});
|
|
7849
7843
|
if (nativeAsset) {
|
|
@@ -7932,7 +7926,7 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
7932
7926
|
while (1) switch (_context3.n) {
|
|
7933
7927
|
case 0:
|
|
7934
7928
|
assetFrom = options.assetFrom, assetTo = options.assetTo, amount = options.amount, origin = options.origin, papiApi = options.papiApi;
|
|
7935
|
-
nativeAsset = getExchangeAsset(this.
|
|
7929
|
+
nativeAsset = getExchangeAsset(this.chain, {
|
|
7936
7930
|
symbol: getNativeAssetSymbol(this.chain)
|
|
7937
7931
|
});
|
|
7938
7932
|
if (nativeAsset) {
|
|
@@ -8829,15 +8823,15 @@ var HydrationExchange = /*#__PURE__*/function (_ExchangeChain) {
|
|
|
8829
8823
|
|
|
8830
8824
|
var record = {
|
|
8831
8825
|
// Reuse classes for Kusama equivalents
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
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')
|
|
8841
8835
|
};
|
|
8842
8836
|
var createExchangeInstance = function createExchangeInstance(chain) {
|
|
8843
8837
|
return record[chain];
|
|
@@ -9100,7 +9094,7 @@ var canBuildToExchangeTx = /*#__PURE__*/function () {
|
|
|
9100
9094
|
assetFrom: assetFromOrigin
|
|
9101
9095
|
},
|
|
9102
9096
|
exchange: {
|
|
9103
|
-
|
|
9097
|
+
chain: exchangeChain
|
|
9104
9098
|
},
|
|
9105
9099
|
api: api
|
|
9106
9100
|
});
|
|
@@ -9137,7 +9131,7 @@ var canBuildToExchangeTx = /*#__PURE__*/function () {
|
|
|
9137
9131
|
|
|
9138
9132
|
var selectBestExchangeCommon = /*#__PURE__*/function () {
|
|
9139
9133
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, originApi, computeAmountOut) {
|
|
9140
|
-
var api, from, exchange, to, currencyFrom, currencyTo, assetFromOrigin, filteredExchangeChains, bestExchange, maxAmountOut, errors, triedAnyExchange, _iterator, _step, exchangeChain, dex, originSpecified, destinationSpecified, assetFromExchange, assetTo, res,
|
|
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;
|
|
9141
9135
|
return _regenerator().w(function (_context) {
|
|
9142
9136
|
while (1) switch (_context.p = _context.n) {
|
|
9143
9137
|
case 0:
|
|
@@ -9172,14 +9166,14 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
|
|
|
9172
9166
|
dex = createExchangeInstance(exchangeChain);
|
|
9173
9167
|
originSpecified = from && from !== dex.chain;
|
|
9174
9168
|
destinationSpecified = to && to !== dex.chain;
|
|
9175
|
-
assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.
|
|
9169
|
+
assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.chain, assetFromOrigin) : getExchangeAsset(dex.chain, currencyFrom);
|
|
9176
9170
|
if (assetFromExchange) {
|
|
9177
9171
|
_context.n = 5;
|
|
9178
9172
|
break;
|
|
9179
9173
|
}
|
|
9180
9174
|
return _context.a(3, 14);
|
|
9181
9175
|
case 5:
|
|
9182
|
-
assetTo = getExchangeAsset(dex.
|
|
9176
|
+
assetTo = getExchangeAsset(dex.chain, currencyTo, true);
|
|
9183
9177
|
if (assetTo) {
|
|
9184
9178
|
_context.n = 6;
|
|
9185
9179
|
break;
|
|
@@ -9211,8 +9205,8 @@ var selectBestExchangeCommon = /*#__PURE__*/function () {
|
|
|
9211
9205
|
errors.set(dex.chain, res.error);
|
|
9212
9206
|
return _context.a(3, 14);
|
|
9213
9207
|
case 10:
|
|
9214
|
-
|
|
9215
|
-
parsedAmount = applyDecimalAbstraction(options.amount, assetFromExchange === null || assetFromExchange === void 0 ? void 0 : assetFromExchange.decimals, !(isConfig(
|
|
9208
|
+
config = api.config;
|
|
9209
|
+
parsedAmount = applyDecimalAbstraction(options.amount, assetFromExchange === null || assetFromExchange === void 0 ? void 0 : assetFromExchange.decimals, !(isConfig(config) && config.abstractDecimals === false)).toString();
|
|
9216
9210
|
_context.p = 11;
|
|
9217
9211
|
_context.n = 12;
|
|
9218
9212
|
return computeAmountOut(dex, assetFromExchange, assetTo, options, parsedAmount);
|
|
@@ -9282,7 +9276,7 @@ var selectBestExchange = /*#__PURE__*/function () {
|
|
|
9282
9276
|
api = options.api;
|
|
9283
9277
|
return _context2.a(2, selectBestExchangeCommon(options, originApi, /*#__PURE__*/function () {
|
|
9284
9278
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, assetFromExchange, assetTo, options, parsedAmount) {
|
|
9285
|
-
var modifiedOptions, toDestTxFee, _yield$dex$handleMult, amountOut, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10
|
|
9279
|
+
var modifiedOptions, toDestTxFee, _yield$dex$handleMult, amountOut, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10;
|
|
9286
9280
|
return _regenerator().w(function (_context) {
|
|
9287
9281
|
while (1) switch (_context.n) {
|
|
9288
9282
|
case 0:
|
|
@@ -9303,23 +9297,21 @@ var selectBestExchange = /*#__PURE__*/function () {
|
|
|
9303
9297
|
case 3:
|
|
9304
9298
|
_t7 = _context.v;
|
|
9305
9299
|
_t8 = dex.chain;
|
|
9306
|
-
_t9 =
|
|
9307
|
-
_t0 =
|
|
9308
|
-
_t1 =
|
|
9309
|
-
_t10 = {
|
|
9300
|
+
_t9 = assetFromExchange;
|
|
9301
|
+
_t0 = assetTo;
|
|
9302
|
+
_t1 = {
|
|
9310
9303
|
apiPjs: _t5,
|
|
9311
9304
|
apiPapi: _t6,
|
|
9312
9305
|
api: _t7,
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
assetTo: _t1
|
|
9306
|
+
chain: _t8,
|
|
9307
|
+
assetFrom: _t9,
|
|
9308
|
+
assetTo: _t0
|
|
9317
9309
|
};
|
|
9318
|
-
|
|
9310
|
+
_t10 = determineFeeCalcAddress(options.sender, options.recipient);
|
|
9319
9311
|
modifiedOptions = _t(_t2, _t3, {
|
|
9320
9312
|
amount: _t4,
|
|
9321
|
-
exchange:
|
|
9322
|
-
feeCalcAddress:
|
|
9313
|
+
exchange: _t1,
|
|
9314
|
+
feeCalcAddress: _t10
|
|
9323
9315
|
});
|
|
9324
9316
|
_context.n = 4;
|
|
9325
9317
|
return calculateFromExchangeFee(modifiedOptions);
|
|
@@ -9364,16 +9356,16 @@ var resolveAssets = function resolveAssets(dex, _ref) {
|
|
|
9364
9356
|
if (originSpecified && !assetFromOrigin) {
|
|
9365
9357
|
throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " not found in ").concat(from, "."));
|
|
9366
9358
|
}
|
|
9367
|
-
var assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.
|
|
9359
|
+
var assetFromExchange = originSpecified && assetFromOrigin ? getExchangeAssetByOriginAsset(dex.chain, assetFromOrigin) : getExchangeAsset(dex.chain, currencyFrom);
|
|
9368
9360
|
if (!assetFromExchange) {
|
|
9369
9361
|
if (!originSpecified && findAssetInfo(dex.chain, currencyFrom)) {
|
|
9370
|
-
throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " exists in ").concat(dex.chain, " but is not swappable on ").concat(dex.
|
|
9362
|
+
throw new RoutingResolutionError("Currency from ".concat(JSON.stringify(currencyFrom), " exists in ").concat(dex.chain, " but is not swappable on ").concat(dex.chain, "."));
|
|
9371
9363
|
}
|
|
9372
|
-
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, "."));
|
|
9373
9365
|
}
|
|
9374
|
-
var assetTo = getExchangeAsset(dex.
|
|
9366
|
+
var assetTo = getExchangeAsset(dex.chain, currencyTo);
|
|
9375
9367
|
if (!assetTo) {
|
|
9376
|
-
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, "."));
|
|
9377
9369
|
}
|
|
9378
9370
|
if (destinationSpecified && !hasSupportForAsset(to, assetTo.symbol)) {
|
|
9379
9371
|
throw new RoutingResolutionError("Currency to ".concat(JSON.stringify(currencyTo), " not supported by ").concat(to, "."));
|
|
@@ -9382,7 +9374,7 @@ var resolveAssets = function resolveAssets(dex, _ref) {
|
|
|
9382
9374
|
if (feeAsset && originSpecified && !feeAssetFromOrigin) {
|
|
9383
9375
|
throw new RoutingResolutionError("Fee asset ".concat(JSON.stringify(feeAsset), " not found in ").concat(from, "."));
|
|
9384
9376
|
}
|
|
9385
|
-
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;
|
|
9386
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;
|
|
9387
9379
|
if (feeAsset && resolvedFeeAssetLocation) {
|
|
9388
9380
|
var sdkAsset = findAssetInfoOrThrow(from !== null && from !== void 0 ? from : dex.chain, {
|
|
@@ -9402,18 +9394,16 @@ var resolveAssets = function resolveAssets(dex, _ref) {
|
|
|
9402
9394
|
};
|
|
9403
9395
|
|
|
9404
9396
|
var createToExchangeBuilder = function createToExchangeBuilder(_ref) {
|
|
9405
|
-
var
|
|
9406
|
-
|
|
9407
|
-
assetFrom = _ref$origin.assetFrom,
|
|
9408
|
-
baseChain = _ref.exchange.baseChain,
|
|
9397
|
+
var origin = _ref.origin,
|
|
9398
|
+
exchange = _ref.exchange,
|
|
9409
9399
|
sender = _ref.sender,
|
|
9410
9400
|
evmSenderAddress = _ref.evmSenderAddress,
|
|
9411
9401
|
amount = _ref.amount,
|
|
9412
9402
|
api = _ref.api;
|
|
9413
|
-
return Builder(api.clone()).from(
|
|
9414
|
-
location: assetFrom.location,
|
|
9403
|
+
return Builder(api.clone()).from(origin.chain).to(exchange.chain).currency({
|
|
9404
|
+
location: origin.assetFrom.location,
|
|
9415
9405
|
amount: amount
|
|
9416
|
-
}).sender(isChainEvm(
|
|
9406
|
+
}).sender(isChainEvm(origin.chain) ? evmSenderAddress : sender).recipient(sender);
|
|
9417
9407
|
};
|
|
9418
9408
|
var buildToExchangeExtrinsic = function buildToExchangeExtrinsic(options) {
|
|
9419
9409
|
return createToExchangeBuilder(options).build();
|
|
@@ -9424,20 +9414,16 @@ var getToExchangeFee = function getToExchangeFee(options, disableFallback) {
|
|
|
9424
9414
|
});
|
|
9425
9415
|
};
|
|
9426
9416
|
var createFromExchangeBuilder = function createFromExchangeBuilder(_ref2) {
|
|
9427
|
-
var
|
|
9428
|
-
|
|
9429
|
-
assetTo = _ref2$exchange.assetTo,
|
|
9430
|
-
_ref2$destination = _ref2.destination,
|
|
9431
|
-
chain = _ref2$destination.chain,
|
|
9432
|
-
address = _ref2$destination.address,
|
|
9417
|
+
var exchange = _ref2.exchange,
|
|
9418
|
+
destination = _ref2.destination,
|
|
9433
9419
|
amount = _ref2.amount,
|
|
9434
9420
|
sender = _ref2.sender,
|
|
9435
9421
|
api = _ref2.api;
|
|
9436
9422
|
var apiForChain = api.clone();
|
|
9437
|
-
return Builder(apiForChain).from(
|
|
9438
|
-
location: assetTo.location,
|
|
9423
|
+
return Builder(apiForChain).from(exchange.chain).to(destination.chain).currency({
|
|
9424
|
+
location: exchange.assetTo.location,
|
|
9439
9425
|
amount: amount
|
|
9440
|
-
}).sender(sender).recipient(address);
|
|
9426
|
+
}).sender(sender).recipient(destination.address);
|
|
9441
9427
|
};
|
|
9442
9428
|
var buildFromExchangeExtrinsic = function buildFromExchangeExtrinsic(options) {
|
|
9443
9429
|
return createFromExchangeBuilder(options).build();
|
|
@@ -9502,8 +9488,7 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
|
|
|
9502
9488
|
_t12,
|
|
9503
9489
|
_t13,
|
|
9504
9490
|
_t14,
|
|
9505
|
-
_t15
|
|
9506
|
-
_t16;
|
|
9491
|
+
_t15;
|
|
9507
9492
|
return _regenerator().w(function (_context) {
|
|
9508
9493
|
while (1) switch (_context.n) {
|
|
9509
9494
|
case 0:
|
|
@@ -9532,13 +9517,13 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
|
|
|
9532
9517
|
break;
|
|
9533
9518
|
case 4:
|
|
9534
9519
|
_context.n = 5;
|
|
9535
|
-
return selectBestExchange(options, originApi === null || originApi === void 0 ? void 0 : originApi.
|
|
9520
|
+
return selectBestExchange(options, originApi === null || originApi === void 0 ? void 0 : originApi.api, isForFeeEstimation);
|
|
9536
9521
|
case 5:
|
|
9537
9522
|
_t2 = _context.v;
|
|
9538
9523
|
case 6:
|
|
9539
9524
|
dex = _t2;
|
|
9540
9525
|
_resolveAssets = resolveAssets(dex, options), assetFromOrigin = _resolveAssets.assetFromOrigin, assetFromExchange = _resolveAssets.assetFromExchange, assetTo = _resolveAssets.assetTo, feeAssetFromOrigin = _resolveAssets.feeAssetFromOrigin, feeAssetFromExchange = _resolveAssets.feeAssetFromExchange;
|
|
9541
|
-
if (supportsExchangePair(dex.
|
|
9526
|
+
if (supportsExchangePair(dex.chain, assetFromExchange, assetTo)) {
|
|
9542
9527
|
_context.n = 7;
|
|
9543
9528
|
break;
|
|
9544
9529
|
}
|
|
@@ -9550,14 +9535,14 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
|
|
|
9550
9535
|
return api.createApiForChain(dex.chain);
|
|
9551
9536
|
case 8:
|
|
9552
9537
|
exchangeApi = _context.v;
|
|
9553
|
-
config = api.
|
|
9538
|
+
config = api.config;
|
|
9554
9539
|
exchangeConfig = convertBuilderConfig(config);
|
|
9555
9540
|
_t3 = _objectSpread2;
|
|
9556
9541
|
_t4 = _objectSpread2({}, options);
|
|
9557
9542
|
_t5 = {};
|
|
9558
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);
|
|
9559
9544
|
_t7 = originSpecified && assetFromOrigin && originApi ? {
|
|
9560
|
-
api: originApi.
|
|
9545
|
+
api: originApi.api,
|
|
9561
9546
|
chain: from,
|
|
9562
9547
|
assetFrom: assetFromOrigin,
|
|
9563
9548
|
feeAssetInfo: feeAssetFromOrigin
|
|
@@ -9572,31 +9557,29 @@ var prepareTransformedOptions = /*#__PURE__*/function () {
|
|
|
9572
9557
|
_t9 = _context.v;
|
|
9573
9558
|
_t0 = exchangeApi;
|
|
9574
9559
|
_t1 = dex.chain;
|
|
9575
|
-
_t10 =
|
|
9576
|
-
_t11 =
|
|
9577
|
-
_t12 =
|
|
9578
|
-
_t13 =
|
|
9579
|
-
_t14 = {
|
|
9560
|
+
_t10 = assetFromExchange;
|
|
9561
|
+
_t11 = assetTo;
|
|
9562
|
+
_t12 = feeAssetFromExchange;
|
|
9563
|
+
_t13 = {
|
|
9580
9564
|
apiPjs: _t8,
|
|
9581
9565
|
apiPapi: _t9,
|
|
9582
9566
|
api: _t0,
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
feeAssetInfo: _t13
|
|
9567
|
+
chain: _t1,
|
|
9568
|
+
assetFrom: _t10,
|
|
9569
|
+
assetTo: _t11,
|
|
9570
|
+
feeAssetInfo: _t12
|
|
9588
9571
|
};
|
|
9589
|
-
|
|
9572
|
+
_t14 = destinationSpecified && recipient ? {
|
|
9590
9573
|
chain: to,
|
|
9591
9574
|
address: recipient
|
|
9592
9575
|
} : undefined;
|
|
9593
|
-
|
|
9576
|
+
_t15 = determineFeeCalcAddress(sender, recipient);
|
|
9594
9577
|
transformed = _t3(_t4, _t5, {
|
|
9595
9578
|
amount: _t6,
|
|
9596
9579
|
origin: _t7,
|
|
9597
|
-
exchange:
|
|
9598
|
-
destination:
|
|
9599
|
-
feeCalcAddress:
|
|
9580
|
+
exchange: _t13,
|
|
9581
|
+
destination: _t14,
|
|
9582
|
+
feeCalcAddress: _t15
|
|
9600
9583
|
});
|
|
9601
9584
|
return _context.a(2, {
|
|
9602
9585
|
dex: dex,
|
|
@@ -9659,7 +9642,7 @@ var calculateFromExchangeFee = /*#__PURE__*/function () {
|
|
|
9659
9642
|
while (1) switch (_context.n) {
|
|
9660
9643
|
case 0:
|
|
9661
9644
|
exchange = options.exchange, destination = options.destination, feeCalcAddress = options.feeCalcAddress, sender = options.sender, api = options.api;
|
|
9662
|
-
if (!(!destination || destination.chain === exchange.
|
|
9645
|
+
if (!(!destination || destination.chain === exchange.chain)) {
|
|
9663
9646
|
_context.n = 1;
|
|
9664
9647
|
break;
|
|
9665
9648
|
}
|
|
@@ -9755,7 +9738,7 @@ var prepareExtrinsics = /*#__PURE__*/function () {
|
|
|
9755
9738
|
return handleSwapExecuteTransfer({
|
|
9756
9739
|
api: api,
|
|
9757
9740
|
chain: origin === null || origin === void 0 ? void 0 : origin.chain,
|
|
9758
|
-
exchangeChain: exchange.
|
|
9741
|
+
exchangeChain: exchange.chain,
|
|
9759
9742
|
destChain: destination === null || destination === void 0 ? void 0 : destination.chain,
|
|
9760
9743
|
assetInfoFrom: _objectSpread2(_objectSpread2({}, (_origin$assetFrom = origin === null || origin === void 0 ? void 0 : origin.assetFrom) !== null && _origin$assetFrom !== void 0 ? _origin$assetFrom : exchange.assetFrom), {}, {
|
|
9761
9744
|
amount: BigInt(amount)
|
|
@@ -9792,7 +9775,7 @@ var prepareExtrinsics = /*#__PURE__*/function () {
|
|
|
9792
9775
|
}
|
|
9793
9776
|
throw _t;
|
|
9794
9777
|
case 5:
|
|
9795
|
-
if (!(origin && origin.chain !== exchange.
|
|
9778
|
+
if (!(origin && origin.chain !== exchange.chain)) {
|
|
9796
9779
|
_context.n = 7;
|
|
9797
9780
|
break;
|
|
9798
9781
|
}
|
|
@@ -9814,7 +9797,7 @@ var prepareExtrinsics = /*#__PURE__*/function () {
|
|
|
9814
9797
|
_yield$createSwapTx = _context.v;
|
|
9815
9798
|
swapTxs = _yield$createSwapTx.txs;
|
|
9816
9799
|
amountOut = _yield$createSwapTx.amountOut;
|
|
9817
|
-
if (!(destination && destination.chain !== exchange.
|
|
9800
|
+
if (!(destination && destination.chain !== exchange.chain)) {
|
|
9818
9801
|
_context.n = 11;
|
|
9819
9802
|
break;
|
|
9820
9803
|
}
|
|
@@ -9869,7 +9852,7 @@ var buildTransactions = /*#__PURE__*/function () {
|
|
|
9869
9852
|
transactions.push({
|
|
9870
9853
|
api: origin.api,
|
|
9871
9854
|
chain: origin.chain,
|
|
9872
|
-
destinationChain: exchange.
|
|
9855
|
+
destinationChain: exchange.chain,
|
|
9873
9856
|
tx: toExchangeTx,
|
|
9874
9857
|
type: 'TRANSFER'
|
|
9875
9858
|
});
|
|
@@ -9877,7 +9860,7 @@ var buildTransactions = /*#__PURE__*/function () {
|
|
|
9877
9860
|
if (toDestTx) {
|
|
9878
9861
|
batchedTx = exchange.api.callBatchMethod([].concat(_toConsumableArray(swapTxs), [toDestTx]), BatchMode.BATCH_ALL);
|
|
9879
9862
|
transactions.push({
|
|
9880
|
-
api: exchange.api.
|
|
9863
|
+
api: exchange.api.api,
|
|
9881
9864
|
chain: dex.chain,
|
|
9882
9865
|
destinationChain: destination === null || destination === void 0 ? void 0 : destination.chain,
|
|
9883
9866
|
tx: batchedTx,
|
|
@@ -9887,7 +9870,7 @@ var buildTransactions = /*#__PURE__*/function () {
|
|
|
9887
9870
|
} else {
|
|
9888
9871
|
if (swapTxs.length === 1) {
|
|
9889
9872
|
transactions.push({
|
|
9890
|
-
api: isExecute ? (_origin$api = origin === null || origin === void 0 ? void 0 : origin.api) !== null && _origin$api !== void 0 ? _origin$api : exchange.api.
|
|
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,
|
|
9891
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,
|
|
9892
9875
|
tx: swapTxs[0],
|
|
9893
9876
|
amountOut: amountOut,
|
|
@@ -9896,7 +9879,7 @@ var buildTransactions = /*#__PURE__*/function () {
|
|
|
9896
9879
|
} else {
|
|
9897
9880
|
batchedSwapTx = exchange.api.callBatchMethod(swapTxs, BatchMode.BATCH_ALL);
|
|
9898
9881
|
transactions.push({
|
|
9899
|
-
api: exchange.api.
|
|
9882
|
+
api: exchange.api.api,
|
|
9900
9883
|
chain: dex.chain,
|
|
9901
9884
|
tx: batchedSwapTx,
|
|
9902
9885
|
amountOut: amountOut,
|
|
@@ -9946,7 +9929,7 @@ var assignIsExchange = function assignIsExchange(result, options) {
|
|
|
9946
9929
|
result.destination.isExchange = true;
|
|
9947
9930
|
}
|
|
9948
9931
|
result.hops = result.hops.map(function (hop) {
|
|
9949
|
-
var isExchange = hop.chain === exchange.
|
|
9932
|
+
var isExchange = hop.chain === exchange.chain;
|
|
9950
9933
|
return _objectSpread2(_objectSpread2({}, hop), {}, {
|
|
9951
9934
|
result: _objectSpread2(_objectSpread2({}, hop.result), {}, {
|
|
9952
9935
|
isExchange: isExchange
|
|
@@ -9966,7 +9949,7 @@ var dryRunTransaction = /*#__PURE__*/function () {
|
|
|
9966
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;
|
|
9967
9950
|
tx = transaction.tx, chain = transaction.chain;
|
|
9968
9951
|
senderResolved = evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender;
|
|
9969
|
-
resolvedDest = (_ref2 = destChain !== null && destChain !== void 0 ? destChain : destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _ref2 !== void 0 ? _ref2 : exchange.
|
|
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;
|
|
9970
9953
|
return _context.a(2, dryRun({
|
|
9971
9954
|
api: api.clone(),
|
|
9972
9955
|
tx: tx,
|
|
@@ -9975,7 +9958,7 @@ var dryRunTransaction = /*#__PURE__*/function () {
|
|
|
9975
9958
|
sender: senderResolved,
|
|
9976
9959
|
swapConfig: {
|
|
9977
9960
|
currencyTo: currencyTo,
|
|
9978
|
-
exchangeChain: exchange.
|
|
9961
|
+
exchangeChain: exchange.chain
|
|
9979
9962
|
},
|
|
9980
9963
|
currency: _objectSpread2(_objectSpread2({}, currencyFrom), {}, {
|
|
9981
9964
|
amount: BigInt(amount)
|
|
@@ -9996,7 +9979,7 @@ var mergeDryRunResults = function mergeDryRunResults(options, originResult, exch
|
|
|
9996
9979
|
origin: originResult.origin,
|
|
9997
9980
|
destination: destination ? exchangeResult.destination : exchangeResult.origin,
|
|
9998
9981
|
hops: [].concat(_toConsumableArray(originResult.hops), _toConsumableArray(destination ? [{
|
|
9999
|
-
chain: exchange.
|
|
9982
|
+
chain: exchange.chain,
|
|
10000
9983
|
result: exchangeResult.origin
|
|
10001
9984
|
}] : []), _toConsumableArray(exchangeResult.hops))
|
|
10002
9985
|
};
|
|
@@ -10011,7 +9994,7 @@ var dryRun2Transactions = /*#__PURE__*/function () {
|
|
|
10011
9994
|
exchange = options.exchange;
|
|
10012
9995
|
_transactions = _slicedToArray(transactions, 2), firstTx = _transactions[0], secondTx = _transactions[1];
|
|
10013
9996
|
_context2.n = 1;
|
|
10014
|
-
return dryRunTransaction(options, firstTx, exchange.
|
|
9997
|
+
return dryRunTransaction(options, firstTx, exchange.chain);
|
|
10015
9998
|
case 1:
|
|
10016
9999
|
firstRes = _context2.v;
|
|
10017
10000
|
_getFailureInfo = getFailureInfo(firstRes), failureReason = _getFailureInfo.failureReason;
|
|
@@ -10185,7 +10168,7 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10185
10168
|
return handleSwapExecuteTransfer({
|
|
10186
10169
|
api: api,
|
|
10187
10170
|
chain: origin === null || origin === void 0 ? void 0 : origin.chain,
|
|
10188
|
-
exchangeChain: exchange.
|
|
10171
|
+
exchangeChain: exchange.chain,
|
|
10189
10172
|
destChain: destination === null || destination === void 0 ? void 0 : destination.chain,
|
|
10190
10173
|
assetInfoFrom: _objectSpread2(_objectSpread2({}, (_origin$assetFrom = origin === null || origin === void 0 ? void 0 : origin.assetFrom) !== null && _origin$assetFrom !== void 0 ? _origin$assetFrom : exchange.assetFrom), {}, {
|
|
10191
10174
|
amount: BigInt(amt)
|
|
@@ -10230,8 +10213,8 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10230
10213
|
return getXcmFee({
|
|
10231
10214
|
api: api,
|
|
10232
10215
|
buildTx: buildTx,
|
|
10233
|
-
origin: (_origin$chain = origin === null || origin === void 0 ? void 0 : origin.chain) !== null && _origin$chain !== void 0 ? _origin$chain : exchange.
|
|
10234
|
-
destination: (_destination$chain = destination === null || destination === void 0 ? void 0 : destination.chain) !== null && _destination$chain !== void 0 ? _destination$chain : exchange.
|
|
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,
|
|
10235
10218
|
sender: evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender,
|
|
10236
10219
|
recipient: recipient !== null && recipient !== void 0 ? recipient : sender,
|
|
10237
10220
|
currency: _objectSpread2(_objectSpread2({}, currencyFrom), {}, {
|
|
@@ -10241,20 +10224,20 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10241
10224
|
disableFallback: disableFallback,
|
|
10242
10225
|
swapConfig: {
|
|
10243
10226
|
currencyTo: currencyTo,
|
|
10244
|
-
exchangeChain: exchange.
|
|
10227
|
+
exchangeChain: exchange.chain,
|
|
10245
10228
|
amountOut: mainAmountOut
|
|
10246
10229
|
}
|
|
10247
10230
|
});
|
|
10248
10231
|
case 3:
|
|
10249
10232
|
executeResult = _context2.v;
|
|
10250
|
-
if (!(executeResult.failureReason === 'NoDeal' && exchange.
|
|
10233
|
+
if (!(executeResult.failureReason === 'NoDeal' && exchange.chain === 'Hydration')) {
|
|
10251
10234
|
_context2.n = 4;
|
|
10252
10235
|
break;
|
|
10253
10236
|
}
|
|
10254
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.');
|
|
10255
10238
|
case 4:
|
|
10256
10239
|
transformedHops = executeResult.hops.map(function (hop) {
|
|
10257
|
-
if (hop.chain === exchange.
|
|
10240
|
+
if (hop.chain === exchange.chain) {
|
|
10258
10241
|
return {
|
|
10259
10242
|
chain: hop.chain,
|
|
10260
10243
|
result: _objectSpread2(_objectSpread2({}, hop.result), {}, {
|
|
@@ -10282,7 +10265,7 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10282
10265
|
}
|
|
10283
10266
|
throw _t;
|
|
10284
10267
|
case 6:
|
|
10285
|
-
if (!(origin && origin.chain !== exchange.
|
|
10268
|
+
if (!(origin && origin.chain !== exchange.chain)) {
|
|
10286
10269
|
_context2.n = 8;
|
|
10287
10270
|
break;
|
|
10288
10271
|
}
|
|
@@ -10304,7 +10287,7 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10304
10287
|
_yield$getSwapFee = _context2.v;
|
|
10305
10288
|
swapChain = _yield$getSwapFee.result;
|
|
10306
10289
|
amountOut = _yield$getSwapFee.amountOut;
|
|
10307
|
-
if (!(destination && destination.chain !== exchange.
|
|
10290
|
+
if (!(destination && destination.chain !== exchange.chain)) {
|
|
10308
10291
|
_context2.n = 12;
|
|
10309
10292
|
break;
|
|
10310
10293
|
}
|
|
@@ -10325,7 +10308,7 @@ var getRouterFees = /*#__PURE__*/function () {
|
|
|
10325
10308
|
case 13:
|
|
10326
10309
|
receivingChain = _t3;
|
|
10327
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 ? [{
|
|
10328
|
-
chain: exchange.
|
|
10311
|
+
chain: exchange.chain,
|
|
10329
10312
|
result: _objectSpread2(_objectSpread2({}, swapChain), {}, {
|
|
10330
10313
|
fee: swapChain.fee + ((_receivingChain$origi = receivingChain === null || receivingChain === void 0 ? void 0 : receivingChain.origin.fee) !== null && _receivingChain$origi !== void 0 ? _receivingChain$origi : 0n),
|
|
10331
10314
|
isExchange: true
|
|
@@ -10468,7 +10451,7 @@ var getBestAmountOut = /*#__PURE__*/function () {
|
|
|
10468
10451
|
}
|
|
10469
10452
|
throw res.error;
|
|
10470
10453
|
case 8:
|
|
10471
|
-
config = api.
|
|
10454
|
+
config = api.config;
|
|
10472
10455
|
exchangeConfig = convertBuilderConfig(config);
|
|
10473
10456
|
_context.n = 9;
|
|
10474
10457
|
return dex.createApiInstance(exchangeConfig);
|
|
@@ -10478,7 +10461,7 @@ var getBestAmountOut = /*#__PURE__*/function () {
|
|
|
10478
10461
|
return dex.createApiInstancePapi(exchangeConfig);
|
|
10479
10462
|
case 10:
|
|
10480
10463
|
papiApi = _context.v;
|
|
10481
|
-
_t3 = dex.
|
|
10464
|
+
_t3 = dex.chain;
|
|
10482
10465
|
_context.n = 11;
|
|
10483
10466
|
return dex.getAmountOut(pjsApi, {
|
|
10484
10467
|
papiApi: papiApi,
|
|
@@ -10508,10 +10491,10 @@ var computeExchangeMinAmount = /*#__PURE__*/function () {
|
|
|
10508
10491
|
while (1) switch (_context.n) {
|
|
10509
10492
|
case 0:
|
|
10510
10493
|
exchange = options.exchange;
|
|
10511
|
-
existentialDeposit = getExistentialDepositOrThrow(exchange.
|
|
10494
|
+
existentialDeposit = getExistentialDepositOrThrow(exchange.chain, {
|
|
10512
10495
|
location: exchange.assetFrom.location
|
|
10513
10496
|
});
|
|
10514
|
-
nativeSymbol = getNativeAssetSymbol(exchange.
|
|
10497
|
+
nativeSymbol = getNativeAssetSymbol(exchange.chain);
|
|
10515
10498
|
isNativeAsset = exchange.assetFrom.symbol === nativeSymbol;
|
|
10516
10499
|
if (isNativeAsset) {
|
|
10517
10500
|
_context.n = 1;
|
|
@@ -10583,15 +10566,15 @@ var computeLocalTransferableAmount = /*#__PURE__*/function () {
|
|
|
10583
10566
|
_context.n = 1;
|
|
10584
10567
|
return getBalance$1({
|
|
10585
10568
|
api: exchange.api,
|
|
10586
|
-
chain: exchange.
|
|
10569
|
+
chain: exchange.chain,
|
|
10587
10570
|
address: sender,
|
|
10588
10571
|
currency: currency
|
|
10589
10572
|
});
|
|
10590
10573
|
case 1:
|
|
10591
10574
|
balance = _context.v;
|
|
10592
|
-
existentialDeposit = getExistentialDepositOrThrow(exchange.
|
|
10575
|
+
existentialDeposit = getExistentialDepositOrThrow(exchange.chain, currency);
|
|
10593
10576
|
swapFee = 0n;
|
|
10594
|
-
nativeSymbol = getNativeAssetSymbol(exchange.
|
|
10577
|
+
nativeSymbol = getNativeAssetSymbol(exchange.chain);
|
|
10595
10578
|
if (!(exchange.assetFrom.symbol === nativeSymbol)) {
|
|
10596
10579
|
_context.n = 3;
|
|
10597
10580
|
break;
|
|
@@ -10626,7 +10609,7 @@ var getTransferableAmount = /*#__PURE__*/function () {
|
|
|
10626
10609
|
dex = _yield$prepareTransfo.dex;
|
|
10627
10610
|
options = _yield$prepareTransfo.options;
|
|
10628
10611
|
transformedOptions = options;
|
|
10629
|
-
if (!(transformedOptions.origin && transformedOptions.origin.chain !== transformedOptions.exchange.
|
|
10612
|
+
if (!(transformedOptions.origin && transformedOptions.origin.chain !== transformedOptions.exchange.chain)) {
|
|
10630
10613
|
_context2.n = 2;
|
|
10631
10614
|
break;
|
|
10632
10615
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/swap",
|
|
3
|
-
"version": "13.0.0
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "Tool for XCM cross-chain asset exchanging across Polkadot and Kusama ecosystems",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"postcss": "^8.5.8",
|
|
51
51
|
"react": "^19.2.4",
|
|
52
52
|
"rxjs": "^7.8.2",
|
|
53
|
-
"@paraspell/sdk": "
|
|
54
|
-
"@paraspell/sdk-
|
|
55
|
-
"@paraspell/sdk-
|
|
53
|
+
"@paraspell/sdk": "13.0.0",
|
|
54
|
+
"@paraspell/sdk-pjs": "13.0.0",
|
|
55
|
+
"@paraspell/sdk-core": "13.0.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@babel/core": "^7.29.0",
|