@atomiqlabs/chain-solana 13.5.13 → 13.5.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 (131) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +73 -73
  3. package/dist/index.d.ts +81 -81
  4. package/dist/index.js +102 -102
  5. package/dist/node/index.d.ts +9 -9
  6. package/dist/node/index.js +13 -13
  7. package/dist/solana/SolanaChainType.d.ts +15 -15
  8. package/dist/solana/SolanaChainType.js +2 -2
  9. package/dist/solana/SolanaChains.d.ts +12 -12
  10. package/dist/solana/SolanaChains.js +45 -45
  11. package/dist/solana/SolanaInitializer.d.ts +94 -94
  12. package/dist/solana/SolanaInitializer.js +174 -174
  13. package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +222 -222
  14. package/dist/solana/btcrelay/SolanaBtcRelay.js +455 -455
  15. package/dist/solana/btcrelay/headers/SolanaBtcHeader.d.ts +84 -84
  16. package/dist/solana/btcrelay/headers/SolanaBtcHeader.js +70 -70
  17. package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.d.ts +92 -92
  18. package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.js +109 -109
  19. package/dist/solana/btcrelay/program/programIdl.json +671 -671
  20. package/dist/solana/chain/SolanaAction.d.ts +26 -26
  21. package/dist/solana/chain/SolanaAction.js +87 -87
  22. package/dist/solana/chain/SolanaChainInterface.d.ts +224 -224
  23. package/dist/solana/chain/SolanaChainInterface.js +275 -275
  24. package/dist/solana/chain/SolanaModule.d.ts +14 -14
  25. package/dist/solana/chain/SolanaModule.js +13 -13
  26. package/dist/solana/chain/modules/SolanaAddresses.d.ts +8 -8
  27. package/dist/solana/chain/modules/SolanaAddresses.js +22 -22
  28. package/dist/solana/chain/modules/SolanaBlocks.d.ts +32 -32
  29. package/dist/solana/chain/modules/SolanaBlocks.js +78 -78
  30. package/dist/solana/chain/modules/SolanaEvents.d.ts +68 -68
  31. package/dist/solana/chain/modules/SolanaEvents.js +238 -238
  32. package/dist/solana/chain/modules/SolanaFees.d.ts +189 -189
  33. package/dist/solana/chain/modules/SolanaFees.js +434 -434
  34. package/dist/solana/chain/modules/SolanaSignatures.d.ts +24 -24
  35. package/dist/solana/chain/modules/SolanaSignatures.js +39 -39
  36. package/dist/solana/chain/modules/SolanaSlots.d.ts +33 -33
  37. package/dist/solana/chain/modules/SolanaSlots.js +72 -72
  38. package/dist/solana/chain/modules/SolanaTokens.d.ts +123 -123
  39. package/dist/solana/chain/modules/SolanaTokens.js +242 -242
  40. package/dist/solana/chain/modules/SolanaTransactions.d.ts +149 -149
  41. package/dist/solana/chain/modules/SolanaTransactions.js +445 -445
  42. package/dist/solana/connection/ConnectionWithRetries.d.ts +35 -35
  43. package/dist/solana/connection/ConnectionWithRetries.js +86 -71
  44. package/dist/solana/events/SolanaChainEvents.d.ts +45 -45
  45. package/dist/solana/events/SolanaChainEvents.js +108 -108
  46. package/dist/solana/events/SolanaChainEventsBrowser.d.ts +205 -205
  47. package/dist/solana/events/SolanaChainEventsBrowser.js +404 -404
  48. package/dist/solana/program/SolanaProgramBase.d.ts +73 -73
  49. package/dist/solana/program/SolanaProgramBase.js +54 -54
  50. package/dist/solana/program/SolanaProgramModule.d.ts +8 -8
  51. package/dist/solana/program/SolanaProgramModule.js +11 -11
  52. package/dist/solana/program/modules/SolanaProgramEvents.d.ts +53 -53
  53. package/dist/solana/program/modules/SolanaProgramEvents.js +117 -117
  54. package/dist/solana/swaps/SolanaSwapData.d.ts +333 -333
  55. package/dist/solana/swaps/SolanaSwapData.js +535 -535
  56. package/dist/solana/swaps/SolanaSwapModule.d.ts +11 -11
  57. package/dist/solana/swaps/SolanaSwapModule.js +12 -12
  58. package/dist/solana/swaps/SolanaSwapProgram.d.ts +376 -376
  59. package/dist/solana/swaps/SolanaSwapProgram.js +769 -769
  60. package/dist/solana/swaps/SwapTypeEnum.d.ts +11 -11
  61. package/dist/solana/swaps/SwapTypeEnum.js +43 -43
  62. package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +95 -95
  63. package/dist/solana/swaps/modules/SolanaDataAccount.js +232 -232
  64. package/dist/solana/swaps/modules/SolanaLpVault.d.ts +69 -69
  65. package/dist/solana/swaps/modules/SolanaLpVault.js +171 -171
  66. package/dist/solana/swaps/modules/SwapClaim.d.ts +126 -126
  67. package/dist/solana/swaps/modules/SwapClaim.js +294 -294
  68. package/dist/solana/swaps/modules/SwapInit.d.ts +213 -213
  69. package/dist/solana/swaps/modules/SwapInit.js +658 -658
  70. package/dist/solana/swaps/modules/SwapRefund.d.ts +87 -87
  71. package/dist/solana/swaps/modules/SwapRefund.js +293 -293
  72. package/dist/solana/swaps/programIdl.json +945 -945
  73. package/dist/solana/swaps/programTypes.d.ts +943 -943
  74. package/dist/solana/swaps/programTypes.js +945 -945
  75. package/dist/solana/swaps/v1/programIdl.json +945 -945
  76. package/dist/solana/swaps/v1/programTypes.d.ts +943 -943
  77. package/dist/solana/swaps/v1/programTypes.js +945 -945
  78. package/dist/solana/swaps/v2/programIdl.json +952 -952
  79. package/dist/solana/swaps/v2/programTypes.d.ts +950 -950
  80. package/dist/solana/swaps/v2/programTypes.js +952 -952
  81. package/dist/solana/wallet/SolanaKeypairWallet.d.ts +29 -29
  82. package/dist/solana/wallet/SolanaKeypairWallet.js +50 -50
  83. package/dist/solana/wallet/SolanaSigner.d.ts +30 -30
  84. package/dist/solana/wallet/SolanaSigner.js +30 -30
  85. package/dist/utils/Utils.d.ts +58 -58
  86. package/dist/utils/Utils.js +170 -170
  87. package/node/index.d.ts +1 -1
  88. package/node/index.js +3 -3
  89. package/package.json +46 -46
  90. package/src/index.ts +87 -87
  91. package/src/node/index.ts +9 -9
  92. package/src/solana/SolanaChainType.ts +32 -32
  93. package/src/solana/SolanaChains.ts +46 -46
  94. package/src/solana/SolanaInitializer.ts +278 -278
  95. package/src/solana/btcrelay/SolanaBtcRelay.ts +615 -615
  96. package/src/solana/btcrelay/headers/SolanaBtcHeader.ts +116 -116
  97. package/src/solana/btcrelay/headers/SolanaBtcStoredHeader.ts +148 -148
  98. package/src/solana/btcrelay/program/programIdl.json +670 -670
  99. package/src/solana/chain/SolanaAction.ts +109 -109
  100. package/src/solana/chain/SolanaChainInterface.ts +404 -404
  101. package/src/solana/chain/SolanaModule.ts +20 -20
  102. package/src/solana/chain/modules/SolanaAddresses.ts +20 -20
  103. package/src/solana/chain/modules/SolanaBlocks.ts +89 -89
  104. package/src/solana/chain/modules/SolanaEvents.ts +271 -271
  105. package/src/solana/chain/modules/SolanaFees.ts +522 -522
  106. package/src/solana/chain/modules/SolanaSignatures.ts +39 -39
  107. package/src/solana/chain/modules/SolanaSlots.ts +85 -85
  108. package/src/solana/chain/modules/SolanaTokens.ts +300 -300
  109. package/src/solana/chain/modules/SolanaTransactions.ts +503 -503
  110. package/src/solana/connection/ConnectionWithRetries.ts +113 -96
  111. package/src/solana/events/SolanaChainEvents.ts +127 -127
  112. package/src/solana/events/SolanaChainEventsBrowser.ts +495 -495
  113. package/src/solana/program/SolanaProgramBase.ts +119 -119
  114. package/src/solana/program/SolanaProgramModule.ts +15 -15
  115. package/src/solana/program/modules/SolanaProgramEvents.ts +157 -157
  116. package/src/solana/swaps/SolanaSwapData.ts +735 -735
  117. package/src/solana/swaps/SolanaSwapModule.ts +19 -19
  118. package/src/solana/swaps/SolanaSwapProgram.ts +1074 -1074
  119. package/src/solana/swaps/SwapTypeEnum.ts +30 -30
  120. package/src/solana/swaps/modules/SolanaDataAccount.ts +302 -302
  121. package/src/solana/swaps/modules/SolanaLpVault.ts +208 -208
  122. package/src/solana/swaps/modules/SwapClaim.ts +387 -387
  123. package/src/solana/swaps/modules/SwapInit.ts +785 -785
  124. package/src/solana/swaps/modules/SwapRefund.ts +353 -353
  125. package/src/solana/swaps/v1/programIdl.json +944 -944
  126. package/src/solana/swaps/v1/programTypes.ts +1885 -1885
  127. package/src/solana/swaps/v2/programIdl.json +951 -951
  128. package/src/solana/swaps/v2/programTypes.ts +1899 -1899
  129. package/src/solana/wallet/SolanaKeypairWallet.ts +56 -56
  130. package/src/solana/wallet/SolanaSigner.ts +43 -43
  131. package/src/utils/Utils.ts +194 -194
@@ -1,171 +1,171 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolanaLpVault = void 0;
4
- const SolanaSwapModule_1 = require("../SolanaSwapModule");
5
- const SolanaAction_1 = require("../../chain/SolanaAction");
6
- const web3_js_1 = require("@solana/web3.js");
7
- const spl_token_1 = require("@solana/spl-token");
8
- const Utils_1 = require("../../../utils/Utils");
9
- const SolanaTokens_1 = require("../../chain/modules/SolanaTokens");
10
- class SolanaLpVault extends SolanaSwapModule_1.SolanaSwapModule {
11
- /**
12
- * Action for withdrawing funds from the LP vault
13
- *
14
- * @param signer
15
- * @param token
16
- * @param amount
17
- * @private
18
- */
19
- async Withdraw(signer, token, amount) {
20
- const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(token, signer);
21
- return new SolanaAction_1.SolanaAction(signer, this.root, await this.swapProgram.methods
22
- .withdraw((0, Utils_1.toBN)(amount))
23
- .accounts({
24
- signer,
25
- signerAta: ata,
26
- userData: this.program._SwapUserVault(signer, token),
27
- vault: this.program._SwapVault(token),
28
- vaultAuthority: this.program._SwapVaultAuthority,
29
- mint: token,
30
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID
31
- })
32
- .instruction(), SolanaLpVault.CUCosts.WITHDRAW);
33
- }
34
- /**
35
- * Action for depositing funds to the LP vault
36
- *
37
- * @param signer
38
- * @param token
39
- * @param amount
40
- * @private
41
- */
42
- async Deposit(signer, token, amount) {
43
- const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(token, signer);
44
- return new SolanaAction_1.SolanaAction(signer, this.root, await this.swapProgram.methods
45
- .deposit((0, Utils_1.toBN)(amount))
46
- .accounts({
47
- signer,
48
- signerAta: ata,
49
- userData: this.program._SwapUserVault(signer, token),
50
- vault: this.program._SwapVault(token),
51
- vaultAuthority: this.program._SwapVaultAuthority,
52
- mint: token,
53
- systemProgram: web3_js_1.SystemProgram.programId,
54
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID
55
- })
56
- .instruction(), SolanaLpVault.CUCosts.DEPOSIT);
57
- }
58
- /**
59
- * Returns intermediary's reputation & vault balance for a specific token
60
- *
61
- * @param address
62
- * @param token
63
- */
64
- async getIntermediaryData(address, token) {
65
- const data = await this.swapProgram.account.userAccount.fetchNullable(this.program._SwapUserVault(address, token));
66
- if (data == null)
67
- return null;
68
- const response = [];
69
- for (let i = 0; i < data.successVolume.length; i++) {
70
- response[i] = {
71
- successVolume: data.successVolume[i],
72
- successCount: data.successCount[i],
73
- failVolume: data.failVolume[i],
74
- failCount: data.failCount[i],
75
- coopCloseVolume: data.coopCloseVolume[i],
76
- coopCloseCount: data.coopCloseCount[i]
77
- };
78
- }
79
- return {
80
- balance: (0, Utils_1.toBigInt)(data.amount),
81
- reputation: response
82
- };
83
- }
84
- /**
85
- * Returns intermediary's reputation for a specific token
86
- *
87
- * @param address
88
- * @param token
89
- */
90
- async getIntermediaryReputation(address, token) {
91
- const intermediaryData = await this.getIntermediaryData(address, token);
92
- return intermediaryData?.reputation ?? null;
93
- }
94
- /**
95
- * Returns the balance of the token an intermediary has in his LP vault
96
- *
97
- * @param address
98
- * @param token
99
- */
100
- async getIntermediaryBalance(address, token) {
101
- const intermediaryData = await this.getIntermediaryData(address, token);
102
- const balance = intermediaryData?.balance ?? 0n;
103
- this.logger.debug("getIntermediaryBalance(): token LP balance fetched, token: " + token.toString() +
104
- " address: " + address + " amount: " + balance.toString());
105
- return balance;
106
- }
107
- /**
108
- * Creates transactions for withdrawing funds from the LP vault, creates ATA if it doesn't exist and unwraps
109
- * WSOL to SOL if required
110
- *
111
- * @param signer
112
- * @param token
113
- * @param amount
114
- * @param feeRate
115
- */
116
- async txsWithdraw(signer, token, amount, feeRate) {
117
- const ata = await (0, spl_token_1.getAssociatedTokenAddress)(token, signer);
118
- feeRate = feeRate || await this.getFeeRate(signer, token);
119
- const action = new SolanaAction_1.SolanaAction(signer, this.root);
120
- if (!await this.root.Tokens.ataExists(ata)) {
121
- action.add(this.root.Tokens.InitAta(signer, signer, token));
122
- }
123
- action.add(await this.Withdraw(signer, token, amount));
124
- const shouldUnwrap = token.equals(SolanaTokens_1.SolanaTokens.WSOL_ADDRESS);
125
- if (shouldUnwrap)
126
- action.add(this.root.Tokens.Unwrap(signer));
127
- this.logger.debug("txsWithdraw(): withdraw TX created, token: " + token.toString() +
128
- " amount: " + amount.toString(10) + " unwrapping: " + shouldUnwrap);
129
- return [await action.tx(feeRate)];
130
- }
131
- /**
132
- * Creates transaction for depositing funds into the LP vault, wraps SOL to WSOL if required
133
- *
134
- * @param signer
135
- * @param token
136
- * @param amount
137
- * @param feeRate
138
- */
139
- async txsDeposit(signer, token, amount, feeRate) {
140
- const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(token, signer);
141
- feeRate = feeRate || await this.getFeeRate(signer, token);
142
- const action = new SolanaAction_1.SolanaAction(signer, this.root);
143
- let wrapping = false;
144
- if (token.equals(SolanaTokens_1.SolanaTokens.WSOL_ADDRESS)) {
145
- const account = await this.root.Tokens.getATAOrNull(ata);
146
- let balance = account == null ? 0n : account.amount;
147
- if (balance < amount) {
148
- action.add(this.root.Tokens.Wrap(signer, amount - balance, account == null));
149
- wrapping = true;
150
- }
151
- }
152
- action.addAction(await this.Deposit(signer, token, amount));
153
- this.logger.debug("txsDeposit(): deposit TX created, token: " + token.toString() +
154
- " amount: " + amount.toString(10) + " wrapping: " + wrapping);
155
- return [await action.tx(feeRate)];
156
- }
157
- getFeeRate(signer, token) {
158
- const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(token, signer);
159
- return this.root.Fees.getFeeRate([
160
- signer,
161
- ata,
162
- this.program._SwapUserVault(signer, token),
163
- this.program._SwapVault(token)
164
- ]);
165
- }
166
- }
167
- exports.SolanaLpVault = SolanaLpVault;
168
- SolanaLpVault.CUCosts = {
169
- WITHDRAW: 50000,
170
- DEPOSIT: 50000
171
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolanaLpVault = void 0;
4
+ const SolanaSwapModule_1 = require("../SolanaSwapModule");
5
+ const SolanaAction_1 = require("../../chain/SolanaAction");
6
+ const web3_js_1 = require("@solana/web3.js");
7
+ const spl_token_1 = require("@solana/spl-token");
8
+ const Utils_1 = require("../../../utils/Utils");
9
+ const SolanaTokens_1 = require("../../chain/modules/SolanaTokens");
10
+ class SolanaLpVault extends SolanaSwapModule_1.SolanaSwapModule {
11
+ /**
12
+ * Action for withdrawing funds from the LP vault
13
+ *
14
+ * @param signer
15
+ * @param token
16
+ * @param amount
17
+ * @private
18
+ */
19
+ async Withdraw(signer, token, amount) {
20
+ const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(token, signer);
21
+ return new SolanaAction_1.SolanaAction(signer, this.root, await this.swapProgram.methods
22
+ .withdraw((0, Utils_1.toBN)(amount))
23
+ .accounts({
24
+ signer,
25
+ signerAta: ata,
26
+ userData: this.program._SwapUserVault(signer, token),
27
+ vault: this.program._SwapVault(token),
28
+ vaultAuthority: this.program._SwapVaultAuthority,
29
+ mint: token,
30
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID
31
+ })
32
+ .instruction(), SolanaLpVault.CUCosts.WITHDRAW);
33
+ }
34
+ /**
35
+ * Action for depositing funds to the LP vault
36
+ *
37
+ * @param signer
38
+ * @param token
39
+ * @param amount
40
+ * @private
41
+ */
42
+ async Deposit(signer, token, amount) {
43
+ const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(token, signer);
44
+ return new SolanaAction_1.SolanaAction(signer, this.root, await this.swapProgram.methods
45
+ .deposit((0, Utils_1.toBN)(amount))
46
+ .accounts({
47
+ signer,
48
+ signerAta: ata,
49
+ userData: this.program._SwapUserVault(signer, token),
50
+ vault: this.program._SwapVault(token),
51
+ vaultAuthority: this.program._SwapVaultAuthority,
52
+ mint: token,
53
+ systemProgram: web3_js_1.SystemProgram.programId,
54
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID
55
+ })
56
+ .instruction(), SolanaLpVault.CUCosts.DEPOSIT);
57
+ }
58
+ /**
59
+ * Returns intermediary's reputation & vault balance for a specific token
60
+ *
61
+ * @param address
62
+ * @param token
63
+ */
64
+ async getIntermediaryData(address, token) {
65
+ const data = await this.swapProgram.account.userAccount.fetchNullable(this.program._SwapUserVault(address, token));
66
+ if (data == null)
67
+ return null;
68
+ const response = [];
69
+ for (let i = 0; i < data.successVolume.length; i++) {
70
+ response[i] = {
71
+ successVolume: data.successVolume[i],
72
+ successCount: data.successCount[i],
73
+ failVolume: data.failVolume[i],
74
+ failCount: data.failCount[i],
75
+ coopCloseVolume: data.coopCloseVolume[i],
76
+ coopCloseCount: data.coopCloseCount[i]
77
+ };
78
+ }
79
+ return {
80
+ balance: (0, Utils_1.toBigInt)(data.amount),
81
+ reputation: response
82
+ };
83
+ }
84
+ /**
85
+ * Returns intermediary's reputation for a specific token
86
+ *
87
+ * @param address
88
+ * @param token
89
+ */
90
+ async getIntermediaryReputation(address, token) {
91
+ const intermediaryData = await this.getIntermediaryData(address, token);
92
+ return intermediaryData?.reputation ?? null;
93
+ }
94
+ /**
95
+ * Returns the balance of the token an intermediary has in his LP vault
96
+ *
97
+ * @param address
98
+ * @param token
99
+ */
100
+ async getIntermediaryBalance(address, token) {
101
+ const intermediaryData = await this.getIntermediaryData(address, token);
102
+ const balance = intermediaryData?.balance ?? 0n;
103
+ this.logger.debug("getIntermediaryBalance(): token LP balance fetched, token: " + token.toString() +
104
+ " address: " + address + " amount: " + balance.toString());
105
+ return balance;
106
+ }
107
+ /**
108
+ * Creates transactions for withdrawing funds from the LP vault, creates ATA if it doesn't exist and unwraps
109
+ * WSOL to SOL if required
110
+ *
111
+ * @param signer
112
+ * @param token
113
+ * @param amount
114
+ * @param feeRate
115
+ */
116
+ async txsWithdraw(signer, token, amount, feeRate) {
117
+ const ata = await (0, spl_token_1.getAssociatedTokenAddress)(token, signer);
118
+ feeRate = feeRate || await this.getFeeRate(signer, token);
119
+ const action = new SolanaAction_1.SolanaAction(signer, this.root);
120
+ if (!await this.root.Tokens.ataExists(ata)) {
121
+ action.add(this.root.Tokens.InitAta(signer, signer, token));
122
+ }
123
+ action.add(await this.Withdraw(signer, token, amount));
124
+ const shouldUnwrap = token.equals(SolanaTokens_1.SolanaTokens.WSOL_ADDRESS);
125
+ if (shouldUnwrap)
126
+ action.add(this.root.Tokens.Unwrap(signer));
127
+ this.logger.debug("txsWithdraw(): withdraw TX created, token: " + token.toString() +
128
+ " amount: " + amount.toString(10) + " unwrapping: " + shouldUnwrap);
129
+ return [await action.tx(feeRate)];
130
+ }
131
+ /**
132
+ * Creates transaction for depositing funds into the LP vault, wraps SOL to WSOL if required
133
+ *
134
+ * @param signer
135
+ * @param token
136
+ * @param amount
137
+ * @param feeRate
138
+ */
139
+ async txsDeposit(signer, token, amount, feeRate) {
140
+ const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(token, signer);
141
+ feeRate = feeRate || await this.getFeeRate(signer, token);
142
+ const action = new SolanaAction_1.SolanaAction(signer, this.root);
143
+ let wrapping = false;
144
+ if (token.equals(SolanaTokens_1.SolanaTokens.WSOL_ADDRESS)) {
145
+ const account = await this.root.Tokens.getATAOrNull(ata);
146
+ let balance = account == null ? 0n : account.amount;
147
+ if (balance < amount) {
148
+ action.add(this.root.Tokens.Wrap(signer, amount - balance, account == null));
149
+ wrapping = true;
150
+ }
151
+ }
152
+ action.addAction(await this.Deposit(signer, token, amount));
153
+ this.logger.debug("txsDeposit(): deposit TX created, token: " + token.toString() +
154
+ " amount: " + amount.toString(10) + " wrapping: " + wrapping);
155
+ return [await action.tx(feeRate)];
156
+ }
157
+ getFeeRate(signer, token) {
158
+ const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(token, signer);
159
+ return this.root.Fees.getFeeRate([
160
+ signer,
161
+ ata,
162
+ this.program._SwapUserVault(signer, token),
163
+ this.program._SwapVault(token)
164
+ ]);
165
+ }
166
+ }
167
+ exports.SolanaLpVault = SolanaLpVault;
168
+ SolanaLpVault.CUCosts = {
169
+ WITHDRAW: 50000,
170
+ DEPOSIT: 50000
171
+ };
@@ -1,126 +1,126 @@
1
- import { SolanaSwapModule } from "../SolanaSwapModule";
2
- import { SolanaSwapData } from "../SolanaSwapData";
3
- import { RelaySynchronizer } from "@atomiqlabs/base";
4
- import { PublicKey } from "@solana/web3.js";
5
- import { SolanaTx } from "../../chain/modules/SolanaTransactions";
6
- import { SolanaBtcStoredHeader } from "../../btcrelay/headers/SolanaBtcStoredHeader";
7
- import { SolanaBtcRelay } from "../../btcrelay/SolanaBtcRelay";
8
- import { SolanaSwapProgram } from "../SolanaSwapProgram";
9
- import { SolanaSigner } from "../../wallet/SolanaSigner";
10
- import { SolanaChainInterface } from "../../chain/SolanaChainInterface";
11
- export declare class SwapClaim extends SolanaSwapModule {
12
- private static readonly CUCosts;
13
- readonly btcRelay: SolanaBtcRelay<any>;
14
- /**
15
- * Claim action which uses the provided hex encoded secret for claiming the swap
16
- *
17
- * @param signer
18
- * @param swapData
19
- * @param secret
20
- * @private
21
- */
22
- private Claim;
23
- /**
24
- * Verify and claim action required for BTC on-chain swaps verified through btc relay, adds the btc relay verify
25
- * instruction to the 0th index in the transaction, also intentionally sets compute budget to null such that no
26
- * compute budget instruction is added, since that takes up too much space and txs are limited to 1232 bytes
27
- *
28
- * @param signer
29
- * @param swapData
30
- * @param storeDataKey
31
- * @param merkleProof
32
- * @param commitedHeader
33
- * @private
34
- */
35
- private VerifyAndClaim;
36
- constructor(chainInterface: SolanaChainInterface, program: SolanaSwapProgram, btcRelay: SolanaBtcRelay<any>);
37
- /**
38
- * Gets the compute budget required for claiming the swap
39
- *
40
- * @param swapData
41
- * @private
42
- */
43
- private getComputeBudget;
44
- /**
45
- * Gets committed header, identified by blockhash & blockheight, determines required BTC relay blockheight based on
46
- * requiredConfirmations
47
- * If synchronizer is passed & blockhash is not found, it produces transactions to sync up the btc relay to the
48
- * current chain tip & adds them to the txs array
49
- *
50
- * @param signer
51
- * @param txBlockheight transaction blockheight
52
- * @param requiredConfirmations required confirmation for the swap to be claimable with that TX
53
- * @param blockhash blockhash of the block which includes the transaction
54
- * @param txs solana transaction array, in case we need to synchronize the btc relay ourselves the synchronization
55
- * txns are added here
56
- * @param synchronizer optional synchronizer to use to synchronize the btc relay in case it is not yet synchronized
57
- * to the required blockheight
58
- * @private
59
- */
60
- private getCommitedHeaderAndSynchronize;
61
- /**
62
- * Adds the transactions required for initialization and writing of transaction data to the data account
63
- *
64
- * @param signer
65
- * @param tx transaction to be written
66
- * @param vout vout of the transaction to use to satisfy swap conditions
67
- * @param feeRate fee rate for the transactions
68
- * @param txs solana transaction array, init & write transactions are added here
69
- * @private
70
- * @returns {Promise<PublicKey>} publicKey/address of the data account
71
- */
72
- private addTxsWriteTransactionData;
73
- /**
74
- * Checks whether we should unwrap the WSOL to SOL when claiming the swap
75
- *
76
- * @param signer
77
- * @param swapData
78
- * @private
79
- */
80
- private shouldUnwrap;
81
- /**
82
- * Creates transactions claiming the swap using a secret (for HTLC swaps)
83
- *
84
- * @param signer
85
- * @param swapData swap to claim
86
- * @param secret hex encoded secret pre-image to the HTLC hash
87
- * @param checkExpiry whether to check if the swap is already expired (trying to claim an expired swap with a secret
88
- * is dangerous because we might end up revealing the secret to the counterparty without being able to claim the swap)
89
- * @param initAta whether to init the claimer's ATA if it doesn't exist
90
- * @param feeRate fee rate to use for the transaction
91
- * @param skipAtaCheck whether to check if ATA exists
92
- */
93
- txsClaimWithSecret(signer: PublicKey, swapData: SolanaSwapData, secret: string, checkExpiry?: boolean, initAta?: boolean, feeRate?: string, skipAtaCheck?: boolean): Promise<SolanaTx[]>;
94
- /**
95
- * Creates transaction claiming the swap using a confirmed transaction data (for BTC on-chain swaps)
96
- *
97
- * @param signer
98
- * @param swapData swap to claim
99
- * @param tx bitcoin transaction that satisfies the swap condition
100
- * @param vout vout of the bitcoin transaction that satisfies the swap condition
101
- * @param commitedHeader commited header data from btc relay (fetched internally if null)
102
- * @param synchronizer optional synchronizer to use in case we need to sync up the btc relay ourselves
103
- * @param initAta whether to initialize claimer's ATA
104
- * @param feeRate fee rate to be used for the transactions
105
- */
106
- txsClaimWithTxData(signer: PublicKey | SolanaSigner, swapData: SolanaSwapData, tx: {
107
- blockhash: string;
108
- txid: string;
109
- hex: string;
110
- height: number;
111
- }, vout: number, commitedHeader?: SolanaBtcStoredHeader | null, synchronizer?: RelaySynchronizer<any, SolanaTx, any>, initAta?: boolean, feeRate?: string): Promise<{
112
- txs: SolanaTx[];
113
- claimTxIndex: number;
114
- storageAcc: PublicKey;
115
- }>;
116
- getClaimFeeRate(signer: PublicKey, swapData: SolanaSwapData): Promise<string>;
117
- /**
118
- * Get the estimated solana transaction fee of the claim transaction in the worst case scenario in case where the
119
- * ATA needs to be initialized again (i.e. adding the ATA rent exempt lamports to the fee)
120
- */
121
- getClaimFee(signer: PublicKey, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
122
- /**
123
- * Get the estimated solana transaction fee of the claim transaction, without
124
- */
125
- getRawClaimFee(signer: PublicKey, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
126
- }
1
+ import { SolanaSwapModule } from "../SolanaSwapModule";
2
+ import { SolanaSwapData } from "../SolanaSwapData";
3
+ import { RelaySynchronizer } from "@atomiqlabs/base";
4
+ import { PublicKey } from "@solana/web3.js";
5
+ import { SolanaTx } from "../../chain/modules/SolanaTransactions";
6
+ import { SolanaBtcStoredHeader } from "../../btcrelay/headers/SolanaBtcStoredHeader";
7
+ import { SolanaBtcRelay } from "../../btcrelay/SolanaBtcRelay";
8
+ import { SolanaSwapProgram } from "../SolanaSwapProgram";
9
+ import { SolanaSigner } from "../../wallet/SolanaSigner";
10
+ import { SolanaChainInterface } from "../../chain/SolanaChainInterface";
11
+ export declare class SwapClaim extends SolanaSwapModule {
12
+ private static readonly CUCosts;
13
+ readonly btcRelay: SolanaBtcRelay<any>;
14
+ /**
15
+ * Claim action which uses the provided hex encoded secret for claiming the swap
16
+ *
17
+ * @param signer
18
+ * @param swapData
19
+ * @param secret
20
+ * @private
21
+ */
22
+ private Claim;
23
+ /**
24
+ * Verify and claim action required for BTC on-chain swaps verified through btc relay, adds the btc relay verify
25
+ * instruction to the 0th index in the transaction, also intentionally sets compute budget to null such that no
26
+ * compute budget instruction is added, since that takes up too much space and txs are limited to 1232 bytes
27
+ *
28
+ * @param signer
29
+ * @param swapData
30
+ * @param storeDataKey
31
+ * @param merkleProof
32
+ * @param commitedHeader
33
+ * @private
34
+ */
35
+ private VerifyAndClaim;
36
+ constructor(chainInterface: SolanaChainInterface, program: SolanaSwapProgram, btcRelay: SolanaBtcRelay<any>);
37
+ /**
38
+ * Gets the compute budget required for claiming the swap
39
+ *
40
+ * @param swapData
41
+ * @private
42
+ */
43
+ private getComputeBudget;
44
+ /**
45
+ * Gets committed header, identified by blockhash & blockheight, determines required BTC relay blockheight based on
46
+ * requiredConfirmations
47
+ * If synchronizer is passed & blockhash is not found, it produces transactions to sync up the btc relay to the
48
+ * current chain tip & adds them to the txs array
49
+ *
50
+ * @param signer
51
+ * @param txBlockheight transaction blockheight
52
+ * @param requiredConfirmations required confirmation for the swap to be claimable with that TX
53
+ * @param blockhash blockhash of the block which includes the transaction
54
+ * @param txs solana transaction array, in case we need to synchronize the btc relay ourselves the synchronization
55
+ * txns are added here
56
+ * @param synchronizer optional synchronizer to use to synchronize the btc relay in case it is not yet synchronized
57
+ * to the required blockheight
58
+ * @private
59
+ */
60
+ private getCommitedHeaderAndSynchronize;
61
+ /**
62
+ * Adds the transactions required for initialization and writing of transaction data to the data account
63
+ *
64
+ * @param signer
65
+ * @param tx transaction to be written
66
+ * @param vout vout of the transaction to use to satisfy swap conditions
67
+ * @param feeRate fee rate for the transactions
68
+ * @param txs solana transaction array, init & write transactions are added here
69
+ * @private
70
+ * @returns {Promise<PublicKey>} publicKey/address of the data account
71
+ */
72
+ private addTxsWriteTransactionData;
73
+ /**
74
+ * Checks whether we should unwrap the WSOL to SOL when claiming the swap
75
+ *
76
+ * @param signer
77
+ * @param swapData
78
+ * @private
79
+ */
80
+ private shouldUnwrap;
81
+ /**
82
+ * Creates transactions claiming the swap using a secret (for HTLC swaps)
83
+ *
84
+ * @param signer
85
+ * @param swapData swap to claim
86
+ * @param secret hex encoded secret pre-image to the HTLC hash
87
+ * @param checkExpiry whether to check if the swap is already expired (trying to claim an expired swap with a secret
88
+ * is dangerous because we might end up revealing the secret to the counterparty without being able to claim the swap)
89
+ * @param initAta whether to init the claimer's ATA if it doesn't exist
90
+ * @param feeRate fee rate to use for the transaction
91
+ * @param skipAtaCheck whether to check if ATA exists
92
+ */
93
+ txsClaimWithSecret(signer: PublicKey, swapData: SolanaSwapData, secret: string, checkExpiry?: boolean, initAta?: boolean, feeRate?: string, skipAtaCheck?: boolean): Promise<SolanaTx[]>;
94
+ /**
95
+ * Creates transaction claiming the swap using a confirmed transaction data (for BTC on-chain swaps)
96
+ *
97
+ * @param signer
98
+ * @param swapData swap to claim
99
+ * @param tx bitcoin transaction that satisfies the swap condition
100
+ * @param vout vout of the bitcoin transaction that satisfies the swap condition
101
+ * @param commitedHeader commited header data from btc relay (fetched internally if null)
102
+ * @param synchronizer optional synchronizer to use in case we need to sync up the btc relay ourselves
103
+ * @param initAta whether to initialize claimer's ATA
104
+ * @param feeRate fee rate to be used for the transactions
105
+ */
106
+ txsClaimWithTxData(signer: PublicKey | SolanaSigner, swapData: SolanaSwapData, tx: {
107
+ blockhash: string;
108
+ txid: string;
109
+ hex: string;
110
+ height: number;
111
+ }, vout: number, commitedHeader?: SolanaBtcStoredHeader | null, synchronizer?: RelaySynchronizer<any, SolanaTx, any>, initAta?: boolean, feeRate?: string): Promise<{
112
+ txs: SolanaTx[];
113
+ claimTxIndex: number;
114
+ storageAcc: PublicKey;
115
+ }>;
116
+ getClaimFeeRate(signer: PublicKey, swapData: SolanaSwapData): Promise<string>;
117
+ /**
118
+ * Get the estimated solana transaction fee of the claim transaction in the worst case scenario in case where the
119
+ * ATA needs to be initialized again (i.e. adding the ATA rent exempt lamports to the fee)
120
+ */
121
+ getClaimFee(signer: PublicKey, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
122
+ /**
123
+ * Get the estimated solana transaction fee of the claim transaction, without
124
+ */
125
+ getRawClaimFee(signer: PublicKey, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
126
+ }