@paraspell/swap 12.9.7 → 13.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +95 -219
- package/dist/index.mjs +368 -415
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { TPjsApi, Extrinsic
|
|
4
|
-
import { PolkadotSigner } from 'polkadot-api';
|
|
5
|
-
import { ApiPromise } from '@polkadot/api';
|
|
1
|
+
import { TSubstrateChain, TExchangeInput, TChain, TCurrencyInput, TAmount, TStatusChangeCallback, TExchangeChain, TAssetInfo, IPolkadotApi, TParachain, TLocation, WithApi, TGetXcmFeeBuilderOptions, TGetXcmFeeResult, TDryRunResult } from '@paraspell/sdk-core';
|
|
2
|
+
import { TPapiApi, TPapiTransaction } from '@paraspell/sdk';
|
|
3
|
+
import { TPjsApi, Extrinsic } from '@paraspell/sdk-pjs';
|
|
6
4
|
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
type TSwapOptions = {
|
|
5
|
+
type TSwapOptions<TApi> = {
|
|
10
6
|
papiApi: TPapiApi;
|
|
11
7
|
assetFrom: TAssetInfo;
|
|
12
8
|
assetTo: TAssetInfo;
|
|
13
9
|
amount: bigint;
|
|
14
10
|
slippagePct: string;
|
|
15
|
-
|
|
11
|
+
sender: string;
|
|
16
12
|
feeCalcAddress: string;
|
|
17
|
-
origin?: TOriginInfo
|
|
13
|
+
origin?: TOriginInfo<TApi>;
|
|
18
14
|
isForFeeEstimation?: boolean;
|
|
19
15
|
};
|
|
20
|
-
type TGetAmountOutOptions = {
|
|
16
|
+
type TGetAmountOutOptions<TApi> = {
|
|
21
17
|
papiApi: TPapiApi;
|
|
22
|
-
origin?: TOriginInfo
|
|
18
|
+
origin?: TOriginInfo<TApi>;
|
|
23
19
|
assetFrom: TAssetInfo;
|
|
24
20
|
assetTo: TAssetInfo;
|
|
25
21
|
amount: bigint;
|
|
@@ -34,40 +30,10 @@ type TMultiSwapResult = {
|
|
|
34
30
|
txs: TExtrinsic[];
|
|
35
31
|
amountOut: bigint;
|
|
36
32
|
};
|
|
37
|
-
/** @deprecated Use `TSwapEventType` instead. Will be removed in v13 */
|
|
38
|
-
type TRouterEventType = TTransactionType | 'SELECTING_EXCHANGE' | 'COMPLETED';
|
|
39
|
-
/**
|
|
40
|
-
* @deprecated Use `TSwapEvent` instead. Will be removed in v13
|
|
41
|
-
*
|
|
42
|
-
* The transaction progress information.
|
|
43
|
-
*/
|
|
44
|
-
type TRouterEvent = {
|
|
45
|
-
/**
|
|
46
|
-
* Current execution phase type
|
|
47
|
-
*/
|
|
48
|
-
type: TRouterEventType;
|
|
49
|
-
/**
|
|
50
|
-
* Full transaction plan for visualization
|
|
51
|
-
*/
|
|
52
|
-
routerPlan?: TRouterPlan;
|
|
53
|
-
/**
|
|
54
|
-
* Current transaction's origin chain
|
|
55
|
-
*/
|
|
56
|
-
chain?: TSubstrateChain;
|
|
57
|
-
/**
|
|
58
|
-
* Current transaction's destination chain
|
|
59
|
-
*/
|
|
60
|
-
destinationChain?: TChain;
|
|
61
|
-
/**
|
|
62
|
-
* 0-based step index of current operation
|
|
63
|
-
*/
|
|
64
|
-
currentStep?: number;
|
|
65
|
-
};
|
|
66
|
-
type TStatusChangeCallback = (info: TRouterEvent) => void;
|
|
67
33
|
/**
|
|
68
34
|
* The options for an XCM Router transfer.
|
|
69
35
|
*/
|
|
70
|
-
type
|
|
36
|
+
type TTransferBaseOptions<TApi, TRes, TSigner> = {
|
|
71
37
|
/**
|
|
72
38
|
* The origin chain to transfer from.
|
|
73
39
|
*/
|
|
@@ -96,7 +62,7 @@ type TTransferOptions = {
|
|
|
96
62
|
/**
|
|
97
63
|
* The sender address.
|
|
98
64
|
*/
|
|
99
|
-
|
|
65
|
+
sender: string;
|
|
100
66
|
/**
|
|
101
67
|
* The EVM injector address. Used when dealing with EVM chains.
|
|
102
68
|
*/
|
|
@@ -104,19 +70,19 @@ type TTransferOptions = {
|
|
|
104
70
|
/**
|
|
105
71
|
* The recipient address.
|
|
106
72
|
*/
|
|
107
|
-
|
|
73
|
+
recipient?: string;
|
|
108
74
|
/**
|
|
109
75
|
* The slippage percentage.
|
|
110
76
|
*/
|
|
111
77
|
slippagePct: string;
|
|
112
78
|
/**
|
|
113
|
-
* The
|
|
79
|
+
* The signer instance.
|
|
114
80
|
*/
|
|
115
|
-
signer:
|
|
81
|
+
signer: TSigner;
|
|
116
82
|
/**
|
|
117
|
-
* The
|
|
83
|
+
* The EVM signer instance.
|
|
118
84
|
*/
|
|
119
|
-
evmSigner?:
|
|
85
|
+
evmSigner?: TSigner;
|
|
120
86
|
/**
|
|
121
87
|
* The asset used to pay XCM fees.
|
|
122
88
|
*/
|
|
@@ -124,25 +90,29 @@ type TTransferOptions = {
|
|
|
124
90
|
/**
|
|
125
91
|
* The callback function to call when the transaction status changes.
|
|
126
92
|
*/
|
|
127
|
-
onStatusChange?: TStatusChangeCallback
|
|
93
|
+
onStatusChange?: TStatusChangeCallback<TApi, TRes>;
|
|
128
94
|
};
|
|
129
|
-
type
|
|
95
|
+
type TTransferOptions<TApi, TRes, TSigner> = WithApi<TTransferBaseOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner>;
|
|
96
|
+
type TGetBestAmountOutBaseOptions<TApi, TRes, TSigner> = Omit<TTransferBaseOptions<TApi, TRes, TSigner>, 'onStatusChange' | 'signer' | 'evmSigner' | 'recipient' | 'slippagePct' | 'sender' | 'evmSenderAddress'>;
|
|
97
|
+
type TGetBestAmountOutOptions<TApi, TRes, TSigner> = WithApi<TGetBestAmountOutBaseOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner>;
|
|
130
98
|
type TGetBestAmountOutResult = {
|
|
131
99
|
exchange: TExchangeChain;
|
|
132
100
|
amountOut: bigint;
|
|
133
101
|
};
|
|
134
|
-
type
|
|
135
|
-
type
|
|
136
|
-
type
|
|
137
|
-
type
|
|
138
|
-
|
|
102
|
+
type TBuildTransactionsBaseOptions<TApi, TRes, TSigner> = Omit<TTransferBaseOptions<TApi, TRes, TSigner>, 'onStatusChange' | 'signer' | 'evmSigner'>;
|
|
103
|
+
type TBuildTransactionsOptions<TApi, TRes, TSigner> = WithApi<TBuildTransactionsBaseOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner>;
|
|
104
|
+
type TCommonRouterOptions<TApi, TRes, TSigner> = TTransferOptions<TApi, TRes, TSigner> | TBuildTransactionsOptions<TApi, TRes, TSigner>;
|
|
105
|
+
type TTransformedOptions<T, TApi, TRes, TSigner> = Omit<T, 'exchange' | 'amount'> & WithApi<TAdditionalTransferOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner>;
|
|
106
|
+
type TOriginInfo<TApi> = {
|
|
107
|
+
api: TApi;
|
|
139
108
|
chain: TSubstrateChain;
|
|
140
109
|
assetFrom: TAssetInfo;
|
|
141
110
|
feeAssetInfo?: TAssetInfo;
|
|
142
111
|
};
|
|
143
|
-
type TExchangeInfo = {
|
|
144
|
-
|
|
112
|
+
type TExchangeInfo<TApi, TRes, TSigner> = {
|
|
113
|
+
apiPjs: TPjsApi;
|
|
145
114
|
apiPapi: TPapiApi;
|
|
115
|
+
api: IPolkadotApi<TApi, TRes, TSigner>;
|
|
146
116
|
baseChain: TParachain;
|
|
147
117
|
exchangeChain: TExchangeChain;
|
|
148
118
|
assetFrom: TAssetInfo;
|
|
@@ -153,13 +123,12 @@ type TDestinationInfo = {
|
|
|
153
123
|
chain: TChain;
|
|
154
124
|
address: string;
|
|
155
125
|
};
|
|
156
|
-
type TAdditionalTransferOptions = {
|
|
126
|
+
type TAdditionalTransferOptions<TApi, TRes, TSigner> = {
|
|
157
127
|
amount: bigint;
|
|
158
|
-
origin?: TOriginInfo
|
|
159
|
-
exchange: TExchangeInfo
|
|
128
|
+
origin?: TOriginInfo<TApi>;
|
|
129
|
+
exchange: TExchangeInfo<TApi, TRes, TSigner>;
|
|
160
130
|
destination?: TDestinationInfo;
|
|
161
131
|
feeCalcAddress: string;
|
|
162
|
-
builderOptions?: TRouterBuilderOptions;
|
|
163
132
|
};
|
|
164
133
|
type TPairs = TLocation[][];
|
|
165
134
|
type TDexConfigBase = {
|
|
@@ -173,72 +142,57 @@ type TDexConfigStored = {
|
|
|
173
142
|
assets: TLocation[];
|
|
174
143
|
} & TDexConfigBase;
|
|
175
144
|
type TAssetsRecord = Record<TExchangeChain, TDexConfigStored>;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
type TBaseTransaction = {
|
|
179
|
-
api: TPapiApi;
|
|
145
|
+
type TBaseTransaction<TApi, TRes> = {
|
|
146
|
+
api: TApi;
|
|
180
147
|
chain: TSubstrateChain;
|
|
181
148
|
destinationChain?: TChain;
|
|
182
|
-
tx:
|
|
149
|
+
tx: TRes;
|
|
183
150
|
};
|
|
184
|
-
type TSwapTransaction = TBaseTransaction & {
|
|
151
|
+
type TSwapTransaction<TApi, TRes> = TBaseTransaction<TApi, TRes> & {
|
|
185
152
|
type: 'SWAP';
|
|
186
153
|
amountOut: bigint;
|
|
187
154
|
};
|
|
188
|
-
type TTransferTransaction = TBaseTransaction & {
|
|
155
|
+
type TTransferTransaction<TApi, TRes> = TBaseTransaction<TApi, TRes> & {
|
|
189
156
|
type: 'TRANSFER';
|
|
190
157
|
};
|
|
191
|
-
type TSwapAndTransferTransaction = TBaseTransaction & {
|
|
158
|
+
type TSwapAndTransferTransaction<TApi, TRes> = TBaseTransaction<TApi, TRes> & {
|
|
192
159
|
type: 'SWAP_AND_TRANSFER';
|
|
193
160
|
amountOut: bigint;
|
|
194
161
|
};
|
|
195
|
-
type TTransaction = TSwapTransaction | TSwapAndTransferTransaction | TTransferTransaction
|
|
196
|
-
type TRouterPlan = TTransaction[];
|
|
197
|
-
type TExecuteRouterPlanOptions = {
|
|
198
|
-
signer:
|
|
199
|
-
|
|
162
|
+
type TTransaction<TApi, TRes> = TSwapTransaction<TApi, TRes> | TSwapAndTransferTransaction<TApi, TRes> | TTransferTransaction<TApi, TRes>;
|
|
163
|
+
type TRouterPlan<TApi, TRes> = TTransaction<TApi, TRes>[];
|
|
164
|
+
type TExecuteRouterPlanOptions<TApi, TRes, TSigner> = {
|
|
165
|
+
signer: TSigner;
|
|
166
|
+
sender: string;
|
|
200
167
|
destination?: TChain;
|
|
201
|
-
evmSigner?:
|
|
168
|
+
evmSigner?: TSigner;
|
|
202
169
|
evmSenderAddress?: string;
|
|
203
|
-
onStatusChange?: TStatusChangeCallback
|
|
170
|
+
onStatusChange?: TStatusChangeCallback<TApi, TRes>;
|
|
171
|
+
api: IPolkadotApi<TApi, TRes, TSigner>;
|
|
204
172
|
};
|
|
205
|
-
type TPreparedExtrinsics = {
|
|
206
|
-
toExchangeTx?:
|
|
207
|
-
swapTxs:
|
|
173
|
+
type TPreparedExtrinsics<TRes> = {
|
|
174
|
+
toExchangeTx?: TRes;
|
|
175
|
+
swapTxs: TRes[];
|
|
208
176
|
isExecute?: boolean;
|
|
209
|
-
toDestTx?:
|
|
177
|
+
toDestTx?: TRes;
|
|
210
178
|
amountOut: bigint;
|
|
211
179
|
};
|
|
212
|
-
type TBuildToExchangeTxOptions = {
|
|
213
|
-
origin: TOriginInfo
|
|
214
|
-
exchange: TExchangeInfo
|
|
215
|
-
|
|
180
|
+
type TBuildToExchangeTxOptions<TApi, TRes, TSigner> = {
|
|
181
|
+
origin: TOriginInfo<TApi>;
|
|
182
|
+
exchange: TExchangeInfo<TApi, TRes, TSigner>;
|
|
183
|
+
sender: string;
|
|
216
184
|
evmSenderAddress?: string;
|
|
217
185
|
amount: bigint;
|
|
218
|
-
|
|
186
|
+
api: IPolkadotApi<TApi, TRes, TSigner>;
|
|
219
187
|
};
|
|
220
|
-
type TBuildFromExchangeTxOptions = {
|
|
221
|
-
exchange: TExchangeInfo
|
|
188
|
+
type TBuildFromExchangeTxOptions<TApi, TRes, TSigner> = {
|
|
189
|
+
exchange: TExchangeInfo<TApi, TRes, TSigner>;
|
|
222
190
|
destination: TDestinationInfo;
|
|
223
191
|
amount: bigint;
|
|
224
|
-
|
|
225
|
-
|
|
192
|
+
sender: string;
|
|
193
|
+
api: IPolkadotApi<TApi, TRes, TSigner>;
|
|
226
194
|
};
|
|
227
195
|
|
|
228
|
-
/** @deprecated - Use TDryRunChainResult instead. Will be removed in v13. */
|
|
229
|
-
type TRouterDryRunChainResult = TDryRunChainResult;
|
|
230
|
-
/** @deprecated - Use THopInfo instead. Will be removed in v13. */
|
|
231
|
-
type TRouterDryRunHopInfo = THopInfo;
|
|
232
|
-
/** @deprecated - Use TDryRunResult instead. Will be removed in v13. */
|
|
233
|
-
type TRouterDryRunResult = TDryRunResult;
|
|
234
|
-
|
|
235
|
-
/** @deprecated - Use TConditionalXcmFeeHopInfo instead. Will be removed in v13. */
|
|
236
|
-
type TRouterXcmFeeHopInfo = TXcmFeeHopInfo;
|
|
237
|
-
/** @deprecated - Use TConditionalXcmFeeDetail instead. Will be removed in v13. */
|
|
238
|
-
type TRouterXcmFeeDetail = TXcmFeeDetail;
|
|
239
|
-
/** @deprecated - Use TGetXcmFeeResult instead. Will be removed in v13. */
|
|
240
|
-
type TRouterXcmFeeResult = TGetXcmFeeResult;
|
|
241
|
-
|
|
242
196
|
declare const getExchangeConfig: (exchange: TExchangeChain) => TDexConfig;
|
|
243
197
|
declare const getExchangeAssets: (exchange: TExchangeChain) => TAssetInfo[];
|
|
244
198
|
|
|
@@ -272,22 +226,18 @@ declare const getSupportedAssetsTo: (exchangeInput: TExchangeInput, to: TChain |
|
|
|
272
226
|
*/
|
|
273
227
|
declare const getSupportedFeeAssets: (from: TChain | undefined, exchangeInput: TExchangeInput) => TAssetInfo[];
|
|
274
228
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
*
|
|
278
|
-
* @deprecated Use `@paraspell/sdk` with the "swap" extension installed instead.
|
|
279
|
-
*/
|
|
280
|
-
declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
229
|
+
declare class RouterBuilderCore<TApi, TRes, TSigner, T extends Partial<TTransferBaseOptions<TApi, TRes, TSigner>> = object> {
|
|
230
|
+
readonly _api: IPolkadotApi<TApi, TRes, TSigner>;
|
|
281
231
|
readonly _options: T;
|
|
282
|
-
readonly _builderOptions?:
|
|
283
|
-
constructor(
|
|
232
|
+
readonly _builderOptions?: TTransferBaseOptions<TApi, TRes, TSigner>;
|
|
233
|
+
constructor(api: IPolkadotApi<TApi, TRes, TSigner>, options?: T);
|
|
284
234
|
/**
|
|
285
235
|
* Specifies the origin chain of the transfer.
|
|
286
236
|
*
|
|
287
237
|
* @param chain - The origin chain.
|
|
288
238
|
* @returns The current builder instance.
|
|
289
239
|
*/
|
|
290
|
-
from(chain: TSubstrateChain | undefined): RouterBuilderCore<T & {
|
|
240
|
+
from(chain: TSubstrateChain | undefined): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
291
241
|
from: TSubstrateChain | undefined;
|
|
292
242
|
}>;
|
|
293
243
|
/**
|
|
@@ -296,7 +246,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
296
246
|
* @param chain - The exchange chain, or `undefined` to auto-select.
|
|
297
247
|
* @returns The current builder instance.
|
|
298
248
|
*/
|
|
299
|
-
exchange(chain: TExchangeInput): RouterBuilderCore<T & {
|
|
249
|
+
exchange(chain: TExchangeInput): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
300
250
|
exchange: TExchangeInput;
|
|
301
251
|
}>;
|
|
302
252
|
/**
|
|
@@ -305,7 +255,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
305
255
|
* @param chain - The destination chain.
|
|
306
256
|
* @returns The current builder instance.
|
|
307
257
|
*/
|
|
308
|
-
to(chain: TChain | undefined): RouterBuilderCore<T & {
|
|
258
|
+
to(chain: TChain | undefined): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
309
259
|
to: TChain | undefined;
|
|
310
260
|
}>;
|
|
311
261
|
/**
|
|
@@ -314,7 +264,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
314
264
|
* @param currencyFrom - The currency to send.
|
|
315
265
|
* @returns The current builder instance.
|
|
316
266
|
*/
|
|
317
|
-
currencyFrom(currency: TCurrencyInput): RouterBuilderCore<T & {
|
|
267
|
+
currencyFrom(currency: TCurrencyInput): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
318
268
|
currencyFrom: TCurrencyInput;
|
|
319
269
|
}>;
|
|
320
270
|
/**
|
|
@@ -323,7 +273,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
323
273
|
* @param currencyTo - The currency to receive.
|
|
324
274
|
* @returns The current builder instance.
|
|
325
275
|
*/
|
|
326
|
-
currencyTo(currency: TCurrencyInput): RouterBuilderCore<T & {
|
|
276
|
+
currencyTo(currency: TCurrencyInput): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
327
277
|
currencyTo: TCurrencyInput;
|
|
328
278
|
}>;
|
|
329
279
|
/**
|
|
@@ -332,7 +282,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
332
282
|
* @param currency - The fee asset currency, or `undefined` to use the default.
|
|
333
283
|
* @returns The current builder instance.
|
|
334
284
|
*/
|
|
335
|
-
feeAsset(currency: TCurrencyInput | undefined): RouterBuilderCore<T & {
|
|
285
|
+
feeAsset(currency: TCurrencyInput | undefined): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
336
286
|
feeAsset: TCurrencyInput | undefined;
|
|
337
287
|
}>;
|
|
338
288
|
/**
|
|
@@ -341,17 +291,17 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
341
291
|
* @param amount - The amount to transfer.
|
|
342
292
|
* @returns The current builder instance.
|
|
343
293
|
*/
|
|
344
|
-
amount(amount: TAmount): RouterBuilderCore<T & {
|
|
294
|
+
amount(amount: TAmount): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
345
295
|
amount: TAmount;
|
|
346
296
|
}>;
|
|
347
297
|
/**
|
|
348
298
|
* Specifies the recipient address on the destination chain.
|
|
349
299
|
*
|
|
350
|
-
* @param
|
|
300
|
+
* @param recipient - The recipient address.
|
|
351
301
|
* @returns The current builder instance.
|
|
352
302
|
*/
|
|
353
|
-
|
|
354
|
-
|
|
303
|
+
recipient(address: string | undefined): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
304
|
+
recipient: string | undefined;
|
|
355
305
|
}>;
|
|
356
306
|
/**
|
|
357
307
|
* Specifies the sender address initiating the transfer.
|
|
@@ -359,17 +309,17 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
359
309
|
* @param senderAddress - The sender address.
|
|
360
310
|
* @returns The current builder instance.
|
|
361
311
|
*/
|
|
362
|
-
|
|
363
|
-
|
|
312
|
+
sender(address: string): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
313
|
+
sender: string;
|
|
364
314
|
}>;
|
|
365
315
|
/**
|
|
366
|
-
* Specifies the
|
|
316
|
+
* Specifies the signer for the transaction.
|
|
367
317
|
*
|
|
368
|
-
* @param signer - The
|
|
318
|
+
* @param signer - The signer instance.
|
|
369
319
|
* @returns The current builder instance.
|
|
370
320
|
*/
|
|
371
|
-
signer(signer:
|
|
372
|
-
signer:
|
|
321
|
+
signer(signer: TSigner): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
322
|
+
signer: TSigner;
|
|
373
323
|
}>;
|
|
374
324
|
/**
|
|
375
325
|
* Specifies the EVM sender address, required if `evmSigner` is provided. Used when dealing with EVM chains.
|
|
@@ -377,7 +327,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
377
327
|
* @param evmSenderAddress - The EVM sender address.
|
|
378
328
|
* @returns The current builder instance.
|
|
379
329
|
*/
|
|
380
|
-
evmSenderAddress(address: string | undefined): RouterBuilderCore<T & {
|
|
330
|
+
evmSenderAddress(address: string | undefined): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
381
331
|
evmSenderAddress: string | undefined;
|
|
382
332
|
}>;
|
|
383
333
|
/**
|
|
@@ -386,8 +336,8 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
386
336
|
* @param evmSigner - The EVM signer.
|
|
387
337
|
* @returns The current builder instance.
|
|
388
338
|
*/
|
|
389
|
-
evmSigner(signer:
|
|
390
|
-
evmSigner:
|
|
339
|
+
evmSigner(signer: TSigner | undefined): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
340
|
+
evmSigner: TSigner | undefined;
|
|
391
341
|
}>;
|
|
392
342
|
/**
|
|
393
343
|
* Specifies the maximum slippage percentage for swaps.
|
|
@@ -395,7 +345,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
395
345
|
* @param slippagePct - The slippage percentage.
|
|
396
346
|
* @returns The current builder instance.
|
|
397
347
|
*/
|
|
398
|
-
slippagePct(pct: string): RouterBuilderCore<T & {
|
|
348
|
+
slippagePct(pct: string): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
399
349
|
slippagePct: string;
|
|
400
350
|
}>;
|
|
401
351
|
/**
|
|
@@ -404,113 +354,39 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
404
354
|
* @param callback - The status change callback.
|
|
405
355
|
* @returns The current builder instance.
|
|
406
356
|
*/
|
|
407
|
-
onStatusChange(callback: TStatusChangeCallback): RouterBuilderCore<T & {
|
|
408
|
-
onStatusChange: TStatusChangeCallback
|
|
357
|
+
onStatusChange(callback: TStatusChangeCallback<TApi, TRes>): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
358
|
+
onStatusChange: TStatusChangeCallback<TApi, TRes>;
|
|
409
359
|
}>;
|
|
410
360
|
/**
|
|
411
361
|
* Returns the XCM fee for origin, exchange, and destination.
|
|
412
362
|
*
|
|
413
363
|
* @returns The XCM fee result.
|
|
414
364
|
*/
|
|
415
|
-
getXcmFees<TDisableFallback extends boolean = false>(this: RouterBuilderCore<
|
|
365
|
+
getXcmFees<TDisableFallback extends boolean = false>(this: RouterBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>, options?: TGetXcmFeeBuilderOptions & {
|
|
416
366
|
disableFallback: TDisableFallback;
|
|
417
367
|
}): Promise<TGetXcmFeeResult<TDisableFallback>>;
|
|
418
|
-
getTransferableAmount(this: RouterBuilderCore<
|
|
419
|
-
getMinTransferableAmount(this: RouterBuilderCore<
|
|
368
|
+
getTransferableAmount(this: RouterBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<bigint>;
|
|
369
|
+
getMinTransferableAmount(this: RouterBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<bigint>;
|
|
420
370
|
/**
|
|
421
371
|
* Executes the transfer with the provided parameters.
|
|
422
372
|
*
|
|
373
|
+
* @returns An array of finalized transaction hashes (hex) in execution order.
|
|
423
374
|
* @throws Error if required parameters are missing.
|
|
424
375
|
*/
|
|
425
|
-
|
|
376
|
+
signAndSubmit(this: RouterBuilderCore<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner>>): Promise<string[]>;
|
|
426
377
|
/**
|
|
427
378
|
* Builds the transactions for the transfer with the provided parameters.
|
|
428
379
|
*/
|
|
429
|
-
|
|
430
|
-
dryRun(this: RouterBuilderCore<
|
|
431
|
-
getBestAmountOut(this: RouterBuilderCore<
|
|
380
|
+
build(this: RouterBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<TRouterPlan<TApi, TRes>>;
|
|
381
|
+
dryRun(this: RouterBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<TDryRunResult>;
|
|
382
|
+
getBestAmountOut(this: RouterBuilderCore<TApi, TRes, TSigner, TGetBestAmountOutBaseOptions<TApi, TRes, TSigner>>): Promise<TGetBestAmountOutResult>;
|
|
432
383
|
}
|
|
433
|
-
|
|
434
|
-
* Creates a new `RouterBuilder` instance for constructing and executing cross-chain transfers using the XCM Router.
|
|
435
|
-
*
|
|
436
|
-
* @deprecated Use `@paraspell/sdk` with the "swap" extension installed instead.
|
|
437
|
-
*
|
|
438
|
-
* **Example usage:**
|
|
439
|
-
* ```typescript
|
|
440
|
-
* await RouterBuilder(options)
|
|
441
|
-
* .from('Polkadot')
|
|
442
|
-
* .exchange('HydrationDex')
|
|
443
|
-
* .to('Astar')
|
|
444
|
-
* .currencyFrom({ symbol: 'DOT' })
|
|
445
|
-
* .currencyTo({ symbol: 'ASTR' })
|
|
446
|
-
* .amount(1000000n)
|
|
447
|
-
* .slippagePct('1')
|
|
448
|
-
* .senderAddress('sender_address')
|
|
449
|
-
* .recipientAddress('recipient_address')
|
|
450
|
-
* .signer(yourSigner)
|
|
451
|
-
* .onStatusChange((status) => {
|
|
452
|
-
* console.log(status);
|
|
453
|
-
* })
|
|
454
|
-
* .build();
|
|
455
|
-
* ```
|
|
456
|
-
*
|
|
457
|
-
* @returns A new `RouterBuilder`.
|
|
458
|
-
*/
|
|
459
|
-
declare const RouterBuilder: (options?: TRouterBuilderOptions) => RouterBuilderCore<object>;
|
|
384
|
+
declare const RouterBuilder: <TApi, TRes, TSigner>(api: IPolkadotApi<TApi, TRes, TSigner>) => RouterBuilderCore<TApi, TRes, TSigner, object>;
|
|
460
385
|
|
|
461
386
|
declare const FEE_BUFFER_PCT = 10;
|
|
462
387
|
declare const DEST_FEE_BUFFER_PCT = -1;
|
|
463
388
|
declare const FALLBACK_FEE_CALC_ADDRESS = "5EtHZF4E8QagNCz6naobCkCAUT52SbcEqaXiDUu2PjUHxZid";
|
|
464
389
|
declare const FALLBACK_FEE_CALC_EVM_ADDRESS = "0x1501C1413e4178c38567Ada8945A80351F7B8496";
|
|
465
390
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
private readonly _exchangeChain;
|
|
469
|
-
constructor(chain: TParachain$1, exchangeChain: TExchangeChain);
|
|
470
|
-
get chain(): TParachain$1;
|
|
471
|
-
get exchangeChain(): TExchangeChain;
|
|
472
|
-
abstract swapCurrency(api: ApiPromise, options: TSwapOptions, toDestTransactionFee: bigint): Promise<TSingleSwapResult>;
|
|
473
|
-
handleMultiSwap(api: ApiPromise, options: TSwapOptions, toDestTransactionFee: bigint): Promise<TMultiSwapResult>;
|
|
474
|
-
abstract getAmountOut(api: ApiPromise, options: TGetAmountOutOptions): Promise<bigint>;
|
|
475
|
-
abstract getDexConfig(api: ApiPromise): Promise<TDexConfigStored>;
|
|
476
|
-
createApiInstance(builderOptions?: TBuilderOptions<TPjsApiOrUrl>): Promise<ApiPromise>;
|
|
477
|
-
createApiInstancePapi(builderOptions?: TBuilderOptions<TPapiApiOrUrl>): Promise<TPapiApi>;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
declare const createExchangeInstance: (chain: TExchangeChain) => ExchangeChain;
|
|
481
|
-
|
|
482
|
-
declare const buildApiTransactions: (initialOptions: TBuildTransactionsOptions, builderOptions?: TRouterBuilderOptions) => Promise<TRouterPlan>;
|
|
483
|
-
|
|
484
|
-
declare const buildTransactions: (dex: ExchangeChain, options: TTransformedOptions<TBuildTransactionsOptions>) => Promise<TRouterPlan>;
|
|
485
|
-
|
|
486
|
-
/**
|
|
487
|
-
* This function allows users to send one type of token and receive a different one on the destination chain
|
|
488
|
-
* in a one operation. It integrates with multiple exchanges like Acala, Basilisk, Bifrost, HydraDX, Interlay,
|
|
489
|
-
* Karura, and Kintsugi, covering over 500 asset pools.
|
|
490
|
-
*
|
|
491
|
-
* **Example Usage:**
|
|
492
|
-
* ```typescript
|
|
493
|
-
* await transfer({
|
|
494
|
-
* from: 'Polkadot',
|
|
495
|
-
* to: 'Astar',
|
|
496
|
-
* currencyFrom: { symbol: 'DOT' },
|
|
497
|
-
* currencyTo: { symbol: 'ASTR' },
|
|
498
|
-
* amount: '1000000',
|
|
499
|
-
* slippagePct: '1',
|
|
500
|
-
* senderAddress: 'your_injector_address',
|
|
501
|
-
* recipientAddress: 'recipient_address',
|
|
502
|
-
* signer: 'your_signer',
|
|
503
|
-
* onStatusChange: (status) => {
|
|
504
|
-
* console.log(status);
|
|
505
|
-
* },
|
|
506
|
-
* });
|
|
507
|
-
* ```
|
|
508
|
-
*
|
|
509
|
-
* @param initialOptions - An object containing transfer details such as origin, destination, currencies, amount, addresses, and signers.
|
|
510
|
-
* @returns A Promise that resolves when the transfer is complete.
|
|
511
|
-
* @throws An error if required parameters are missing or invalid.
|
|
512
|
-
*/
|
|
513
|
-
declare const transfer: (initialOptions: TTransferOptions, builderOptions?: TRouterBuilderOptions) => Promise<void>;
|
|
514
|
-
|
|
515
|
-
export { DEST_FEE_BUFFER_PCT, FALLBACK_FEE_CALC_ADDRESS, FALLBACK_FEE_CALC_EVM_ADDRESS, FEE_BUFFER_PCT, RouterBuilder, RouterBuilderCore, buildApiTransactions, buildTransactions, createExchangeInstance, getExchangeAssets, getExchangeConfig, getExchangePairs, getSupportedAssetsFrom, getSupportedAssetsTo, getSupportedFeeAssets, transfer };
|
|
516
|
-
export type { TAdditionalTransferOptions, TAssetsRecord, TBuildFromExchangeTxOptions, TBuildToExchangeTxOptions, TBuildTransactionsOptions, TCommonRouterOptions, TDestinationInfo, TDexConfig, TDexConfigBase, TDexConfigStored, TExchangeInfo, TExecuteRouterPlanOptions, TExtrinsic, TGetAmountOutOptions, TGetBestAmountOutOptions, TGetBestAmountOutResult, TMultiSwapResult, TOriginInfo, TPairs, TPreparedExtrinsics, TRouterBuilderOptions, TRouterDryRunChainResult, TRouterDryRunHopInfo, TRouterDryRunResult, TRouterEvent, TRouterEventType, TRouterPlan, TRouterXcmFeeDetail, TRouterXcmFeeHopInfo, TRouterXcmFeeResult, TSingleSwapResult, TStatusChangeCallback, TSwapAndTransferTransaction, TSwapOptions, TSwapTransaction, TTransaction, TTransactionType, TTransferOptions, TTransformedOptions };
|
|
391
|
+
export { DEST_FEE_BUFFER_PCT, FALLBACK_FEE_CALC_ADDRESS, FALLBACK_FEE_CALC_EVM_ADDRESS, FEE_BUFFER_PCT, RouterBuilder, RouterBuilderCore, getExchangeAssets, getExchangeConfig, getExchangePairs, getSupportedAssetsFrom, getSupportedAssetsTo, getSupportedFeeAssets };
|
|
392
|
+
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 };
|