@paraspell/swap 12.9.7 → 12.10.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 +96 -221
- package/dist/index.mjs +434 -497
- 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, PolkadotApi, 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,27 +90,30 @@ 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;
|
|
146
|
-
|
|
147
|
-
|
|
115
|
+
api: PolkadotApi<TApi, TRes, TSigner>;
|
|
116
|
+
chain: TExchangeChain;
|
|
148
117
|
assetFrom: TAssetInfo;
|
|
149
118
|
assetTo: TAssetInfo;
|
|
150
119
|
feeAssetInfo?: TAssetInfo;
|
|
@@ -153,13 +122,12 @@ type TDestinationInfo = {
|
|
|
153
122
|
chain: TChain;
|
|
154
123
|
address: string;
|
|
155
124
|
};
|
|
156
|
-
type TAdditionalTransferOptions = {
|
|
125
|
+
type TAdditionalTransferOptions<TApi, TRes, TSigner> = {
|
|
157
126
|
amount: bigint;
|
|
158
|
-
origin?: TOriginInfo
|
|
159
|
-
exchange: TExchangeInfo
|
|
127
|
+
origin?: TOriginInfo<TApi>;
|
|
128
|
+
exchange: TExchangeInfo<TApi, TRes, TSigner>;
|
|
160
129
|
destination?: TDestinationInfo;
|
|
161
130
|
feeCalcAddress: string;
|
|
162
|
-
builderOptions?: TRouterBuilderOptions;
|
|
163
131
|
};
|
|
164
132
|
type TPairs = TLocation[][];
|
|
165
133
|
type TDexConfigBase = {
|
|
@@ -173,72 +141,57 @@ type TDexConfigStored = {
|
|
|
173
141
|
assets: TLocation[];
|
|
174
142
|
} & TDexConfigBase;
|
|
175
143
|
type TAssetsRecord = Record<TExchangeChain, TDexConfigStored>;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
type TBaseTransaction = {
|
|
179
|
-
api: TPapiApi;
|
|
144
|
+
type TBaseTransaction<TApi, TRes> = {
|
|
145
|
+
api: TApi;
|
|
180
146
|
chain: TSubstrateChain;
|
|
181
147
|
destinationChain?: TChain;
|
|
182
|
-
tx:
|
|
148
|
+
tx: TRes;
|
|
183
149
|
};
|
|
184
|
-
type TSwapTransaction = TBaseTransaction & {
|
|
150
|
+
type TSwapTransaction<TApi, TRes> = TBaseTransaction<TApi, TRes> & {
|
|
185
151
|
type: 'SWAP';
|
|
186
152
|
amountOut: bigint;
|
|
187
153
|
};
|
|
188
|
-
type TTransferTransaction = TBaseTransaction & {
|
|
154
|
+
type TTransferTransaction<TApi, TRes> = TBaseTransaction<TApi, TRes> & {
|
|
189
155
|
type: 'TRANSFER';
|
|
190
156
|
};
|
|
191
|
-
type TSwapAndTransferTransaction = TBaseTransaction & {
|
|
157
|
+
type TSwapAndTransferTransaction<TApi, TRes> = TBaseTransaction<TApi, TRes> & {
|
|
192
158
|
type: 'SWAP_AND_TRANSFER';
|
|
193
159
|
amountOut: bigint;
|
|
194
160
|
};
|
|
195
|
-
type TTransaction = TSwapTransaction | TSwapAndTransferTransaction | TTransferTransaction
|
|
196
|
-
type TRouterPlan = TTransaction[];
|
|
197
|
-
type TExecuteRouterPlanOptions = {
|
|
198
|
-
signer:
|
|
199
|
-
|
|
161
|
+
type TTransaction<TApi, TRes> = TSwapTransaction<TApi, TRes> | TSwapAndTransferTransaction<TApi, TRes> | TTransferTransaction<TApi, TRes>;
|
|
162
|
+
type TRouterPlan<TApi, TRes> = TTransaction<TApi, TRes>[];
|
|
163
|
+
type TExecuteRouterPlanOptions<TApi, TRes, TSigner> = {
|
|
164
|
+
signer: TSigner;
|
|
165
|
+
sender: string;
|
|
200
166
|
destination?: TChain;
|
|
201
|
-
evmSigner?:
|
|
167
|
+
evmSigner?: TSigner;
|
|
202
168
|
evmSenderAddress?: string;
|
|
203
|
-
onStatusChange?: TStatusChangeCallback
|
|
169
|
+
onStatusChange?: TStatusChangeCallback<TApi, TRes>;
|
|
170
|
+
api: PolkadotApi<TApi, TRes, TSigner>;
|
|
204
171
|
};
|
|
205
|
-
type TPreparedExtrinsics = {
|
|
206
|
-
toExchangeTx?:
|
|
207
|
-
swapTxs:
|
|
172
|
+
type TPreparedExtrinsics<TRes> = {
|
|
173
|
+
toExchangeTx?: TRes;
|
|
174
|
+
swapTxs: TRes[];
|
|
208
175
|
isExecute?: boolean;
|
|
209
|
-
toDestTx?:
|
|
176
|
+
toDestTx?: TRes;
|
|
210
177
|
amountOut: bigint;
|
|
211
178
|
};
|
|
212
|
-
type TBuildToExchangeTxOptions = {
|
|
213
|
-
origin: TOriginInfo
|
|
214
|
-
exchange: TExchangeInfo
|
|
215
|
-
|
|
179
|
+
type TBuildToExchangeTxOptions<TApi, TRes, TSigner> = {
|
|
180
|
+
origin: TOriginInfo<TApi>;
|
|
181
|
+
exchange: TExchangeInfo<TApi, TRes, TSigner>;
|
|
182
|
+
sender: string;
|
|
216
183
|
evmSenderAddress?: string;
|
|
217
184
|
amount: bigint;
|
|
218
|
-
|
|
185
|
+
api: PolkadotApi<TApi, TRes, TSigner>;
|
|
219
186
|
};
|
|
220
|
-
type TBuildFromExchangeTxOptions = {
|
|
221
|
-
exchange: TExchangeInfo
|
|
187
|
+
type TBuildFromExchangeTxOptions<TApi, TRes, TSigner> = {
|
|
188
|
+
exchange: TExchangeInfo<TApi, TRes, TSigner>;
|
|
222
189
|
destination: TDestinationInfo;
|
|
223
190
|
amount: bigint;
|
|
224
|
-
|
|
225
|
-
|
|
191
|
+
sender: string;
|
|
192
|
+
api: PolkadotApi<TApi, TRes, TSigner>;
|
|
226
193
|
};
|
|
227
194
|
|
|
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
195
|
declare const getExchangeConfig: (exchange: TExchangeChain) => TDexConfig;
|
|
243
196
|
declare const getExchangeAssets: (exchange: TExchangeChain) => TAssetInfo[];
|
|
244
197
|
|
|
@@ -272,22 +225,18 @@ declare const getSupportedAssetsTo: (exchangeInput: TExchangeInput, to: TChain |
|
|
|
272
225
|
*/
|
|
273
226
|
declare const getSupportedFeeAssets: (from: TChain | undefined, exchangeInput: TExchangeInput) => TAssetInfo[];
|
|
274
227
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
*
|
|
278
|
-
* @deprecated Use `@paraspell/sdk` with the "swap" extension installed instead.
|
|
279
|
-
*/
|
|
280
|
-
declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
228
|
+
declare class RouterBuilderCore<TApi, TRes, TSigner, T extends Partial<TTransferBaseOptions<TApi, TRes, TSigner>> = object> {
|
|
229
|
+
readonly _api: PolkadotApi<TApi, TRes, TSigner>;
|
|
281
230
|
readonly _options: T;
|
|
282
|
-
readonly _builderOptions?:
|
|
283
|
-
constructor(
|
|
231
|
+
readonly _builderOptions?: TTransferBaseOptions<TApi, TRes, TSigner>;
|
|
232
|
+
constructor(api: PolkadotApi<TApi, TRes, TSigner>, options?: T);
|
|
284
233
|
/**
|
|
285
234
|
* Specifies the origin chain of the transfer.
|
|
286
235
|
*
|
|
287
236
|
* @param chain - The origin chain.
|
|
288
237
|
* @returns The current builder instance.
|
|
289
238
|
*/
|
|
290
|
-
from(chain: TSubstrateChain | undefined): RouterBuilderCore<T & {
|
|
239
|
+
from(chain: TSubstrateChain | undefined): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
291
240
|
from: TSubstrateChain | undefined;
|
|
292
241
|
}>;
|
|
293
242
|
/**
|
|
@@ -296,7 +245,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
296
245
|
* @param chain - The exchange chain, or `undefined` to auto-select.
|
|
297
246
|
* @returns The current builder instance.
|
|
298
247
|
*/
|
|
299
|
-
exchange(chain: TExchangeInput): RouterBuilderCore<T & {
|
|
248
|
+
exchange(chain: TExchangeInput): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
300
249
|
exchange: TExchangeInput;
|
|
301
250
|
}>;
|
|
302
251
|
/**
|
|
@@ -305,7 +254,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
305
254
|
* @param chain - The destination chain.
|
|
306
255
|
* @returns The current builder instance.
|
|
307
256
|
*/
|
|
308
|
-
to(chain: TChain | undefined): RouterBuilderCore<T & {
|
|
257
|
+
to(chain: TChain | undefined): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
309
258
|
to: TChain | undefined;
|
|
310
259
|
}>;
|
|
311
260
|
/**
|
|
@@ -314,7 +263,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
314
263
|
* @param currencyFrom - The currency to send.
|
|
315
264
|
* @returns The current builder instance.
|
|
316
265
|
*/
|
|
317
|
-
currencyFrom(currency: TCurrencyInput): RouterBuilderCore<T & {
|
|
266
|
+
currencyFrom(currency: TCurrencyInput): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
318
267
|
currencyFrom: TCurrencyInput;
|
|
319
268
|
}>;
|
|
320
269
|
/**
|
|
@@ -323,7 +272,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
323
272
|
* @param currencyTo - The currency to receive.
|
|
324
273
|
* @returns The current builder instance.
|
|
325
274
|
*/
|
|
326
|
-
currencyTo(currency: TCurrencyInput): RouterBuilderCore<T & {
|
|
275
|
+
currencyTo(currency: TCurrencyInput): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
327
276
|
currencyTo: TCurrencyInput;
|
|
328
277
|
}>;
|
|
329
278
|
/**
|
|
@@ -332,7 +281,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
332
281
|
* @param currency - The fee asset currency, or `undefined` to use the default.
|
|
333
282
|
* @returns The current builder instance.
|
|
334
283
|
*/
|
|
335
|
-
feeAsset(currency: TCurrencyInput | undefined): RouterBuilderCore<T & {
|
|
284
|
+
feeAsset(currency: TCurrencyInput | undefined): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
336
285
|
feeAsset: TCurrencyInput | undefined;
|
|
337
286
|
}>;
|
|
338
287
|
/**
|
|
@@ -341,17 +290,17 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
341
290
|
* @param amount - The amount to transfer.
|
|
342
291
|
* @returns The current builder instance.
|
|
343
292
|
*/
|
|
344
|
-
amount(amount: TAmount): RouterBuilderCore<T & {
|
|
293
|
+
amount(amount: TAmount): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
345
294
|
amount: TAmount;
|
|
346
295
|
}>;
|
|
347
296
|
/**
|
|
348
297
|
* Specifies the recipient address on the destination chain.
|
|
349
298
|
*
|
|
350
|
-
* @param
|
|
299
|
+
* @param recipient - The recipient address.
|
|
351
300
|
* @returns The current builder instance.
|
|
352
301
|
*/
|
|
353
|
-
|
|
354
|
-
|
|
302
|
+
recipient(address: string | undefined): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
303
|
+
recipient: string | undefined;
|
|
355
304
|
}>;
|
|
356
305
|
/**
|
|
357
306
|
* Specifies the sender address initiating the transfer.
|
|
@@ -359,17 +308,17 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
359
308
|
* @param senderAddress - The sender address.
|
|
360
309
|
* @returns The current builder instance.
|
|
361
310
|
*/
|
|
362
|
-
|
|
363
|
-
|
|
311
|
+
sender(address: string): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
312
|
+
sender: string;
|
|
364
313
|
}>;
|
|
365
314
|
/**
|
|
366
|
-
* Specifies the
|
|
315
|
+
* Specifies the signer for the transaction.
|
|
367
316
|
*
|
|
368
|
-
* @param signer - The
|
|
317
|
+
* @param signer - The signer instance.
|
|
369
318
|
* @returns The current builder instance.
|
|
370
319
|
*/
|
|
371
|
-
signer(signer:
|
|
372
|
-
signer:
|
|
320
|
+
signer(signer: TSigner): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
321
|
+
signer: TSigner;
|
|
373
322
|
}>;
|
|
374
323
|
/**
|
|
375
324
|
* Specifies the EVM sender address, required if `evmSigner` is provided. Used when dealing with EVM chains.
|
|
@@ -377,7 +326,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
377
326
|
* @param evmSenderAddress - The EVM sender address.
|
|
378
327
|
* @returns The current builder instance.
|
|
379
328
|
*/
|
|
380
|
-
evmSenderAddress(address: string | undefined): RouterBuilderCore<T & {
|
|
329
|
+
evmSenderAddress(address: string | undefined): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
381
330
|
evmSenderAddress: string | undefined;
|
|
382
331
|
}>;
|
|
383
332
|
/**
|
|
@@ -386,8 +335,8 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
386
335
|
* @param evmSigner - The EVM signer.
|
|
387
336
|
* @returns The current builder instance.
|
|
388
337
|
*/
|
|
389
|
-
evmSigner(signer:
|
|
390
|
-
evmSigner:
|
|
338
|
+
evmSigner(signer: TSigner | undefined): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
339
|
+
evmSigner: TSigner | undefined;
|
|
391
340
|
}>;
|
|
392
341
|
/**
|
|
393
342
|
* Specifies the maximum slippage percentage for swaps.
|
|
@@ -395,7 +344,7 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
395
344
|
* @param slippagePct - The slippage percentage.
|
|
396
345
|
* @returns The current builder instance.
|
|
397
346
|
*/
|
|
398
|
-
slippagePct(pct: string): RouterBuilderCore<T & {
|
|
347
|
+
slippagePct(pct: string): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
399
348
|
slippagePct: string;
|
|
400
349
|
}>;
|
|
401
350
|
/**
|
|
@@ -404,113 +353,39 @@ declare class RouterBuilderCore<T extends Partial<TTransferOptions> = object> {
|
|
|
404
353
|
* @param callback - The status change callback.
|
|
405
354
|
* @returns The current builder instance.
|
|
406
355
|
*/
|
|
407
|
-
onStatusChange(callback: TStatusChangeCallback): RouterBuilderCore<T & {
|
|
408
|
-
onStatusChange: TStatusChangeCallback
|
|
356
|
+
onStatusChange(callback: TStatusChangeCallback<TApi, TRes>): RouterBuilderCore<TApi, TRes, TSigner, T & {
|
|
357
|
+
onStatusChange: TStatusChangeCallback<TApi, TRes>;
|
|
409
358
|
}>;
|
|
410
359
|
/**
|
|
411
360
|
* Returns the XCM fee for origin, exchange, and destination.
|
|
412
361
|
*
|
|
413
362
|
* @returns The XCM fee result.
|
|
414
363
|
*/
|
|
415
|
-
getXcmFees<TDisableFallback extends boolean = false>(this: RouterBuilderCore<
|
|
364
|
+
getXcmFees<TDisableFallback extends boolean = false>(this: RouterBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>, options?: TGetXcmFeeBuilderOptions & {
|
|
416
365
|
disableFallback: TDisableFallback;
|
|
417
366
|
}): Promise<TGetXcmFeeResult<TDisableFallback>>;
|
|
418
|
-
getTransferableAmount(this: RouterBuilderCore<
|
|
419
|
-
getMinTransferableAmount(this: RouterBuilderCore<
|
|
367
|
+
getTransferableAmount(this: RouterBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<bigint>;
|
|
368
|
+
getMinTransferableAmount(this: RouterBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<bigint>;
|
|
420
369
|
/**
|
|
421
370
|
* Executes the transfer with the provided parameters.
|
|
422
371
|
*
|
|
372
|
+
* @returns An array of finalized transaction hashes (hex) in execution order.
|
|
423
373
|
* @throws Error if required parameters are missing.
|
|
424
374
|
*/
|
|
425
|
-
|
|
375
|
+
signAndSubmit(this: RouterBuilderCore<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner>>): Promise<string[]>;
|
|
426
376
|
/**
|
|
427
377
|
* Builds the transactions for the transfer with the provided parameters.
|
|
428
378
|
*/
|
|
429
|
-
|
|
430
|
-
dryRun(this: RouterBuilderCore<
|
|
431
|
-
getBestAmountOut(this: RouterBuilderCore<
|
|
379
|
+
build(this: RouterBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<TRouterPlan<TApi, TRes>>;
|
|
380
|
+
dryRun(this: RouterBuilderCore<TApi, TRes, TSigner, TBuildTransactionsBaseOptions<TApi, TRes, TSigner>>): Promise<TDryRunResult>;
|
|
381
|
+
getBestAmountOut(this: RouterBuilderCore<TApi, TRes, TSigner, TGetBestAmountOutBaseOptions<TApi, TRes, TSigner>>): Promise<TGetBestAmountOutResult>;
|
|
432
382
|
}
|
|
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>;
|
|
383
|
+
declare const RouterBuilder: <TApi, TRes, TSigner>(api: PolkadotApi<TApi, TRes, TSigner>) => RouterBuilderCore<TApi, TRes, TSigner, object>;
|
|
460
384
|
|
|
461
385
|
declare const FEE_BUFFER_PCT = 10;
|
|
462
386
|
declare const DEST_FEE_BUFFER_PCT = -1;
|
|
463
387
|
declare const FALLBACK_FEE_CALC_ADDRESS = "5EtHZF4E8QagNCz6naobCkCAUT52SbcEqaXiDUu2PjUHxZid";
|
|
464
388
|
declare const FALLBACK_FEE_CALC_EVM_ADDRESS = "0x1501C1413e4178c38567Ada8945A80351F7B8496";
|
|
465
389
|
|
|
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 };
|
|
390
|
+
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 };
|
|
391
|
+
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 };
|