@atomiqlabs/chain-evm 2.1.11 → 2.1.14

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.
Files changed (151) hide show
  1. package/README.md +75 -0
  2. package/dist/chains/EVMOptions.d.ts +66 -0
  3. package/dist/chains/EVMOptions.js +2 -0
  4. package/dist/chains/alpen/AlpenInitializer.d.ts +3 -30
  5. package/dist/chains/alpen/AlpenInitializer.js +3 -3
  6. package/dist/chains/botanix/BotanixInitializer.d.ts +3 -30
  7. package/dist/chains/botanix/BotanixInitializer.js +3 -3
  8. package/dist/chains/citrea/CitreaBtcRelay.d.ts +5 -0
  9. package/dist/chains/citrea/CitreaBtcRelay.js +7 -2
  10. package/dist/chains/citrea/CitreaFees.d.ts +3 -5
  11. package/dist/chains/citrea/CitreaFees.js +3 -5
  12. package/dist/chains/citrea/CitreaInitializer.d.ts +3 -29
  13. package/dist/chains/citrea/CitreaInitializer.js +3 -3
  14. package/dist/chains/citrea/CitreaSpvVaultContract.d.ts +5 -0
  15. package/dist/chains/citrea/CitreaSpvVaultContract.js +7 -2
  16. package/dist/chains/citrea/CitreaSwapContract.d.ts +7 -2
  17. package/dist/chains/citrea/CitreaSwapContract.js +10 -5
  18. package/dist/chains/citrea/CitreaTokens.d.ts +5 -0
  19. package/dist/chains/citrea/CitreaTokens.js +5 -0
  20. package/dist/chains/goat/GoatInitializer.d.ts +3 -30
  21. package/dist/chains/goat/GoatInitializer.js +3 -3
  22. package/dist/evm/btcrelay/EVMBtcRelay.d.ts +41 -10
  23. package/dist/evm/btcrelay/EVMBtcRelay.js +50 -18
  24. package/dist/evm/btcrelay/headers/EVMBtcHeader.d.ts +53 -7
  25. package/dist/evm/btcrelay/headers/EVMBtcHeader.js +43 -5
  26. package/dist/evm/btcrelay/headers/EVMBtcStoredHeader.d.ts +53 -8
  27. package/dist/evm/btcrelay/headers/EVMBtcStoredHeader.js +41 -1
  28. package/dist/evm/chain/EVMChainInterface.d.ts +57 -2
  29. package/dist/evm/chain/EVMChainInterface.js +7 -7
  30. package/dist/evm/chain/EVMModule.d.ts +5 -0
  31. package/dist/evm/chain/EVMModule.js +6 -1
  32. package/dist/evm/chain/modules/EVMBlocks.d.ts +7 -0
  33. package/dist/evm/chain/modules/EVMBlocks.js +2 -0
  34. package/dist/evm/chain/modules/EVMEvents.js +19 -19
  35. package/dist/evm/chain/modules/EVMFees.d.ts +41 -5
  36. package/dist/evm/chain/modules/EVMFees.js +24 -5
  37. package/dist/evm/chain/modules/EVMTokens.d.ts +1 -1
  38. package/dist/evm/chain/modules/EVMTokens.js +1 -1
  39. package/dist/evm/chain/modules/EVMTransactions.d.ts +20 -2
  40. package/dist/evm/chain/modules/EVMTransactions.js +11 -8
  41. package/dist/evm/contract/EVMContractBase.d.ts +28 -10
  42. package/dist/evm/contract/EVMContractBase.js +9 -18
  43. package/dist/evm/contract/EVMContractModule.d.ts +5 -0
  44. package/dist/evm/contract/EVMContractModule.js +5 -0
  45. package/dist/evm/contract/modules/EVMContractEvents.d.ts +7 -1
  46. package/dist/evm/contract/modules/EVMContractEvents.js +23 -3
  47. package/dist/evm/events/EVMChainEvents.d.ts +8 -0
  48. package/dist/evm/events/EVMChainEvents.js +8 -0
  49. package/dist/evm/events/EVMChainEventsBrowser.d.ts +87 -19
  50. package/dist/evm/events/EVMChainEventsBrowser.js +53 -18
  51. package/dist/evm/providers/JsonRpcProviderWithRetries.d.ts +9 -0
  52. package/dist/evm/providers/JsonRpcProviderWithRetries.js +9 -0
  53. package/dist/evm/providers/ReconnectingWebSocketProvider.d.ts +5 -0
  54. package/dist/evm/providers/ReconnectingWebSocketProvider.js +5 -0
  55. package/dist/evm/providers/WebSocketProviderWithRetries.d.ts +9 -0
  56. package/dist/evm/providers/WebSocketProviderWithRetries.js +9 -0
  57. package/dist/evm/spv_swap/EVMSpvVaultContract.d.ts +46 -21
  58. package/dist/evm/spv_swap/EVMSpvVaultContract.js +62 -22
  59. package/dist/evm/spv_swap/EVMSpvVaultData.d.ts +57 -2
  60. package/dist/evm/spv_swap/EVMSpvVaultData.js +57 -2
  61. package/dist/evm/spv_swap/EVMSpvWithdrawalData.d.ts +12 -0
  62. package/dist/evm/spv_swap/EVMSpvWithdrawalData.js +12 -0
  63. package/dist/evm/swaps/EVMSwapContract.d.ts +58 -13
  64. package/dist/evm/swaps/EVMSwapContract.js +81 -54
  65. package/dist/evm/swaps/EVMSwapData.d.ts +27 -6
  66. package/dist/evm/swaps/EVMSwapData.js +26 -0
  67. package/dist/evm/swaps/EVMSwapModule.d.ts +5 -0
  68. package/dist/evm/swaps/EVMSwapModule.js +5 -0
  69. package/dist/evm/swaps/handlers/IHandler.d.ts +5 -0
  70. package/dist/evm/swaps/handlers/claim/ClaimHandlers.d.ts +15 -0
  71. package/dist/evm/swaps/handlers/claim/ClaimHandlers.js +5 -0
  72. package/dist/evm/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.d.ts +5 -0
  73. package/dist/evm/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.d.ts +10 -0
  74. package/dist/evm/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.d.ts +5 -0
  75. package/dist/evm/swaps/handlers/claim/btc/IBitcoinClaimHandler.d.ts +15 -0
  76. package/dist/evm/swaps/handlers/claim/btc/IBitcoinClaimHandler.js +7 -2
  77. package/dist/evm/swaps/modules/EVMLpVault.d.ts +5 -0
  78. package/dist/evm/swaps/modules/EVMLpVault.js +9 -4
  79. package/dist/evm/swaps/modules/EVMSwapClaim.d.ts +7 -2
  80. package/dist/evm/swaps/modules/EVMSwapClaim.js +11 -6
  81. package/dist/evm/swaps/modules/EVMSwapInit.d.ts +10 -0
  82. package/dist/evm/swaps/modules/EVMSwapInit.js +11 -6
  83. package/dist/evm/swaps/modules/EVMSwapRefund.d.ts +5 -0
  84. package/dist/evm/swaps/modules/EVMSwapRefund.js +9 -4
  85. package/dist/evm/wallet/EVMBrowserSigner.d.ts +22 -2
  86. package/dist/evm/wallet/EVMBrowserSigner.js +40 -2
  87. package/dist/evm/wallet/EVMPersistentSigner.d.ts +13 -2
  88. package/dist/evm/wallet/EVMPersistentSigner.js +13 -1
  89. package/dist/evm/wallet/EVMSigner.d.ts +30 -1
  90. package/dist/evm/wallet/EVMSigner.js +34 -1
  91. package/dist/index.d.ts +71 -0
  92. package/dist/index.js +70 -0
  93. package/dist/node/index.d.ts +10 -0
  94. package/dist/node/index.js +15 -0
  95. package/dist/utils/Utils.d.ts +50 -0
  96. package/dist/utils/Utils.js +45 -0
  97. package/node/index.d.ts +1 -0
  98. package/node/index.js +3 -0
  99. package/package.json +4 -3
  100. package/src/chains/EVMOptions.ts +70 -0
  101. package/src/chains/alpen/AlpenInitializer.ts +5 -27
  102. package/src/chains/botanix/BotanixChainType.ts +5 -5
  103. package/src/chains/botanix/BotanixInitializer.ts +5 -27
  104. package/src/chains/citrea/CitreaBtcRelay.ts +8 -3
  105. package/src/chains/citrea/CitreaFees.ts +3 -6
  106. package/src/chains/citrea/CitreaInitializer.ts +5 -27
  107. package/src/chains/citrea/CitreaSpvVaultContract.ts +7 -2
  108. package/src/chains/citrea/CitreaSwapContract.ts +11 -6
  109. package/src/chains/citrea/CitreaTokens.ts +6 -1
  110. package/src/chains/goat/GoatChainType.ts +5 -5
  111. package/src/chains/goat/GoatInitializer.ts +3 -25
  112. package/src/evm/btcrelay/EVMBtcRelay.ts +54 -22
  113. package/src/evm/btcrelay/headers/EVMBtcHeader.ts +60 -13
  114. package/src/evm/btcrelay/headers/EVMBtcStoredHeader.ts +55 -10
  115. package/src/evm/chain/EVMChainInterface.ts +66 -14
  116. package/src/evm/chain/EVMModule.ts +6 -1
  117. package/src/evm/chain/modules/EVMBlocks.ts +7 -0
  118. package/src/evm/chain/modules/EVMEvents.ts +19 -19
  119. package/src/evm/chain/modules/EVMFees.ts +41 -5
  120. package/src/evm/chain/modules/EVMTokens.ts +1 -1
  121. package/src/evm/chain/modules/EVMTransactions.ts +27 -8
  122. package/src/evm/contract/EVMContractBase.ts +29 -24
  123. package/src/evm/contract/EVMContractModule.ts +5 -0
  124. package/src/evm/contract/modules/EVMContractEvents.ts +27 -8
  125. package/src/evm/events/EVMChainEvents.ts +8 -0
  126. package/src/evm/events/EVMChainEventsBrowser.ts +103 -29
  127. package/src/evm/providers/JsonRpcProviderWithRetries.ts +10 -1
  128. package/src/evm/providers/ReconnectingWebSocketProvider.ts +6 -1
  129. package/src/evm/providers/WebSocketProviderWithRetries.ts +10 -1
  130. package/src/evm/spv_swap/EVMSpvVaultContract.ts +73 -31
  131. package/src/evm/spv_swap/EVMSpvVaultData.ts +57 -2
  132. package/src/evm/spv_swap/EVMSpvWithdrawalData.ts +12 -0
  133. package/src/evm/swaps/EVMSwapContract.ts +108 -63
  134. package/src/evm/swaps/EVMSwapData.ts +27 -1
  135. package/src/evm/swaps/EVMSwapModule.ts +5 -0
  136. package/src/evm/swaps/handlers/IHandler.ts +5 -0
  137. package/src/evm/swaps/handlers/claim/ClaimHandlers.ts +15 -0
  138. package/src/evm/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.ts +5 -0
  139. package/src/evm/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.ts +10 -0
  140. package/src/evm/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.ts +5 -0
  141. package/src/evm/swaps/handlers/claim/btc/IBitcoinClaimHandler.ts +17 -2
  142. package/src/evm/swaps/modules/EVMLpVault.ts +10 -5
  143. package/src/evm/swaps/modules/EVMSwapClaim.ts +12 -7
  144. package/src/evm/swaps/modules/EVMSwapInit.ts +17 -7
  145. package/src/evm/swaps/modules/EVMSwapRefund.ts +9 -4
  146. package/src/evm/wallet/EVMBrowserSigner.ts +44 -5
  147. package/src/evm/wallet/EVMPersistentSigner.ts +14 -2
  148. package/src/evm/wallet/EVMSigner.ts +37 -1
  149. package/src/index.ts +72 -0
  150. package/src/node/index.ts +10 -0
  151. package/src/utils/Utils.ts +50 -1
@@ -8,39 +8,38 @@ import { EVMSigner } from "../wallet/EVMSigner";
8
8
  import { SpvVaultManager } from "./SpvVaultContractTypechain";
9
9
  import { EVMBtcRelay } from "../btcrelay/EVMBtcRelay";
10
10
  import { EVMChainInterface } from "../chain/EVMChainInterface";
11
- import { TransactionRequest } from "ethers";
12
11
  import { EVMSpvVaultData } from "./EVMSpvVaultData";
13
12
  import { EVMSpvWithdrawalData } from "./EVMSpvWithdrawalData";
14
13
  import { EVMBtcStoredHeader } from "../btcrelay/headers/EVMBtcStoredHeader";
14
+ /**
15
+ * Packs vault owner and vault id into compact `owner+vaultId` event key format.
16
+ *
17
+ * @category Swaps
18
+ */
15
19
  export declare function packOwnerAndVaultId(owner: string, vaultId: bigint): string;
20
+ /**
21
+ * Unpacks compact `owner+vaultId` event key format into owner and vault id.
22
+ *
23
+ * @category Swaps
24
+ */
16
25
  export declare function unpackOwnerAndVaultId(data: string): [string, bigint];
17
26
  /**
27
+ * EVM SPV vault (UTXO-controlled vault) contract representation.
28
+ *
18
29
  * @category Swaps
19
30
  */
20
31
  export declare class EVMSpvVaultContract<ChainId extends string> extends EVMContractBase<SpvVaultManager> implements SpvVaultContract<EVMTx, EVMSigner, ChainId, EVMSpvWithdrawalData, EVMSpvVaultData> {
21
- static readonly GasCosts: {
22
- DEPOSIT_BASE: number;
23
- DEPOSIT_ERC20: number;
24
- OPEN: number;
25
- CLAIM_BASE: number;
26
- CLAIM_NATIVE_TRANSFER: number;
27
- CLAIM_ERC20_TRANSFER: number;
28
- CLAIM_EXECUTION_SCHEDULE: number;
29
- FRONT_BASE: number;
30
- FRONT_NATIVE_TRANSFER: number;
31
- FRONT_ERC20_TRANSFER: number;
32
- FRONT_EXECUTION_SCHEDULE: number;
33
- };
32
+ private static readonly GasCosts;
34
33
  readonly chainId: ChainId;
35
- readonly btcRelay: EVMBtcRelay<any>;
36
- readonly bitcoinRpc: BitcoinRpc<any>;
37
34
  readonly claimTimeout: number;
38
- readonly logger: import("../../utils/Utils").LoggerType;
35
+ private readonly btcRelay;
36
+ private readonly bitcoinRpc;
37
+ private readonly logger;
39
38
  constructor(chainInterface: EVMChainInterface<ChainId>, btcRelay: EVMBtcRelay<any>, bitcoinRpc: BitcoinRpc<any>, contractAddress: string, contractDeploymentHeight?: number);
40
- protected Open(signer: string, vault: EVMSpvVaultData, feeRate: string): Promise<TransactionRequest>;
41
- protected Deposit(signer: string, vault: EVMSpvVaultData, rawAmounts: bigint[], feeRate: string): Promise<TransactionRequest>;
42
- protected Front(signer: string, vault: EVMSpvVaultData, data: EVMSpvWithdrawalData, withdrawalSequence: number, feeRate: string): Promise<TransactionRequest>;
43
- protected Claim(signer: string, vault: EVMSpvVaultData, data: EVMSpvWithdrawalData, blockheader: EVMBtcStoredHeader, merkle: Buffer[], position: number, feeRate: string): Promise<TransactionRequest>;
39
+ private Open;
40
+ private Deposit;
41
+ private Front;
42
+ private Claim;
44
43
  /**
45
44
  * @inheritDoc
46
45
  */
@@ -130,6 +129,11 @@ export declare class EVMSpvVaultContract<ChainId extends string> extends EVMCont
130
129
  rawAmounts: bigint[];
131
130
  executionHash?: string;
132
131
  };
132
+ /**
133
+ * Parses withdrawal params from OP_RETURN data.
134
+ *
135
+ * @param data Data as specified in the OP_RETURN output of the transaction
136
+ */
133
137
  static fromOpReturnData(data: Buffer): {
134
138
  recipient: string;
135
139
  rawAmounts: bigint[];
@@ -139,6 +143,13 @@ export declare class EVMSpvVaultContract<ChainId extends string> extends EVMCont
139
143
  * @inheritDoc
140
144
  */
141
145
  toOpReturnData(recipient: string, rawAmounts: bigint[], executionHash?: string): Buffer;
146
+ /**
147
+ * Serializes withdrawal params to OP_RETURN data.
148
+ *
149
+ * @param recipient Recipient of the withdrawn tokens
150
+ * @param rawAmounts Raw amount of tokens to withdraw
151
+ * @param executionHash Optional execution hash of the actions to execute
152
+ */
142
153
  static toOpReturnData(recipient: string, rawAmounts: bigint[], executionHash?: string): Buffer;
143
154
  /**
144
155
  * @inheritDoc
@@ -178,7 +189,21 @@ export declare class EVMSpvVaultContract<ChainId extends string> extends EVMCont
178
189
  * @inheritDoc
179
190
  */
180
191
  txsOpen(signer: string, vault: EVMSpvVaultData, feeRate?: string): Promise<EVMTx[]>;
192
+ /**
193
+ * Returns an estimated gas amount for a claim transaction.
194
+ *
195
+ * @param signer Signer address executing the claim
196
+ * @param vault Vault data used to determine transfer paths
197
+ * @param data Parsed withdrawal data
198
+ */
181
199
  getClaimGas(signer: string, vault?: EVMSpvVaultData, data?: EVMSpvWithdrawalData): number;
200
+ /**
201
+ * Returns an estimated gas amount for a front-liquidity transaction.
202
+ *
203
+ * @param signer Signer address executing the front action
204
+ * @param vault Vault data used to determine transfer paths
205
+ * @param data Parsed withdrawal data
206
+ */
182
207
  getFrontGas(signer: string, vault: EVMSpvVaultData, data?: EVMSpvWithdrawalData): number;
183
208
  /**
184
209
  * @inheritDoc
@@ -20,17 +20,29 @@ function decodeUtxo(utxo) {
20
20
  vout: BigInt(vout)
21
21
  };
22
22
  }
23
+ /**
24
+ * Packs vault owner and vault id into compact `owner+vaultId` event key format.
25
+ *
26
+ * @category Swaps
27
+ */
23
28
  function packOwnerAndVaultId(owner, vaultId) {
24
29
  if (owner.length !== 42)
25
30
  throw new Error("Invalid owner address");
26
31
  return owner.toLowerCase() + base_1.BigIntBufferUtils.toBuffer(vaultId, "be", 12).toString("hex");
27
32
  }
28
33
  exports.packOwnerAndVaultId = packOwnerAndVaultId;
34
+ /**
35
+ * Unpacks compact `owner+vaultId` event key format into owner and vault id.
36
+ *
37
+ * @category Swaps
38
+ */
29
39
  function unpackOwnerAndVaultId(data) {
30
40
  return [(0, ethers_1.getAddress)(data.substring(0, 42)), BigInt("0x" + data.substring(42, 66))];
31
41
  }
32
42
  exports.unpackOwnerAndVaultId = unpackOwnerAndVaultId;
33
43
  /**
44
+ * EVM SPV vault (UTXO-controlled vault) contract representation.
45
+ *
34
46
  * @category Swaps
35
47
  */
36
48
  class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
@@ -49,7 +61,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
49
61
  const tokens = vault.getTokenData();
50
62
  if (tokens.length !== 2)
51
63
  throw new Error("Must specify exactly 2 tokens for vault!");
52
- const tx = await this.contract.open.populateTransaction(vault.vaultId, vault.getVaultParamsStruct(), txHash, vout);
64
+ const tx = await this.contract.open.populateTransaction(vault.vaultId, vault._getVaultParamsStruct(), txHash, vout);
53
65
  tx.from = signer;
54
66
  EVMFees_1.EVMFees.applyFeeRate(tx, EVMSpvVaultContract.GasCosts.OPEN, feeRate);
55
67
  return tx;
@@ -71,7 +83,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
71
83
  if (rawAmounts[1] != null && rawAmounts[1] > 0n && vault.token0.token.toLowerCase() !== vault.token1.token.toLowerCase())
72
84
  totalGas += EVMSpvVaultContract.GasCosts.DEPOSIT_ERC20;
73
85
  }
74
- const tx = await this.contract.deposit.populateTransaction(vault.owner, vault.vaultId, vault.getVaultParamsStruct(), rawAmounts[0], rawAmounts[1] ?? 0n, { value });
86
+ const tx = await this.contract.deposit.populateTransaction(vault.owner, vault.vaultId, vault._getVaultParamsStruct(), rawAmounts[0], rawAmounts[1] ?? 0n, { value });
75
87
  tx.from = signer;
76
88
  EVMFees_1.EVMFees.applyFeeRate(tx, totalGas, feeRate);
77
89
  return tx;
@@ -83,13 +95,13 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
83
95
  value += frontingAmount[0] * vault.token0.multiplier;
84
96
  if (vault.token1.token.toLowerCase() === this.Chain.getNativeCurrencyAddress().toLowerCase())
85
97
  value += (frontingAmount[1] ?? 0n) * vault.token1.multiplier;
86
- const tx = await this.contract.front.populateTransaction(vault.owner, vault.vaultId, vault.getVaultParamsStruct(), withdrawalSequence, data.getTxHash(), data.serializeToStruct(), { value });
98
+ const tx = await this.contract.front.populateTransaction(vault.owner, vault.vaultId, vault._getVaultParamsStruct(), withdrawalSequence, data.getTxHash(), data.serializeToStruct(), { value });
87
99
  tx.from = signer;
88
100
  EVMFees_1.EVMFees.applyFeeRate(tx, this.getFrontGas(signer, vault, data), feeRate);
89
101
  return tx;
90
102
  }
91
103
  async Claim(signer, vault, data, blockheader, merkle, position, feeRate) {
92
- const tx = await this.contract.claim.populateTransaction(vault.owner, vault.vaultId, vault.getVaultParamsStruct(), "0x" + data.btcTx.hex, blockheader.serializeToStruct(), merkle, position);
104
+ const tx = await this.contract.claim.populateTransaction(vault.owner, vault.vaultId, vault._getVaultParamsStruct(), "0x" + data.btcTx.hex, blockheader.serializeToStruct(), merkle, position);
93
105
  tx.from = signer;
94
106
  EVMFees_1.EVMFees.applyFeeRate(tx, this.getClaimGas(signer, vault, data), feeRate);
95
107
  return tx;
@@ -109,7 +121,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
109
121
  if (tokenData.length !== 2)
110
122
  throw new Error("Must specify 2 tokens in tokenData!");
111
123
  const vaultParams = {
112
- btcRelayContract: this.btcRelay.contractAddress,
124
+ btcRelayContract: this.btcRelay._contractAddress,
113
125
  token0: tokenData[0].token,
114
126
  token1: tokenData[1].token,
115
127
  token0Multiplier: tokenData[0].multiplier,
@@ -149,7 +161,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
149
161
  promises.push(this.getFronterAddress(owner, vaultId, withdrawal).then(val => {
150
162
  result[withdrawal.getTxId()] = val;
151
163
  }));
152
- if (promises.length >= this.Chain.config.maxParallelCalls) {
164
+ if (promises.length >= this.Chain._config.maxParallelCalls) {
153
165
  await Promise.all(promises);
154
166
  promises = [];
155
167
  }
@@ -166,7 +178,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
166
178
  return null;
167
179
  const vaultParams = await this.vaultParamsCache.getOrComputeAsync(vaultState.spvVaultParametersCommitment, async () => {
168
180
  const blockheight = Number(vaultState.openBlockheight);
169
- const events = await this.Events.getContractBlockEvents(["Opened"], [
181
+ const events = await this._Events.getContractBlockEvents(["Opened"], [
170
182
  "0x" + owner.substring(2).padStart(64, "0"),
171
183
  (0, ethers_1.hexlify)(base_1.BigIntBufferUtils.toBuffer(vaultId, "be", 32))
172
184
  ], blockheight);
@@ -175,7 +187,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
175
187
  throw new Error("Valid open event not found!");
176
188
  return foundEvent.args.params;
177
189
  });
178
- if (vaultParams.btcRelayContract.toLowerCase() !== this.btcRelay.contractAddress.toLowerCase())
190
+ if (vaultParams.btcRelayContract.toLowerCase() !== this.btcRelay._contractAddress.toLowerCase())
179
191
  return null;
180
192
  return new EVMSpvVaultData_1.EVMSpvVaultData(owner, vaultId, vaultState, vaultParams);
181
193
  }
@@ -191,7 +203,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
191
203
  result[owner] ?? (result[owner] = {});
192
204
  result[owner][vaultId.toString(10)] = val;
193
205
  }));
194
- if (promises.length >= this.Chain.config.maxParallelCalls) {
206
+ if (promises.length >= this.Chain._config.maxParallelCalls) {
195
207
  await Promise.all(promises);
196
208
  promises = [];
197
209
  }
@@ -221,7 +233,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
221
233
  result[owner] ?? (result[owner] = {});
222
234
  result[owner][vaultId.toString(10)] = val;
223
235
  }));
224
- if (promises.length >= this.Chain.config.maxParallelCalls) {
236
+ if (promises.length >= this.Chain._config.maxParallelCalls) {
225
237
  await Promise.all(promises);
226
238
  promises = [];
227
239
  }
@@ -234,7 +246,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
234
246
  */
235
247
  async getAllVaults(owner) {
236
248
  const openedVaults = new Map();
237
- await this.Events.findInContractEventsForward(["Opened", "Closed"], owner == null ? null : [
249
+ await this._Events.findInContractEventsForward(["Opened", "Closed"], owner == null ? null : [
238
250
  "0x" + owner.substring(2).padStart(64, "0")
239
251
  ], (event) => {
240
252
  const vaultIdentifier = event.args.owner + ":" + event.args.vaultId.toString(10);
@@ -250,13 +262,15 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
250
262
  const vaults = [];
251
263
  let promises = [];
252
264
  for (let [identifier, vaultParams] of openedVaults.entries()) {
265
+ if (vaultParams.btcRelayContract.toLowerCase() !== this.btcRelay._contractAddress.toLowerCase())
266
+ continue;
253
267
  const [owner, vaultIdStr] = identifier.split(":");
254
268
  promises.push(this.contract.getVault(owner, BigInt(vaultIdStr)).then(vaultState => {
255
269
  if (vaultState.spvVaultParametersCommitment === (0, EVMSpvVaultData_1.getVaultParamsCommitment)(vaultParams)) {
256
270
  vaults.push(new EVMSpvVaultData_1.EVMSpvVaultData(owner, BigInt(vaultIdStr), vaultState, vaultParams));
257
271
  }
258
272
  }));
259
- if (promises.length >= this.Chain.config.maxParallelCalls) {
273
+ if (promises.length >= this.Chain._config.maxParallelCalls) {
260
274
  await Promise.all(promises);
261
275
  promises = [];
262
276
  }
@@ -326,12 +340,12 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
326
340
  const keys = [null, null, (0, ethers_1.hexlify)(txHash)];
327
341
  let result;
328
342
  if (scStartHeight == null) {
329
- result = await this.Events.findInContractEvents(events, keys, async (event) => {
343
+ result = await this._Events.findInContractEvents(events, keys, async (event) => {
330
344
  return this.parseWithdrawalEvent(event);
331
345
  });
332
346
  }
333
347
  else {
334
- result = await this.Events.findInContractEventsForward(events, keys, async (event) => {
348
+ result = await this._Events.findInContractEventsForward(events, keys, async (event) => {
335
349
  const result = this.parseWithdrawalEvent(event);
336
350
  if (result == null)
337
351
  return null;
@@ -357,8 +371,8 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
357
371
  var _a;
358
372
  const result = {};
359
373
  const events = ["Fronted", "Claimed", "Closed"];
360
- for (let i = 0; i < withdrawalTxs.length; i += this.Chain.config.maxLogTopics) {
361
- const checkWithdrawalTxs = withdrawalTxs.slice(i, i + this.Chain.config.maxLogTopics);
374
+ for (let i = 0; i < withdrawalTxs.length; i += this.Chain._config.maxLogTopics) {
375
+ const checkWithdrawalTxs = withdrawalTxs.slice(i, i + this.Chain._config.maxLogTopics);
362
376
  const checkWithdrawalTxsMap = new Map(checkWithdrawalTxs.map(val => [val.withdrawal.getTxId(), val.withdrawal]));
363
377
  let scStartHeight = null;
364
378
  for (let val of checkWithdrawalTxs) {
@@ -370,7 +384,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
370
384
  }
371
385
  const keys = [null, null, checkWithdrawalTxs.map(withdrawal => (0, ethers_1.hexlify)(buffer_1.Buffer.from(withdrawal.withdrawal.getTxId(), "hex").reverse()))];
372
386
  if (scStartHeight == null) {
373
- await this.Events.findInContractEvents(events, keys, async (event) => {
387
+ await this._Events.findInContractEvents(events, keys, async (event) => {
374
388
  const _event = event;
375
389
  const btcTxId = buffer_1.Buffer.from(_event.args.btcTxHash.substring(2), "hex").reverse().toString("hex");
376
390
  if (!checkWithdrawalTxsMap.has(btcTxId)) {
@@ -387,7 +401,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
387
401
  });
388
402
  }
389
403
  else {
390
- await this.Events.findInContractEventsForward(events, keys, async (event) => {
404
+ await this._Events.findInContractEventsForward(events, keys, async (event) => {
391
405
  const _event = event;
392
406
  const btcTxId = buffer_1.Buffer.from(_event.args.btcTxHash.substring(2), "hex").reverse().toString("hex");
393
407
  const withdrawalTx = checkWithdrawalTxsMap.get(btcTxId);
@@ -423,7 +437,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
423
437
  async getHistoricalWithdrawalStates(recipient, startBlockheight) {
424
438
  const { height: latestBlockheight } = await this.Chain.getFinalizedBlock();
425
439
  const withdrawals = {};
426
- await this.Events.findInContractEventsForward(["Claimed", "Fronted"], [null, recipient], async (_event) => {
440
+ await this._Events.findInContractEventsForward(["Claimed", "Fronted"], [null, recipient], async (_event) => {
427
441
  const eventResult = this.parseWithdrawalEvent(_event);
428
442
  if (eventResult == null || eventResult.type === base_1.SpvWithdrawalStateType.CLOSED)
429
443
  return null;
@@ -447,6 +461,11 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
447
461
  fromOpReturnData(data) {
448
462
  return EVMSpvVaultContract.fromOpReturnData(data);
449
463
  }
464
+ /**
465
+ * Parses withdrawal params from OP_RETURN data.
466
+ *
467
+ * @param data Data as specified in the OP_RETURN output of the transaction
468
+ */
450
469
  static fromOpReturnData(data) {
451
470
  let rawAmount0 = 0n;
452
471
  let rawAmount1 = 0n;
@@ -481,6 +500,13 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
481
500
  toOpReturnData(recipient, rawAmounts, executionHash) {
482
501
  return EVMSpvVaultContract.toOpReturnData(recipient, rawAmounts, executionHash);
483
502
  }
503
+ /**
504
+ * Serializes withdrawal params to OP_RETURN data.
505
+ *
506
+ * @param recipient Recipient of the withdrawn tokens
507
+ * @param rawAmounts Raw amount of tokens to withdraw
508
+ * @param executionHash Optional execution hash of the actions to execute
509
+ */
484
510
  static toOpReturnData(recipient, rawAmounts, executionHash) {
485
511
  if (!EVMAddresses_1.EVMAddresses.isValidAddress(recipient))
486
512
  throw new Error("Invalid recipient specified");
@@ -606,7 +632,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
606
632
  requiredApprovals[vault.token1.token.toLowerCase()] += realAmount1;
607
633
  }
608
634
  }
609
- const requiredApprovalTxns = await Promise.all(Object.keys(requiredApprovals).map(token => this.Chain.Tokens.checkAndGetApproveTx(signer, token, requiredApprovals[token], this.contractAddress, feeRate)));
635
+ const requiredApprovalTxns = await Promise.all(Object.keys(requiredApprovals).map(token => this.Chain.Tokens.checkAndGetApproveTx(signer, token, requiredApprovals[token], this._contractAddress, feeRate)));
610
636
  requiredApprovalTxns.forEach(tx => tx != null && txs.push(tx));
611
637
  txs.push(await this.Deposit(signer, vault, rawAmounts, feeRate));
612
638
  this.logger.debug("txsDeposit(): deposit TX created," +
@@ -642,7 +668,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
642
668
  requiredApprovals[vault.token1.token.toLowerCase()] += realAmount1;
643
669
  }
644
670
  }
645
- const requiredApprovalTxns = await Promise.all(Object.keys(requiredApprovals).map(token => this.Chain.Tokens.checkAndGetApproveTx(signer, token, requiredApprovals[token], this.contractAddress, feeRate)));
671
+ const requiredApprovalTxns = await Promise.all(Object.keys(requiredApprovals).map(token => this.Chain.Tokens.checkAndGetApproveTx(signer, token, requiredApprovals[token], this._contractAddress, feeRate)));
646
672
  requiredApprovalTxns.forEach(tx => tx != null && txs.push(tx));
647
673
  txs.push(await this.Front(signer, vault, realWithdrawalTx, withdrawSequence, feeRate));
648
674
  this.logger.debug("txsFrontLiquidity(): front TX created," +
@@ -662,6 +688,13 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
662
688
  " vaultId: " + vault.getVaultId().toString(10));
663
689
  return [tx];
664
690
  }
691
+ /**
692
+ * Returns an estimated gas amount for a claim transaction.
693
+ *
694
+ * @param signer Signer address executing the claim
695
+ * @param vault Vault data used to determine transfer paths
696
+ * @param data Parsed withdrawal data
697
+ */
665
698
  getClaimGas(signer, vault, data) {
666
699
  let totalGas = EVMSpvVaultContract.GasCosts.CLAIM_BASE;
667
700
  if (data == null || (data.rawAmounts[0] != null && data.rawAmounts[0] > 0n)) {
@@ -686,6 +719,13 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
686
719
  totalGas += EVMSpvVaultContract.GasCosts.CLAIM_EXECUTION_SCHEDULE;
687
720
  return totalGas;
688
721
  }
722
+ /**
723
+ * Returns an estimated gas amount for a front-liquidity transaction.
724
+ *
725
+ * @param signer Signer address executing the front action
726
+ * @param vault Vault data used to determine transfer paths
727
+ * @param data Parsed withdrawal data
728
+ */
689
729
  getFrontGas(signer, vault, data) {
690
730
  let totalGas = EVMSpvVaultContract.GasCosts.FRONT_BASE;
691
731
  if (data == null || (data.rawAmounts[0] != null && data.rawAmounts[0] > 0n)) {
@@ -711,7 +751,7 @@ class EVMSpvVaultContract extends EVMContractBase_1.EVMContractBase {
711
751
  * @inheritDoc
712
752
  */
713
753
  async getFrontFee(signer, vault, withdrawalData, feeRate) {
714
- vault ?? (vault = EVMSpvVaultData_1.EVMSpvVaultData.randomVault());
754
+ vault ?? (vault = EVMSpvVaultData_1.EVMSpvVaultData._randomVault());
715
755
  feeRate ?? (feeRate = await this.Chain.Fees.getFeeRate());
716
756
  let totalFee = EVMFees_1.EVMFees.getGasFee(this.getFrontGas(signer, vault, withdrawalData), feeRate);
717
757
  if (withdrawalData == null || (withdrawalData.rawAmounts[0] != null && withdrawalData.rawAmounts[0] > 0n)) {
@@ -1,9 +1,21 @@
1
1
  import { SpvVaultClaimEvent, SpvVaultCloseEvent, SpvVaultData, SpvVaultDepositEvent, SpvVaultOpenEvent, SpvVaultTokenBalance, SpvVaultTokenData } from "@atomiqlabs/base";
2
2
  import { EVMSpvWithdrawalData } from "./EVMSpvWithdrawalData";
3
3
  import { SpvVaultParametersStruct, SpvVaultStateStruct } from "./SpvVaultContractTypechain";
4
+ /**
5
+ * Computes the vault parameter commitment hash used by the on-chain SPV vault state.
6
+ *
7
+ * @category Swaps
8
+ */
4
9
  export declare function getVaultParamsCommitment(vaultParams: SpvVaultParametersStruct): string;
10
+ /**
11
+ * Decodes UTXO reference (`txid:vout`) from the on-chain SPV vault state struct.
12
+ *
13
+ * @category Swaps
14
+ */
5
15
  export declare function getVaultUtxoFromState(state: SpvVaultStateStruct): string;
6
16
  /**
17
+ * Represents the state of the EVM SPV vault (UTXO-controlled vault).
18
+ *
7
19
  * @category Swaps
8
20
  */
9
21
  export declare class EVMSpvVaultData extends SpvVaultData<EVMSpvWithdrawalData> {
@@ -27,17 +39,60 @@ export declare class EVMSpvVaultData extends SpvVaultData<EVMSpvWithdrawalData>
27
39
  depositCount: number;
28
40
  constructor(owner: string, vaultId: bigint, state: SpvVaultStateStruct, params: SpvVaultParametersStruct, initialUtxo?: string);
29
41
  constructor(serializedObj: any);
42
+ /**
43
+ * @inheritDoc
44
+ */
30
45
  getBalances(): SpvVaultTokenBalance[];
46
+ /**
47
+ * @inheritDoc
48
+ */
31
49
  getConfirmations(): number;
50
+ /**
51
+ * @inheritDoc
52
+ */
32
53
  getOwner(): string;
54
+ /**
55
+ * @inheritDoc
56
+ */
33
57
  getTokenData(): SpvVaultTokenData[];
58
+ /**
59
+ * @inheritDoc
60
+ */
34
61
  getUtxo(): string;
62
+ /**
63
+ * @inheritDoc
64
+ */
35
65
  getVaultId(): bigint;
66
+ /**
67
+ * @inheritDoc
68
+ */
36
69
  getWithdrawalCount(): number;
70
+ /**
71
+ * @inheritDoc
72
+ */
37
73
  isOpened(): boolean;
74
+ /**
75
+ * @inheritDoc
76
+ */
38
77
  serialize(): any;
78
+ /**
79
+ * @inheritDoc
80
+ */
39
81
  updateState(withdrawalTxOrEvent: SpvVaultClaimEvent | SpvVaultCloseEvent | SpvVaultOpenEvent | SpvVaultDepositEvent | EVMSpvWithdrawalData): void;
82
+ /**
83
+ * @inheritDoc
84
+ */
40
85
  getDepositCount(): number;
41
- getVaultParamsStruct(): SpvVaultParametersStruct;
42
- static randomVault(): EVMSpvVaultData;
86
+ /**
87
+ * Serializes this spv vault data to a struct object which can be passed to the ether.js functions
88
+ *
89
+ * @internal
90
+ */
91
+ _getVaultParamsStruct(): SpvVaultParametersStruct;
92
+ /**
93
+ * Returns a dummy random vault that can be used for e.g. fee estimation
94
+ *
95
+ * @internal
96
+ */
97
+ static _randomVault(): EVMSpvVaultData;
43
98
  }
@@ -7,16 +7,28 @@ const EVMSpvWithdrawalData_1 = require("./EVMSpvWithdrawalData");
7
7
  const ethers_1 = require("ethers");
8
8
  const ethers_2 = require("ethers");
9
9
  const EVMAddresses_1 = require("../chain/modules/EVMAddresses");
10
+ /**
11
+ * Computes the vault parameter commitment hash used by the on-chain SPV vault state.
12
+ *
13
+ * @category Swaps
14
+ */
10
15
  function getVaultParamsCommitment(vaultParams) {
11
16
  return (0, ethers_2.keccak256)(ethers_2.AbiCoder.defaultAbiCoder().encode(["address", "address", "address", "uint192", "uint192", "uint256"], [vaultParams.btcRelayContract, vaultParams.token0, vaultParams.token1, vaultParams.token0Multiplier, vaultParams.token1Multiplier, vaultParams.confirmations]));
12
17
  }
13
18
  exports.getVaultParamsCommitment = getVaultParamsCommitment;
19
+ /**
20
+ * Decodes UTXO reference (`txid:vout`) from the on-chain SPV vault state struct.
21
+ *
22
+ * @category Swaps
23
+ */
14
24
  function getVaultUtxoFromState(state) {
15
25
  const txHash = buffer_1.Buffer.from((0, ethers_1.hexlify)(state.utxoTxHash).substring(2), "hex");
16
26
  return txHash.reverse().toString("hex") + ":" + BigInt(state.utxoVout).toString(10);
17
27
  }
18
28
  exports.getVaultUtxoFromState = getVaultUtxoFromState;
19
29
  /**
30
+ * Represents the state of the EVM SPV vault (UTXO-controlled vault).
31
+ *
20
32
  * @category Swaps
21
33
  */
22
34
  class EVMSpvVaultData extends base_1.SpvVaultData {
@@ -69,33 +81,60 @@ class EVMSpvVaultData extends base_1.SpvVaultData {
69
81
  this.initialUtxo = ownerOrObj.initialUtxo;
70
82
  }
71
83
  }
84
+ /**
85
+ * @inheritDoc
86
+ */
72
87
  getBalances() {
73
88
  return [
74
89
  { ...this.token0, scaledAmount: this.token0.rawAmount * this.token0.multiplier },
75
90
  { ...this.token1, scaledAmount: this.token1.rawAmount * this.token1.multiplier }
76
91
  ];
77
92
  }
93
+ /**
94
+ * @inheritDoc
95
+ */
78
96
  getConfirmations() {
79
97
  return this.confirmations;
80
98
  }
99
+ /**
100
+ * @inheritDoc
101
+ */
81
102
  getOwner() {
82
103
  return this.owner;
83
104
  }
105
+ /**
106
+ * @inheritDoc
107
+ */
84
108
  getTokenData() {
85
109
  return [this.token0, this.token1];
86
110
  }
111
+ /**
112
+ * @inheritDoc
113
+ */
87
114
  getUtxo() {
88
115
  return this.isOpened() ? this.utxo : this.initialUtxo;
89
116
  }
117
+ /**
118
+ * @inheritDoc
119
+ */
90
120
  getVaultId() {
91
121
  return this.vaultId;
92
122
  }
123
+ /**
124
+ * @inheritDoc
125
+ */
93
126
  getWithdrawalCount() {
94
127
  return this.withdrawCount;
95
128
  }
129
+ /**
130
+ * @inheritDoc
131
+ */
96
132
  isOpened() {
97
133
  return this.utxo !== "0000000000000000000000000000000000000000000000000000000000000000:0";
98
134
  }
135
+ /**
136
+ * @inheritDoc
137
+ */
99
138
  serialize() {
100
139
  return {
101
140
  type: "EVM",
@@ -119,6 +158,9 @@ class EVMSpvVaultData extends base_1.SpvVaultData {
119
158
  initialUtxo: this.initialUtxo
120
159
  };
121
160
  }
161
+ /**
162
+ * @inheritDoc
163
+ */
122
164
  updateState(withdrawalTxOrEvent) {
123
165
  if (withdrawalTxOrEvent instanceof base_1.SpvVaultClaimEvent) {
124
166
  if (withdrawalTxOrEvent.withdrawCount <= this.withdrawCount)
@@ -155,10 +197,18 @@ class EVMSpvVaultData extends base_1.SpvVaultData {
155
197
  this.utxo = withdrawalTxOrEvent.btcTx.txid + ":0";
156
198
  }
157
199
  }
200
+ /**
201
+ * @inheritDoc
202
+ */
158
203
  getDepositCount() {
159
204
  return this.depositCount;
160
205
  }
161
- getVaultParamsStruct() {
206
+ /**
207
+ * Serializes this spv vault data to a struct object which can be passed to the ether.js functions
208
+ *
209
+ * @internal
210
+ */
211
+ _getVaultParamsStruct() {
162
212
  return {
163
213
  btcRelayContract: this.relayContract,
164
214
  token0: this.token0.token,
@@ -168,7 +218,12 @@ class EVMSpvVaultData extends base_1.SpvVaultData {
168
218
  confirmations: this.confirmations
169
219
  };
170
220
  }
171
- static randomVault() {
221
+ /**
222
+ * Returns a dummy random vault that can be used for e.g. fee estimation
223
+ *
224
+ * @internal
225
+ */
226
+ static _randomVault() {
172
227
  const spvVaultParams = {
173
228
  btcRelayContract: EVMAddresses_1.EVMAddresses.randomAddress(),
174
229
  token0: EVMAddresses_1.EVMAddresses.randomAddress(),
@@ -4,6 +4,9 @@ import { SpvWithdrawalTransactionData } from "@atomiqlabs/base";
4
4
  import { Buffer } from "buffer";
5
5
  import { BitcoinVaultTransactionDataStruct } from "./SpvVaultContractTypechain";
6
6
  /**
7
+ * Represents parsed withdrawal data used for claiming assets from the EVM SPV vault
8
+ * (UTXO-controlled vault).
9
+ *
7
10
  * @category Swaps
8
11
  */
9
12
  export declare class EVMSpvWithdrawalData extends SpvWithdrawalTransactionData {
@@ -24,11 +27,20 @@ export declare class EVMSpvWithdrawalData extends SpvWithdrawalTransactionData {
24
27
  * @inheritDoc
25
28
  */
26
29
  getFrontingId(): string;
30
+ /**
31
+ * @inheritDoc
32
+ */
27
33
  getTxHash(): string;
34
+ /**
35
+ * @inheritDoc
36
+ */
28
37
  getFrontingAmount(): bigint[];
29
38
  /**
30
39
  * @inheritDoc
31
40
  */
32
41
  serialize(): any;
42
+ /**
43
+ * Serializes the withdrawal data to the EVM contract struct representation.
44
+ */
33
45
  serializeToStruct(): BitcoinVaultTransactionDataStruct;
34
46
  }
@@ -6,6 +6,9 @@ const buffer_1 = require("buffer");
6
6
  const EVMSpvVaultContract_1 = require("./EVMSpvVaultContract");
7
7
  const ethers_1 = require("ethers");
8
8
  /**
9
+ * Represents parsed withdrawal data used for claiming assets from the EVM SPV vault
10
+ * (UTXO-controlled vault).
11
+ *
9
12
  * @category Swaps
10
13
  */
11
14
  class EVMSpvWithdrawalData extends base_1.SpvWithdrawalTransactionData {
@@ -33,9 +36,15 @@ class EVMSpvWithdrawalData extends base_1.SpvWithdrawalTransactionData {
33
36
  const txDataHash = (0, ethers_1.keccak256)(ethers_1.AbiCoder.defaultAbiCoder().encode(["address", "uint64", "uint64", "uint64", "uint64", "uint64", "uint64", "uint64", "bytes32", "uint256"], [this.recipient, this.rawAmounts[0], this.rawAmounts[1], callerFee[0], callerFee[1], frontingFee[0], frontingFee[1], this.getExecutionFee()[0], this.getExecutionHashWith0x(), this.executionExpiry]));
34
37
  return (0, ethers_1.keccak256)(ethers_1.AbiCoder.defaultAbiCoder().encode(["bytes32", "bytes32"], [txDataHash, this.getTxHash()])).substring(2);
35
38
  }
39
+ /**
40
+ * @inheritDoc
41
+ */
36
42
  getTxHash() {
37
43
  return "0x" + buffer_1.Buffer.from(this.btcTx.txid, "hex").reverse().toString("hex");
38
44
  }
45
+ /**
46
+ * @inheritDoc
47
+ */
39
48
  getFrontingAmount() {
40
49
  return [this.rawAmounts[0] + this.getExecutionFee()[0], this.rawAmounts[1]];
41
50
  }
@@ -48,6 +57,9 @@ class EVMSpvWithdrawalData extends base_1.SpvWithdrawalTransactionData {
48
57
  ...super.serialize()
49
58
  };
50
59
  }
60
+ /**
61
+ * Serializes the withdrawal data to the EVM contract struct representation.
62
+ */
51
63
  serializeToStruct() {
52
64
  const callerFee = this.getCallerFee();
53
65
  const frontingFee = this.getFrontingFee();