@hawksightco/hawk-sdk 1.3.263 → 1.3.265

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 (181) hide show
  1. package/package.json +1 -1
  2. package/dist/src/addresses.d.ts +0 -37
  3. package/dist/src/addresses.d.ts.map +0 -1
  4. package/dist/src/addresses.js +0 -84
  5. package/dist/src/anchor.d.ts +0 -22
  6. package/dist/src/anchor.d.ts.map +0 -1
  7. package/dist/src/anchor.js +0 -121
  8. package/dist/src/classes/AltStorage.d.ts +0 -29
  9. package/dist/src/classes/AltStorage.d.ts.map +0 -1
  10. package/dist/src/classes/AltStorage.js +0 -58
  11. package/dist/src/classes/Atomicity.d.ts +0 -34
  12. package/dist/src/classes/Atomicity.d.ts.map +0 -1
  13. package/dist/src/classes/Atomicity.js +0 -110
  14. package/dist/src/classes/Client.d.ts +0 -35
  15. package/dist/src/classes/Client.d.ts.map +0 -1
  16. package/dist/src/classes/Client.js +0 -66
  17. package/dist/src/classes/CombineTransactions.d.ts +0 -11
  18. package/dist/src/classes/CombineTransactions.d.ts.map +0 -1
  19. package/dist/src/classes/CombineTransactions.js +0 -58
  20. package/dist/src/classes/CreateTxMetadata.d.ts +0 -100
  21. package/dist/src/classes/CreateTxMetadata.d.ts.map +0 -1
  22. package/dist/src/classes/CreateTxMetadata.js +0 -415
  23. package/dist/src/classes/General.d.ts +0 -87
  24. package/dist/src/classes/General.d.ts.map +0 -1
  25. package/dist/src/classes/General.js +0 -176
  26. package/dist/src/classes/GeneralUtility.d.ts +0 -79
  27. package/dist/src/classes/GeneralUtility.d.ts.map +0 -1
  28. package/dist/src/classes/GeneralUtility.js +0 -121
  29. package/dist/src/classes/HawkAPI.d.ts +0 -122
  30. package/dist/src/classes/HawkAPI.d.ts.map +0 -1
  31. package/dist/src/classes/HawkAPI.js +0 -169
  32. package/dist/src/classes/Health.d.ts +0 -29
  33. package/dist/src/classes/Health.d.ts.map +0 -1
  34. package/dist/src/classes/Health.js +0 -48
  35. package/dist/src/classes/JupiterAlts.d.ts +0 -37
  36. package/dist/src/classes/JupiterAlts.d.ts.map +0 -1
  37. package/dist/src/classes/JupiterAlts.js +0 -114
  38. package/dist/src/classes/JupiterSwap.d.ts +0 -21
  39. package/dist/src/classes/JupiterSwap.d.ts.map +0 -1
  40. package/dist/src/classes/JupiterSwap.js +0 -40
  41. package/dist/src/classes/Logging.d.ts +0 -13
  42. package/dist/src/classes/Logging.d.ts.map +0 -1
  43. package/dist/src/classes/Logging.js +0 -50
  44. package/dist/src/classes/MultiTransaction.d.ts +0 -75
  45. package/dist/src/classes/MultiTransaction.d.ts.map +0 -1
  46. package/dist/src/classes/MultiTransaction.js +0 -296
  47. package/dist/src/classes/RaydiumSDK.d.ts +0 -67
  48. package/dist/src/classes/RaydiumSDK.d.ts.map +0 -1
  49. package/dist/src/classes/RaydiumSDK.js +0 -206
  50. package/dist/src/classes/Search.d.ts +0 -100
  51. package/dist/src/classes/Search.d.ts.map +0 -1
  52. package/dist/src/classes/Search.js +0 -216
  53. package/dist/src/classes/SimpleIxGenerator.d.ts +0 -57
  54. package/dist/src/classes/SimpleIxGenerator.d.ts.map +0 -1
  55. package/dist/src/classes/SimpleIxGenerator.js +0 -62
  56. package/dist/src/classes/SimplePdaGenerator.d.ts +0 -28
  57. package/dist/src/classes/SimplePdaGenerator.d.ts.map +0 -1
  58. package/dist/src/classes/SimplePdaGenerator.js +0 -33
  59. package/dist/src/classes/Transaction.d.ts +0 -229
  60. package/dist/src/classes/Transaction.d.ts.map +0 -1
  61. package/dist/src/classes/Transaction.js +0 -643
  62. package/dist/src/classes/Transaction2.d.ts +0 -107
  63. package/dist/src/classes/Transaction2.d.ts.map +0 -1
  64. package/dist/src/classes/Transaction2.js +0 -249
  65. package/dist/src/classes/Transaction3.d.ts +0 -165
  66. package/dist/src/classes/Transaction3.d.ts.map +0 -1
  67. package/dist/src/classes/Transaction3.js +0 -416
  68. package/dist/src/classes/TransactionBatchExecute.d.ts +0 -163
  69. package/dist/src/classes/TransactionBatchExecute.d.ts.map +0 -1
  70. package/dist/src/classes/TransactionBatchExecute.js +0 -466
  71. package/dist/src/classes/TransactionBatchExecute2.d.ts +0 -99
  72. package/dist/src/classes/TransactionBatchExecute2.d.ts.map +0 -1
  73. package/dist/src/classes/TransactionBatchExecute2.js +0 -357
  74. package/dist/src/classes/Transactions.d.ts +0 -586
  75. package/dist/src/classes/Transactions.d.ts.map +0 -1
  76. package/dist/src/classes/Transactions.js +0 -7656
  77. package/dist/src/classes/TxGenerator.d.ts +0 -350
  78. package/dist/src/classes/TxGenerator.d.ts.map +0 -1
  79. package/dist/src/classes/TxGenerator.js +0 -1957
  80. package/dist/src/classes/TxGeneratorAutomations.d.ts +0 -186
  81. package/dist/src/classes/TxGeneratorAutomations.d.ts.map +0 -1
  82. package/dist/src/classes/TxGeneratorAutomations.js +0 -897
  83. package/dist/src/classes/Util.d.ts +0 -87
  84. package/dist/src/classes/Util.d.ts.map +0 -1
  85. package/dist/src/classes/Util.js +0 -148
  86. package/dist/src/classes/account-cache/AccountCache.d.ts +0 -54
  87. package/dist/src/classes/account-cache/AccountCache.d.ts.map +0 -1
  88. package/dist/src/classes/account-cache/AccountCache.js +0 -143
  89. package/dist/src/classes/account-cache/MintCache.d.ts +0 -33
  90. package/dist/src/classes/account-cache/MintCache.d.ts.map +0 -1
  91. package/dist/src/classes/account-cache/MintCache.js +0 -47
  92. package/dist/src/classes/account-cache/TokenCache.d.ts +0 -33
  93. package/dist/src/classes/account-cache/TokenCache.d.ts.map +0 -1
  94. package/dist/src/classes/account-cache/TokenCache.js +0 -47
  95. package/dist/src/errors.d.ts +0 -13
  96. package/dist/src/errors.d.ts.map +0 -1
  97. package/dist/src/errors.js +0 -96
  98. package/dist/src/functions.d.ts +0 -514
  99. package/dist/src/functions.d.ts.map +0 -1
  100. package/dist/src/functions.js +0 -1636
  101. package/dist/src/hawksight.d.ts +0 -53
  102. package/dist/src/hawksight.d.ts.map +0 -1
  103. package/dist/src/hawksight.js +0 -328
  104. package/dist/src/hsToMeteora.d.ts +0 -31
  105. package/dist/src/hsToMeteora.d.ts.map +0 -1
  106. package/dist/src/hsToMeteora.js +0 -3175
  107. package/dist/src/idl/iyf-extension-idl.d.ts +0 -14583
  108. package/dist/src/idl/iyf-extension-idl.d.ts.map +0 -1
  109. package/dist/src/idl/iyf-extension-idl.js +0 -14578
  110. package/dist/src/idl/iyf-extension-wrapper.d.ts +0 -112
  111. package/dist/src/idl/iyf-extension-wrapper.d.ts.map +0 -1
  112. package/dist/src/idl/iyf-extension-wrapper.js +0 -2
  113. package/dist/src/idl/iyf-main-idl.d.ts +0 -11329
  114. package/dist/src/idl/iyf-main-idl.d.ts.map +0 -1
  115. package/dist/src/idl/iyf-main-idl.js +0 -11324
  116. package/dist/src/idl/iyf-main-wrapper.d.ts +0 -112
  117. package/dist/src/idl/iyf-main-wrapper.d.ts.map +0 -1
  118. package/dist/src/idl/iyf-main-wrapper.js +0 -2
  119. package/dist/src/idl/jupiter-idl.d.ts +0 -3063
  120. package/dist/src/idl/jupiter-idl.d.ts.map +0 -1
  121. package/dist/src/idl/jupiter-idl.js +0 -3061
  122. package/dist/src/idl/meteora-idl.d.ts +0 -7371
  123. package/dist/src/idl/meteora-idl.d.ts.map +0 -1
  124. package/dist/src/idl/meteora-idl.js +0 -7372
  125. package/dist/src/idl/orca-idl.d.ts +0 -3833
  126. package/dist/src/idl/orca-idl.d.ts.map +0 -1
  127. package/dist/src/idl/orca-idl.js +0 -3834
  128. package/dist/src/idl/raydium-idl.d.ts +0 -3054
  129. package/dist/src/idl/raydium-idl.d.ts.map +0 -1
  130. package/dist/src/idl/raydium-idl.js +0 -3055
  131. package/dist/src/index.d.ts +0 -9
  132. package/dist/src/index.d.ts.map +0 -1
  133. package/dist/src/index.js +0 -31
  134. package/dist/src/ixGenerator/IyfExtensionIxGenerator.d.ts +0 -126
  135. package/dist/src/ixGenerator/IyfExtensionIxGenerator.d.ts.map +0 -1
  136. package/dist/src/ixGenerator/IyfExtensionIxGenerator.js +0 -467
  137. package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts +0 -330
  138. package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts.map +0 -1
  139. package/dist/src/ixGenerator/IyfMainIxGenerator.js +0 -1239
  140. package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts +0 -685
  141. package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts.map +0 -1
  142. package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.js +0 -3005
  143. package/dist/src/ixGenerator/OrcaIxGenerator.d.ts +0 -119
  144. package/dist/src/ixGenerator/OrcaIxGenerator.d.ts.map +0 -1
  145. package/dist/src/ixGenerator/OrcaIxGenerator.js +0 -438
  146. package/dist/src/ixGenerator/RaydiumIxGenerator.d.ts +0 -99
  147. package/dist/src/ixGenerator/RaydiumIxGenerator.d.ts.map +0 -1
  148. package/dist/src/ixGenerator/RaydiumIxGenerator.js +0 -558
  149. package/dist/src/ixGenerator/UtilIxGenerator.d.ts +0 -20
  150. package/dist/src/ixGenerator/UtilIxGenerator.d.ts.map +0 -1
  151. package/dist/src/ixGenerator/UtilIxGenerator.js +0 -25
  152. package/dist/src/meteora/index.d.ts +0 -2
  153. package/dist/src/meteora/index.d.ts.map +0 -1
  154. package/dist/src/meteora/index.js +0 -17
  155. package/dist/src/meteora/liquidityStrategy.d.ts +0 -408
  156. package/dist/src/meteora/liquidityStrategy.d.ts.map +0 -1
  157. package/dist/src/meteora/liquidityStrategy.js +0 -1325
  158. package/dist/src/meteora.d.ts +0 -669
  159. package/dist/src/meteora.d.ts.map +0 -1
  160. package/dist/src/meteora.js +0 -1932
  161. package/dist/src/orca.d.ts +0 -57
  162. package/dist/src/orca.d.ts.map +0 -1
  163. package/dist/src/orca.js +0 -123
  164. package/dist/src/pdaGenerator/HawksightPdaGenerator.d.ts +0 -29
  165. package/dist/src/pdaGenerator/HawksightPdaGenerator.d.ts.map +0 -1
  166. package/dist/src/pdaGenerator/HawksightPdaGenerator.js +0 -75
  167. package/dist/src/pdaGenerator/MeteoraPdaGenerator.d.ts +0 -76
  168. package/dist/src/pdaGenerator/MeteoraPdaGenerator.d.ts.map +0 -1
  169. package/dist/src/pdaGenerator/MeteoraPdaGenerator.js +0 -166
  170. package/dist/src/pdaGenerator/OrcaPdaGenerator.d.ts +0 -23
  171. package/dist/src/pdaGenerator/OrcaPdaGenerator.d.ts.map +0 -1
  172. package/dist/src/pdaGenerator/OrcaPdaGenerator.js +0 -68
  173. package/dist/src/pdaGenerator/RaydiumPdaGenerator.d.ts +0 -49
  174. package/dist/src/pdaGenerator/RaydiumPdaGenerator.d.ts.map +0 -1
  175. package/dist/src/pdaGenerator/RaydiumPdaGenerator.js +0 -114
  176. package/dist/src/pdaGenerator/UtilPdaGenerator.d.ts +0 -8
  177. package/dist/src/pdaGenerator/UtilPdaGenerator.d.ts.map +0 -1
  178. package/dist/src/pdaGenerator/UtilPdaGenerator.js +0 -51
  179. package/dist/src/types.d.ts +0 -1100
  180. package/dist/src/types.d.ts.map +0 -1
  181. package/dist/src/types.js +0 -95
@@ -1,1957 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- var __importDefault = (this && this.__importDefault) || function (mod) {
45
- return (mod && mod.__esModule) ? mod : { "default": mod };
46
- };
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.TxGenerator = void 0;
49
- const web3 = __importStar(require("@solana/web3.js"));
50
- const types_1 = require("../types");
51
- const functions_1 = require("../functions");
52
- const anchor_1 = require("../anchor");
53
- const Transactions_1 = require("./Transactions");
54
- const bn_js_1 = __importDefault(require("bn.js"));
55
- const Logging_1 = require("./Logging");
56
- const SimpleIxGenerator_1 = require("./SimpleIxGenerator");
57
- const SimplePdaGenerator_1 = require("./SimplePdaGenerator");
58
- /**
59
- * The `TxGenerator` class encapsulates methods to generate transactions with various trading operations
60
- * on decentralized market making platforms like Meteora and Orca within the Solana ecosystem. It allows
61
- * setting custom transaction priority and fees to manage transaction processing speed and cost.
62
- */
63
- class TxGenerator {
64
- /**
65
- * Initializes a new instance of the TxGenerator class with a specified client.
66
- *
67
- * @param client An instance of Client used to interact with various APIs for transaction generation.
68
- */
69
- constructor(client, generalUtility) {
70
- this.client = client;
71
- this.generalUtility = generalUtility;
72
- this.ix = new SimpleIxGenerator_1.SimpleIxGenerator();
73
- this.pda = new SimplePdaGenerator_1.SimplePdaGenerator();
74
- }
75
- /**
76
- * Claim token from STA. Fallbacks to ATA if STA is not yet initialized.
77
- * @param connection A Solana web3 connection for interacting with the blockchain.
78
- * @param payer The public key of the payer for transaction fees.
79
- * @param params Parameters required.
80
- * Note: Subject to refactor. Dirty implementation.
81
- *
82
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
83
- */
84
- claimTokenFromSta(connection, payer, params) {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- // Initialize anchor
87
- anchor_1.Anchor.initialize(connection);
88
- try {
89
- const result = yield Transactions_1.txgen.claimTokenFromSta({
90
- connection,
91
- params,
92
- fetch: undefined,
93
- });
94
- return {
95
- status: 200,
96
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
97
- };
98
- }
99
- catch (e) {
100
- if (e instanceof Error) {
101
- return {
102
- status: 400,
103
- data: {
104
- code: 'custom',
105
- message: e.message,
106
- path: [],
107
- },
108
- };
109
- }
110
- return {
111
- status: 400,
112
- data: {
113
- code: 'custom',
114
- message: e,
115
- path: [],
116
- },
117
- };
118
- }
119
- });
120
- }
121
- /**
122
- * Claim token from ATA.
123
- * @param connection A Solana web3 connection for interacting with the blockchain.
124
- * @param payer The public key of the payer for transaction fees.
125
- * @param params Parameters required.
126
- *
127
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
128
- */
129
- claimTokenFromAta(connection, payer, params) {
130
- return __awaiter(this, void 0, void 0, function* () {
131
- // Initialize anchor
132
- anchor_1.Anchor.initialize(connection);
133
- try {
134
- const result = yield Transactions_1.txgen.claimTokenFromAta({
135
- connection,
136
- params,
137
- fetch: undefined,
138
- });
139
- return {
140
- status: 200,
141
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
142
- };
143
- }
144
- catch (e) {
145
- if (e instanceof Error) {
146
- return {
147
- status: 400,
148
- data: {
149
- code: 'custom',
150
- message: e.message,
151
- path: [],
152
- },
153
- };
154
- }
155
- return {
156
- status: 400,
157
- data: {
158
- code: 'custom',
159
- message: e,
160
- path: [],
161
- },
162
- };
163
- }
164
- });
165
- }
166
- /**
167
- * Claim tokens from STA.
168
- * @param connection A Solana web3 connection for interacting with the blockchain.
169
- * @param payer The public key of the payer for transaction fees.
170
- * @param params Parameters required.
171
- * Note: Subject to refactor. Dirty implementation.
172
- *
173
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
174
- */
175
- claimTokensFromSta(connection, payer, params) {
176
- return __awaiter(this, void 0, void 0, function* () {
177
- // Initialize anchor
178
- anchor_1.Anchor.initialize(connection);
179
- try {
180
- const result = yield Transactions_1.txgen.claimTokensFromSta({
181
- connection,
182
- params,
183
- fetch: undefined,
184
- });
185
- return {
186
- status: 200,
187
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
188
- };
189
- }
190
- catch (e) {
191
- if (e instanceof Error) {
192
- return {
193
- status: 400,
194
- data: {
195
- code: 'custom',
196
- message: e.message,
197
- path: [],
198
- },
199
- };
200
- }
201
- return {
202
- status: 400,
203
- data: {
204
- code: 'custom',
205
- message: e,
206
- path: [],
207
- },
208
- };
209
- }
210
- });
211
- }
212
- /**
213
- * Creates instructions to initialize storage token accounts
214
- *
215
- * @param connection A Solana web3 connection for interacting with the blockchain.
216
- * @param payer The public key of the payer for transaction fees.
217
- * @param params Parameters required.
218
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
219
- */
220
- initializeStorageTokenAccounts(connection, payer, params) {
221
- return __awaiter(this, void 0, void 0, function* () {
222
- // Initialize anchor
223
- anchor_1.Anchor.initialize(connection);
224
- try {
225
- const result = yield Transactions_1.txgen.initializeStorageTokenAccounts({
226
- connection,
227
- params,
228
- fetch: undefined,
229
- });
230
- return {
231
- status: 200,
232
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
233
- };
234
- }
235
- catch (e) {
236
- if (e instanceof Error) {
237
- return {
238
- status: 400,
239
- data: {
240
- code: 'custom',
241
- message: e.message,
242
- path: [],
243
- },
244
- };
245
- }
246
- return {
247
- status: 400,
248
- data: {
249
- code: 'custom',
250
- message: e,
251
- path: [],
252
- },
253
- };
254
- }
255
- });
256
- }
257
- createLimitToken(connection, params) {
258
- return __awaiter(this, void 0, void 0, function* () {
259
- // Initialize anchor
260
- anchor_1.Anchor.initialize(connection);
261
- // Generate instructions
262
- const ixs = [];
263
- // Create limit token account
264
- ixs.push(yield this.ix.iyfMain.createLimitToken({
265
- connection,
266
- userWallet: params.userWallet,
267
- payer: params.payer,
268
- mint: params.mint,
269
- }));
270
- // Return executable instructions
271
- return yield (0, functions_1.legacyTxMetadata)({
272
- connection,
273
- generalUtility: this.generalUtility,
274
- payer: params.payer,
275
- description: 'Create Limit Token',
276
- ixs,
277
- });
278
- });
279
- }
280
- closeLimitToken(connection, params) {
281
- return __awaiter(this, void 0, void 0, function* () {
282
- // Initialize anchor
283
- anchor_1.Anchor.initialize(connection);
284
- // Generate instructions
285
- const ixs = [];
286
- // Close limit token account
287
- ixs.push(yield this.ix.iyfMain.closeLimitToken({
288
- connection,
289
- userWallet: params.userWallet,
290
- mint: params.mint,
291
- }));
292
- // Return executable instructions
293
- return yield (0, functions_1.legacyTxMetadata)({
294
- connection,
295
- generalUtility: this.generalUtility,
296
- payer: params.userWallet,
297
- description: 'Close Limit Token',
298
- ixs,
299
- });
300
- });
301
- }
302
- /**
303
- * Create executable instructions to initialize and deposit to limit token accounts.
304
- *
305
- * @param connection The Solana web3 connection object for blockchain interactions.
306
- * @param params Parameters required
307
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
308
- */
309
- depositToLta(connection, params) {
310
- return __awaiter(this, void 0, void 0, function* () {
311
- // Initialize anchor
312
- anchor_1.Anchor.initialize(connection);
313
- // Instructions
314
- const ixs = [];
315
- // Idempotently create limit token accounts (generate instruction)
316
- for (const deposit of params.deposit) {
317
- ixs.push(yield this.ix.iyfMain.createLimitToken({
318
- connection,
319
- userWallet: params.userWallet,
320
- payer: params.userWallet,
321
- mint: deposit.mint,
322
- }));
323
- }
324
- // Deposit to limit token accounts
325
- ixs.push(yield this.ix.iyfMain.depositMultipleTokenV2({
326
- connection,
327
- payer: params.userWallet,
328
- deposit: params.deposit,
329
- pdaTokenType: types_1.TokenType.LTA,
330
- }));
331
- // Return executable instructions
332
- return yield (0, functions_1.legacyTxMetadata)({
333
- connection,
334
- generalUtility: this.generalUtility,
335
- payer: params.userWallet,
336
- description: 'Deposit to limit token accounts',
337
- ixs,
338
- });
339
- });
340
- }
341
- /**
342
- * Creates executable instruction to withdraw from limit token accounts.
343
- *
344
- * @param connection The Solana web3 connection object for blockchain interactions.
345
- * @param params Parameters required
346
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
347
- */
348
- withdrawFromLta(connection, params) {
349
- return __awaiter(this, void 0, void 0, function* () {
350
- // Initialize anchor
351
- anchor_1.Anchor.initialize(connection);
352
- // Instructions
353
- const ixs = [];
354
- // Withdraw from limit token accounts
355
- ixs.push(yield this.ix.iyfMain.withdrawMultipleTokenV2({
356
- connection,
357
- payer: params.userWallet,
358
- withdraw: params.withdraw,
359
- pdaTokenType: types_1.TokenType.LTA,
360
- hasAmount: params.hasAmount,
361
- }));
362
- // Return executable instructions
363
- return yield (0, functions_1.legacyTxMetadata)({
364
- connection,
365
- generalUtility: this.generalUtility,
366
- payer: params.userWallet,
367
- description: 'Withdraw from limit token accounts',
368
- ixs,
369
- });
370
- });
371
- }
372
- /**
373
- * Creates meteora instruction that creates new position and deposit.
374
- *
375
- * @deprecated Use meteoraCreatePositionAndDepositToLargePosition instead
376
- *
377
- * @param connection The Solana web3 connection object for blockchain interactions.
378
- * @param payer The public key of the payer for transaction fees.
379
- * @param params Parameters required
380
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
381
- */
382
- meteoraCreatePositionAndDeposit(connection, payer, params) {
383
- return __awaiter(this, void 0, void 0, function* () {
384
- // Initialize anchor
385
- anchor_1.Anchor.initialize(connection);
386
- try {
387
- const result = yield Transactions_1.txgen.meteoraCreatePositionAndDeposit({
388
- connection,
389
- params: {
390
- position: new web3.PublicKey(params.position),
391
- pool: new web3.PublicKey(params.pool),
392
- userWallet: new web3.PublicKey(params.userWallet),
393
- totalXAmount: new bn_js_1.default(params.totalXAmount),
394
- totalYAmount: new bn_js_1.default(params.totalYAmount),
395
- binRange: {
396
- lowerRange: params.lowerBinRange,
397
- upperRange: params.upperBinRange,
398
- },
399
- slippage: params.slippage,
400
- distribution: params.distribution,
401
- skipInputTokenCheck: true,
402
- },
403
- fetch: undefined,
404
- });
405
- return {
406
- status: 200,
407
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
408
- };
409
- }
410
- catch (e) {
411
- if (e instanceof Error) {
412
- return {
413
- status: 400,
414
- data: {
415
- code: 'custom',
416
- message: e.message,
417
- path: [],
418
- },
419
- };
420
- }
421
- return {
422
- status: 400,
423
- data: {
424
- code: 'custom',
425
- message: e,
426
- path: [],
427
- },
428
- };
429
- }
430
- });
431
- }
432
- /**
433
- * Creates meteora instruction that creates new position and deposit.
434
- *
435
- * @param connection The Solana web3 connection object for blockchain interactions.
436
- * @param payer The public key of the payer for transaction fees.
437
- * @param params Parameters required
438
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
439
- */
440
- meteoraCreatePositionAndDepositPda(connection, payer, params) {
441
- return __awaiter(this, void 0, void 0, function* () {
442
- // Initialize anchor
443
- anchor_1.Anchor.initialize(connection);
444
- try {
445
- const result = yield Transactions_1.txgen.meteoraCreatePositionAndDepositPda({
446
- connection,
447
- params: {
448
- position: new web3.PublicKey(params.position),
449
- pool: new web3.PublicKey(params.pool),
450
- userWallet: new web3.PublicKey(params.userWallet),
451
- binRange: {
452
- lowerRange: params.binRange.lowerRange,
453
- upperRange: params.binRange.upperRange,
454
- },
455
- slippage: params.slippage,
456
- distribution: params.distribution,
457
- skipInputTokenCheck: true,
458
- },
459
- fetch: undefined,
460
- });
461
- return {
462
- status: 200,
463
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
464
- };
465
- }
466
- catch (e) {
467
- if (e instanceof Error) {
468
- return {
469
- status: 400,
470
- data: {
471
- code: 'custom',
472
- message: e.message,
473
- path: [],
474
- },
475
- };
476
- }
477
- return {
478
- status: 400,
479
- data: {
480
- code: 'custom',
481
- message: e,
482
- path: [],
483
- },
484
- };
485
- }
486
- });
487
- }
488
- /**
489
- * Creates meteora instruction that deposits to position.
490
- *
491
- * @deprecated Use meteoraDepositToLargePosition instead
492
- *
493
- * @param connection The Solana web3 connection object for blockchain interactions.
494
- * @param payer The public key of the payer for transaction fees.
495
- * @param params Parameters required
496
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
497
- */
498
- meteoraDeposit(connection, payer, params) {
499
- return __awaiter(this, void 0, void 0, function* () {
500
- var _a;
501
- // Initialize anchor
502
- anchor_1.Anchor.initialize(connection);
503
- try {
504
- const result = yield Transactions_1.txgen.meteoraDeposit({
505
- connection,
506
- params: {
507
- position: new web3.PublicKey(params.position),
508
- userWallet: new web3.PublicKey(params.userWallet),
509
- totalXAmount: new bn_js_1.default(params.totalXAmount),
510
- totalYAmount: new bn_js_1.default(params.totalYAmount),
511
- distribution: params.distribution,
512
- slippage: params.slippage,
513
- skipInputTokenCheck: params.skipInputTokenCheck,
514
- fastGeneration: params.fastGeneration
515
- ? Object.assign(Object.assign({}, params.fastGeneration), { pool: new web3.PublicKey(params.fastGeneration.pool) }) : undefined,
516
- pdaTokenType: (_a = params.pdaTokenType) !== null && _a !== void 0 ? _a : types_1.TokenType.ATA,
517
- },
518
- fetch: undefined,
519
- });
520
- return {
521
- status: 200,
522
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
523
- };
524
- }
525
- catch (e) {
526
- if (e instanceof Error) {
527
- return {
528
- status: 400,
529
- data: {
530
- code: 'custom',
531
- message: e.message,
532
- path: [],
533
- },
534
- };
535
- }
536
- return {
537
- status: 400,
538
- data: {
539
- code: 'custom',
540
- message: e,
541
- path: [],
542
- },
543
- };
544
- }
545
- });
546
- }
547
- /**
548
- * Creates meteora instruction withdraws from a position.
549
- *
550
- * @deprecated Use meteoraWithdrawLargerPosition instead
551
- *
552
- * @param connection The Solana web3 connection object for blockchain interactions.
553
- * @param payer The public key of the payer for transaction fees.
554
- * @param params Parameters required
555
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
556
- */
557
- meteoraWithdraw(connection, payer, params) {
558
- return __awaiter(this, void 0, void 0, function* () {
559
- var _a;
560
- // Initialize anchor
561
- anchor_1.Anchor.initialize(connection);
562
- try {
563
- const result = yield Transactions_1.txgen.meteoraWithdraw({
564
- connection,
565
- params: {
566
- position: new web3.PublicKey(params.position),
567
- userWallet: new web3.PublicKey(params.userWallet),
568
- amountBps: new bn_js_1.default(params.amountBps),
569
- shouldClaimAndClose: params.shouldClaimAndClose,
570
- fastGeneration: params.fastGeneration
571
- ? {
572
- pool: new web3.PublicKey(params.fastGeneration.pool),
573
- lowerBinId: params.fastGeneration.lowerBinId,
574
- upperBinId: params.fastGeneration.upperBinId,
575
- }
576
- : undefined,
577
- pdaTokenType: (_a = params.pdaTokenType) !== null && _a !== void 0 ? _a : types_1.TokenType.ATA,
578
- },
579
- fetch: undefined,
580
- });
581
- return {
582
- status: 200,
583
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
584
- };
585
- }
586
- catch (e) {
587
- if (e instanceof Error) {
588
- return {
589
- status: 400,
590
- data: {
591
- code: 'custom',
592
- message: e.message,
593
- path: [],
594
- },
595
- };
596
- }
597
- return {
598
- status: 400,
599
- data: {
600
- code: 'custom',
601
- message: e,
602
- path: [],
603
- },
604
- };
605
- }
606
- });
607
- }
608
- /**
609
- * Creates meteora instruction withdraws from a position.
610
- *
611
- * @param connection The Solana web3 connection object for blockchain interactions.
612
- * @param payer The public key of the payer for transaction fees.
613
- * @param params Parameters required
614
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
615
- */
616
- meteoraWithdrawPda(connection, payer, params, pdaTokenType) {
617
- return __awaiter(this, void 0, void 0, function* () {
618
- // Initialize anchor
619
- anchor_1.Anchor.initialize(connection);
620
- try {
621
- const result = yield Transactions_1.txgen.meteoraWithdrawPda({
622
- connection,
623
- params: {
624
- position: new web3.PublicKey(params.position),
625
- userWallet: new web3.PublicKey(params.userWallet),
626
- amountBps: new bn_js_1.default(params.amountBps),
627
- shouldClaimAndClose: params.shouldClaimAndClose,
628
- fastGeneration: params.fastGeneration
629
- ? {
630
- pool: new web3.PublicKey(params.fastGeneration.pool),
631
- lowerBinId: params.fastGeneration.lowerBinId,
632
- upperBinId: params.fastGeneration.upperBinId,
633
- }
634
- : undefined,
635
- useAta: params.useAta,
636
- pdaTokenType: pdaTokenType !== null && pdaTokenType !== void 0 ? pdaTokenType : types_1.TokenType.ATA,
637
- },
638
- fetch: undefined,
639
- });
640
- return {
641
- status: 200,
642
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
643
- };
644
- }
645
- catch (e) {
646
- if (e instanceof Error) {
647
- return {
648
- status: 400,
649
- data: {
650
- code: 'custom',
651
- message: e.message,
652
- path: [],
653
- },
654
- };
655
- }
656
- return {
657
- status: 400,
658
- data: {
659
- code: 'custom',
660
- message: e,
661
- path: [],
662
- },
663
- };
664
- }
665
- });
666
- }
667
- /**
668
- * Withdraw liquidity from a large Meteora DLMM position (up to 1400 bins).
669
- * For ≤149 bins: single tx. For ≥150 bins: multi-tx with chunked withdrawals.
670
- */
671
- meteoraWithdrawLargePosition(connection, payer, params) {
672
- return __awaiter(this, void 0, void 0, function* () {
673
- var _a;
674
- // Initialize anchor
675
- anchor_1.Anchor.initialize(connection);
676
- try {
677
- const results = yield Transactions_1.txgen.meteoraWithdrawLargePosition({
678
- connection,
679
- params: {
680
- position: new web3.PublicKey(params.position),
681
- userWallet: new web3.PublicKey(params.userWallet),
682
- amountBps: new bn_js_1.default(params.amountBps),
683
- shouldClaimAndClose: params.shouldClaimAndClose,
684
- fastGeneration: params.fastGeneration
685
- ? {
686
- pool: new web3.PublicKey(params.fastGeneration.pool),
687
- lowerBinId: params.fastGeneration.lowerBinId,
688
- upperBinId: params.fastGeneration.upperBinId,
689
- }
690
- : undefined,
691
- useAta: params.useAta,
692
- pdaTokenType: (_a = params.pdaTokenType) !== null && _a !== void 0 ? _a : types_1.TokenType.ATA,
693
- },
694
- });
695
- const txMetadatas = [];
696
- for (const result of results) {
697
- const txMeta = yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result);
698
- txMetadatas.push(txMeta);
699
- }
700
- return {
701
- status: 200,
702
- data: txMetadatas,
703
- };
704
- }
705
- catch (e) {
706
- if (e instanceof Error) {
707
- return {
708
- status: 400,
709
- data: {
710
- code: 'custom',
711
- message: e.message,
712
- path: [],
713
- },
714
- };
715
- }
716
- return {
717
- status: 400,
718
- data: {
719
- code: 'custom',
720
- message: e,
721
- path: [],
722
- },
723
- };
724
- }
725
- });
726
- }
727
- /**
728
- * Creates meteora instruction that claims fees and rewards.
729
- *
730
- * @param connection The Solana web3 connection object for blockchain interactions.
731
- * @param payer The public key of the payer for transaction fees.
732
- * @param params Parameters required
733
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
734
- */
735
- meteoraClaim(connection, payer, params) {
736
- return __awaiter(this, void 0, void 0, function* () {
737
- // Initialize anchor
738
- anchor_1.Anchor.initialize(connection);
739
- try {
740
- const startTime = new Date().getTime() / 1000;
741
- (0, Logging_1.Log)('meteoraClaim: Benchmarking txgen.meteoraClaim');
742
- const result = yield Transactions_1.txgen.meteoraClaim({
743
- connection,
744
- params: {
745
- position: new web3.PublicKey(params.position),
746
- userWallet: new web3.PublicKey(params.userWallet),
747
- fastGeneration: params.fastGeneration
748
- ? {
749
- pool: new web3.PublicKey(params.fastGeneration.pool),
750
- }
751
- : undefined,
752
- pdaTokenType: params.pdaTokenType,
753
- },
754
- fetch: undefined,
755
- });
756
- (0, Logging_1.Log)(`meteoraClaim: await txgen.meteoraClaim elapsed time: ${new Date().getTime() / 1000 - startTime}`);
757
- return {
758
- status: 200,
759
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
760
- };
761
- }
762
- catch (e) {
763
- if (e instanceof Error) {
764
- return {
765
- status: 400,
766
- data: {
767
- code: 'custom',
768
- message: `${e.message} at ${e.stack}`,
769
- path: [],
770
- },
771
- };
772
- }
773
- return {
774
- status: 400,
775
- data: {
776
- code: 'custom',
777
- message: e,
778
- path: [],
779
- },
780
- };
781
- }
782
- });
783
- }
784
- /**
785
- * Claim fees and rewards from a large Meteora DLMM position (up to 1400 bins).
786
- *
787
- * For ≤149 bins, delegates to single-TX meteoraClaim.
788
- * For ≥150 bins, chunks the bin range into ≤149-bin pieces, returning multiple TXs.
789
- *
790
- * @param connection The Solana web3 connection object for blockchain interactions.
791
- * @param payer The public key of the payer for transaction fees.
792
- * @param params Parameters required
793
- * @returns A ResponseWithStatus containing an array of TransactionMetadata.
794
- */
795
- meteoraClaimLargePosition(connection, payer, params) {
796
- return __awaiter(this, void 0, void 0, function* () {
797
- var _a;
798
- // Initialize anchor
799
- anchor_1.Anchor.initialize(connection);
800
- try {
801
- const results = yield Transactions_1.txgen.meteoraClaimLargePosition({
802
- connection,
803
- params: {
804
- position: new web3.PublicKey(params.position),
805
- userWallet: new web3.PublicKey(params.userWallet),
806
- fastGeneration: params.fastGeneration
807
- ? {
808
- pool: new web3.PublicKey(params.fastGeneration.pool),
809
- }
810
- : undefined,
811
- pdaTokenType: params.pdaTokenType,
812
- },
813
- });
814
- const txMetadatas = [];
815
- for (const result of results) {
816
- const txMeta = yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result);
817
- txMetadatas.push(txMeta);
818
- }
819
- return {
820
- status: 200,
821
- data: txMetadatas,
822
- };
823
- }
824
- catch (e) {
825
- if (e instanceof Error) {
826
- return {
827
- status: 400,
828
- data: {
829
- code: 'custom',
830
- message: e.message,
831
- stack: (_a = e.stack) === null || _a === void 0 ? void 0 : _a.split('\n'),
832
- path: [],
833
- },
834
- };
835
- }
836
- return {
837
- status: 400,
838
- data: {
839
- code: 'custom',
840
- message: e,
841
- path: [],
842
- },
843
- };
844
- }
845
- });
846
- }
847
- /**
848
- * Creates meteora instruction that claims fees and rewards.
849
- *
850
- * @param connection The Solana web3 connection object for blockchain interactions.
851
- * @param payer The public key of the payer for transaction fees.
852
- * @param params Parameters required
853
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
854
- */
855
- meteoraClaimAll(connection, payer, params) {
856
- return __awaiter(this, void 0, void 0, function* () {
857
- // Initialize anchor
858
- anchor_1.Anchor.initialize(connection);
859
- const startTime = new Date().getTime() / 1000;
860
- (0, Logging_1.Log)('meteoraClaimAll: Benchmarking txgen.meteoraClaimAll');
861
- const result = yield Transactions_1.txgen.meteoraClaimAll({
862
- connection,
863
- params,
864
- fetch: undefined,
865
- }, new web3.PublicKey(payer), this.generalUtility);
866
- (0, Logging_1.Log)(`meteoraClaim: await txgen.meteoraClaimAll elapsed time: ${new Date().getTime() / 1000 - startTime}`);
867
- return result;
868
- });
869
- }
870
- /**
871
- * Creates meteora instruction that closes position.
872
- *
873
- * @param connection The Solana web3 connection object for blockchain interactions.
874
- * @param payer The public key of the payer for transaction fees.
875
- * @param params Parameters required
876
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
877
- */
878
- meteoraClosePosition(connection, payer, params) {
879
- return __awaiter(this, void 0, void 0, function* () {
880
- // Initialize anchor
881
- anchor_1.Anchor.initialize(connection);
882
- try {
883
- const startTime = new Date().getTime() / 1000;
884
- const result = yield Transactions_1.txgen.meteoraClosePosition({
885
- connection,
886
- params: {
887
- position: new web3.PublicKey(params.position),
888
- userWallet: new web3.PublicKey(params.userWallet),
889
- },
890
- fetch: undefined,
891
- });
892
- return {
893
- status: 200,
894
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
895
- };
896
- }
897
- catch (e) {
898
- if (e instanceof Error) {
899
- return {
900
- status: 400,
901
- data: {
902
- code: 'custom',
903
- message: e.message,
904
- path: [],
905
- },
906
- };
907
- }
908
- return {
909
- status: 400,
910
- data: {
911
- code: 'custom',
912
- message: e,
913
- path: [],
914
- },
915
- };
916
- }
917
- });
918
- }
919
- /**
920
- * Creates meteora instruction that initializes bin arrays (via hawkfi program -- main iyf)
921
- *
922
- * @param connection The Solana web3 connection object for blockchain interactions.
923
- * @param payer The public key of the payer for transaction fees.
924
- * @param params Parameters required
925
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
926
- */
927
- meteoraInitializeBinArrays(connection, payer, params) {
928
- return __awaiter(this, void 0, void 0, function* () {
929
- // Initialize anchor
930
- anchor_1.Anchor.initialize(connection);
931
- try {
932
- const result = yield Transactions_1.txgen.meteoraInitializeBinArrays({
933
- connection,
934
- params: {
935
- pool: new web3.PublicKey(params.pool),
936
- userWallet: new web3.PublicKey(params.userWallet),
937
- minBinId: params.minBinId,
938
- maxBinId: params.maxBinId,
939
- },
940
- fetch: undefined,
941
- });
942
- return {
943
- status: 200,
944
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
945
- };
946
- }
947
- catch (e) {
948
- if (e instanceof Error) {
949
- return {
950
- status: 400,
951
- data: {
952
- code: 'custom',
953
- message: e.message,
954
- path: [],
955
- },
956
- };
957
- }
958
- return {
959
- status: 400,
960
- data: {
961
- code: 'custom',
962
- message: e,
963
- path: [],
964
- },
965
- };
966
- }
967
- });
968
- }
969
- /**
970
- * Creates meteora instruction that initializes bin arrays
971
- *
972
- * @param connection The Solana web3 connection object for blockchain interactions.
973
- * @param payer The public key of the payer for transaction fees.
974
- * @param params Parameters required
975
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
976
- */
977
- meteoraInitializeBinArrays2(connection, payer, params) {
978
- return __awaiter(this, void 0, void 0, function* () {
979
- // Initialize anchor
980
- anchor_1.Anchor.initialize(connection);
981
- try {
982
- const result = yield Transactions_1.txgen.meteoraInitializeBinArrays2({
983
- connection,
984
- params,
985
- fetch: undefined,
986
- });
987
- return {
988
- status: 200,
989
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
990
- };
991
- }
992
- catch (e) {
993
- if (e instanceof Error) {
994
- return {
995
- status: 400,
996
- data: {
997
- code: 'custom',
998
- message: e.message,
999
- path: [],
1000
- },
1001
- };
1002
- }
1003
- return {
1004
- status: 400,
1005
- data: {
1006
- code: 'custom',
1007
- message: e,
1008
- path: [],
1009
- },
1010
- };
1011
- }
1012
- });
1013
- }
1014
- meteoraCreatePoolAndPosition(connection, payer, params) {
1015
- return __awaiter(this, void 0, void 0, function* () {
1016
- // Initialize anchor
1017
- anchor_1.Anchor.initialize(connection);
1018
- try {
1019
- const result = yield Transactions_1.txgen.meteoraCreatePoolAndPosition({
1020
- connection,
1021
- params,
1022
- fetch: undefined,
1023
- });
1024
- return {
1025
- status: 200,
1026
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1027
- };
1028
- }
1029
- catch (e) {
1030
- if (e instanceof Error) {
1031
- return {
1032
- status: 400,
1033
- data: {
1034
- code: 'custom',
1035
- message: e.message,
1036
- path: [],
1037
- },
1038
- };
1039
- }
1040
- return {
1041
- status: 400,
1042
- data: {
1043
- code: 'custom',
1044
- message: e,
1045
- path: [],
1046
- },
1047
- };
1048
- }
1049
- });
1050
- }
1051
- /**
1052
- * Creates meteora instruction that initializes a large position.
1053
- * Supports up to 1400 bins, splitting across multiple transactions if needed.
1054
- *
1055
- * @param connection - Solana connection
1056
- * @param payer - Public key of the payer for transaction fees.
1057
- * @param params - Parameters required
1058
- * @returns A ResponseWithStatus containing an array of TransactionMetadata.
1059
- */
1060
- meteoraInitializeLargePosition(connection, payer, params) {
1061
- return __awaiter(this, void 0, void 0, function* () {
1062
- // Initialize anchor
1063
- anchor_1.Anchor.initialize(connection);
1064
- try {
1065
- const results = yield Transactions_1.txgen.meteoraInitializeLargePosition({
1066
- connection,
1067
- params,
1068
- fetch: undefined,
1069
- });
1070
- const txMetadatas = [];
1071
- for (const result of results) {
1072
- const txMeta = yield (0, functions_1.createTxMetadataWithActions)(this.generalUtility, connection, payer, result);
1073
- txMetadatas.push(txMeta);
1074
- }
1075
- return {
1076
- status: 200,
1077
- data: txMetadatas,
1078
- };
1079
- }
1080
- catch (e) {
1081
- if (e instanceof Error) {
1082
- return {
1083
- status: 400,
1084
- data: {
1085
- code: 'custom',
1086
- message: e.message,
1087
- path: [],
1088
- },
1089
- };
1090
- }
1091
- return {
1092
- status: 400,
1093
- data: {
1094
- code: 'custom',
1095
- message: e,
1096
- path: [],
1097
- },
1098
- };
1099
- }
1100
- });
1101
- }
1102
- /**
1103
- * Deposit liquidity to a large Meteora DLMM position.
1104
- * Generates a single rebalanceLiquidity instruction for the entire position range.
1105
- *
1106
- * Uses rebalance_liquidity to chunk the deposit into multiple transactions.
1107
- * Author note: Do not use yet. No infra support yet for automations.
1108
- *
1109
- * @param connection The Solana web3 connection object for blockchain interactions.
1110
- * @param payer The public key of the payer for transaction fees.
1111
- * @param params MeteoraDeposit parameters
1112
- * @returns A ResponseWithStatus containing an array of TransactionMetadata.
1113
- */
1114
- meteoraDepositToLargePosition(connection, payer, params) {
1115
- return __awaiter(this, void 0, void 0, function* () {
1116
- // Initialize anchor
1117
- anchor_1.Anchor.initialize(connection);
1118
- try {
1119
- const results = yield Transactions_1.txgen.meteoraDepositToLargePosition({
1120
- connection,
1121
- params,
1122
- fetch: undefined,
1123
- });
1124
- const txMetadatas = [];
1125
- for (const result of results) {
1126
- const txMeta = yield (0, functions_1.createTxMetadataWithActions)(this.generalUtility, connection, payer, result);
1127
- txMetadatas.push(txMeta);
1128
- }
1129
- return {
1130
- status: 200,
1131
- data: txMetadatas,
1132
- };
1133
- }
1134
- catch (e) {
1135
- if (e instanceof Error) {
1136
- return {
1137
- status: 400,
1138
- data: {
1139
- code: 'custom',
1140
- message: e.message,
1141
- path: [],
1142
- },
1143
- };
1144
- }
1145
- return {
1146
- status: 400,
1147
- data: {
1148
- code: 'custom',
1149
- message: e,
1150
- path: [],
1151
- },
1152
- };
1153
- }
1154
- });
1155
- }
1156
- /**
1157
- * Create a position and deposit liquidity for any bin count.
1158
- * For ≤149 bins: single tx. For ≥150 bins: multi-tx with init + deposit.
1159
- */
1160
- meteoraCreatePositionAndDepositToLargePosition(connection, payer, params) {
1161
- return __awaiter(this, void 0, void 0, function* () {
1162
- // Initialize anchor
1163
- anchor_1.Anchor.initialize(connection);
1164
- try {
1165
- const results = yield Transactions_1.txgen.meteoraCreatePositionAndDepositToLargePosition({
1166
- connection,
1167
- params,
1168
- });
1169
- const txMetadatas = [];
1170
- for (const result of results) {
1171
- const txMeta = yield (0, functions_1.createTxMetadataWithActions)(this.generalUtility, connection, payer, result);
1172
- txMetadatas.push(txMeta);
1173
- }
1174
- return {
1175
- status: 200,
1176
- data: txMetadatas,
1177
- };
1178
- }
1179
- catch (e) {
1180
- if (e instanceof Error) {
1181
- return {
1182
- status: 400,
1183
- data: {
1184
- code: 'custom',
1185
- message: e.message,
1186
- path: [],
1187
- },
1188
- };
1189
- }
1190
- return {
1191
- status: 400,
1192
- data: {
1193
- code: 'custom',
1194
- message: e,
1195
- path: [],
1196
- },
1197
- };
1198
- }
1199
- });
1200
- }
1201
- meteoraDepositHybridToLargePosition(connection, payer, params) {
1202
- return __awaiter(this, void 0, void 0, function* () {
1203
- anchor_1.Anchor.initialize(connection);
1204
- try {
1205
- const results = yield Transactions_1.txgen.meteoraDepositHybridToLargePosition({
1206
- connection,
1207
- params,
1208
- });
1209
- const txMetadatas = [];
1210
- for (const result of results) {
1211
- const txMeta = yield (0, functions_1.createTxMetadataWithActions)(this.generalUtility, connection, payer, result);
1212
- txMetadatas.push(txMeta);
1213
- }
1214
- return {
1215
- status: 200,
1216
- data: txMetadatas,
1217
- };
1218
- }
1219
- catch (e) {
1220
- if (e instanceof Error) {
1221
- return {
1222
- status: 400,
1223
- data: {
1224
- code: 'custom',
1225
- message: e.message,
1226
- path: [],
1227
- },
1228
- };
1229
- }
1230
- return {
1231
- status: 400,
1232
- data: {
1233
- code: 'custom',
1234
- message: e,
1235
- path: [],
1236
- },
1237
- };
1238
- }
1239
- });
1240
- }
1241
- meteoraCreatePositionAndDepositHybridToLargePosition(connection, payer, params) {
1242
- return __awaiter(this, void 0, void 0, function* () {
1243
- anchor_1.Anchor.initialize(connection);
1244
- try {
1245
- const results = yield Transactions_1.txgen.meteoraCreatePositionAndDepositHybridToLargePosition({
1246
- connection,
1247
- params,
1248
- });
1249
- const txMetadatas = [];
1250
- for (const result of results) {
1251
- const txMeta = yield (0, functions_1.createTxMetadataWithActions)(this.generalUtility, connection, payer, result);
1252
- txMetadatas.push(txMeta);
1253
- }
1254
- return {
1255
- status: 200,
1256
- data: txMetadatas,
1257
- };
1258
- }
1259
- catch (e) {
1260
- if (e instanceof Error) {
1261
- return {
1262
- status: 400,
1263
- data: {
1264
- code: 'custom',
1265
- message: e.message,
1266
- path: [],
1267
- },
1268
- };
1269
- }
1270
- return {
1271
- status: 400,
1272
- data: {
1273
- code: 'custom',
1274
- message: e,
1275
- path: [],
1276
- },
1277
- };
1278
- }
1279
- });
1280
- }
1281
- /**
1282
- * Deposit liquidity to a Meteora DLMM position (up to 70 bins) with optional position initialization.
1283
- *
1284
- * This method combines:
1285
- * - Initialize bin arrays (idempotent)
1286
- * - Optionally initialize position (if initializePosition is true)
1287
- * - Add liquidity using addLiquidityByStrategy
1288
- *
1289
- * Designed for automation compatibility - all operations in a single transaction.
1290
- * Note: Number of bins limited to 70 due to Meteora InitializePosition width constraint.
1291
- *
1292
- * @param connection The Solana web3 connection object for blockchain interactions.
1293
- * @param payer The public key of the payer for transaction fees.
1294
- * @param params MeteoraDepositLargerPosition parameters
1295
- * @returns A ResponseWithStatus containing TransactionMetadata.
1296
- */
1297
- meteoraDepositLargerPosition(connection, payer, params) {
1298
- return __awaiter(this, void 0, void 0, function* () {
1299
- // Initialize anchor
1300
- anchor_1.Anchor.initialize(connection);
1301
- try {
1302
- const result = yield Transactions_1.txgen.meteoraDepositLargerPosition({
1303
- connection,
1304
- params,
1305
- fetch: undefined,
1306
- });
1307
- return {
1308
- status: 200,
1309
- data: yield (0, functions_1.createTxMetadataWithActions)(this.generalUtility, connection, payer, result),
1310
- };
1311
- }
1312
- catch (e) {
1313
- if (e instanceof Error) {
1314
- return {
1315
- status: 400,
1316
- data: {
1317
- code: 'custom',
1318
- message: e.message,
1319
- path: [],
1320
- },
1321
- };
1322
- }
1323
- return {
1324
- status: 400,
1325
- data: {
1326
- code: 'custom',
1327
- message: e,
1328
- path: [],
1329
- },
1330
- };
1331
- }
1332
- });
1333
- }
1334
- /**
1335
- * Creates orca instruction that opens new position
1336
- *
1337
- * @param connection The Solana web3 connection object for blockchain interactions.
1338
- * @param payer The public key of the payer for transaction fees.
1339
- * @param params Parameters required
1340
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
1341
- */
1342
- orcaOpenPosition(connection, payer, params) {
1343
- return __awaiter(this, void 0, void 0, function* () {
1344
- // Initialize anchor
1345
- anchor_1.Anchor.initialize(connection);
1346
- try {
1347
- const result = yield Transactions_1.txgen.orcaOpenPosition({
1348
- connection,
1349
- params: {
1350
- userWallet: params.userWallet,
1351
- positionMint: params.positionMint,
1352
- whirlpool: params.whirlpool,
1353
- tickLowerIndex: params.tickLowerIndex,
1354
- tickUpperIndex: params.tickUpperIndex,
1355
- },
1356
- fetch: undefined,
1357
- });
1358
- return {
1359
- status: 200,
1360
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1361
- };
1362
- }
1363
- catch (e) {
1364
- if (e instanceof Error) {
1365
- return {
1366
- status: 400,
1367
- data: {
1368
- code: 'custom',
1369
- message: e.message,
1370
- path: [],
1371
- },
1372
- };
1373
- }
1374
- return {
1375
- status: 400,
1376
- data: {
1377
- code: 'custom',
1378
- message: e,
1379
- path: [],
1380
- },
1381
- };
1382
- }
1383
- });
1384
- }
1385
- /**
1386
- * Creates orca instruction that closes position
1387
- *
1388
- * @param connection The Solana web3 connection object for blockchain interactions.
1389
- * @param payer The public key of the payer for transaction fees.
1390
- * @param params Parameters required
1391
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
1392
- */
1393
- orcaClosePosition(connection, payer, params) {
1394
- return __awaiter(this, void 0, void 0, function* () {
1395
- // Initialize anchor
1396
- anchor_1.Anchor.initialize(connection);
1397
- try {
1398
- const result = yield Transactions_1.txgen.orcaClosePosition({
1399
- connection,
1400
- params: {
1401
- userWallet: params.userWallet,
1402
- position: params.position,
1403
- farm: params.farm,
1404
- },
1405
- fetch: undefined,
1406
- });
1407
- return {
1408
- status: 200,
1409
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1410
- };
1411
- }
1412
- catch (e) {
1413
- if (e instanceof Error) {
1414
- return {
1415
- status: 400,
1416
- data: {
1417
- code: 'custom',
1418
- message: e.message,
1419
- path: [],
1420
- },
1421
- };
1422
- }
1423
- return {
1424
- status: 400,
1425
- data: {
1426
- code: 'custom',
1427
- message: e,
1428
- path: [],
1429
- },
1430
- };
1431
- }
1432
- });
1433
- }
1434
- /**
1435
- * Creates orca instruction that deposits to a position
1436
- *
1437
- * @param connection The Solana web3 connection object for blockchain interactions.
1438
- * @param payer The public key of the payer for transaction fees.
1439
- * @param params Parameters required
1440
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
1441
- */
1442
- orcaDeposit(connection, payer, params) {
1443
- return __awaiter(this, void 0, void 0, function* () {
1444
- // Initialize anchor
1445
- anchor_1.Anchor.initialize(connection);
1446
- try {
1447
- const result = yield Transactions_1.txgen.orcaDeposit({
1448
- connection,
1449
- params: {
1450
- userWallet: params.userWallet,
1451
- mintOrPosition: params.mintOrPosition,
1452
- totalXAmount: params.totalXAmount,
1453
- totalYAmount: params.totalYAmount,
1454
- newPosition: params.newPosition,
1455
- is2022Position: params.is2022Position,
1456
- farm: params.farm,
1457
- },
1458
- fetch: undefined,
1459
- });
1460
- return {
1461
- status: 200,
1462
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1463
- };
1464
- }
1465
- catch (e) {
1466
- if (e instanceof Error) {
1467
- return {
1468
- status: 400,
1469
- data: {
1470
- code: 'custom',
1471
- message: e.message,
1472
- path: [],
1473
- },
1474
- };
1475
- }
1476
- return {
1477
- status: 400,
1478
- data: {
1479
- code: 'custom',
1480
- message: e,
1481
- path: [],
1482
- },
1483
- };
1484
- }
1485
- });
1486
- }
1487
- /**
1488
- * Creates orca instruction that deposits to a position
1489
- *
1490
- * @param connection The Solana web3 connection object for blockchain interactions.
1491
- * @param payer The public key of the payer for transaction fees.
1492
- * @param params Parameters required
1493
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
1494
- */
1495
- orcaDepositPda(connection, payer, params) {
1496
- return __awaiter(this, void 0, void 0, function* () {
1497
- // Initialize anchor
1498
- anchor_1.Anchor.initialize(connection);
1499
- try {
1500
- const result = yield Transactions_1.txgen.orcaDepositPda({
1501
- connection,
1502
- params: {
1503
- userWallet: params.userWallet,
1504
- mintOrPosition: params.mintOrPosition,
1505
- totalXAmount: params.totalXAmount,
1506
- totalYAmount: params.totalYAmount,
1507
- newPosition: params.newPosition,
1508
- farm: params.farm,
1509
- },
1510
- fetch: undefined,
1511
- });
1512
- return {
1513
- status: 200,
1514
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1515
- };
1516
- }
1517
- catch (e) {
1518
- if (e instanceof Error) {
1519
- return {
1520
- status: 400,
1521
- data: {
1522
- code: 'custom',
1523
- message: e.message,
1524
- path: [],
1525
- },
1526
- };
1527
- }
1528
- return {
1529
- status: 400,
1530
- data: {
1531
- code: 'custom',
1532
- message: e,
1533
- path: [],
1534
- },
1535
- };
1536
- }
1537
- });
1538
- }
1539
- /**
1540
- * Creates orca instruction that withdraws from a position
1541
- *
1542
- * @param connection The Solana web3 connection object for blockchain interactions.
1543
- * @param payer The public key of the payer for transaction fees.
1544
- * @param params Parameters required
1545
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
1546
- */
1547
- orcaWithdraw(connection, payer, params) {
1548
- return __awaiter(this, void 0, void 0, function* () {
1549
- // Initialize anchor
1550
- anchor_1.Anchor.initialize(connection);
1551
- try {
1552
- const result = yield Transactions_1.txgen.orcaWithdraw({
1553
- connection,
1554
- params: {
1555
- userWallet: params.userWallet,
1556
- position: params.position,
1557
- percentage: params.percentage,
1558
- is2022Position: params.is2022Position,
1559
- farm: params.farm,
1560
- },
1561
- fetch: undefined,
1562
- });
1563
- return {
1564
- status: 200,
1565
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1566
- };
1567
- }
1568
- catch (e) {
1569
- if (e instanceof Error) {
1570
- return {
1571
- status: 400,
1572
- data: {
1573
- code: 'custom',
1574
- message: e.message,
1575
- path: [],
1576
- },
1577
- };
1578
- }
1579
- return {
1580
- status: 400,
1581
- data: {
1582
- code: 'custom',
1583
- message: e,
1584
- path: [],
1585
- },
1586
- };
1587
- }
1588
- });
1589
- }
1590
- /**
1591
- * Creates orca instruction that withdraws from a position
1592
- *
1593
- * @param connection The Solana web3 connection object for blockchain interactions.
1594
- * @param payer The public key of the payer for transaction fees.
1595
- * @param params Parameters required
1596
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
1597
- */
1598
- orcaWithdrawPda(connection, payer, params) {
1599
- return __awaiter(this, void 0, void 0, function* () {
1600
- // Initialize anchor
1601
- anchor_1.Anchor.initialize(connection);
1602
- try {
1603
- const result = yield Transactions_1.txgen.orcaWithdrawPda({
1604
- connection,
1605
- params: {
1606
- userWallet: params.userWallet,
1607
- position: params.position,
1608
- percentage: params.percentage,
1609
- farm: params.farm,
1610
- },
1611
- fetch: undefined,
1612
- });
1613
- return {
1614
- status: 200,
1615
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1616
- };
1617
- }
1618
- catch (e) {
1619
- if (e instanceof Error) {
1620
- return {
1621
- status: 400,
1622
- data: {
1623
- code: 'custom',
1624
- message: e.message,
1625
- path: [],
1626
- },
1627
- };
1628
- }
1629
- return {
1630
- status: 400,
1631
- data: {
1632
- code: 'custom',
1633
- message: e,
1634
- path: [],
1635
- },
1636
- };
1637
- }
1638
- });
1639
- }
1640
- /**
1641
- * Creates orca instruction that withdraws from a position
1642
- *
1643
- * @param connection The Solana web3 connection object for blockchain interactions.
1644
- * @param payer The public key of the payer for transaction fees.
1645
- * @param params Parameters required
1646
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
1647
- */
1648
- orcaSweepDust(connection, payer, params) {
1649
- return __awaiter(this, void 0, void 0, function* () {
1650
- // Initialize anchor
1651
- anchor_1.Anchor.initialize(connection);
1652
- try {
1653
- const result = yield Transactions_1.txgen.orcaSweepDust({
1654
- connection,
1655
- params: params,
1656
- fetch: undefined,
1657
- });
1658
- return {
1659
- status: 200,
1660
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1661
- };
1662
- }
1663
- catch (e) {
1664
- if (e instanceof Error) {
1665
- return {
1666
- status: 400,
1667
- data: {
1668
- code: 'custom',
1669
- message: e.message,
1670
- path: [],
1671
- },
1672
- };
1673
- }
1674
- return {
1675
- status: 400,
1676
- data: {
1677
- code: 'custom',
1678
- message: e,
1679
- path: [],
1680
- },
1681
- };
1682
- }
1683
- });
1684
- }
1685
- /**
1686
- * Creates orca instruction that claims fees and rewards
1687
- *
1688
- * @param connection The Solana web3 connection object for blockchain interactions.
1689
- * @param payer The public key of the payer for transaction fees.
1690
- * @param params Parameters required
1691
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
1692
- */
1693
- orcaClaimRewards(connection, payer, params) {
1694
- return __awaiter(this, void 0, void 0, function* () {
1695
- // Initialize anchor
1696
- anchor_1.Anchor.initialize(connection);
1697
- try {
1698
- const result = yield Transactions_1.txgen.orcaClaimRewards({
1699
- connection,
1700
- params: {
1701
- userWallet: params.userWallet,
1702
- position: params.position,
1703
- is2022Position: params.is2022Position,
1704
- farm: params.farm,
1705
- },
1706
- fetch: undefined,
1707
- });
1708
- return {
1709
- status: 200,
1710
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1711
- };
1712
- }
1713
- catch (e) {
1714
- if (e instanceof Error) {
1715
- return {
1716
- status: 400,
1717
- data: {
1718
- code: 'custom',
1719
- message: e.message,
1720
- path: [],
1721
- },
1722
- };
1723
- }
1724
- return {
1725
- status: 400,
1726
- data: {
1727
- code: 'custom',
1728
- message: e,
1729
- path: [],
1730
- },
1731
- };
1732
- }
1733
- });
1734
- }
1735
- raydiumOpenPosition(connection, payer, params) {
1736
- return __awaiter(this, void 0, void 0, function* () {
1737
- // Initialize anchor
1738
- anchor_1.Anchor.initialize(connection);
1739
- try {
1740
- const result = yield Transactions_1.txgen.raydiumOpenPosition({
1741
- connection,
1742
- params,
1743
- fetch: undefined,
1744
- });
1745
- return {
1746
- status: 200,
1747
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1748
- };
1749
- }
1750
- catch (e) {
1751
- if (e instanceof Error) {
1752
- return {
1753
- status: 400,
1754
- data: {
1755
- code: 'custom',
1756
- message: e.message,
1757
- path: [],
1758
- },
1759
- };
1760
- }
1761
- return {
1762
- status: 400,
1763
- data: {
1764
- code: 'custom',
1765
- message: e,
1766
- path: [],
1767
- },
1768
- };
1769
- }
1770
- });
1771
- }
1772
- raydiumClosePosition(connection, payer, params) {
1773
- return __awaiter(this, void 0, void 0, function* () {
1774
- // Initialize anchor
1775
- anchor_1.Anchor.initialize(connection);
1776
- try {
1777
- const result = yield Transactions_1.txgen.raydiumClosePosition({
1778
- connection,
1779
- params,
1780
- fetch: undefined,
1781
- });
1782
- return {
1783
- status: 200,
1784
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1785
- };
1786
- }
1787
- catch (e) {
1788
- if (e instanceof Error) {
1789
- return {
1790
- status: 400,
1791
- data: {
1792
- code: 'custom',
1793
- message: e.message,
1794
- path: [],
1795
- },
1796
- };
1797
- }
1798
- return {
1799
- status: 400,
1800
- data: {
1801
- code: 'custom',
1802
- message: e,
1803
- path: [],
1804
- },
1805
- };
1806
- }
1807
- });
1808
- }
1809
- raydiumWithdrawAndClosePosition(connection, payer, params) {
1810
- return __awaiter(this, void 0, void 0, function* () {
1811
- // Initialize anchor
1812
- anchor_1.Anchor.initialize(connection);
1813
- try {
1814
- const result = yield Transactions_1.txgen.raydiumWithdrawAndClosePosition({
1815
- connection,
1816
- params,
1817
- fetch: undefined,
1818
- });
1819
- return {
1820
- status: 200,
1821
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1822
- };
1823
- }
1824
- catch (e) {
1825
- if (e instanceof Error) {
1826
- return {
1827
- status: 400,
1828
- data: {
1829
- code: 'custom',
1830
- message: e.message,
1831
- path: [],
1832
- },
1833
- };
1834
- }
1835
- return {
1836
- status: 400,
1837
- data: {
1838
- code: 'custom',
1839
- message: e,
1840
- path: [],
1841
- },
1842
- };
1843
- }
1844
- });
1845
- }
1846
- raydiumIncreaseLiquidity(connection, payer, params) {
1847
- return __awaiter(this, void 0, void 0, function* () {
1848
- // Initialize anchor
1849
- anchor_1.Anchor.initialize(connection);
1850
- try {
1851
- const result = yield Transactions_1.txgen.raydiumIncreaseLiquidity({
1852
- connection,
1853
- params,
1854
- fetch: undefined,
1855
- });
1856
- return {
1857
- status: 200,
1858
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1859
- };
1860
- }
1861
- catch (e) {
1862
- if (e instanceof Error) {
1863
- return {
1864
- status: 400,
1865
- data: {
1866
- code: 'custom',
1867
- message: e.message,
1868
- path: [],
1869
- },
1870
- };
1871
- }
1872
- return {
1873
- status: 400,
1874
- data: {
1875
- code: 'custom',
1876
- message: e,
1877
- path: [],
1878
- },
1879
- };
1880
- }
1881
- });
1882
- }
1883
- raydiumDecreaseLiquidity(connection, payer, params) {
1884
- return __awaiter(this, void 0, void 0, function* () {
1885
- // Initialize anchor
1886
- anchor_1.Anchor.initialize(connection);
1887
- try {
1888
- const result = yield Transactions_1.txgen.raydiumDecreaseLiquidity({
1889
- connection,
1890
- params,
1891
- fetch: undefined,
1892
- });
1893
- return {
1894
- status: 200,
1895
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1896
- };
1897
- }
1898
- catch (e) {
1899
- if (e instanceof Error) {
1900
- return {
1901
- status: 400,
1902
- data: {
1903
- code: 'custom',
1904
- message: e.message,
1905
- path: [],
1906
- },
1907
- };
1908
- }
1909
- return {
1910
- status: 400,
1911
- data: {
1912
- code: 'custom',
1913
- message: e,
1914
- path: [],
1915
- },
1916
- };
1917
- }
1918
- });
1919
- }
1920
- saberWithdrawAndClosePosition(connection, payer, params) {
1921
- return __awaiter(this, void 0, void 0, function* () {
1922
- anchor_1.Anchor.initialize(connection);
1923
- try {
1924
- const result = yield Transactions_1.txgen.saberWithdrawAndClosePosition({
1925
- connection,
1926
- params,
1927
- fetch: undefined,
1928
- });
1929
- return {
1930
- status: 200,
1931
- data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
1932
- };
1933
- }
1934
- catch (e) {
1935
- if (e instanceof Error) {
1936
- return {
1937
- status: 400,
1938
- data: {
1939
- code: 'custom',
1940
- message: e.message,
1941
- path: [],
1942
- },
1943
- };
1944
- }
1945
- return {
1946
- status: 400,
1947
- data: {
1948
- code: 'custom',
1949
- message: e,
1950
- path: [],
1951
- },
1952
- };
1953
- }
1954
- });
1955
- }
1956
- }
1957
- exports.TxGenerator = TxGenerator;