@paraspell/swap 13.4.1 → 13.6.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 +55 -12
- package/dist/index.mjs +2052 -943
- package/package.json +20 -20
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
import { TSubstrateChain, TExchangeInput, TChain, TCurrencyInput, TAmount, TStatusChangeCallback, TAssetInfo, PolkadotApi, TExchangeChain, TLocation, WithApi, TSwapBuilder, TGetXcmFeeBuilderOptions, TGetXcmFeeResult, TTransactionContext, TDryRunResult } from '@paraspell/sdk-core';
|
|
2
|
-
import { TPapiApi } from '@paraspell/sdk';
|
|
3
|
-
import {
|
|
1
|
+
import { TSubstrateChain, TExchangeInput, TChain, TCurrencyInput, TAmount, TStatusChangeCallback, TAssetInfo, PolkadotApi, TExchangeChain, TLocation, WithApi, TCustomCtx, TSwapBuilder, TGetXcmFeeBuilderOptions, TGetXcmFeeResult, TXcmFeeDetailWithForwardedXcm, TTransferInfo, TTransactionContext, TDryRunResult, TDryRunPreviewOptions } from '@paraspell/sdk-core';
|
|
2
|
+
import { TPapiApi, TPapiTransaction } from '@paraspell/sdk';
|
|
3
|
+
import { Extrinsic } from '@paraspell/sdk-pjs';
|
|
4
4
|
import { ApiPromise } from '@polkadot/api';
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type TExchangeApiType = 'PJS' | 'PAPI' | 'GENERIC';
|
|
7
|
+
type TExchangeApiVariant = {
|
|
8
|
+
apiType: 'PJS';
|
|
7
9
|
apiPjs: ApiPromise;
|
|
10
|
+
} | {
|
|
11
|
+
apiType: 'PAPI';
|
|
12
|
+
apiPapi: TPapiApi;
|
|
13
|
+
} | {
|
|
14
|
+
apiType: 'GENERIC';
|
|
15
|
+
};
|
|
16
|
+
type TGetDexConfigApi<TApiType extends TExchangeApiType> = TApiType extends 'PJS' ? ApiPromise : TPapiApi;
|
|
17
|
+
type WithApiVariant<TBase, TApiType extends TExchangeApiType = TExchangeApiType> = TBase & Extract<TExchangeApiVariant, {
|
|
18
|
+
apiType: TApiType;
|
|
19
|
+
}>;
|
|
20
|
+
type TSwapOptionsCommon<TApi, TRes, TSigner> = {
|
|
8
21
|
api: PolkadotApi<TApi, TRes, TSigner>;
|
|
9
22
|
assetFrom: TAssetInfo;
|
|
10
23
|
assetTo: TAssetInfo;
|
|
@@ -15,8 +28,12 @@ type TSwapOptions<TApi, TRes, TSigner> = {
|
|
|
15
28
|
origin?: TOriginInfo<TApi>;
|
|
16
29
|
isForFeeEstimation?: boolean;
|
|
17
30
|
};
|
|
18
|
-
type
|
|
19
|
-
|
|
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> = {
|
|
20
37
|
api: PolkadotApi<TApi, TRes, TSigner>;
|
|
21
38
|
origin?: TOriginInfo<TApi>;
|
|
22
39
|
assetFrom: TAssetInfo;
|
|
@@ -24,7 +41,12 @@ type TGetAmountOutOptions<TApi, TRes, TSigner> = {
|
|
|
24
41
|
amount: bigint;
|
|
25
42
|
slippagePct?: string;
|
|
26
43
|
};
|
|
27
|
-
type
|
|
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'>;
|
|
49
|
+
type TExtrinsic<TRes> = Extrinsic | TPapiTransaction | TRes;
|
|
28
50
|
type TSingleSwapResult<TRes> = {
|
|
29
51
|
tx: TExtrinsic<TRes>;
|
|
30
52
|
amountOut: bigint;
|
|
@@ -112,15 +134,18 @@ type TOriginInfo<TApi> = {
|
|
|
112
134
|
assetFrom: TAssetInfo;
|
|
113
135
|
feeAssetInfo?: TAssetInfo;
|
|
114
136
|
};
|
|
115
|
-
type
|
|
116
|
-
apiPjs: TPjsApi;
|
|
117
|
-
apiPapi: TPapiApi;
|
|
137
|
+
type TExchangeInfoCommon<TApi, TRes, TSigner> = {
|
|
118
138
|
api: PolkadotApi<TApi, TRes, TSigner>;
|
|
119
139
|
chain: TExchangeChain;
|
|
120
140
|
assetFrom: TAssetInfo;
|
|
121
141
|
assetTo: TAssetInfo;
|
|
122
142
|
feeAssetInfo?: TAssetInfo;
|
|
123
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>;
|
|
146
|
+
type TPjsExchangeInfo<TApi, TRes, TSigner> = TExchangeInfoFor<TApi, TRes, TSigner, 'PJS'>;
|
|
147
|
+
type TPapiExchangeInfo<TApi, TRes, TSigner> = TExchangeInfoFor<TApi, TRes, TSigner, 'PAPI'>;
|
|
148
|
+
type TGenericExchangeInfo<TApi, TRes, TSigner> = TExchangeInfoFor<TApi, TRes, TSigner, 'GENERIC'>;
|
|
124
149
|
type TDestinationInfo = {
|
|
125
150
|
chain: TChain;
|
|
126
151
|
address: string;
|
|
@@ -194,12 +219,23 @@ type TBuildFromExchangeTxOptions<TApi, TRes, TSigner> = {
|
|
|
194
219
|
sender: string;
|
|
195
220
|
api: PolkadotApi<TApi, TRes, TSigner>;
|
|
196
221
|
};
|
|
222
|
+
type TSwapTransformedOptions<TApi, TRes, TSigner> = TTransformedOptions<TBuildTransactionsOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner>;
|
|
223
|
+
type TCallDexAmountOutOverrides = {
|
|
224
|
+
amount?: bigint;
|
|
225
|
+
assetTo?: TAssetInfo;
|
|
226
|
+
slippagePct?: string;
|
|
227
|
+
};
|
|
228
|
+
type TBuildSwapExecuteOverrides = {
|
|
229
|
+
amount?: bigint;
|
|
230
|
+
feeEstimation?: boolean;
|
|
231
|
+
};
|
|
197
232
|
|
|
198
233
|
declare const getExchangeConfig: (exchange: TExchangeChain) => TDexConfig;
|
|
199
234
|
declare const getExchangeAssets: (exchange: TExchangeChain) => TAssetInfo[];
|
|
200
235
|
|
|
201
236
|
declare const getExchangePairs: (exchange: TExchangeInput) => [TAssetInfo, TAssetInfo][];
|
|
202
237
|
|
|
238
|
+
declare const getSupportedAssetsFromImpl: <TCustomChain extends string = never>(from: TChain | TCustomChain | undefined, exchangeInput: TExchangeInput, ctx?: TCustomCtx) => TAssetInfo[];
|
|
203
239
|
/**
|
|
204
240
|
* Retrieves the list of assets supported for transfer from the origin chain to the exchange chain.
|
|
205
241
|
*
|
|
@@ -209,6 +245,7 @@ declare const getExchangePairs: (exchange: TExchangeInput) => [TAssetInfo, TAsse
|
|
|
209
245
|
*/
|
|
210
246
|
declare const getSupportedAssetsFrom: (from: TChain | undefined, exchangeInput: TExchangeInput) => TAssetInfo[];
|
|
211
247
|
|
|
248
|
+
declare const getSupportedAssetsToImpl: <TCustomChain extends string = never>(exchangeInput: TExchangeInput, to: TChain | TCustomChain | undefined, ctx?: TCustomCtx) => TAssetInfo[];
|
|
212
249
|
/**
|
|
213
250
|
* Retrieves the list of assets supported for transfer to the destination chain.
|
|
214
251
|
*
|
|
@@ -219,6 +256,7 @@ declare const getSupportedAssetsFrom: (from: TChain | undefined, exchangeInput:
|
|
|
219
256
|
*/
|
|
220
257
|
declare const getSupportedAssetsTo: (exchangeInput: TExchangeInput, to: TChain | undefined) => TAssetInfo[];
|
|
221
258
|
|
|
259
|
+
declare const getSupportedFeeAssetsImpl: <TCustomChain extends string = never>(from: TChain | TCustomChain | undefined, exchangeInput: TExchangeInput, ctx?: TCustomCtx) => TAssetInfo[];
|
|
222
260
|
/**
|
|
223
261
|
* Retrieves the list of assets that can be used to pay for fees on the origin chain.
|
|
224
262
|
*
|
|
@@ -277,11 +315,16 @@ declare class SwapBuilderCore<TApi, TRes, TSigner, T extends Partial<TTransferBa
|
|
|
277
315
|
getXcmFees<TDisableFallback extends boolean = false>(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>, options?: TGetXcmFeeBuilderOptions & {
|
|
278
316
|
disableFallback: TDisableFallback;
|
|
279
317
|
}): Promise<TGetXcmFeeResult<TDisableFallback>>;
|
|
318
|
+
getOriginXcmFee<TDisableFallback extends boolean = false>(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>, options?: TGetXcmFeeBuilderOptions & {
|
|
319
|
+
disableFallback: TDisableFallback;
|
|
320
|
+
}): Promise<TXcmFeeDetailWithForwardedXcm<TDisableFallback>>;
|
|
321
|
+
getSwapInfo(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<TTransferInfo>;
|
|
280
322
|
getTransferableAmount(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<bigint>;
|
|
281
323
|
getMinTransferableAmount(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<bigint>;
|
|
282
324
|
signAndSubmit(this: SwapBuilderCore<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner>>): Promise<string[]>;
|
|
283
325
|
build(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<TTransactionContext<TApi, TRes>[]>;
|
|
284
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>;
|
|
285
328
|
getBestAmountOut(this: SwapBuilderCore<TApi, TRes, TSigner, TGetBestAmountOutBaseOptions<TApi, TRes, TSigner>>): Promise<{
|
|
286
329
|
exchange: TExchangeChain;
|
|
287
330
|
amountOut: bigint;
|
|
@@ -294,5 +337,5 @@ declare const DEST_FEE_BUFFER_PCT = -1;
|
|
|
294
337
|
declare const FALLBACK_FEE_CALC_ADDRESS = "5EtHZF4E8QagNCz6naobCkCAUT52SbcEqaXiDUu2PjUHxZid";
|
|
295
338
|
declare const FALLBACK_FEE_CALC_EVM_ADDRESS = "0x1501C1413e4178c38567Ada8945A80351F7B8496";
|
|
296
339
|
|
|
297
|
-
export { DEST_FEE_BUFFER_PCT, FALLBACK_FEE_CALC_ADDRESS, FALLBACK_FEE_CALC_EVM_ADDRESS, FEE_BUFFER_PCT, SwapBuilder, SwapBuilderCore, getExchangeAssets, getExchangeConfig, getExchangePairs, getSupportedAssetsFrom, getSupportedAssetsTo, getSupportedFeeAssets };
|
|
298
|
-
export type { TAdditionalTransferOptions, TAssetsRecord, TBuildFromExchangeTxOptions, TBuildToExchangeTxOptions, TBuildTransactionsBaseOptions, TBuildTransactionsOptions, TCommonRouterOptions, TDestinationInfo, TDexConfig, TDexConfigBase, TDexConfigStored, TExchangeInfo, TExecuteRouterPlanOptions, TExtrinsic, TGetAmountOutOptions, TGetBestAmountOutBaseOptions, TGetBestAmountOutOptions, TGetBestAmountOutResult, TMultiSwapResult, TOriginInfo, TPairs, TPreparedExtrinsics, TRouterPlan, TSingleSwapResult, TSwapAndTransferTransaction, TSwapOptions, TSwapTransaction, TTransaction, TTransferBaseOptions, TTransferOptions, TTransformedOptions };
|
|
340
|
+
export { DEST_FEE_BUFFER_PCT, FALLBACK_FEE_CALC_ADDRESS, FALLBACK_FEE_CALC_EVM_ADDRESS, FEE_BUFFER_PCT, SwapBuilder, SwapBuilderCore, getExchangeAssets, getExchangeConfig, getExchangePairs, getSupportedAssetsFrom, getSupportedAssetsFromImpl, getSupportedAssetsTo, getSupportedAssetsToImpl, getSupportedFeeAssets, getSupportedFeeAssetsImpl };
|
|
341
|
+
export type { TAdditionalTransferOptions, TAssetsRecord, TBuildFromExchangeTxOptions, TBuildSwapExecuteOverrides, TBuildToExchangeTxOptions, TBuildTransactionsBaseOptions, TBuildTransactionsOptions, TCallDexAmountOutOverrides, TCommonRouterOptions, TDestinationInfo, TDexConfig, TDexConfigBase, TDexConfigStored, TExchangeApiType, TExchangeApiVariant, TExchangeInfo, TExchangeInfoFor, TExecuteRouterPlanOptions, TExtrinsic, TGenericExchangeInfo, TGenericGetAmountOutOptions, TGenericSwapOptions, TGetAmountOutOptions, TGetAmountOutOptionsFor, TGetBestAmountOutBaseOptions, TGetBestAmountOutOptions, TGetBestAmountOutResult, TGetDexConfigApi, TMultiSwapResult, TOriginInfo, TPairs, TPapiExchangeInfo, TPapiGetAmountOutOptions, TPapiSwapOptions, TPjsExchangeInfo, TPjsGetAmountOutOptions, TPjsSwapOptions, TPreparedExtrinsics, TRouterPlan, TSingleSwapResult, TSwapAndTransferTransaction, TSwapOptions, TSwapOptionsFor, TSwapTransaction, TSwapTransformedOptions, TTransaction, TTransferBaseOptions, TTransferOptions, TTransformedOptions };
|