@paraspell/swap 13.4.0 → 13.5.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 +51 -11
- package/dist/index.mjs +2010 -900
- package/package.json +18 -19
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, 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,6 +219,16 @@ 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[];
|
|
@@ -277,11 +312,16 @@ declare class SwapBuilderCore<TApi, TRes, TSigner, T extends Partial<TTransferBa
|
|
|
277
312
|
getXcmFees<TDisableFallback extends boolean = false>(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>, options?: TGetXcmFeeBuilderOptions & {
|
|
278
313
|
disableFallback: TDisableFallback;
|
|
279
314
|
}): Promise<TGetXcmFeeResult<TDisableFallback>>;
|
|
315
|
+
getOriginXcmFee<TDisableFallback extends boolean = false>(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>, options?: TGetXcmFeeBuilderOptions & {
|
|
316
|
+
disableFallback: TDisableFallback;
|
|
317
|
+
}): Promise<TXcmFeeDetailWithForwardedXcm<TDisableFallback>>;
|
|
318
|
+
getSwapInfo(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<TTransferInfo>;
|
|
280
319
|
getTransferableAmount(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<bigint>;
|
|
281
320
|
getMinTransferableAmount(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<bigint>;
|
|
282
321
|
signAndSubmit(this: SwapBuilderCore<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner>>): Promise<string[]>;
|
|
283
322
|
build(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<TTransactionContext<TApi, TRes>[]>;
|
|
284
323
|
dryRun(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<TDryRunResult>;
|
|
324
|
+
dryRunPreview(this: SwapBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>, previewOptions?: TDryRunPreviewOptions): Promise<TDryRunResult>;
|
|
285
325
|
getBestAmountOut(this: SwapBuilderCore<TApi, TRes, TSigner, TGetBestAmountOutBaseOptions<TApi, TRes, TSigner>>): Promise<{
|
|
286
326
|
exchange: TExchangeChain;
|
|
287
327
|
amountOut: bigint;
|
|
@@ -295,4 +335,4 @@ declare const FALLBACK_FEE_CALC_ADDRESS = "5EtHZF4E8QagNCz6naobCkCAUT52SbcEqaXiD
|
|
|
295
335
|
declare const FALLBACK_FEE_CALC_EVM_ADDRESS = "0x1501C1413e4178c38567Ada8945A80351F7B8496";
|
|
296
336
|
|
|
297
337
|
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 };
|
|
338
|
+
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 };
|