@paraspell/swap 13.7.1 → 13.8.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 CHANGED
@@ -17,8 +17,8 @@ type TGetDexConfigApi<TApiType extends TExchangeApiType> = TApiType extends 'PJS
17
17
  type WithApiVariant<TBase, TApiType extends TExchangeApiType = TExchangeApiType> = TBase & Extract<TExchangeApiVariant, {
18
18
  apiType: TApiType;
19
19
  }>;
20
- type TSwapOptionsCommon<TApi, TRes, TSigner> = {
21
- api: PolkadotApi<TApi, TRes, TSigner>;
20
+ type TSwapOptionsCommon<TApi, TRes, TSigner, TCustomChain extends string = never> = {
21
+ api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>;
22
22
  assetFrom: TAssetInfo;
23
23
  assetTo: TAssetInfo;
24
24
  amount: bigint;
@@ -28,24 +28,24 @@ type TSwapOptionsCommon<TApi, TRes, TSigner> = {
28
28
  origin?: TOriginInfo<TApi>;
29
29
  isForFeeEstimation?: boolean;
30
30
  };
31
- type TSwapOptions<TApi, TRes, TSigner> = WithApiVariant<TSwapOptionsCommon<TApi, TRes, TSigner>>;
32
- type TSwapOptionsFor<TApi, TRes, TSigner, TApiType extends TExchangeApiType> = WithApiVariant<TSwapOptionsCommon<TApi, TRes, TSigner>, TApiType>;
33
- type TPjsSwapOptions<TApi, TRes, TSigner> = TSwapOptionsFor<TApi, TRes, TSigner, 'PJS'>;
34
- type TPapiSwapOptions<TApi, TRes, TSigner> = TSwapOptionsFor<TApi, TRes, TSigner, 'PAPI'>;
35
- type TGenericSwapOptions<TApi, TRes, TSigner> = TSwapOptionsFor<TApi, TRes, TSigner, 'GENERIC'>;
36
- type TGetAmountOutOptionsCommon<TApi, TRes, TSigner> = {
37
- api: PolkadotApi<TApi, TRes, TSigner>;
31
+ type TSwapOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = WithApiVariant<TSwapOptionsCommon<TApi, TRes, TSigner, TCustomChain>>;
32
+ type TSwapOptionsFor<TApi, TRes, TSigner, TApiType extends TExchangeApiType, TCustomChain extends string = never> = WithApiVariant<TSwapOptionsCommon<TApi, TRes, TSigner, TCustomChain>, TApiType>;
33
+ type TPjsSwapOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = TSwapOptionsFor<TApi, TRes, TSigner, 'PJS', TCustomChain>;
34
+ type TPapiSwapOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = TSwapOptionsFor<TApi, TRes, TSigner, 'PAPI', TCustomChain>;
35
+ type TGenericSwapOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = TSwapOptionsFor<TApi, TRes, TSigner, 'GENERIC', TCustomChain>;
36
+ type TGetAmountOutOptionsCommon<TApi, TRes, TSigner, TCustomChain extends string = never> = {
37
+ api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>;
38
38
  origin?: TOriginInfo<TApi>;
39
39
  assetFrom: TAssetInfo;
40
40
  assetTo: TAssetInfo;
41
41
  amount: bigint;
42
42
  slippagePct?: string;
43
43
  };
44
- type TGetAmountOutOptions<TApi, TRes, TSigner> = WithApiVariant<TGetAmountOutOptionsCommon<TApi, TRes, TSigner>>;
45
- type TGetAmountOutOptionsFor<TApi, TRes, TSigner, TApiType extends TExchangeApiType> = WithApiVariant<TGetAmountOutOptionsCommon<TApi, TRes, TSigner>, TApiType>;
46
- type TPjsGetAmountOutOptions<TApi, TRes, TSigner> = TGetAmountOutOptionsFor<TApi, TRes, TSigner, 'PJS'>;
47
- type TPapiGetAmountOutOptions<TApi, TRes, TSigner> = TGetAmountOutOptionsFor<TApi, TRes, TSigner, 'PAPI'>;
48
- type TGenericGetAmountOutOptions<TApi, TRes, TSigner> = TGetAmountOutOptionsFor<TApi, TRes, TSigner, 'GENERIC'>;
44
+ type TGetAmountOutOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = WithApiVariant<TGetAmountOutOptionsCommon<TApi, TRes, TSigner, TCustomChain>>;
45
+ type TGetAmountOutOptionsFor<TApi, TRes, TSigner, TApiType extends TExchangeApiType, TCustomChain extends string = never> = WithApiVariant<TGetAmountOutOptionsCommon<TApi, TRes, TSigner, TCustomChain>, TApiType>;
46
+ type TPjsGetAmountOutOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = TGetAmountOutOptionsFor<TApi, TRes, TSigner, 'PJS', TCustomChain>;
47
+ type TPapiGetAmountOutOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = TGetAmountOutOptionsFor<TApi, TRes, TSigner, 'PAPI', TCustomChain>;
48
+ type TGenericGetAmountOutOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = TGetAmountOutOptionsFor<TApi, TRes, TSigner, 'GENERIC', TCustomChain>;
49
49
  type TExtrinsic<TRes> = Extrinsic | TPapiTransaction | TRes;
50
50
  type TSingleSwapResult<TRes> = {
51
51
  tx: TExtrinsic<TRes>;
@@ -117,32 +117,32 @@ type TTransferBaseOptions<TApi, TRes, TSigner> = {
117
117
  */
118
118
  onStatusChange?: TStatusChangeCallback<TApi, TRes>;
119
119
  };
120
- type TTransferOptions<TApi, TRes, TSigner> = WithApi<TTransferBaseOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner>;
120
+ type TTransferOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = WithApi<TTransferBaseOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner, TCustomChain>;
121
121
  type TGetBestAmountOutBaseOptions<TApi, TRes, TSigner> = Omit<TTransferBaseOptions<TApi, TRes, TSigner>, 'onStatusChange' | 'signer' | 'evmSigner' | 'recipient' | 'slippagePct' | 'sender' | 'evmSenderAddress'>;
122
- type TGetBestAmountOutOptions<TApi, TRes, TSigner> = WithApi<TGetBestAmountOutBaseOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner>;
122
+ type TGetBestAmountOutOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = WithApi<TGetBestAmountOutBaseOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner, TCustomChain>;
123
123
  type TGetBestAmountOutResult = {
124
124
  exchange: TExchangeChain;
125
125
  amountOut: bigint;
126
126
  };
127
127
  type TBuildTransactionsBaseOptions<TApi, TRes, TSigner> = Omit<TTransferBaseOptions<TApi, TRes, TSigner>, 'onStatusChange' | 'signer' | 'evmSigner'>;
128
- type TBuildTransactionsOptions<TApi, TRes, TSigner> = WithApi<TBuildTransactionsBaseOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner>;
129
- type TCommonRouterOptions<TApi, TRes, TSigner> = TTransferOptions<TApi, TRes, TSigner> | TBuildTransactionsOptions<TApi, TRes, TSigner>;
130
- type TTransformedOptions<T, TApi, TRes, TSigner> = Omit<T, 'exchange' | 'amount'> & WithApi<TAdditionalTransferOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner>;
128
+ type TBuildTransactionsOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = WithApi<TBuildTransactionsBaseOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner, TCustomChain>;
129
+ type TCommonRouterOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = TTransferOptions<TApi, TRes, TSigner, TCustomChain> | TBuildTransactionsOptions<TApi, TRes, TSigner, TCustomChain>;
130
+ type TTransformedOptions<T, TApi, TRes, TSigner, TCustomChain extends string = never> = Omit<T, 'exchange' | 'amount'> & WithApi<TAdditionalTransferOptions<TApi, TRes, TSigner, TCustomChain>, TApi, TRes, TSigner, TCustomChain>;
131
131
  type TOriginInfo<TApi> = {
132
132
  api: TApi;
133
133
  chain: TSubstrateChain;
134
134
  assetFrom: TAssetInfo;
135
135
  feeAssetInfo?: TAssetInfo;
136
136
  };
137
- type TExchangeInfoCommon<TApi, TRes, TSigner> = {
138
- api: PolkadotApi<TApi, TRes, TSigner>;
137
+ type TExchangeInfoCommon<TApi, TRes, TSigner, TCustomChain extends string = never> = {
138
+ api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>;
139
139
  chain: TExchangeChain;
140
140
  assetFrom: TAssetInfo;
141
141
  assetTo: TAssetInfo;
142
142
  feeAssetInfo?: TAssetInfo;
143
143
  };
144
- type TExchangeInfo<TApi, TRes, TSigner> = WithApiVariant<TExchangeInfoCommon<TApi, TRes, TSigner>>;
145
- type TExchangeInfoFor<TApi, TRes, TSigner, TApiType extends TExchangeApiType> = WithApiVariant<TExchangeInfoCommon<TApi, TRes, TSigner>, TApiType>;
144
+ type TExchangeInfo<TApi, TRes, TSigner, TCustomChain extends string = never> = WithApiVariant<TExchangeInfoCommon<TApi, TRes, TSigner, TCustomChain>>;
145
+ type TExchangeInfoFor<TApi, TRes, TSigner, TApiType extends TExchangeApiType, TCustomChain extends string = never> = WithApiVariant<TExchangeInfoCommon<TApi, TRes, TSigner, TCustomChain>, TApiType>;
146
146
  type TPjsExchangeInfo<TApi, TRes, TSigner> = TExchangeInfoFor<TApi, TRes, TSigner, 'PJS'>;
147
147
  type TPapiExchangeInfo<TApi, TRes, TSigner> = TExchangeInfoFor<TApi, TRes, TSigner, 'PAPI'>;
148
148
  type TGenericExchangeInfo<TApi, TRes, TSigner> = TExchangeInfoFor<TApi, TRes, TSigner, 'GENERIC'>;
@@ -150,10 +150,10 @@ type TDestinationInfo = {
150
150
  chain: TChain;
151
151
  address: string;
152
152
  };
153
- type TAdditionalTransferOptions<TApi, TRes, TSigner> = {
153
+ type TAdditionalTransferOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = {
154
154
  amount: bigint;
155
155
  origin?: TOriginInfo<TApi>;
156
- exchange: TExchangeInfo<TApi, TRes, TSigner>;
156
+ exchange: TExchangeInfo<TApi, TRes, TSigner, TCustomChain>;
157
157
  destination?: TDestinationInfo;
158
158
  feeCalcAddress: string;
159
159
  };
@@ -188,14 +188,14 @@ type TSwapAndTransferTransaction<TApi, TRes> = TBaseTransaction<TApi, TRes> & {
188
188
  };
189
189
  type TTransaction<TApi, TRes> = TSwapTransaction<TApi, TRes> | TSwapAndTransferTransaction<TApi, TRes> | TTransferTransaction<TApi, TRes>;
190
190
  type TRouterPlan<TApi, TRes> = TTransaction<TApi, TRes>[];
191
- type TExecuteRouterPlanOptions<TApi, TRes, TSigner> = {
191
+ type TExecuteRouterPlanOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = {
192
192
  signer: TSigner;
193
193
  sender: string;
194
194
  destination?: TChain;
195
195
  evmSigner?: TSigner;
196
196
  evmSenderAddress?: string;
197
197
  onStatusChange?: TStatusChangeCallback<TApi, TRes>;
198
- api: PolkadotApi<TApi, TRes, TSigner>;
198
+ api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>;
199
199
  };
200
200
  type TPreparedExtrinsics<TRes> = {
201
201
  toExchangeTx?: TRes;
@@ -204,22 +204,22 @@ type TPreparedExtrinsics<TRes> = {
204
204
  toDestTx?: TRes;
205
205
  amountOut: bigint;
206
206
  };
207
- type TBuildToExchangeTxOptions<TApi, TRes, TSigner> = {
207
+ type TBuildToExchangeTxOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = {
208
208
  origin: TOriginInfo<TApi>;
209
- exchange: TExchangeInfo<TApi, TRes, TSigner>;
209
+ exchange: TExchangeInfo<TApi, TRes, TSigner, TCustomChain>;
210
210
  sender: string;
211
211
  evmSenderAddress?: string;
212
212
  amount: bigint;
213
- api: PolkadotApi<TApi, TRes, TSigner>;
213
+ api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>;
214
214
  };
215
- type TBuildFromExchangeTxOptions<TApi, TRes, TSigner> = {
216
- exchange: TExchangeInfo<TApi, TRes, TSigner>;
215
+ type TBuildFromExchangeTxOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = {
216
+ exchange: TExchangeInfo<TApi, TRes, TSigner, TCustomChain>;
217
217
  destination: TDestinationInfo;
218
218
  amount: bigint;
219
219
  sender: string;
220
- api: PolkadotApi<TApi, TRes, TSigner>;
220
+ api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>;
221
221
  };
222
- type TSwapTransformedOptions<TApi, TRes, TSigner> = TTransformedOptions<TBuildTransactionsOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner>;
222
+ type TSwapTransformedOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = TTransformedOptions<TBuildTransactionsOptions<TApi, TRes, TSigner, TCustomChain>, TApi, TRes, TSigner, TCustomChain>;
223
223
  type TCallDexAmountOutOverrides = {
224
224
  amount?: bigint;
225
225
  assetTo?: TAssetInfo;
@@ -266,71 +266,71 @@ declare const getSupportedFeeAssetsImpl: <TCustomChain extends string = never>(f
266
266
  */
267
267
  declare const getSupportedFeeAssets: (from: TChain | undefined, exchangeInput: TExchangeInput) => TAssetInfo[];
268
268
 
269
- declare class SwapBuilderCore<TApi, TRes, TSigner, T extends Partial<TTransferBaseOptions<TApi, TRes, TSigner>> = object> {
270
- readonly _api: PolkadotApi<TApi, TRes, TSigner>;
269
+ declare class SwapBuilderCore<TApi, TRes, TSigner, T extends Partial<TTransferBaseOptions<TApi, TRes, TSigner>> = object, TCustomChain extends string = never> {
270
+ readonly _api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>;
271
271
  readonly _options: T;
272
- constructor(api: PolkadotApi<TApi, TRes, TSigner>, options?: T);
272
+ constructor(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, options?: T);
273
273
  from(chain: TSubstrateChain | undefined): SwapBuilderCore<TApi, TRes, TSigner, T & {
274
274
  from: TSubstrateChain | undefined;
275
- }>;
275
+ }, TCustomChain>;
276
276
  exchange(chain: TExchangeInput): SwapBuilderCore<TApi, TRes, TSigner, T & {
277
277
  exchange: TExchangeInput;
278
- }>;
278
+ }, TCustomChain>;
279
279
  to(chain: TChain | undefined): SwapBuilderCore<TApi, TRes, TSigner, T & {
280
280
  to: TChain | undefined;
281
- }>;
281
+ }, TCustomChain>;
282
282
  currencyFrom(currency: TCurrencyInput): SwapBuilderCore<TApi, TRes, TSigner, T & {
283
283
  currencyFrom: TCurrencyInput;
284
- }>;
284
+ }, TCustomChain>;
285
285
  currencyTo(currency: TCurrencyInput): SwapBuilderCore<TApi, TRes, TSigner, T & {
286
286
  currencyTo: TCurrencyInput;
287
- }>;
287
+ }, TCustomChain>;
288
288
  feeAsset(currency: TCurrencyInput | undefined): SwapBuilderCore<TApi, TRes, TSigner, T & {
289
289
  feeAsset: TCurrencyInput | undefined;
290
- }>;
290
+ }, TCustomChain>;
291
291
  amount(amount: TAmount): SwapBuilderCore<TApi, TRes, TSigner, T & {
292
292
  amount: TAmount;
293
- }>;
293
+ }, TCustomChain>;
294
294
  recipient(address: string | undefined): SwapBuilderCore<TApi, TRes, TSigner, T & {
295
295
  recipient: string | undefined;
296
- }>;
296
+ }, TCustomChain>;
297
297
  sender(address: string): SwapBuilderCore<TApi, TRes, TSigner, T & {
298
298
  sender: string;
299
- }>;
299
+ }, TCustomChain>;
300
300
  signer(signer: TSigner): SwapBuilderCore<TApi, TRes, TSigner, T & {
301
301
  signer: TSigner;
302
- }>;
302
+ }, TCustomChain>;
303
303
  evmSenderAddress(address: string | undefined): SwapBuilderCore<TApi, TRes, TSigner, T & {
304
304
  evmSenderAddress: string | undefined;
305
- }>;
305
+ }, TCustomChain>;
306
306
  evmSigner(signer: TSigner | undefined): SwapBuilderCore<TApi, TRes, TSigner, T & {
307
307
  evmSigner: TSigner | undefined;
308
- }>;
308
+ }, TCustomChain>;
309
309
  slippagePct(pct: string): SwapBuilderCore<TApi, TRes, TSigner, T & {
310
310
  slippagePct: string;
311
- }>;
311
+ }, TCustomChain>;
312
312
  onStatusChange(callback: TStatusChangeCallback<TApi, TRes>): SwapBuilderCore<TApi, TRes, TSigner, T & {
313
313
  onStatusChange: TStatusChangeCallback<TApi, TRes>;
314
- }>;
315
- getXcmFees<TDisableFallback extends boolean = false>(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>, options?: TGetXcmFeeBuilderOptions & {
314
+ }, TCustomChain>;
315
+ getXcmFees<TDisableFallback extends boolean = false>(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>, TCustomChain>, options?: TGetXcmFeeBuilderOptions & {
316
316
  disableFallback: TDisableFallback;
317
317
  }): Promise<TGetXcmFeeResult<TDisableFallback>>;
318
- getOriginXcmFee<TDisableFallback extends boolean = false>(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>, options?: TGetXcmFeeBuilderOptions & {
318
+ getOriginXcmFee<TDisableFallback extends boolean = false>(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>, TCustomChain>, options?: TGetXcmFeeBuilderOptions & {
319
319
  disableFallback: TDisableFallback;
320
320
  }): Promise<TXcmFeeDetailWithForwardedXcm<TDisableFallback>>;
321
- getSwapInfo(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<TTransferInfo>;
322
- getTransferableAmount(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<bigint>;
323
- getMinTransferableAmount(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<bigint>;
324
- signAndSubmit(this: SwapBuilderCore<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner>>): Promise<string[]>;
325
- build(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<TTransactionContext<TApi, TRes>[]>;
326
- dryRun(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<TDryRunResult>;
327
- dryRunPreview(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>, previewOptions?: TDryRunPreviewOptions): Promise<TDryRunResult>;
328
- getBestAmountOut(this: SwapBuilderCore<TApi, TRes, TSigner, TGetBestAmountOutBaseOptions<TApi, TRes, TSigner>>): Promise<{
321
+ getSwapInfo(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>, TCustomChain>): Promise<TTransferInfo>;
322
+ getTransferableAmount(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>, TCustomChain>): Promise<bigint>;
323
+ getMinTransferableAmount(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>, TCustomChain>): Promise<bigint>;
324
+ signAndSubmit(this: SwapBuilderCore<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner>, TCustomChain>): Promise<string[]>;
325
+ build(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>, TCustomChain>): Promise<TTransactionContext<TApi, TRes>[]>;
326
+ dryRun(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>, TCustomChain>): Promise<TDryRunResult>;
327
+ dryRunPreview(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>, TCustomChain>, previewOptions?: TDryRunPreviewOptions): Promise<TDryRunResult>;
328
+ getBestAmountOut(this: SwapBuilderCore<TApi, TRes, TSigner, TGetBestAmountOutBaseOptions<TApi, TRes, TSigner>, TCustomChain>): Promise<{
329
329
  exchange: TExchangeChain;
330
330
  amountOut: bigint;
331
331
  }>;
332
332
  }
333
- declare const SwapBuilder: <TApi, TRes, TSigner>(api: PolkadotApi<TApi, TRes, TSigner>) => TSwapBuilder<TApi, TRes, TSigner>;
333
+ declare const SwapBuilder: <TApi, TRes, TSigner, TCustomChain extends string = never>(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>) => TSwapBuilder<TApi, TRes, TSigner>;
334
334
 
335
335
  declare const FEE_BUFFER_PCT = 10;
336
336
  declare const DEST_FEE_BUFFER_PCT = -1;
package/dist/index.mjs CHANGED
@@ -9,6 +9,7 @@ import { firstValueFrom } from 'rxjs';
9
9
  import { createChainClient, formatUnits } from '@paraspell/sdk-pjs';
10
10
  import { options } from '@acala-network/api';
11
11
  import { WsProvider, ApiPromise } from '@polkadot/api';
12
+ import { snakeToCamel } from '@paraspell/sdk-common';
12
13
  import { Amount, Token, getCurrencyCombinations } from '@crypto-dex-sdk/currency';
13
14
  import { Percent } from '@crypto-dex-sdk/math';
14
15
  import { PAIR_ADDRESSES, isNativeCurrency, addressToNodeCurrency, SwapRouter } from '@crypto-dex-sdk/parachains-bifrost';
@@ -1072,6 +1073,16 @@ var AssetHubPolkadot = {
1072
1073
  ]
1073
1074
  }
1074
1075
  },
1076
+ {
1077
+ parents: 1,
1078
+ interior: {
1079
+ X1: [
1080
+ {
1081
+ Parachain: 3377
1082
+ }
1083
+ ]
1084
+ }
1085
+ },
1075
1086
  {
1076
1087
  parents: 2,
1077
1088
  interior: {
@@ -1683,6 +1694,22 @@ var Hydration = {
1683
1694
  ]
1684
1695
  }
1685
1696
  },
1697
+ {
1698
+ parents: 1,
1699
+ interior: {
1700
+ X2: [
1701
+ {
1702
+ Parachain: 2034
1703
+ },
1704
+ {
1705
+ AccountKey20: {
1706
+ network: null,
1707
+ key: "0xcec8977efb147760919b983a952033f936c590df"
1708
+ }
1709
+ }
1710
+ ]
1711
+ }
1712
+ },
1686
1713
  {
1687
1714
  parents: 1,
1688
1715
  interior: {
@@ -1829,6 +1856,26 @@ var Hydration = {
1829
1856
  ]
1830
1857
  }
1831
1858
  },
1859
+ {
1860
+ parents: 2,
1861
+ interior: {
1862
+ X2: [
1863
+ {
1864
+ GlobalConsensus: {
1865
+ Ethereum: {
1866
+ chainId: 1
1867
+ }
1868
+ }
1869
+ },
1870
+ {
1871
+ AccountKey20: {
1872
+ network: null,
1873
+ key: "0x38eeb52f0771140d10c4e9a9a72349a329fe8a6a"
1874
+ }
1875
+ }
1876
+ ]
1877
+ }
1878
+ },
1832
1879
  {
1833
1880
  parents: 2,
1834
1881
  interior: {
@@ -1920,22 +1967,6 @@ var Hydration = {
1920
1967
  ]
1921
1968
  }
1922
1969
  },
1923
- {
1924
- parents: 1,
1925
- interior: {
1926
- X2: [
1927
- {
1928
- Parachain: 2000
1929
- },
1930
- {
1931
- GeneralKey: {
1932
- length: 2,
1933
- data: "0x0000000000000000000000000000000000000000000000000000000000000000"
1934
- }
1935
- }
1936
- ]
1937
- }
1938
- },
1939
1970
  {
1940
1971
  parents: 2,
1941
1972
  interior: {
@@ -2519,6 +2550,16 @@ var Hydration = {
2519
2550
  ]
2520
2551
  }
2521
2552
  },
2553
+ {
2554
+ parents: 1,
2555
+ interior: {
2556
+ X1: [
2557
+ {
2558
+ Parachain: 3370
2559
+ }
2560
+ ]
2561
+ }
2562
+ },
2522
2563
  {
2523
2564
  parents: 1,
2524
2565
  interior: {
@@ -2659,6 +2700,26 @@ var Hydration = {
2659
2700
  ]
2660
2701
  }
2661
2702
  },
2703
+ {
2704
+ parents: 2,
2705
+ interior: {
2706
+ X2: [
2707
+ {
2708
+ GlobalConsensus: {
2709
+ Ethereum: {
2710
+ chainId: 1
2711
+ }
2712
+ }
2713
+ },
2714
+ {
2715
+ AccountKey20: {
2716
+ network: null,
2717
+ key: "0xd166337499e176bbc38a1fbd113ab144e5bd2df7"
2718
+ }
2719
+ }
2720
+ ]
2721
+ }
2722
+ },
2662
2723
  {
2663
2724
  parents: 2,
2664
2725
  interior: {
@@ -8393,11 +8454,6 @@ var AcalaExchange = /*#__PURE__*/function (_ExchangeChain) {
8393
8454
  // variant carries no data (e.g. `Kusama` -> `kusama`). Struct/tuple variants
8394
8455
  // like `Ethereum { chain_id }` keep their PascalCase.
8395
8456
  var LOWERCASED_PLAIN_VARIANTS = new Set(['Polkadot', 'Kusama', 'Westend', 'Rococo', 'Wococo', 'BitcoinCore', 'BitcoinCash', 'PolkadotBulletin']);
8396
- var snakeToCamel = function snakeToCamel(key) {
8397
- return key.replace(/_([a-z])/g, function (_, c) {
8398
- return c.toUpperCase();
8399
- });
8400
- };
8401
8457
  var isBinary = function isBinary(v) {
8402
8458
  return _typeof(v) === 'object' && v !== null && 'asHex' in v && typeof v.asHex === 'function';
8403
8459
  };
@@ -8558,7 +8614,7 @@ var AssetHubExchange = /*#__PURE__*/function (_ExchangeChain) {
8558
8614
  keep_alive: !!assetFrom.isNative
8559
8615
  }
8560
8616
  });
8561
- if (!(assetTo.symbol == getNativeAssetSymbol(this.chain))) {
8617
+ if (!(toDestTxFee === 0n || assetTo.symbol == getNativeAssetSymbol(this.chain))) {
8562
8618
  _context2.n = 2;
8563
8619
  break;
8564
8620
  }
@@ -11625,7 +11681,7 @@ var buildExecuteSwapHops = /*#__PURE__*/function () {
11625
11681
  var getExecuteSwapInfo = /*#__PURE__*/function () {
11626
11682
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dex, options) {
11627
11683
  var _origin$chain, _destination$chain;
11628
- var api, origin, exchange, currencyFrom, currencyTo, destination, amount, sender, recipient, evmSenderAddress, _yield$getSwapExecute, xcmFeeResult, amountOut, originChain, destChain, senderAddress, recipientAddress, originAsset, originInfo, builtHops, exchangeHopIdx, postSwapHops, _aggregateHopFees, totalHopFee, bridgeFee, destinationInfo;
11684
+ var api, origin, exchange, currencyFrom, currencyTo, destination, amount, sender, recipient, evmSenderAddress, _yield$getSwapExecute, xcmFeeResult, amountOut, originChain, destChain, senderAddress, recipientAddress, originAsset, _yield$buildOriginInf, selectedCurrency, originXcmFee, originInfo, builtHops, exchangeHopIdx, postSwapHops, _aggregateHopFees, totalHopFee, bridgeFee, destinationInfo;
11629
11685
  return _regenerator().w(function (_context) {
11630
11686
  while (1) switch (_context.n) {
11631
11687
  case 0:
@@ -11648,15 +11704,22 @@ var getExecuteSwapInfo = /*#__PURE__*/function () {
11648
11704
  api: api,
11649
11705
  origin: originChain,
11650
11706
  sender: senderAddress,
11651
- currency: currencyFrom,
11652
- originAsset: originAsset,
11707
+ assets: [_objectSpread2(_objectSpread2({}, originAsset), {}, {
11708
+ amount: BigInt(amount)
11709
+ })],
11653
11710
  amount: BigInt(amount),
11654
11711
  originFee: xcmFeeResult.origin.fee,
11655
11712
  originFeeAsset: xcmFeeResult.origin.asset,
11656
11713
  isFeeAssetAh: false
11657
11714
  });
11658
11715
  case 2:
11659
- originInfo = _context.v;
11716
+ _yield$buildOriginInf = _context.v;
11717
+ selectedCurrency = _yield$buildOriginInf.selectedCurrency;
11718
+ originXcmFee = _yield$buildOriginInf.xcmFee;
11719
+ originInfo = {
11720
+ selectedCurrency: selectedCurrency[0],
11721
+ xcmFee: originXcmFee
11722
+ };
11660
11723
  _context.n = 3;
11661
11724
  return buildExecuteSwapHops({
11662
11725
  api: api,
@@ -11685,6 +11748,7 @@ var getExecuteSwapInfo = /*#__PURE__*/function () {
11685
11748
  }),
11686
11749
  originFee: xcmFeeResult.origin.fee,
11687
11750
  isFeeAssetAh: false,
11751
+ paysDestFee: true,
11688
11752
  destFeeDetail: xcmFeeResult.destination,
11689
11753
  totalHopFee: totalHopFee,
11690
11754
  bridgeFee: bridgeFee
@@ -11713,21 +11777,40 @@ var getExecuteSwapInfo = /*#__PURE__*/function () {
11713
11777
  };
11714
11778
  }();
11715
11779
 
11716
- var buildExchangeOriginInfo = function buildExchangeOriginInfo(exchange, sender, amount, swapFee) {
11717
- return buildOriginInfo({
11718
- api: exchange.api,
11719
- origin: exchange.chain,
11720
- sender: sender,
11721
- currency: {
11722
- location: exchange.assetFrom.location
11723
- },
11724
- originAsset: exchange.assetFrom,
11725
- amount: amount,
11726
- originFee: swapFee.fee,
11727
- originFeeAsset: swapFee.asset,
11728
- isFeeAssetAh: false
11729
- });
11730
- };
11780
+ var buildExchangeOriginInfo = /*#__PURE__*/function () {
11781
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(exchange, sender, amount, swapFee) {
11782
+ var _yield$buildOriginInf, selectedCurrency, xcmFee;
11783
+ return _regenerator().w(function (_context) {
11784
+ while (1) switch (_context.n) {
11785
+ case 0:
11786
+ _context.n = 1;
11787
+ return buildOriginInfo({
11788
+ api: exchange.api,
11789
+ origin: exchange.chain,
11790
+ sender: sender,
11791
+ assets: [_objectSpread2(_objectSpread2({}, exchange.assetFrom), {}, {
11792
+ amount: amount
11793
+ })],
11794
+ amount: amount,
11795
+ originFee: swapFee.fee,
11796
+ originFeeAsset: swapFee.asset,
11797
+ isFeeAssetAh: false
11798
+ });
11799
+ case 1:
11800
+ _yield$buildOriginInf = _context.v;
11801
+ selectedCurrency = _yield$buildOriginInf.selectedCurrency;
11802
+ xcmFee = _yield$buildOriginInf.xcmFee;
11803
+ return _context.a(2, {
11804
+ selectedCurrency: selectedCurrency[0],
11805
+ xcmFee: xcmFee
11806
+ });
11807
+ }
11808
+ }, _callee);
11809
+ }));
11810
+ return function buildExchangeOriginInfo(_x, _x2, _x3, _x4) {
11811
+ return _ref.apply(this, arguments);
11812
+ };
11813
+ }();
11731
11814
  var buildExchangeDestInfo = function buildExchangeDestInfo(exchange, recipient, amountOut, currencyTo) {
11732
11815
  return buildDestInfo({
11733
11816
  api: exchange.api,
@@ -11739,6 +11822,7 @@ var buildExchangeDestInfo = function buildExchangeDestInfo(exchange, recipient,
11739
11822
  }),
11740
11823
  originFee: 0n,
11741
11824
  isFeeAssetAh: false,
11825
+ paysDestFee: true,
11742
11826
  destFeeDetail: {
11743
11827
  fee: 0n,
11744
11828
  asset: exchange.assetTo,
@@ -11748,33 +11832,33 @@ var buildExchangeDestInfo = function buildExchangeDestInfo(exchange, recipient,
11748
11832
  });
11749
11833
  };
11750
11834
  var getSwapInfo = /*#__PURE__*/function () {
11751
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(initialOptions) {
11835
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(initialOptions) {
11752
11836
  var _origin$chain, _destination$chain, _sendingInfo$hops, _receivingInfo$hops, _sendingInfo$origin, _receivingInfo$destin;
11753
11837
  var _yield$prepareTransfo, options, dex, api, origin, exchange, currencyTo, destination, amount, sender, evmSenderAddress, senderAddress, sendingInfo, _yield$getSwapFee, swapChain, amountOut, receivingInfo, originChain, destChain, exchangeHopEntry, hops, finalOrigin, finalDestination, _t, _t2, _t3, _t4, _t5;
11754
- return _regenerator().w(function (_context) {
11755
- while (1) switch (_context.p = _context.n) {
11838
+ return _regenerator().w(function (_context2) {
11839
+ while (1) switch (_context2.p = _context2.n) {
11756
11840
  case 0:
11757
11841
  validateTransferOptions(initialOptions);
11758
- _context.n = 1;
11842
+ _context2.n = 1;
11759
11843
  return prepareTransformedOptions(initialOptions, true);
11760
11844
  case 1:
11761
- _yield$prepareTransfo = _context.v;
11845
+ _yield$prepareTransfo = _context2.v;
11762
11846
  options = _yield$prepareTransfo.options;
11763
11847
  dex = _yield$prepareTransfo.dex;
11764
11848
  if (!canUseExecuteTransfer(dex, options)) {
11765
- _context.n = 5;
11849
+ _context2.n = 5;
11766
11850
  break;
11767
11851
  }
11768
- _context.p = 2;
11769
- _context.n = 3;
11852
+ _context2.p = 2;
11853
+ _context2.n = 3;
11770
11854
  return getExecuteSwapInfo(dex, options);
11771
11855
  case 3:
11772
- return _context.a(2, _context.v);
11856
+ return _context2.a(2, _context2.v);
11773
11857
  case 4:
11774
- _context.p = 4;
11775
- _t = _context.v;
11858
+ _context2.p = 4;
11859
+ _t = _context2.v;
11776
11860
  if (isFilteredError(_t)) {
11777
- _context.n = 5;
11861
+ _context2.n = 5;
11778
11862
  break;
11779
11863
  }
11780
11864
  throw _t;
@@ -11783,10 +11867,10 @@ var getSwapInfo = /*#__PURE__*/function () {
11783
11867
  assertCurrencyCore(currencyTo);
11784
11868
  senderAddress = evmSenderAddress !== null && evmSenderAddress !== void 0 ? evmSenderAddress : sender;
11785
11869
  if (!(origin && origin.chain !== exchange.chain)) {
11786
- _context.n = 7;
11870
+ _context2.n = 7;
11787
11871
  break;
11788
11872
  }
11789
- _context.n = 6;
11873
+ _context2.n = 6;
11790
11874
  return createToExchangeBuilder({
11791
11875
  origin: origin,
11792
11876
  exchange: exchange,
@@ -11796,24 +11880,24 @@ var getSwapInfo = /*#__PURE__*/function () {
11796
11880
  api: api
11797
11881
  }).getTransferInfo();
11798
11882
  case 6:
11799
- _t2 = _context.v;
11800
- _context.n = 8;
11883
+ _t2 = _context2.v;
11884
+ _context2.n = 8;
11801
11885
  break;
11802
11886
  case 7:
11803
11887
  _t2 = undefined;
11804
11888
  case 8:
11805
11889
  sendingInfo = _t2;
11806
- _context.n = 9;
11890
+ _context2.n = 9;
11807
11891
  return getSwapFee(dex, options);
11808
11892
  case 9:
11809
- _yield$getSwapFee = _context.v;
11893
+ _yield$getSwapFee = _context2.v;
11810
11894
  swapChain = _yield$getSwapFee.result;
11811
11895
  amountOut = _yield$getSwapFee.amountOut;
11812
11896
  if (!(destination && destination.chain !== exchange.chain)) {
11813
- _context.n = 11;
11897
+ _context2.n = 11;
11814
11898
  break;
11815
11899
  }
11816
- _context.n = 10;
11900
+ _context2.n = 10;
11817
11901
  return createFromExchangeBuilder({
11818
11902
  exchange: exchange,
11819
11903
  destination: destination,
@@ -11822,8 +11906,8 @@ var getSwapInfo = /*#__PURE__*/function () {
11822
11906
  api: api
11823
11907
  }).getTransferInfo();
11824
11908
  case 10:
11825
- _t3 = _context.v;
11826
- _context.n = 12;
11909
+ _t3 = _context2.v;
11910
+ _context2.n = 12;
11827
11911
  break;
11828
11912
  case 11:
11829
11913
  _t3 = undefined;
@@ -11844,34 +11928,34 @@ var getSwapInfo = /*#__PURE__*/function () {
11844
11928
  } : undefined;
11845
11929
  hops = [].concat(_toConsumableArray((_sendingInfo$hops = sendingInfo === null || sendingInfo === void 0 ? void 0 : sendingInfo.hops) !== null && _sendingInfo$hops !== void 0 ? _sendingInfo$hops : []), _toConsumableArray(exchangeHopEntry ? [exchangeHopEntry] : []), _toConsumableArray((_receivingInfo$hops = receivingInfo === null || receivingInfo === void 0 ? void 0 : receivingInfo.hops) !== null && _receivingInfo$hops !== void 0 ? _receivingInfo$hops : []));
11846
11930
  if (!((_sendingInfo$origin = sendingInfo === null || sendingInfo === void 0 ? void 0 : sendingInfo.origin) !== null && _sendingInfo$origin !== void 0)) {
11847
- _context.n = 13;
11931
+ _context2.n = 13;
11848
11932
  break;
11849
11933
  }
11850
11934
  _t4 = _sendingInfo$origin;
11851
- _context.n = 15;
11935
+ _context2.n = 15;
11852
11936
  break;
11853
11937
  case 13:
11854
- _context.n = 14;
11938
+ _context2.n = 14;
11855
11939
  return buildExchangeOriginInfo(exchange, senderAddress, amount, swapChain);
11856
11940
  case 14:
11857
- _t4 = _context.v;
11941
+ _t4 = _context2.v;
11858
11942
  case 15:
11859
11943
  finalOrigin = _t4;
11860
11944
  if (!((_receivingInfo$destin = receivingInfo === null || receivingInfo === void 0 ? void 0 : receivingInfo.destination) !== null && _receivingInfo$destin !== void 0)) {
11861
- _context.n = 16;
11945
+ _context2.n = 16;
11862
11946
  break;
11863
11947
  }
11864
11948
  _t5 = _receivingInfo$destin;
11865
- _context.n = 18;
11949
+ _context2.n = 18;
11866
11950
  break;
11867
11951
  case 16:
11868
- _context.n = 17;
11952
+ _context2.n = 17;
11869
11953
  return buildExchangeDestInfo(exchange, sender, amountOut, currencyTo);
11870
11954
  case 17:
11871
- _t5 = _context.v;
11955
+ _t5 = _context2.v;
11872
11956
  case 18:
11873
11957
  finalDestination = _t5;
11874
- return _context.a(2, {
11958
+ return _context2.a(2, {
11875
11959
  chain: {
11876
11960
  origin: originChain,
11877
11961
  destination: destChain,
@@ -11886,10 +11970,10 @@ var getSwapInfo = /*#__PURE__*/function () {
11886
11970
  })
11887
11971
  });
11888
11972
  }
11889
- }, _callee, null, [[2, 4]]);
11973
+ }, _callee2, null, [[2, 4]]);
11890
11974
  }));
11891
- return function getSwapInfo(_x) {
11892
- return _ref.apply(this, arguments);
11975
+ return function getSwapInfo(_x5) {
11976
+ return _ref2.apply(this, arguments);
11893
11977
  };
11894
11978
  }();
11895
11979
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/swap",
3
- "version": "13.7.1",
3
+ "version": "13.8.0",
4
4
  "description": "Tool for XCM cross-chain asset exchanging across Polkadot and Kusama ecosystems",
5
5
  "type": "module",
6
6
  "exports": {
@@ -46,29 +46,27 @@
46
46
  "ethers-v6": "npm:ethers@^6.16.0",
47
47
  "jsbi": "^4.3.2",
48
48
  "lodash-es": "^4.18.1",
49
- "polkadot-api": "^2.1.4",
49
+ "polkadot-api": "^2.1.6",
50
50
  "postcss": "^8.5.15",
51
51
  "react": "^19.2.6",
52
52
  "rxjs": "^7.8.2",
53
- "@paraspell/sdk": "13.7.1",
54
- "@paraspell/sdk-core": "13.7.1",
55
- "@paraspell/sdk-pjs": "13.7.1"
53
+ "@paraspell/sdk": "13.8.0",
54
+ "@paraspell/sdk-common": "13.8.0",
55
+ "@paraspell/sdk-core": "13.8.0",
56
+ "@paraspell/sdk-pjs": "13.8.0"
56
57
  },
57
58
  "devDependencies": {
58
- "@babel/core": "^7.29.7",
59
59
  "@babel/plugin-syntax-import-attributes": "^7.29.7",
60
60
  "@babel/preset-env": "^7.29.7",
61
61
  "@codecov/rollup-plugin": "^2.0.1",
62
62
  "@rollup/plugin-babel": "^7.0.0",
63
63
  "@rollup/plugin-json": "^6.1.0",
64
64
  "@rollup/plugin-typescript": "^12.3.0",
65
- "@types/lodash-es": "^4.17.12",
66
65
  "@vitest/coverage-v8": "^4.1.7",
67
66
  "dotenv": "^17.4.2",
68
67
  "rollup": "^4.60.4",
69
68
  "rollup-plugin-dts": "^6.4.1",
70
- "ts-node": "^10.9.2",
71
- "tslib": "^2.8.1"
69
+ "tsx": "^4.22.4"
72
70
  },
73
71
  "scripts": {
74
72
  "compile": "tsc --noEmit",
@@ -81,6 +79,6 @@
81
79
  "test:cov": "vitest run --coverage",
82
80
  "test:watch": "vitest",
83
81
  "runAll": "pnpm compile && pnpm format:write && pnpm lint && pnpm test",
84
- "updateAssets": "node --loader ts-node/esm --experimental-specifier-resolution=node ./scripts/updateAssets.ts"
82
+ "updateAssets": "tsx ./scripts/updateAssets.ts"
85
83
  }
86
84
  }