@atomiqlabs/chain-evm 2.0.7 → 2.0.8
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/evm/btcrelay/EVMBtcRelay.d.ts +15 -48
- package/dist/evm/btcrelay/EVMBtcRelay.js +15 -48
- package/dist/evm/chain/EVMChainInterface.d.ts +69 -0
- package/dist/evm/chain/EVMChainInterface.js +69 -0
- package/dist/evm/chain/modules/EVMTransactions.js +12 -2
- package/dist/evm/events/EVMChainEventsBrowser.d.ts +15 -0
- package/dist/evm/events/EVMChainEventsBrowser.js +15 -0
- package/dist/evm/spv_swap/EVMSpvVaultContract.d.ts +72 -0
- package/dist/evm/spv_swap/EVMSpvVaultContract.js +72 -0
- package/dist/evm/spv_swap/EVMSpvWithdrawalData.d.ts +12 -0
- package/dist/evm/spv_swap/EVMSpvWithdrawalData.js +12 -0
- package/dist/evm/swaps/EVMSwapContract.d.ts +117 -33
- package/dist/evm/swaps/EVMSwapContract.js +117 -33
- package/dist/evm/swaps/EVMSwapData.d.ts +90 -0
- package/dist/evm/swaps/EVMSwapData.js +90 -0
- package/dist/evm/wallet/EVMSigner.d.ts +3 -0
- package/dist/evm/wallet/EVMSigner.js +3 -0
- package/package.json +1 -1
- package/src/evm/btcrelay/EVMBtcRelay.ts +15 -48
- package/src/evm/chain/EVMChainInterface.ts +69 -0
- package/src/evm/chain/modules/EVMTransactions.ts +10 -2
- package/src/evm/events/EVMChainEventsBrowser.ts +15 -0
- package/src/evm/spv_swap/EVMSpvVaultContract.ts +72 -0
- package/src/evm/spv_swap/EVMSpvWithdrawalData.ts +12 -0
- package/src/evm/swaps/EVMSwapContract.ts +117 -33
- package/src/evm/swaps/EVMSwapData.ts +90 -0
- package/src/evm/wallet/EVMSigner.ts +3 -0
|
@@ -41,9 +41,21 @@ export declare class EVMSpvVaultContract<ChainId extends string> extends EVMCont
|
|
|
41
41
|
protected Deposit(signer: string, vault: EVMSpvVaultData, rawAmounts: bigint[], feeRate: string): Promise<TransactionRequest>;
|
|
42
42
|
protected Front(signer: string, vault: EVMSpvVaultData, data: EVMSpvWithdrawalData, withdrawalSequence: number, feeRate: string): Promise<TransactionRequest>;
|
|
43
43
|
protected Claim(signer: string, vault: EVMSpvVaultData, data: EVMSpvWithdrawalData, blockheader: EVMBtcStoredHeader, merkle: Buffer[], position: number, feeRate: string): Promise<TransactionRequest>;
|
|
44
|
+
/**
|
|
45
|
+
* @inheritDoc
|
|
46
|
+
*/
|
|
44
47
|
checkWithdrawalTx(tx: SpvWithdrawalTransactionData): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* @inheritDoc
|
|
50
|
+
*/
|
|
45
51
|
createVaultData(owner: string, vaultId: bigint, utxo: string, confirmations: number, tokenData: SpvVaultTokenData[]): Promise<EVMSpvVaultData>;
|
|
52
|
+
/**
|
|
53
|
+
* @inheritDoc
|
|
54
|
+
*/
|
|
46
55
|
getFronterAddress(owner: string, vaultId: bigint, withdrawal: EVMSpvWithdrawalData): Promise<string | null>;
|
|
56
|
+
/**
|
|
57
|
+
* @inheritDoc
|
|
58
|
+
*/
|
|
47
59
|
getFronterAddresses(withdrawals: {
|
|
48
60
|
owner: string;
|
|
49
61
|
vaultId: bigint;
|
|
@@ -52,7 +64,13 @@ export declare class EVMSpvVaultContract<ChainId extends string> extends EVMCont
|
|
|
52
64
|
[btcTxId: string]: string | null;
|
|
53
65
|
}>;
|
|
54
66
|
private vaultParamsCache;
|
|
67
|
+
/**
|
|
68
|
+
* @inheritDoc
|
|
69
|
+
*/
|
|
55
70
|
getVaultData(owner: string, vaultId: bigint): Promise<EVMSpvVaultData | null>;
|
|
71
|
+
/**
|
|
72
|
+
* @inheritDoc
|
|
73
|
+
*/
|
|
56
74
|
getMultipleVaultData(vaults: {
|
|
57
75
|
owner: string;
|
|
58
76
|
vaultId: bigint;
|
|
@@ -61,7 +79,13 @@ export declare class EVMSpvVaultContract<ChainId extends string> extends EVMCont
|
|
|
61
79
|
[vaultId: string]: EVMSpvVaultData | null;
|
|
62
80
|
};
|
|
63
81
|
}>;
|
|
82
|
+
/**
|
|
83
|
+
* @inheritDoc
|
|
84
|
+
*/
|
|
64
85
|
getVaultLatestUtxo(owner: string, vaultId: bigint): Promise<string | null>;
|
|
86
|
+
/**
|
|
87
|
+
* @inheritDoc
|
|
88
|
+
*/
|
|
65
89
|
getVaultLatestUtxos(vaults: {
|
|
66
90
|
owner: string;
|
|
67
91
|
vaultId: bigint;
|
|
@@ -70,16 +94,31 @@ export declare class EVMSpvVaultContract<ChainId extends string> extends EVMCont
|
|
|
70
94
|
[vaultId: string]: string | null;
|
|
71
95
|
};
|
|
72
96
|
}>;
|
|
97
|
+
/**
|
|
98
|
+
* @inheritDoc
|
|
99
|
+
*/
|
|
73
100
|
getAllVaults(owner?: string): Promise<EVMSpvVaultData[]>;
|
|
74
101
|
private parseWithdrawalEvent;
|
|
102
|
+
/**
|
|
103
|
+
* @inheritDoc
|
|
104
|
+
*/
|
|
75
105
|
getWithdrawalState(withdrawalTx: EVMSpvWithdrawalData, scStartHeight?: number): Promise<SpvWithdrawalState>;
|
|
106
|
+
/**
|
|
107
|
+
* @inheritDoc
|
|
108
|
+
*/
|
|
76
109
|
getWithdrawalStates(withdrawalTxs: {
|
|
77
110
|
withdrawal: EVMSpvWithdrawalData;
|
|
78
111
|
scStartBlockheight?: number;
|
|
79
112
|
}[]): Promise<{
|
|
80
113
|
[btcTxId: string]: SpvWithdrawalState;
|
|
81
114
|
}>;
|
|
115
|
+
/**
|
|
116
|
+
* @inheritDoc
|
|
117
|
+
*/
|
|
82
118
|
getWithdrawalData(btcTx: BtcTx): Promise<EVMSpvWithdrawalData>;
|
|
119
|
+
/**
|
|
120
|
+
* @inheritDoc
|
|
121
|
+
*/
|
|
83
122
|
fromOpReturnData(data: Buffer): {
|
|
84
123
|
recipient: string;
|
|
85
124
|
rawAmounts: bigint[];
|
|
@@ -90,24 +129,57 @@ export declare class EVMSpvVaultContract<ChainId extends string> extends EVMCont
|
|
|
90
129
|
rawAmounts: bigint[];
|
|
91
130
|
executionHash?: string;
|
|
92
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* @inheritDoc
|
|
134
|
+
*/
|
|
93
135
|
toOpReturnData(recipient: string, rawAmounts: bigint[], executionHash?: string): Buffer;
|
|
94
136
|
static toOpReturnData(recipient: string, rawAmounts: bigint[], executionHash?: string): Buffer;
|
|
137
|
+
/**
|
|
138
|
+
* @inheritDoc
|
|
139
|
+
*/
|
|
95
140
|
claim(signer: EVMSigner, vault: EVMSpvVaultData, txs: {
|
|
96
141
|
tx: EVMSpvWithdrawalData;
|
|
97
142
|
storedHeader?: EVMBtcStoredHeader;
|
|
98
143
|
}[], synchronizer?: RelaySynchronizer<any, any, any>, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
144
|
+
/**
|
|
145
|
+
* @inheritDoc
|
|
146
|
+
*/
|
|
99
147
|
deposit(signer: EVMSigner, vault: EVMSpvVaultData, rawAmounts: bigint[], txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
148
|
+
/**
|
|
149
|
+
* @inheritDoc
|
|
150
|
+
*/
|
|
100
151
|
frontLiquidity(signer: EVMSigner, vault: EVMSpvVaultData, realWithdrawalTx: EVMSpvWithdrawalData, withdrawSequence: number, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
152
|
+
/**
|
|
153
|
+
* @inheritDoc
|
|
154
|
+
*/
|
|
101
155
|
open(signer: EVMSigner, vault: EVMSpvVaultData, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
156
|
+
/**
|
|
157
|
+
* @inheritDoc
|
|
158
|
+
*/
|
|
102
159
|
txsClaim(signer: string, vault: EVMSpvVaultData, txs: {
|
|
103
160
|
tx: EVMSpvWithdrawalData;
|
|
104
161
|
storedHeader?: EVMBtcStoredHeader;
|
|
105
162
|
}[], synchronizer?: RelaySynchronizer<any, any, any>, initAta?: boolean, feeRate?: string): Promise<EVMTx[]>;
|
|
163
|
+
/**
|
|
164
|
+
* @inheritDoc
|
|
165
|
+
*/
|
|
106
166
|
txsDeposit(signer: string, vault: EVMSpvVaultData, rawAmounts: bigint[], feeRate?: string): Promise<EVMTx[]>;
|
|
167
|
+
/**
|
|
168
|
+
* @inheritDoc
|
|
169
|
+
*/
|
|
107
170
|
txsFrontLiquidity(signer: string, vault: EVMSpvVaultData, realWithdrawalTx: EVMSpvWithdrawalData, withdrawSequence: number, feeRate?: string): Promise<EVMTx[]>;
|
|
171
|
+
/**
|
|
172
|
+
* @inheritDoc
|
|
173
|
+
*/
|
|
108
174
|
txsOpen(signer: string, vault: EVMSpvVaultData, feeRate?: string): Promise<EVMTx[]>;
|
|
109
175
|
getClaimGas(signer: string, vault?: EVMSpvVaultData, data?: EVMSpvWithdrawalData): number;
|
|
110
176
|
getFrontGas(signer: string, vault: EVMSpvVaultData, data?: EVMSpvWithdrawalData): number;
|
|
177
|
+
/**
|
|
178
|
+
* @inheritDoc
|
|
179
|
+
*/
|
|
111
180
|
getClaimFee(signer: string, vault?: EVMSpvVaultData, withdrawalData?: EVMSpvWithdrawalData, feeRate?: string): Promise<bigint>;
|
|
181
|
+
/**
|
|
182
|
+
* @inheritDoc
|
|
183
|
+
*/
|
|
112
184
|
getFrontFee(signer: string, vault?: EVMSpvVaultData, withdrawalData?: EVMSpvWithdrawalData, feeRate?: string): Promise<bigint>;
|
|
113
185
|
}
|
|
@@ -94,11 +94,17 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
94
94
|
EVMFees_1.EVMFees.applyFeeRate(tx, this.getClaimGas(signer, vault, data), feeRate);
|
|
95
95
|
return tx;
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* @inheritDoc
|
|
99
|
+
*/
|
|
97
100
|
async checkWithdrawalTx(tx) {
|
|
98
101
|
const result = await this.contract.parseBitcoinTx(buffer_1.Buffer.from(tx.btcTx.hex, "hex"));
|
|
99
102
|
if (result == null)
|
|
100
103
|
throw new Error("Failed to parse transaction!");
|
|
101
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* @inheritDoc
|
|
107
|
+
*/
|
|
102
108
|
createVaultData(owner, vaultId, utxo, confirmations, tokenData) {
|
|
103
109
|
if (tokenData.length !== 2)
|
|
104
110
|
throw new Error("Must specify 2 tokens in tokenData!");
|
|
@@ -123,12 +129,18 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
123
129
|
}, vaultParams, utxo));
|
|
124
130
|
}
|
|
125
131
|
//Getters
|
|
132
|
+
/**
|
|
133
|
+
* @inheritDoc
|
|
134
|
+
*/
|
|
126
135
|
async getFronterAddress(owner, vaultId, withdrawal) {
|
|
127
136
|
const frontingAddress = await this.contract.getFronterById(owner, vaultId, "0x" + withdrawal.getFrontingId());
|
|
128
137
|
if (frontingAddress === ethers_1.ZeroAddress)
|
|
129
138
|
return null;
|
|
130
139
|
return frontingAddress;
|
|
131
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* @inheritDoc
|
|
143
|
+
*/
|
|
132
144
|
async getFronterAddresses(withdrawals) {
|
|
133
145
|
const result = {};
|
|
134
146
|
let promises = [];
|
|
@@ -145,6 +157,9 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
145
157
|
await Promise.all(promises);
|
|
146
158
|
return result;
|
|
147
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* @inheritDoc
|
|
162
|
+
*/
|
|
148
163
|
async getVaultData(owner, vaultId) {
|
|
149
164
|
const vaultState = await this.contract.getVault(owner, vaultId);
|
|
150
165
|
if (vaultState.spvVaultParametersCommitment === ethers_1.ZeroHash)
|
|
@@ -164,6 +179,9 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
164
179
|
return null;
|
|
165
180
|
return new EVMSpvVaultData_1.EVMSpvVaultData(owner, vaultId, vaultState, vaultParams);
|
|
166
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* @inheritDoc
|
|
184
|
+
*/
|
|
167
185
|
async getMultipleVaultData(vaults) {
|
|
168
186
|
const result = {};
|
|
169
187
|
let promises = [];
|
|
@@ -181,6 +199,9 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
181
199
|
await Promise.all(promises);
|
|
182
200
|
return result;
|
|
183
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* @inheritDoc
|
|
204
|
+
*/
|
|
184
205
|
async getVaultLatestUtxo(owner, vaultId) {
|
|
185
206
|
const vaultState = await this.contract.getVault(owner, vaultId);
|
|
186
207
|
const utxo = (0, EVMSpvVaultData_1.getVaultUtxoFromState)(vaultState);
|
|
@@ -188,6 +209,9 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
188
209
|
return null;
|
|
189
210
|
return utxo;
|
|
190
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* @inheritDoc
|
|
214
|
+
*/
|
|
191
215
|
async getVaultLatestUtxos(vaults) {
|
|
192
216
|
const result = {};
|
|
193
217
|
let promises = [];
|
|
@@ -205,6 +229,9 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
205
229
|
await Promise.all(promises);
|
|
206
230
|
return result;
|
|
207
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* @inheritDoc
|
|
234
|
+
*/
|
|
208
235
|
async getAllVaults(owner) {
|
|
209
236
|
const openedVaults = new Map();
|
|
210
237
|
await this.Events.findInContractEventsForward(["Opened", "Closed"], owner == null ? null : [
|
|
@@ -268,6 +295,9 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
268
295
|
return null;
|
|
269
296
|
}
|
|
270
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* @inheritDoc
|
|
300
|
+
*/
|
|
271
301
|
async getWithdrawalState(withdrawalTx, scStartHeight) {
|
|
272
302
|
const txHash = buffer_1.Buffer.from(withdrawalTx.getTxId(), "hex").reverse();
|
|
273
303
|
const events = ["Fronted", "Claimed", "Closed"];
|
|
@@ -298,6 +328,9 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
298
328
|
});
|
|
299
329
|
return result;
|
|
300
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* @inheritDoc
|
|
333
|
+
*/
|
|
301
334
|
async getWithdrawalStates(withdrawalTxs) {
|
|
302
335
|
var _a;
|
|
303
336
|
const result = {};
|
|
@@ -365,10 +398,16 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
365
398
|
}
|
|
366
399
|
return result;
|
|
367
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* @inheritDoc
|
|
403
|
+
*/
|
|
368
404
|
getWithdrawalData(btcTx) {
|
|
369
405
|
return Promise.resolve(new EVMSpvWithdrawalData_1.EVMSpvWithdrawalData(btcTx));
|
|
370
406
|
}
|
|
371
407
|
//OP_RETURN data encoding/decoding
|
|
408
|
+
/**
|
|
409
|
+
* @inheritDoc
|
|
410
|
+
*/
|
|
372
411
|
fromOpReturnData(data) {
|
|
373
412
|
return EVMSpvVaultContract.fromOpReturnData(data);
|
|
374
413
|
}
|
|
@@ -400,6 +439,9 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
400
439
|
throw new Error("Invalid recipient specified");
|
|
401
440
|
return { executionHash, rawAmounts: [rawAmount0, rawAmount1], recipient: (0, ethers_1.getAddress)(recipient) };
|
|
402
441
|
}
|
|
442
|
+
/**
|
|
443
|
+
* @inheritDoc
|
|
444
|
+
*/
|
|
403
445
|
toOpReturnData(recipient, rawAmounts, executionHash) {
|
|
404
446
|
return EVMSpvVaultContract.toOpReturnData(recipient, rawAmounts, executionHash);
|
|
405
447
|
}
|
|
@@ -432,27 +474,42 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
432
474
|
]);
|
|
433
475
|
}
|
|
434
476
|
//Actions
|
|
477
|
+
/**
|
|
478
|
+
* @inheritDoc
|
|
479
|
+
*/
|
|
435
480
|
async claim(signer, vault, txs, synchronizer, initAta, txOptions) {
|
|
436
481
|
const result = await this.txsClaim(signer.getAddress(), vault, txs, synchronizer, initAta, txOptions?.feeRate);
|
|
437
482
|
const [signature] = await this.Chain.sendAndConfirm(signer, result, txOptions?.waitForConfirmation, txOptions?.abortSignal);
|
|
438
483
|
return signature;
|
|
439
484
|
}
|
|
485
|
+
/**
|
|
486
|
+
* @inheritDoc
|
|
487
|
+
*/
|
|
440
488
|
async deposit(signer, vault, rawAmounts, txOptions) {
|
|
441
489
|
const result = await this.txsDeposit(signer.getAddress(), vault, rawAmounts, txOptions?.feeRate);
|
|
442
490
|
const txHashes = await this.Chain.sendAndConfirm(signer, result, txOptions?.waitForConfirmation, txOptions?.abortSignal);
|
|
443
491
|
return txHashes[txHashes.length - 1];
|
|
444
492
|
}
|
|
493
|
+
/**
|
|
494
|
+
* @inheritDoc
|
|
495
|
+
*/
|
|
445
496
|
async frontLiquidity(signer, vault, realWithdrawalTx, withdrawSequence, txOptions) {
|
|
446
497
|
const result = await this.txsFrontLiquidity(signer.getAddress(), vault, realWithdrawalTx, withdrawSequence, txOptions?.feeRate);
|
|
447
498
|
const txHashes = await this.Chain.sendAndConfirm(signer, result, txOptions?.waitForConfirmation, txOptions?.abortSignal);
|
|
448
499
|
return txHashes[txHashes.length - 1];
|
|
449
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* @inheritDoc
|
|
503
|
+
*/
|
|
450
504
|
async open(signer, vault, txOptions) {
|
|
451
505
|
const result = await this.txsOpen(signer.getAddress(), vault, txOptions?.feeRate);
|
|
452
506
|
const [signature] = await this.Chain.sendAndConfirm(signer, result, txOptions?.waitForConfirmation, txOptions?.abortSignal);
|
|
453
507
|
return signature;
|
|
454
508
|
}
|
|
455
509
|
//Transactions
|
|
510
|
+
/**
|
|
511
|
+
* @inheritDoc
|
|
512
|
+
*/
|
|
456
513
|
async txsClaim(signer, vault, txs, synchronizer, initAta, feeRate) {
|
|
457
514
|
if (!vault.isOpened())
|
|
458
515
|
throw new Error("Cannot claim from a closed vault!");
|
|
@@ -487,6 +544,9 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
487
544
|
" vaultId: " + vault.getVaultId().toString(10));
|
|
488
545
|
return evmTxs;
|
|
489
546
|
}
|
|
547
|
+
/**
|
|
548
|
+
* @inheritDoc
|
|
549
|
+
*/
|
|
490
550
|
async txsDeposit(signer, vault, rawAmounts, feeRate) {
|
|
491
551
|
var _a;
|
|
492
552
|
if (!vault.isOpened())
|
|
@@ -518,6 +578,9 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
518
578
|
" token1: " + vault.token1.token + " rawAmount1: " + (rawAmounts[1] ?? 0n).toString(10) + " amount1: " + realAmount1.toString(10));
|
|
519
579
|
return txs;
|
|
520
580
|
}
|
|
581
|
+
/**
|
|
582
|
+
* @inheritDoc
|
|
583
|
+
*/
|
|
521
584
|
async txsFrontLiquidity(signer, vault, realWithdrawalTx, withdrawSequence, feeRate) {
|
|
522
585
|
var _a;
|
|
523
586
|
if (!vault.isOpened())
|
|
@@ -551,6 +614,9 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
551
614
|
" token1: " + vault.token1.token + " rawAmount1: " + (rawAmounts[1] ?? 0n).toString(10) + " amount1: " + realAmount1.toString(10));
|
|
552
615
|
return txs;
|
|
553
616
|
}
|
|
617
|
+
/**
|
|
618
|
+
* @inheritDoc
|
|
619
|
+
*/
|
|
554
620
|
async txsOpen(signer, vault, feeRate) {
|
|
555
621
|
if (vault.isOpened())
|
|
556
622
|
throw new Error("Cannot open an already opened vault!");
|
|
@@ -598,10 +664,16 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
|
|
|
598
664
|
totalGas += EVMSpvVaultContract.GasCosts.FRONT_EXECUTION_SCHEDULE;
|
|
599
665
|
return totalGas;
|
|
600
666
|
}
|
|
667
|
+
/**
|
|
668
|
+
* @inheritDoc
|
|
669
|
+
*/
|
|
601
670
|
async getClaimFee(signer, vault, withdrawalData, feeRate) {
|
|
602
671
|
feeRate ?? (feeRate = await this.Chain.Fees.getFeeRate());
|
|
603
672
|
return EVMFees_1.EVMFees.getGasFee(this.getClaimGas(signer, vault, withdrawalData), feeRate);
|
|
604
673
|
}
|
|
674
|
+
/**
|
|
675
|
+
* @inheritDoc
|
|
676
|
+
*/
|
|
605
677
|
async getFrontFee(signer, vault, withdrawalData, feeRate) {
|
|
606
678
|
vault ?? (vault = EVMSpvVaultData_1.EVMSpvVaultData.randomVault());
|
|
607
679
|
feeRate ?? (feeRate = await this.Chain.Fees.getFeeRate());
|
|
@@ -8,15 +8,27 @@ import { BitcoinVaultTransactionDataStruct } from "./SpvVaultContractTypechain";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class EVMSpvWithdrawalData extends SpvWithdrawalTransactionData {
|
|
10
10
|
private getExecutionHashWith0x;
|
|
11
|
+
/**
|
|
12
|
+
* @inheritDoc
|
|
13
|
+
*/
|
|
11
14
|
protected fromOpReturnData(data: Buffer): {
|
|
12
15
|
recipient: string;
|
|
13
16
|
rawAmounts: bigint[];
|
|
14
17
|
executionHash?: string;
|
|
15
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
16
22
|
isRecipient(address: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
17
26
|
getFrontingId(): string;
|
|
18
27
|
getTxHash(): string;
|
|
19
28
|
getFrontingAmount(): bigint[];
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
20
32
|
serialize(): any;
|
|
21
33
|
serializeToStruct(): BitcoinVaultTransactionDataStruct;
|
|
22
34
|
}
|
|
@@ -12,12 +12,21 @@ class EVMSpvWithdrawalData extends base_1.SpvWithdrawalTransactionData {
|
|
|
12
12
|
getExecutionHashWith0x() {
|
|
13
13
|
return this.executionHash == null ? ethers_1.ZeroHash : (this.executionHash.startsWith("0x") ? this.executionHash : "0x" + this.executionHash);
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
15
18
|
fromOpReturnData(data) {
|
|
16
19
|
return EVMSpvVaultContract_1.EVMSpvVaultContract.fromOpReturnData(data);
|
|
17
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
18
24
|
isRecipient(address) {
|
|
19
25
|
return this.getRecipient().toLowerCase() === address.toLowerCase();
|
|
20
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
21
30
|
getFrontingId() {
|
|
22
31
|
const callerFee = this.getCallerFee();
|
|
23
32
|
const frontingFee = this.getFrontingFee();
|
|
@@ -30,6 +39,9 @@ class EVMSpvWithdrawalData extends base_1.SpvWithdrawalTransactionData {
|
|
|
30
39
|
getFrontingAmount() {
|
|
31
40
|
return [this.rawAmounts[0] + this.getExecutionFee()[0], this.rawAmounts[1]];
|
|
32
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* @inheritDoc
|
|
44
|
+
*/
|
|
33
45
|
serialize() {
|
|
34
46
|
return {
|
|
35
47
|
type: "EVM",
|
|
@@ -51,85 +51,118 @@ export declare class EVMSwapContract<ChainId extends string = string> extends EV
|
|
|
51
51
|
[type in ChainSwapType]: string;
|
|
52
52
|
};
|
|
53
53
|
});
|
|
54
|
+
/**
|
|
55
|
+
* @inheritDoc
|
|
56
|
+
*/
|
|
54
57
|
start(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* @inheritDoc
|
|
60
|
+
*/
|
|
55
61
|
preFetchForInitSignatureVerification(): Promise<EVMPreFetchVerification>;
|
|
62
|
+
/**
|
|
63
|
+
* @inheritDoc
|
|
64
|
+
*/
|
|
56
65
|
getInitSignature(signer: EVMSigner, swapData: EVMSwapData, authorizationTimeout: number, preFetchedBlockData?: never, feeRate?: string): Promise<SignatureData>;
|
|
66
|
+
/**
|
|
67
|
+
* @inheritDoc
|
|
68
|
+
*/
|
|
57
69
|
isValidInitAuthorization(sender: string, swapData: EVMSwapData, signature: SignatureData, feeRate?: string, preFetchedData?: EVMPreFetchVerification): Promise<Buffer | null>;
|
|
70
|
+
/**
|
|
71
|
+
* @inheritDoc
|
|
72
|
+
*/
|
|
58
73
|
getInitAuthorizationExpiry(swapData: EVMSwapData, signature: SignatureData, preFetchedData?: EVMPreFetchVerification): Promise<number>;
|
|
74
|
+
/**
|
|
75
|
+
* @inheritDoc
|
|
76
|
+
*/
|
|
59
77
|
isInitAuthorizationExpired(swapData: EVMSwapData, signature: SignatureData): Promise<boolean>;
|
|
78
|
+
/**
|
|
79
|
+
* @inheritDoc
|
|
80
|
+
*/
|
|
60
81
|
getRefundSignature(signer: EVMSigner, swapData: EVMSwapData, authorizationTimeout: number): Promise<SignatureData>;
|
|
82
|
+
/**
|
|
83
|
+
* @inheritDoc
|
|
84
|
+
*/
|
|
61
85
|
isValidRefundAuthorization(swapData: EVMSwapData, signature: SignatureData): Promise<Buffer | null>;
|
|
86
|
+
/**
|
|
87
|
+
* @inheritDoc
|
|
88
|
+
*/
|
|
62
89
|
getDataSignature(signer: EVMSigner, data: Buffer): Promise<string>;
|
|
90
|
+
/**
|
|
91
|
+
* @inheritDoc
|
|
92
|
+
*/
|
|
63
93
|
isValidDataSignature(data: Buffer, signature: string, publicKey: string): Promise<boolean>;
|
|
64
94
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* @param signer
|
|
68
|
-
* @param data
|
|
95
|
+
* @inheritDoc
|
|
69
96
|
*/
|
|
70
97
|
isClaimable(signer: string, data: EVMSwapData): Promise<boolean>;
|
|
71
98
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* @param swapData
|
|
99
|
+
* @inheritDoc
|
|
75
100
|
*/
|
|
76
101
|
isCommited(swapData: EVMSwapData): Promise<boolean>;
|
|
77
102
|
/**
|
|
78
|
-
*
|
|
79
|
-
* the swap expires a bit sooner than it should've & for the offerer it expires a bit later
|
|
80
|
-
*
|
|
81
|
-
* @param signer
|
|
82
|
-
* @param data
|
|
103
|
+
* @inheritDoc
|
|
83
104
|
*/
|
|
84
105
|
isExpired(signer: string, data: EVMSwapData): Promise<boolean>;
|
|
85
106
|
/**
|
|
86
|
-
*
|
|
87
|
-
* is still commited
|
|
88
|
-
*
|
|
89
|
-
* @param signer
|
|
90
|
-
* @param data
|
|
107
|
+
* @inheritDoc
|
|
91
108
|
*/
|
|
92
109
|
isRequestRefundable(signer: string, data: EVMSwapData): Promise<boolean>;
|
|
110
|
+
/**
|
|
111
|
+
* @inheritDoc
|
|
112
|
+
*/
|
|
93
113
|
getHashForTxId(txId: string, confirmations: number): Buffer;
|
|
94
114
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* @param outputScript output script required to claim the swap
|
|
98
|
-
* @param amount sats sent required to claim the swap
|
|
99
|
-
* @param confirmations
|
|
100
|
-
* @param nonce swap nonce uniquely identifying the transaction to prevent replay attacks
|
|
115
|
+
* @inheritDoc
|
|
101
116
|
*/
|
|
102
117
|
getHashForOnchain(outputScript: Buffer, amount: bigint, confirmations: number, nonce?: bigint): Buffer;
|
|
103
118
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* @param paymentHash payment hash of the HTLC
|
|
119
|
+
* @inheritDoc
|
|
107
120
|
*/
|
|
108
121
|
getHashForHtlc(paymentHash: Buffer): Buffer;
|
|
122
|
+
/**
|
|
123
|
+
* @inheritDoc
|
|
124
|
+
*/
|
|
109
125
|
getExtraData(outputScript: Buffer, amount: bigint, confirmations: number, nonce?: bigint): Buffer;
|
|
110
126
|
/**
|
|
111
|
-
*
|
|
112
|
-
* if swap is refundable)
|
|
113
|
-
*
|
|
114
|
-
* @param signer
|
|
115
|
-
* @param data
|
|
127
|
+
* @inheritDoc
|
|
116
128
|
*/
|
|
117
129
|
getCommitStatus(signer: string, data: EVMSwapData): Promise<SwapCommitState>;
|
|
130
|
+
/**
|
|
131
|
+
* @inheritDoc
|
|
132
|
+
*/
|
|
118
133
|
getCommitStatuses(request: {
|
|
119
134
|
signer: string;
|
|
120
135
|
swapData: EVMSwapData;
|
|
121
136
|
}[]): Promise<{
|
|
122
137
|
[p: string]: SwapCommitState;
|
|
123
138
|
}>;
|
|
139
|
+
/**
|
|
140
|
+
* @inheritDoc
|
|
141
|
+
*/
|
|
124
142
|
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<EVMSwapData>;
|
|
143
|
+
/**
|
|
144
|
+
* @inheritDoc
|
|
145
|
+
*/
|
|
125
146
|
getBalance(signer: string, tokenAddress: string, inContract?: boolean): Promise<bigint>;
|
|
147
|
+
/**
|
|
148
|
+
* @inheritDoc
|
|
149
|
+
*/
|
|
126
150
|
getIntermediaryData(address: string, token: string): Promise<{
|
|
127
151
|
balance: bigint;
|
|
128
152
|
reputation: IntermediaryReputationType;
|
|
129
153
|
}>;
|
|
154
|
+
/**
|
|
155
|
+
* @inheritDoc
|
|
156
|
+
*/
|
|
130
157
|
getIntermediaryReputation(address: string, token: string): Promise<IntermediaryReputationType>;
|
|
131
158
|
getIntermediaryBalance(address: string, token: string): Promise<bigint>;
|
|
159
|
+
/**
|
|
160
|
+
* @inheritDoc
|
|
161
|
+
*/
|
|
132
162
|
txsClaimWithSecret(signer: string | EVMSigner, swapData: EVMSwapData, secret: string, checkExpiry?: boolean, initAta?: boolean, feeRate?: string, skipAtaCheck?: boolean): Promise<EVMTx[]>;
|
|
163
|
+
/**
|
|
164
|
+
* @inheritDoc
|
|
165
|
+
*/
|
|
133
166
|
txsClaimWithTxData(signer: string | EVMSigner, swapData: EVMSwapData, tx: {
|
|
134
167
|
blockhash: string;
|
|
135
168
|
confirmations: number;
|
|
@@ -137,12 +170,33 @@ export declare class EVMSwapContract<ChainId extends string = string> extends EV
|
|
|
137
170
|
hex: string;
|
|
138
171
|
height: number;
|
|
139
172
|
}, requiredConfirmations: number, vout: number, commitedHeader?: EVMBtcStoredHeader, synchronizer?: RelaySynchronizer<EVMBtcStoredHeader, EVMTx, any>, initAta?: boolean, feeRate?: string): Promise<EVMTx[]>;
|
|
173
|
+
/**
|
|
174
|
+
* @inheritDoc
|
|
175
|
+
*/
|
|
140
176
|
txsRefund(signer: string, swapData: EVMSwapData, check?: boolean, initAta?: boolean, feeRate?: string): Promise<EVMTx[]>;
|
|
177
|
+
/**
|
|
178
|
+
* @inheritDoc
|
|
179
|
+
*/
|
|
141
180
|
txsRefundWithAuthorization(signer: string, swapData: EVMSwapData, signature: SignatureData, check?: boolean, initAta?: boolean, feeRate?: string): Promise<EVMTx[]>;
|
|
181
|
+
/**
|
|
182
|
+
* @inheritDoc
|
|
183
|
+
*/
|
|
142
184
|
txsInit(signer: string, swapData: EVMSwapData, signature: SignatureData, skipChecks?: boolean, feeRate?: string): Promise<EVMTx[]>;
|
|
185
|
+
/**
|
|
186
|
+
* @inheritDoc
|
|
187
|
+
*/
|
|
143
188
|
txsWithdraw(signer: string, token: string, amount: bigint, feeRate?: string): Promise<EVMTx[]>;
|
|
189
|
+
/**
|
|
190
|
+
* @inheritDoc
|
|
191
|
+
*/
|
|
144
192
|
txsDeposit(signer: string, token: string, amount: bigint, feeRate?: string): Promise<EVMTx[]>;
|
|
193
|
+
/**
|
|
194
|
+
* @inheritDoc
|
|
195
|
+
*/
|
|
145
196
|
claimWithSecret(signer: EVMSigner, swapData: EVMSwapData, secret: string, checkExpiry?: boolean, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
197
|
+
/**
|
|
198
|
+
* @inheritDoc
|
|
199
|
+
*/
|
|
146
200
|
claimWithTxData(signer: EVMSigner, swapData: EVMSwapData, tx: {
|
|
147
201
|
blockhash: string;
|
|
148
202
|
confirmations: number;
|
|
@@ -150,22 +204,52 @@ export declare class EVMSwapContract<ChainId extends string = string> extends EV
|
|
|
150
204
|
hex: string;
|
|
151
205
|
height: number;
|
|
152
206
|
}, requiredConfirmations: number, vout: number, commitedHeader?: EVMBtcStoredHeader, synchronizer?: RelaySynchronizer<EVMBtcStoredHeader, EVMTx, any>, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
207
|
+
/**
|
|
208
|
+
* @inheritDoc
|
|
209
|
+
*/
|
|
153
210
|
refund(signer: EVMSigner, swapData: EVMSwapData, check?: boolean, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
211
|
+
/**
|
|
212
|
+
* @inheritDoc
|
|
213
|
+
*/
|
|
154
214
|
refundWithAuthorization(signer: EVMSigner, swapData: EVMSwapData, signature: SignatureData, check?: boolean, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
215
|
+
/**
|
|
216
|
+
* @inheritDoc
|
|
217
|
+
*/
|
|
155
218
|
init(signer: EVMSigner, swapData: EVMSwapData, signature: SignatureData, skipChecks?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
219
|
+
/**
|
|
220
|
+
* @inheritDoc
|
|
221
|
+
*/
|
|
156
222
|
withdraw(signer: EVMSigner, token: string, amount: bigint, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
223
|
+
/**
|
|
224
|
+
* @inheritDoc
|
|
225
|
+
*/
|
|
157
226
|
deposit(signer: EVMSigner, token: string, amount: bigint, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
227
|
+
/**
|
|
228
|
+
* @inheritDoc
|
|
229
|
+
*/
|
|
158
230
|
getInitPayInFeeRate(offerer?: string, claimer?: string, token?: string, paymentHash?: string): Promise<string>;
|
|
231
|
+
/**
|
|
232
|
+
* @inheritDoc
|
|
233
|
+
*/
|
|
159
234
|
getInitFeeRate(offerer?: string, claimer?: string, token?: string, paymentHash?: string): Promise<string>;
|
|
235
|
+
/**
|
|
236
|
+
* @inheritDoc
|
|
237
|
+
*/
|
|
160
238
|
getRefundFeeRate(swapData: EVMSwapData): Promise<string>;
|
|
239
|
+
/**
|
|
240
|
+
* @inheritDoc
|
|
241
|
+
*/
|
|
161
242
|
getClaimFeeRate(signer: string, swapData: EVMSwapData): Promise<string>;
|
|
243
|
+
/**
|
|
244
|
+
* @inheritDoc
|
|
245
|
+
*/
|
|
162
246
|
getClaimFee(signer: string, swapData: EVMSwapData, feeRate?: string): Promise<bigint>;
|
|
163
247
|
/**
|
|
164
|
-
*
|
|
248
|
+
* @inheritDoc
|
|
165
249
|
*/
|
|
166
250
|
getCommitFee(signer: string, swapData: EVMSwapData, feeRate?: string): Promise<bigint>;
|
|
167
251
|
/**
|
|
168
|
-
*
|
|
252
|
+
* @inheritDoc
|
|
169
253
|
*/
|
|
170
254
|
getRefundFee(signer: string, swapData: EVMSwapData, feeRate?: string): Promise<bigint>;
|
|
171
255
|
}
|