@atomiqlabs/base 10.0.0-dev.2 → 10.0.0-dev.21
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/LICENSE +201 -201
- package/dist/btc/BitcoinNetwork.d.ts +6 -6
- package/dist/btc/BitcoinNetwork.js +10 -10
- package/dist/btc/rpc/BitcoinRpc.d.ts +68 -68
- package/dist/btc/rpc/BitcoinRpc.js +2 -2
- package/dist/btcrelay/BtcRelay.d.ts +61 -61
- package/dist/btcrelay/BtcRelay.js +2 -2
- package/dist/btcrelay/synchronizer/RelaySynchronizer.d.ts +18 -18
- package/dist/btcrelay/synchronizer/RelaySynchronizer.js +2 -2
- package/dist/btcrelay/types/BtcBlock.d.ts +13 -13
- package/dist/btcrelay/types/BtcBlock.js +2 -2
- package/dist/btcrelay/types/BtcHeader.d.ts +10 -10
- package/dist/btcrelay/types/BtcHeader.js +2 -2
- package/dist/btcrelay/types/BtcStoredHeader.d.ts +11 -11
- package/dist/btcrelay/types/BtcStoredHeader.js +2 -2
- package/dist/btcrelay/utils/StatePredictorUtils.d.ts +11 -11
- package/dist/btcrelay/utils/StatePredictorUtils.js +80 -80
- package/dist/chains/ChainData.d.ts +31 -31
- package/dist/chains/ChainData.js +2 -2
- package/dist/chains/ChainInterface.d.ts +133 -110
- package/dist/chains/ChainInterface.js +7 -2
- package/dist/chains/ChainType.d.ts +24 -23
- package/dist/chains/ChainType.js +2 -2
- package/dist/errors/CannotInitializeATAError.d.ts +3 -3
- package/dist/errors/CannotInitializeATAError.js +11 -11
- package/dist/errors/SignatureVerificationError.d.ts +3 -3
- package/dist/errors/SignatureVerificationError.js +11 -11
- package/dist/errors/SwapDataVerificationError.d.ts +3 -3
- package/dist/errors/SwapDataVerificationError.js +11 -11
- package/dist/errors/TransactionRevertedError.d.ts +3 -0
- package/dist/errors/TransactionRevertedError.js +11 -0
- package/dist/events/ChainEvents.d.ts +9 -9
- package/dist/events/ChainEvents.js +2 -2
- package/dist/events/types/ChainEvent.d.ts +7 -7
- package/dist/events/types/ChainEvent.js +6 -6
- package/dist/events/types/spv_vault/SpvVaultClaimEvent.d.ts +12 -12
- package/dist/events/types/spv_vault/SpvVaultClaimEvent.js +18 -18
- package/dist/events/types/spv_vault/SpvVaultCloseEvent.d.ts +7 -7
- package/dist/events/types/spv_vault/SpvVaultCloseEvent.js +13 -13
- package/dist/events/types/spv_vault/SpvVaultDepositEvent.d.ts +7 -7
- package/dist/events/types/spv_vault/SpvVaultDepositEvent.js +13 -13
- package/dist/events/types/spv_vault/SpvVaultEvent.d.ts +15 -15
- package/dist/events/types/spv_vault/SpvVaultEvent.js +20 -20
- package/dist/events/types/spv_vault/SpvVaultFrontEvent.d.ts +10 -10
- package/dist/events/types/spv_vault/SpvVaultFrontEvent.js +16 -16
- package/dist/events/types/spv_vault/SpvVaultOpenEvent.d.ts +7 -7
- package/dist/events/types/spv_vault/SpvVaultOpenEvent.js +13 -13
- package/dist/events/types/swap/ClaimEvent.d.ts +7 -7
- package/dist/events/types/swap/ClaimEvent.js +11 -11
- package/dist/events/types/swap/InitializeEvent.d.ts +9 -9
- package/dist/events/types/swap/InitializeEvent.js +12 -12
- package/dist/events/types/swap/RefundEvent.d.ts +5 -5
- package/dist/events/types/swap/RefundEvent.js +7 -7
- package/dist/events/types/swap/SwapEvent.d.ts +12 -12
- package/dist/events/types/swap/SwapEvent.js +17 -17
- package/dist/index.d.ts +42 -38
- package/dist/index.js +58 -54
- package/dist/lockable/Lockable.d.ts +6 -6
- package/dist/lockable/Lockable.js +28 -28
- package/dist/messaging/Messenger.d.ts +8 -0
- package/dist/messaging/Messenger.js +2 -0
- package/dist/messaging/messages/Message.d.ts +11 -0
- package/dist/messaging/messages/Message.js +22 -0
- package/dist/messaging/messages/SwapClaimWitnessMessage.d.ts +10 -0
- package/dist/messaging/messages/SwapClaimWitnessMessage.js +28 -0
- package/dist/spv_swap/SpvVaultContract.d.ts +258 -199
- package/dist/spv_swap/SpvVaultContract.js +2 -2
- package/dist/spv_swap/SpvVaultData.d.ts +35 -35
- package/dist/spv_swap/SpvVaultData.js +37 -37
- package/dist/spv_swap/SpvWithdrawalState.d.ts +31 -31
- package/dist/spv_swap/SpvWithdrawalState.js +10 -10
- package/dist/spv_swap/SpvWithdrawalTransactionData.d.ts +43 -43
- package/dist/spv_swap/SpvWithdrawalTransactionData.js +143 -143
- package/dist/storage/IStorageManager.d.ts +15 -15
- package/dist/storage/IStorageManager.js +2 -2
- package/dist/storage/StorageObject.d.ts +3 -3
- package/dist/storage/StorageObject.js +2 -2
- package/dist/swaps/ChainSwapType.d.ts +6 -6
- package/dist/swaps/ChainSwapType.js +10 -10
- package/dist/swaps/SwapCommitState.d.ts +39 -38
- package/dist/swaps/SwapCommitState.js +11 -11
- package/dist/swaps/SwapContract.d.ts +479 -467
- package/dist/swaps/SwapContract.js +2 -2
- package/dist/swaps/SwapData.d.ts +37 -36
- package/dist/swaps/SwapData.js +17 -14
- package/dist/utils/BigIntBufferUtils.d.ts +6 -6
- package/dist/utils/BigIntBufferUtils.js +31 -31
- package/package.json +31 -31
- package/src/btc/BitcoinNetwork.ts +6 -6
- package/src/btc/rpc/BitcoinRpc.ts +77 -77
- package/src/btcrelay/BtcRelay.ts +70 -70
- package/src/btcrelay/synchronizer/RelaySynchronizer.ts +17 -17
- package/src/btcrelay/types/BtcBlock.ts +15 -15
- package/src/btcrelay/types/BtcHeader.ts +11 -11
- package/src/btcrelay/types/BtcStoredHeader.ts +12 -12
- package/src/btcrelay/utils/StatePredictorUtils.ts +108 -108
- package/src/chains/ChainData.ts +40 -40
- package/src/chains/ChainInterface.ts +159 -132
- package/src/chains/ChainType.ts +40 -38
- package/src/errors/CannotInitializeATAError.ts +11 -11
- package/src/errors/SignatureVerificationError.ts +11 -11
- package/src/errors/SwapDataVerificationError.ts +11 -11
- package/src/errors/TransactionRevertedError.ts +11 -0
- package/src/events/ChainEvents.ts +13 -13
- package/src/events/types/ChainEvent.ts +10 -10
- package/src/events/types/spv_vault/SpvVaultClaimEvent.ts +31 -31
- package/src/events/types/spv_vault/SpvVaultCloseEvent.ts +17 -17
- package/src/events/types/spv_vault/SpvVaultDepositEvent.ts +17 -17
- package/src/events/types/spv_vault/SpvVaultEvent.ts +25 -25
- package/src/events/types/spv_vault/SpvVaultFrontEvent.ts +27 -27
- package/src/events/types/spv_vault/SpvVaultOpenEvent.ts +16 -16
- package/src/events/types/swap/ClaimEvent.ts +15 -15
- package/src/events/types/swap/InitializeEvent.ts +18 -18
- package/src/events/types/swap/RefundEvent.ts +6 -6
- package/src/events/types/swap/SwapEvent.ts +21 -21
- package/src/index.ts +51 -46
- package/src/lockable/Lockable.ts +30 -30
- package/src/messaging/Messenger.ts +11 -0
- package/src/messaging/messages/Message.ts +25 -0
- package/src/messaging/messages/SwapClaimWitnessMessage.ts +34 -0
- package/src/spv_swap/SpvVaultContract.ts +269 -230
- package/src/spv_swap/SpvVaultData.ts +70 -70
- package/src/spv_swap/SpvWithdrawalState.ts +40 -40
- package/src/spv_swap/SpvWithdrawalTransactionData.ts +169 -169
- package/src/storage/IStorageManager.ts +16 -16
- package/src/storage/StorageObject.ts +6 -6
- package/src/swaps/ChainSwapType.ts +6 -6
- package/src/swaps/SwapCommitState.ts +40 -39
- package/src/swaps/SwapContract.ts +564 -556
- package/src/swaps/SwapData.ts +69 -65
- package/src/utils/BigIntBufferUtils.ts +31 -31
|
@@ -1,467 +1,479 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { SwapData } from "./SwapData";
|
|
3
|
-
import { BtcStoredHeader } from "../btcrelay/types/BtcStoredHeader";
|
|
4
|
-
import { ChainSwapType } from "./ChainSwapType";
|
|
5
|
-
import { RelaySynchronizer } from "../btcrelay/synchronizer/RelaySynchronizer";
|
|
6
|
-
import { Buffer } from "buffer";
|
|
7
|
-
import { AbstractSigner, TransactionConfirmationOptions } from "../chains/ChainInterface";
|
|
8
|
-
import { SwapCommitState } from "./SwapCommitState";
|
|
9
|
-
export type IntermediaryReputationType = {
|
|
10
|
-
[key in ChainSwapType]: {
|
|
11
|
-
successVolume: bigint;
|
|
12
|
-
successCount: bigint;
|
|
13
|
-
failVolume: bigint;
|
|
14
|
-
failCount: bigint;
|
|
15
|
-
coopCloseVolume: bigint;
|
|
16
|
-
coopCloseCount: bigint;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export type SignatureData = {
|
|
20
|
-
prefix: string;
|
|
21
|
-
timeout: string;
|
|
22
|
-
signature: string;
|
|
23
|
-
};
|
|
24
|
-
export type BitcoinTransactionData = {
|
|
25
|
-
blockhash: string;
|
|
26
|
-
confirmations: number;
|
|
27
|
-
txid: string;
|
|
28
|
-
hex: string;
|
|
29
|
-
height: number;
|
|
30
|
-
};
|
|
31
|
-
export interface SwapContract<T extends SwapData = SwapData, TX = any, PreFetchData = any, PreFetchVerification = any, Signer extends AbstractSigner = AbstractSigner, ChainId extends string = string> {
|
|
32
|
-
readonly chainId: ChainId;
|
|
33
|
-
readonly claimWithSecretTimeout: number;
|
|
34
|
-
readonly claimWithTxDataTimeout: number;
|
|
35
|
-
readonly refundTimeout: number;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
-
* @param
|
|
47
|
-
* @param
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @param
|
|
55
|
-
* @param
|
|
56
|
-
* @param
|
|
57
|
-
* @param
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @param
|
|
67
|
-
* @param
|
|
68
|
-
* @param
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* @param
|
|
76
|
-
* @param
|
|
77
|
-
* @param
|
|
78
|
-
* @param
|
|
79
|
-
* @param
|
|
80
|
-
* @param
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* @param
|
|
88
|
-
* @param
|
|
89
|
-
* @param
|
|
90
|
-
* @param
|
|
91
|
-
* @param
|
|
92
|
-
* @param
|
|
93
|
-
* @param
|
|
94
|
-
* @param
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* @param
|
|
102
|
-
* @param
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
105
|
-
* @param
|
|
106
|
-
* @param
|
|
107
|
-
* @param
|
|
108
|
-
* @param
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* @param
|
|
116
|
-
* @param
|
|
117
|
-
* @param
|
|
118
|
-
* @param
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @param
|
|
126
|
-
* @param
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* @param
|
|
136
|
-
* @param
|
|
137
|
-
* @param
|
|
138
|
-
* @param
|
|
139
|
-
* @param
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* @param
|
|
147
|
-
* @param
|
|
148
|
-
* @param
|
|
149
|
-
* @param
|
|
150
|
-
* @param
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* @param
|
|
158
|
-
* @param
|
|
159
|
-
* @param
|
|
160
|
-
* @param
|
|
161
|
-
* @param
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* @param
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* @param
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* @param
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* @param
|
|
197
|
-
*/
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
*
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
*
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
* @param
|
|
224
|
-
* @param
|
|
225
|
-
* @param
|
|
226
|
-
* @
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
* @param
|
|
234
|
-
* @param
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
*
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
*
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
*
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
*
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
*
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
* @param
|
|
290
|
-
* @param
|
|
291
|
-
* @param
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
* @param
|
|
298
|
-
* @param
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
* @param
|
|
305
|
-
* @param
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
*
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
*
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
*
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
*
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
*
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
*
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
*
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
*
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
*
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
*
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
*
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
* @param
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
* @param
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
*
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
*
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
* @param
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
* @param
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
* @param
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
* @param
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
*
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SwapData } from "./SwapData";
|
|
3
|
+
import { BtcStoredHeader } from "../btcrelay/types/BtcStoredHeader";
|
|
4
|
+
import { ChainSwapType } from "./ChainSwapType";
|
|
5
|
+
import { RelaySynchronizer } from "../btcrelay/synchronizer/RelaySynchronizer";
|
|
6
|
+
import { Buffer } from "buffer";
|
|
7
|
+
import { AbstractSigner, TransactionConfirmationOptions } from "../chains/ChainInterface";
|
|
8
|
+
import { SwapCommitState } from "./SwapCommitState";
|
|
9
|
+
export type IntermediaryReputationType = {
|
|
10
|
+
[key in ChainSwapType]: {
|
|
11
|
+
successVolume: bigint;
|
|
12
|
+
successCount: bigint;
|
|
13
|
+
failVolume: bigint;
|
|
14
|
+
failCount: bigint;
|
|
15
|
+
coopCloseVolume: bigint;
|
|
16
|
+
coopCloseCount: bigint;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type SignatureData = {
|
|
20
|
+
prefix: string;
|
|
21
|
+
timeout: string;
|
|
22
|
+
signature: string;
|
|
23
|
+
};
|
|
24
|
+
export type BitcoinTransactionData = {
|
|
25
|
+
blockhash: string;
|
|
26
|
+
confirmations: number;
|
|
27
|
+
txid: string;
|
|
28
|
+
hex: string;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
31
|
+
export interface SwapContract<T extends SwapData = SwapData, TX = any, PreFetchData = any, PreFetchVerification = any, Signer extends AbstractSigner = AbstractSigner, ChainId extends string = string> {
|
|
32
|
+
readonly chainId: ChainId;
|
|
33
|
+
readonly claimWithSecretTimeout: number;
|
|
34
|
+
readonly claimWithTxDataTimeout: number;
|
|
35
|
+
readonly refundTimeout: number;
|
|
36
|
+
readonly supportsInitWithoutClaimer?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Initializes the swap contract
|
|
39
|
+
*/
|
|
40
|
+
start(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Signs & sends transactions for initializing a non-payIn swap (BTC -> SC)
|
|
43
|
+
*
|
|
44
|
+
* @param signer Signer to use for the transaction (must match claimer in swap data)
|
|
45
|
+
* @param swapData Swap to init
|
|
46
|
+
* @param signature Signature data from the offerer
|
|
47
|
+
* @param skipChecks Whether to skip verification of the signature & checking if the swap is already committed
|
|
48
|
+
* @param txOptions Transaction options
|
|
49
|
+
*/
|
|
50
|
+
init(signer: Signer, swapData: T, signature: SignatureData, skipChecks?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the unsigned transactions required for initializing a non-payIn swap (BTC -> SC)
|
|
53
|
+
*
|
|
54
|
+
* @param sender Transaction sender address, must be either offerer or claimer
|
|
55
|
+
* @param swapData Swap to init
|
|
56
|
+
* @param signature Signature data from the offerer
|
|
57
|
+
* @param skipChecks Whether to skip verification of the signature & checking if the swap is already committed
|
|
58
|
+
* @param feeRate Fee rate to use for the transaction
|
|
59
|
+
*/
|
|
60
|
+
txsInit(sender: string, swapData: T, signature: SignatureData, skipChecks?: boolean, feeRate?: string): Promise<TX[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Signs & sends transactions required for claiming an HTLC swap
|
|
63
|
+
*
|
|
64
|
+
* @param signer Signer for which the transaction should be created (doesn't need to match the claimer)
|
|
65
|
+
* @param swapData Swap to claim
|
|
66
|
+
* @param secret Secret pre-image that hashes to the swap hash
|
|
67
|
+
* @param checkExpiry Whether to check expiration of the swap before executing transactions
|
|
68
|
+
* @param initAta Whether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
|
|
69
|
+
* @param txOptions Transaction options
|
|
70
|
+
*/
|
|
71
|
+
claimWithSecret(signer: Signer, swapData: T, secret: string, checkExpiry?: boolean, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Returns the unsigned transactions required for claiming an HTLC swap
|
|
74
|
+
*
|
|
75
|
+
* @param signer Signer for which the transaction should be created (doesn't need to match the claimer)
|
|
76
|
+
* @param swapData Swap to claim
|
|
77
|
+
* @param secret Secret pre-image that hashes to the swap hash
|
|
78
|
+
* @param checkExpiry Whether to check expiration of the swap before returning the transactions
|
|
79
|
+
* @param initAta Whether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
|
|
80
|
+
* @param feeRate Fee rate to use for the transactions
|
|
81
|
+
* @param skipAtaCheck Whether to skip checking if token account exists
|
|
82
|
+
*/
|
|
83
|
+
txsClaimWithSecret(signer: string | Signer, swapData: T, secret: string, checkExpiry?: boolean, initAta?: boolean, feeRate?: string, skipAtaCheck?: boolean): Promise<TX[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Signs & sends transactions required for claiming an on-chain PTLC (proof-time locked contract) swap
|
|
86
|
+
*
|
|
87
|
+
* @param signer Signer for which the transaction should be created (doesn't need to match the claimer)
|
|
88
|
+
* @param swapData Swap to claim
|
|
89
|
+
* @param tx Bitcoin transaction containing the required output
|
|
90
|
+
* @param requiredConfirmations Required confirmations for the escrow to be claimed
|
|
91
|
+
* @param vout Bitcoin tx's output index of the required output
|
|
92
|
+
* @param storedHeader Optional already retrieved stored header to use for proving
|
|
93
|
+
* @param synchronizer Optiona synchronizer to be used if BTC relay contract is not synced up to the required blockheight
|
|
94
|
+
* @param initAta Whether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
|
|
95
|
+
* @param txOptions Transaction options
|
|
96
|
+
*/
|
|
97
|
+
claimWithTxData(signer: Signer, swapData: T, tx: BitcoinTransactionData, requiredConfirmations: number, vout: number, storedHeader?: BtcStoredHeader<any>, synchronizer?: RelaySynchronizer<any, TX, any>, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the unsigned transactions required for claiming an on-chain PTLC (proof-time locked contract) swap
|
|
100
|
+
*
|
|
101
|
+
* @param signer Signer for which the transaction should be created (doesn't need to match the claimer)
|
|
102
|
+
* @param swapData Swap to claim
|
|
103
|
+
* @param tx Bitcoin transaction containing the required output
|
|
104
|
+
* @param requiredConfirmations Required confirmations for the escrow to be claimed
|
|
105
|
+
* @param vout Bitcoin tx's output index of the required output
|
|
106
|
+
* @param storedHeader Optional already retrieved stored header to use for proving
|
|
107
|
+
* @param synchronizer Optiona synchronizer to be used if BTC relay contract is not synced up to the required blockheight
|
|
108
|
+
* @param initAta Whether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
|
|
109
|
+
* @param feeRate Fee rate to use for the transactions
|
|
110
|
+
*/
|
|
111
|
+
txsClaimWithTxData(signer: string | Signer, swapData: T, tx: BitcoinTransactionData, requiredConfirmations: number, vout: number, storedHeader?: BtcStoredHeader<any>, synchronizer?: RelaySynchronizer<any, TX, any>, initAta?: boolean, feeRate?: string): Promise<TX[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Signs & sends transactions for refunding a timed out swap
|
|
114
|
+
*
|
|
115
|
+
* @param signer Signer to use for the transaction (must match offerer in swap data)
|
|
116
|
+
* @param swapData Swap to refund
|
|
117
|
+
* @param check Whether to check if the swap contract still exists on-chain
|
|
118
|
+
* @param initAta Whether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
|
|
119
|
+
* @param txOptions Transaction options
|
|
120
|
+
*/
|
|
121
|
+
refund(signer: Signer, swapData: T, check?: boolean, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
122
|
+
/**
|
|
123
|
+
* Returns the transactions for refunding a timed out swap
|
|
124
|
+
*
|
|
125
|
+
* @param signer Signer of the refund transaction
|
|
126
|
+
* @param swapData Swap to refund
|
|
127
|
+
* @param check Whether to check if the swap contract still exists on-chain
|
|
128
|
+
* @param initAta Whether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
|
|
129
|
+
* @param feeRate Fee rate to use for the transactions
|
|
130
|
+
*/
|
|
131
|
+
txsRefund(signer: string, swapData: T, check?: boolean, initAta?: boolean, feeRate?: string): Promise<TX[]>;
|
|
132
|
+
/**
|
|
133
|
+
* Signs & sends transactions for refunding a swap with a valid refund signature from the claimer
|
|
134
|
+
*
|
|
135
|
+
* @param signer Signer to use for the transaction (must match offerer in swap data)
|
|
136
|
+
* @param swapData Swap to refund
|
|
137
|
+
* @param signature Refund signature received from the claimer
|
|
138
|
+
* @param check Whether to check if the swap contract still exists on-chain
|
|
139
|
+
* @param initAta Whether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
|
|
140
|
+
* @param txOptions Transaction options
|
|
141
|
+
*/
|
|
142
|
+
refundWithAuthorization(signer: Signer, swapData: T, signature: SignatureData, check?: boolean, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
143
|
+
/**
|
|
144
|
+
* Returns the transactions for refunding a swap with a valid refund signature from the claimer
|
|
145
|
+
*
|
|
146
|
+
* @param signer Signer of the refund transaction
|
|
147
|
+
* @param swapData Swap to refund
|
|
148
|
+
* @param signature Refund signature received from the claimer
|
|
149
|
+
* @param check Whether to check if the swap contract still exists on-chain
|
|
150
|
+
* @param initAta Whether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
|
|
151
|
+
* @param feeRate Fee rate to use for the transactions
|
|
152
|
+
*/
|
|
153
|
+
txsRefundWithAuthorization(signer: string, swapData: T, signature: SignatureData, check?: boolean, initAta?: boolean, feeRate?: string): Promise<TX[]>;
|
|
154
|
+
/**
|
|
155
|
+
* Signs & sends transactions for initializing and instantly (upon init confirmation) claiming the HTLC, used for BTC-LN -> SC swaps
|
|
156
|
+
*
|
|
157
|
+
* @param signer Signer to use for the transaction (must match claimer in swap data)
|
|
158
|
+
* @param swapData Swap to process
|
|
159
|
+
* @param signature Signature data from the offerer
|
|
160
|
+
* @param secret Secret pre-image that hashes to the swap hash
|
|
161
|
+
* @param skipChecks Whether to skip verification of the signature & checking if the swap is already committed
|
|
162
|
+
* @param txOptions Transaction options
|
|
163
|
+
*/
|
|
164
|
+
initAndClaimWithSecret?(signer: Signer, swapData: T, signature: SignatureData, secret: string, skipChecks?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string[]>;
|
|
165
|
+
/**
|
|
166
|
+
* Checks whether a swap is already expired, swap expires a bit sooner for the claimer & a bit later for offerer, this
|
|
167
|
+
* is used to account for possible on-chain time skew
|
|
168
|
+
*
|
|
169
|
+
* @param signer Signer to use for checking the expiry
|
|
170
|
+
* @param swapData Swap to check
|
|
171
|
+
*/
|
|
172
|
+
isExpired(signer: string, swapData: T): Promise<boolean>;
|
|
173
|
+
/**
|
|
174
|
+
* Checks whether a swap is claimable for the signer, i.e. it is not expired yet and is committed on-chain
|
|
175
|
+
*
|
|
176
|
+
* @param signer
|
|
177
|
+
* @param swapData
|
|
178
|
+
*/
|
|
179
|
+
isClaimable(signer: string, swapData: T): Promise<boolean>;
|
|
180
|
+
/**
|
|
181
|
+
* Checks whether a given swap is committed on chain (initialized)
|
|
182
|
+
*
|
|
183
|
+
* @param swapData
|
|
184
|
+
*/
|
|
185
|
+
isCommited(swapData: T): Promise<boolean>;
|
|
186
|
+
/**
|
|
187
|
+
* Returns the full status of the swap, expiry is handled by the isExpired function so also requires a signer/sender
|
|
188
|
+
*
|
|
189
|
+
* @param signer
|
|
190
|
+
* @param swapData
|
|
191
|
+
*/
|
|
192
|
+
getCommitStatus(signer: string, swapData: T): Promise<SwapCommitState>;
|
|
193
|
+
/**
|
|
194
|
+
* Returns the full status of the passed swaps, expiry is handled by the isExpired function so also requires a signer/sender
|
|
195
|
+
*
|
|
196
|
+
* @param request
|
|
197
|
+
*/
|
|
198
|
+
getCommitStatuses(request: {
|
|
199
|
+
signer: string;
|
|
200
|
+
swapData: T;
|
|
201
|
+
}[]): Promise<{
|
|
202
|
+
[escrowHash: string]: SwapCommitState;
|
|
203
|
+
}>;
|
|
204
|
+
/**
|
|
205
|
+
* Checks whether a given swap is refundable by us, i.e. it is already expired, we are offerer & swap is committed on-chain
|
|
206
|
+
*
|
|
207
|
+
* @param signer
|
|
208
|
+
* @param swapData
|
|
209
|
+
*/
|
|
210
|
+
isRequestRefundable(signer: string, swapData: T): Promise<boolean>;
|
|
211
|
+
/**
|
|
212
|
+
* Pre-fetches data required for creating init signature
|
|
213
|
+
*/
|
|
214
|
+
preFetchBlockDataForSignatures?(): Promise<PreFetchData>;
|
|
215
|
+
/**
|
|
216
|
+
* Pre-fetches data required for init signature verification
|
|
217
|
+
* @param data
|
|
218
|
+
*/
|
|
219
|
+
preFetchForInitSignatureVerification?(data: PreFetchData): Promise<PreFetchVerification>;
|
|
220
|
+
/**
|
|
221
|
+
* Generates the initialization signature
|
|
222
|
+
*
|
|
223
|
+
* @param signer Signer to use for signing the message
|
|
224
|
+
* @param swapData Swap to sign
|
|
225
|
+
* @param authorizationTimeout Timeout of the authorization
|
|
226
|
+
* @param preFetchedBlockData Optional pre-fetched data required for creating the signature
|
|
227
|
+
* @param feeRate Optional fee rate to use for the authorization
|
|
228
|
+
*/
|
|
229
|
+
getInitSignature(signer: Signer, swapData: T, authorizationTimeout: number, preFetchedBlockData?: PreFetchData, feeRate?: string): Promise<SignatureData>;
|
|
230
|
+
/**
|
|
231
|
+
* Checks whether a signature is a valid initialization signature for a given swap
|
|
232
|
+
*
|
|
233
|
+
* @param sender Address of the sender of the transaction (must be either offerer or claimer)
|
|
234
|
+
* @param swapData Swap to initialize
|
|
235
|
+
* @param signature Signature data
|
|
236
|
+
* @param feeRate Fee rate used for the authorization
|
|
237
|
+
* @param preFetchedVerificationData Optional pre-fetched data required for signature validation
|
|
238
|
+
* @returns {Buffer | null} The message being signed if valid or null if invalid signature
|
|
239
|
+
*/
|
|
240
|
+
isValidInitAuthorization(sender: string, swapData: T, signature: SignatureData, feeRate?: string, preFetchedVerificationData?: PreFetchVerification): Promise<Buffer | null>;
|
|
241
|
+
/**
|
|
242
|
+
* Returns the expiry timestamp (UNIX milliseconds) of the authorization
|
|
243
|
+
*
|
|
244
|
+
* @param swapData Swap
|
|
245
|
+
* @param signature Signature data
|
|
246
|
+
* @param preFetchedVerificationData Optional pre-fetched data required for signature validation
|
|
247
|
+
*/
|
|
248
|
+
getInitAuthorizationExpiry(swapData: T, signature: SignatureData, preFetchedVerificationData?: PreFetchVerification): Promise<number>;
|
|
249
|
+
/**
|
|
250
|
+
* Checks whether a given init signature is already expired
|
|
251
|
+
*
|
|
252
|
+
* @param swapData Swap
|
|
253
|
+
* @param signature Signature data
|
|
254
|
+
*/
|
|
255
|
+
isInitAuthorizationExpired(swapData: T, signature: SignatureData): Promise<boolean>;
|
|
256
|
+
/**
|
|
257
|
+
* Generates the refund signature for a given swap allowing the offerer to refund before expiration
|
|
258
|
+
*
|
|
259
|
+
* @param signer Signer to use for signing the message (must be the same as offerer in swap data)
|
|
260
|
+
* @param swapData Swap to refund
|
|
261
|
+
* @param authorizationTimeout Timeout of the provided refund authorization
|
|
262
|
+
*/
|
|
263
|
+
getRefundSignature(signer: Signer, swapData: T, authorizationTimeout: number): Promise<SignatureData>;
|
|
264
|
+
/**
|
|
265
|
+
* Checks whether a given refund signature is valid
|
|
266
|
+
*
|
|
267
|
+
* @param swapData Swap to refund
|
|
268
|
+
* @param signature Signature received from the claimer
|
|
269
|
+
*/
|
|
270
|
+
isValidRefundAuthorization(swapData: T, signature: SignatureData): Promise<Buffer | null>;
|
|
271
|
+
/**
|
|
272
|
+
* Signs the given data with the provided signer
|
|
273
|
+
*
|
|
274
|
+
* @param signer Signer to sign the message
|
|
275
|
+
* @param data Data to sign
|
|
276
|
+
*/
|
|
277
|
+
getDataSignature(signer: Signer, data: Buffer): Promise<string>;
|
|
278
|
+
/**
|
|
279
|
+
* Checks whether a provided data is signature is valid
|
|
280
|
+
*
|
|
281
|
+
* @param data Data to sign
|
|
282
|
+
* @param signature Signature
|
|
283
|
+
* @param publicKey Public key of the signer
|
|
284
|
+
*/
|
|
285
|
+
isValidDataSignature(data: Buffer, signature: string, publicKey: string): Promise<boolean>;
|
|
286
|
+
/**
|
|
287
|
+
* Returns the token balance of a given signer's address
|
|
288
|
+
*
|
|
289
|
+
* @param signer Address to check the balance of
|
|
290
|
+
* @param token Token
|
|
291
|
+
* @param inContract Whether we are checking the liquidity deposited into the LP vault or just on-chain balance
|
|
292
|
+
*/
|
|
293
|
+
getBalance(signer: string, token: string, inContract: boolean): Promise<bigint>;
|
|
294
|
+
/**
|
|
295
|
+
* Create a swap data for this given chain
|
|
296
|
+
*
|
|
297
|
+
* @param type Type of the swap
|
|
298
|
+
* @param offerer Offerer address
|
|
299
|
+
* @param claimer Claimer addres
|
|
300
|
+
* @param token Token to use for the swap
|
|
301
|
+
* @param amount Amount of tokens for the swap
|
|
302
|
+
* @param paymentHash Payment hash identifying the swap
|
|
303
|
+
* @param sequence Swap sequence uniquelly defining this swap
|
|
304
|
+
* @param expiry Expiration of the swap
|
|
305
|
+
* @param payIn Whether the swap is payIn (offerer paying to the contract, or not payIn offerer using funds in his LP vault)
|
|
306
|
+
* @param payOut Whether the swap is payOut (claimer getting the funds to his on-chain address, or no payOut claimer
|
|
307
|
+
* getting his funds into his LP vault)
|
|
308
|
+
* @param securityDeposit Security deposit for the swap paid by the claimer (options premium)
|
|
309
|
+
* @param claimerBounty Bounty for the claimer of the swap (used for watchtowers)
|
|
310
|
+
* @param depositToken Token to be used for security deposit and claimer bounty
|
|
311
|
+
*/
|
|
312
|
+
createSwapData(type: ChainSwapType, offerer: string, claimer: string, token: string, amount: bigint, paymentHash: string, sequence: bigint, expiry: bigint, payIn: boolean, payOut: boolean, securityDeposit: bigint, claimerBounty: bigint, depositToken?: string): Promise<T>;
|
|
313
|
+
/**
|
|
314
|
+
* Returns intermediary's reputation for a given token swaps
|
|
315
|
+
*
|
|
316
|
+
* @param address
|
|
317
|
+
* @param token
|
|
318
|
+
*/
|
|
319
|
+
getIntermediaryReputation(address: string, token: string): Promise<IntermediaryReputationType>;
|
|
320
|
+
/**
|
|
321
|
+
* Returns the fee in native token base units to commit (initiate) the swap
|
|
322
|
+
*
|
|
323
|
+
* @param signer
|
|
324
|
+
* @param swapData Swap to initiate
|
|
325
|
+
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
326
|
+
*/
|
|
327
|
+
getCommitFee(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
328
|
+
/**
|
|
329
|
+
* Returns raw fee (not including any account deposits we might need) for initiating the swap
|
|
330
|
+
*
|
|
331
|
+
* @param signer
|
|
332
|
+
* @param swapData Swap to initiate
|
|
333
|
+
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
334
|
+
*/
|
|
335
|
+
getRawCommitFee?(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
336
|
+
/**
|
|
337
|
+
* Returns the fee in native token base units to claim the swap
|
|
338
|
+
*
|
|
339
|
+
* @param signer Signer claiming the swap
|
|
340
|
+
* @param swapData Swap to claim
|
|
341
|
+
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
342
|
+
*/
|
|
343
|
+
getClaimFee(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
344
|
+
/**
|
|
345
|
+
* Returns raw fee (not including any refunds we might get that would make the getClaimFee negative) for claiming the swap
|
|
346
|
+
*
|
|
347
|
+
* @param signer Signer claiming the swap
|
|
348
|
+
* @param swapData Swap to claim
|
|
349
|
+
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
350
|
+
*/
|
|
351
|
+
getRawClaimFee?(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
352
|
+
/**
|
|
353
|
+
* Returns the fee in native token base units to refund the swap
|
|
354
|
+
*
|
|
355
|
+
* @param signer
|
|
356
|
+
* @param swapData Swap to refund
|
|
357
|
+
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
358
|
+
*/
|
|
359
|
+
getRefundFee(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
360
|
+
/**
|
|
361
|
+
* Returns raw fee (not including any refunds we might get that would make the getRefundFee negative) for claiming the swap
|
|
362
|
+
*
|
|
363
|
+
* @param signer
|
|
364
|
+
* @param swapData Swap to claim
|
|
365
|
+
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
366
|
+
*/
|
|
367
|
+
getRawRefundFee?(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
368
|
+
/**
|
|
369
|
+
* Returns the fee rate for committing (initializing) a payIn swap
|
|
370
|
+
*
|
|
371
|
+
* @param offerer Offerer of the swap
|
|
372
|
+
* @param claimer Claimer of the swap
|
|
373
|
+
* @param token Token to be swapped
|
|
374
|
+
* @param paymentHash Optional payment hash
|
|
375
|
+
*/
|
|
376
|
+
getInitPayInFeeRate(offerer: string, claimer: string, token: string, paymentHash?: string): Promise<string>;
|
|
377
|
+
/**
|
|
378
|
+
* Returns the fee rate for committing (initializing) a non-payIn swap
|
|
379
|
+
*
|
|
380
|
+
* @param offerer Offerer of the swap
|
|
381
|
+
* @param claimer Claimer of the swap
|
|
382
|
+
* @param token Token to be swapped
|
|
383
|
+
* @param paymentHash Optional payment hash
|
|
384
|
+
*/
|
|
385
|
+
getInitFeeRate(offerer: string, claimer: string, token: string, paymentHash?: string): Promise<string>;
|
|
386
|
+
/**
|
|
387
|
+
* Returns the fee rate for refunding a swap
|
|
388
|
+
*
|
|
389
|
+
* @param swapData Swap to refund
|
|
390
|
+
*/
|
|
391
|
+
getRefundFeeRate(swapData: T): Promise<string>;
|
|
392
|
+
/**
|
|
393
|
+
* Returns the fee rate for claiming a swap as a specific signer
|
|
394
|
+
*
|
|
395
|
+
* @param signer Signer claiming the swap
|
|
396
|
+
* @param swapData Swap to claim
|
|
397
|
+
*/
|
|
398
|
+
getClaimFeeRate(signer: string, swapData: T): Promise<string>;
|
|
399
|
+
getExtraData(outputScript: Buffer, amount: bigint, confirmations: number, nonce?: bigint): Buffer;
|
|
400
|
+
/**
|
|
401
|
+
* Compute the claim hash for a given transaction output, either nonced or just output locked
|
|
402
|
+
*
|
|
403
|
+
* @param outputScript Bitcoin output locking script
|
|
404
|
+
* @param amount Amount of sats in the output
|
|
405
|
+
* @param confirmations Required number of confirmations for the swap to be claimable
|
|
406
|
+
* @param nonce Nonce to be used as replay protection
|
|
407
|
+
*/
|
|
408
|
+
getHashForOnchain(outputScript: Buffer, amount: bigint, confirmations: number, nonce?: bigint): Buffer;
|
|
409
|
+
/**
|
|
410
|
+
* Compute the claim hash for a given transaction id
|
|
411
|
+
*
|
|
412
|
+
* @param txId Bitcoin transaction ID
|
|
413
|
+
* @param confirmations Required number of confirmations for the swap to be claimable
|
|
414
|
+
*/
|
|
415
|
+
getHashForTxId(txId: string, confirmations: number): Buffer;
|
|
416
|
+
/**
|
|
417
|
+
* Compute the claim hash for an HTLC swap with a given swap hash
|
|
418
|
+
*
|
|
419
|
+
* @param swapHash
|
|
420
|
+
*/
|
|
421
|
+
getHashForHtlc(swapHash: Buffer): Buffer;
|
|
422
|
+
/**
|
|
423
|
+
* Withdraws funds from the trading LP vault
|
|
424
|
+
*
|
|
425
|
+
* @param signer Signer to sign the withdrawal with
|
|
426
|
+
* @param token Token to withdraw
|
|
427
|
+
* @param amount Amount of the token to withdraw
|
|
428
|
+
* @param txOptions Transaction options
|
|
429
|
+
*/
|
|
430
|
+
withdraw(signer: Signer, token: string, amount: bigint, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
431
|
+
/**
|
|
432
|
+
* Returns transactions required for signer to withdraw funds from the trading LP vault
|
|
433
|
+
*
|
|
434
|
+
* @param signer Owner of the funds
|
|
435
|
+
* @param token Token to withdraw
|
|
436
|
+
* @param amount Amount of the token to withdraw
|
|
437
|
+
* @param feeRate Optional fee rate to use for the transaction (fetched on-demand if not provided)
|
|
438
|
+
*/
|
|
439
|
+
txsWithdraw(signer: string, token: string, amount: bigint, feeRate?: string): Promise<TX[]>;
|
|
440
|
+
/**
|
|
441
|
+
* Deposits funds to the trading LP vault
|
|
442
|
+
*
|
|
443
|
+
* @param signer Signer to sign the deposit with
|
|
444
|
+
* @param token Token to deposit
|
|
445
|
+
* @param amount Amount of the token to deposit
|
|
446
|
+
* @param txOptions Transaction options
|
|
447
|
+
*/
|
|
448
|
+
deposit(signer: Signer, token: string, amount: bigint, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
449
|
+
/**
|
|
450
|
+
* Returns transactions required for signer to deposit funds to the trading LP vault
|
|
451
|
+
*
|
|
452
|
+
* @param signer Owner of the funds
|
|
453
|
+
* @param token Token to deposit
|
|
454
|
+
* @param amount Amount of the token to deposit
|
|
455
|
+
* @param feeRate Optional fee rate to use for the transaction (fetched on-demand if not provided)
|
|
456
|
+
*/
|
|
457
|
+
txsDeposit(signer: string, token: string, amount: bigint, feeRate?: string): Promise<TX[]>;
|
|
458
|
+
/**
|
|
459
|
+
* Returns the amount of deposits (in native token) that we can claim back (this is useful for SVM chains with the PDAs
|
|
460
|
+
* requiring you to put some deposit in order to store data)
|
|
461
|
+
*
|
|
462
|
+
* @param signer Signer to check the claimable deposits for
|
|
463
|
+
*/
|
|
464
|
+
getClaimableDeposits?(signer: string): Promise<{
|
|
465
|
+
count: number;
|
|
466
|
+
totalValue: bigint;
|
|
467
|
+
}>;
|
|
468
|
+
/**
|
|
469
|
+
* Claims the funds from claimable deposits
|
|
470
|
+
*
|
|
471
|
+
* @param signer Owner of the deposits, transaction signer
|
|
472
|
+
* @param txOptions Transaction options
|
|
473
|
+
*/
|
|
474
|
+
claimDeposits?(signer: Signer, txOptions: TransactionConfirmationOptions): Promise<{
|
|
475
|
+
txIds: string[];
|
|
476
|
+
count: number;
|
|
477
|
+
totalValue: bigint;
|
|
478
|
+
}>;
|
|
479
|
+
}
|