@hawksightco/hawk-sdk 1.3.264 → 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 -7658
  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,3175 +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.meteoraToHawksight = meteoraToHawksight;
49
- exports.meteoraToHawksightLabeled = meteoraToHawksightLabeled;
50
- exports.meteoraToHawksightAutomationIxs = meteoraToHawksightAutomationIxs;
51
- exports.meteoraToHawksightPdaIxs = meteoraToHawksightPdaIxs;
52
- const web3 = __importStar(require("@solana/web3.js"));
53
- const types_1 = require("./types");
54
- const addresses_1 = require("./addresses");
55
- const anchor_1 = require("./anchor");
56
- const bn_js_1 = __importDefault(require("bn.js"));
57
- const util = __importStar(require("./functions"));
58
- // import { Log } from "./classes/Logging";
59
- const SimpleIxGenerator_1 = require("./classes/SimpleIxGenerator");
60
- const AccountCache_1 = require("./classes/account-cache/AccountCache");
61
- /**
62
- * Convert listed meteora instruction to generalized hawksight meteora cpi
63
- *
64
- * @param params
65
- * @returns
66
- */
67
- function meteoraToHawksight(_a) {
68
- return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority, opt }) {
69
- const _ixs = [];
70
- for (const ix of ixs) {
71
- const _ix = yield HawksightMeteoraCpi.factory(ix, userPda, authority, opt).getInstruction();
72
- if (ix.programId.toString() === addresses_1.ASSOCIATED_TOKEN_PROGRAM.toString() && ix.keys.length === 6) {
73
- ix.keys[0] = Object.assign(Object.assign({}, ix.keys[0]), { pubkey: authority });
74
- }
75
- _ixs.push(_ix);
76
- }
77
- return _ixs;
78
- });
79
- }
80
- /**
81
- * Convert listed meteora instruction to generalized hawksight meteora cpi (with label)
82
- *
83
- * @param params
84
- * @returns
85
- */
86
- function meteoraToHawksightLabeled(_a) {
87
- return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority, classification, opt }) {
88
- const _ixs = [];
89
- for (const ix of ixs) {
90
- const _ix = yield HawksightMeteoraCpi.labeledFactory(ix, userPda, authority, classification, opt).getLabeledInstruction();
91
- if (ix.programId.toString() === addresses_1.ASSOCIATED_TOKEN_PROGRAM.toString() && ix.keys.length === 6) {
92
- ix.keys[0] = Object.assign(Object.assign({}, ix.keys[0]), { pubkey: authority });
93
- }
94
- _ixs.push(_ix);
95
- }
96
- return _ixs;
97
- });
98
- }
99
- /**
100
- * Convert listed meteora instruction to hawksight meteora automation cpi
101
- *
102
- * @param params
103
- * @returns
104
- */
105
- function meteoraToHawksightAutomationIxs(_a) {
106
- return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority, opt }) {
107
- const _ixs = [];
108
- for (const ix of ixs) {
109
- const _ix = yield HawksightMeteoraAutomationCpi.factory(ix, userPda, authority, opt).getInstruction();
110
- if (ix.programId.toString() === addresses_1.ASSOCIATED_TOKEN_PROGRAM.toString() && ix.keys.length === 6) {
111
- ix.keys[0] = Object.assign(Object.assign({}, ix.keys[0]), { pubkey: addresses_1.HS_AUTHORITY });
112
- }
113
- _ixs.push(_ix);
114
- }
115
- return _ixs;
116
- });
117
- }
118
- /**
119
- * Convert listed meteora instruction to hawksight meteora automation cpi
120
- *
121
- * @param params
122
- * @returns
123
- */
124
- function meteoraToHawksightPdaIxs(_a) {
125
- return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority, opt }) {
126
- const _ixs = [];
127
- for (const ix of ixs) {
128
- const _ix = yield HawksightMeteoraPdaCpi.factory(ix, userPda, authority, opt).getInstruction();
129
- if (ix.programId.toString() === addresses_1.ASSOCIATED_TOKEN_PROGRAM.toString() && ix.keys.length === 6) {
130
- ix.keys[0] = Object.assign(Object.assign({}, ix.keys[0]), { pubkey: addresses_1.HS_AUTHORITY });
131
- }
132
- _ixs.push(_ix);
133
- }
134
- return _ixs;
135
- });
136
- }
137
- /**
138
- * Abstract base class `HawksightMeteoraCpi` for handling and chaining transaction instructions.
139
- * This class provides a framework for creating and linking complex transaction processes in a blockchain environment.
140
- *
141
- * Attributes:
142
- * - `ix`: web3.TransactionInstruction - The transaction instruction associated with this CPI.
143
- * - `userPda`: web3.PublicKey - The public key of the user's program-derived address (PDA).
144
- * - `authority`: web3.PublicKey - The public key of the authority that can sign transactions.
145
- * - `_next`: HawksightMeteoraCpi | undefined - Pointer to the next CPI in the chain.
146
- * - `sighash`: Buffer - A buffer representing the signature hash used for identifying and validating instructions.
147
- *
148
- * Methods:
149
- * - `constructor(ix, userPda, authority, sighash)`: Constructs an instance of the HawksightMeteoraCpi.
150
- * - `factory(ix, userPda, authority)`: Static factory method to create a chain of CPIs starting with `InitializePosition` and linking subsequent operations.
151
- * - `getInstruction()`: Returns the modified transaction instruction after processing by matching CPIs in the chain.
152
- * - `replace()`: Abstract method to be implemented by subclasses to modify the transaction keys or other properties.
153
- * - `next(next)`: Chains the current CPI instance to the next one.
154
- * - `sighashMatch()`: Checks if the current transaction instruction matches the provided sighash and recurses through the chain if not.
155
- * - `programIdMatch()`: Checks if the program ID of the transaction matches the expected ID.
156
- * - `addHawksightCpi()`: Modifies the transaction instruction to include specific Hawksight CPI details.
157
- *
158
- * Usage:
159
- * This class is intended to be extended by specific CPI implementations like `InitializePosition`, each implementing their own `replace()` method to handle specific transaction modifications.
160
- */
161
- class HawksightMeteoraCpi {
162
- /**
163
- * Constructs an instance of HawksightMeteoraCpi with the necessary transaction parameters.
164
- * @param ix The core transaction instruction.
165
- * @param userPda The user's program-derived address (PDA) as a public key.
166
- * @param authority The authority public key that has signing capabilities over the transaction.
167
- * @param sighash A Buffer containing the sighash used for matching the transaction instruction.
168
- * @param opt Optional parameters for customizing the behavior of the CPI.
169
- * @param label Optional label for identifying the CPI.
170
- * @param classification Optional classification for categorizing the CPI.
171
- */
172
- constructor(ix, userPda, authority, sighash, opt, label, classification) {
173
- this.ix = ix;
174
- this.userPda = userPda;
175
- this.authority = authority;
176
- this.sighash = sighash;
177
- this.opt = opt;
178
- this.label = label;
179
- this.classification = classification;
180
- }
181
- /**
182
- * Factory method to create and link a chain of CPIs starting from `InitializePosition`.
183
- * Subsequent CPIs include operations like adding liquidity, removing liquidity, claiming fees, and rewards, and closing the position.
184
- * @param ix The initial transaction instruction.
185
- * @param userPda The user's public key.
186
- * @param authority The authority public key.
187
- * @returns The first CPI in the chain.
188
- */
189
- static factory(ix, userPda, authority, opt) {
190
- const chain = new InitializePosition(ix, userPda, authority, opt);
191
- chain
192
- .next(new AddLiquidityByWeight(ix, userPda, authority, opt))
193
- .next(new AddLiquidityOneSide(ix, userPda, authority, opt))
194
- .next(new AddLiquidityOneSidePrecise(ix, userPda, authority, opt))
195
- .next(new AddLiquidityOneSidePrecise2(ix, userPda, authority, opt))
196
- .next(new AddLiquidityByStrategy(ix, userPda, authority, undefined, opt))
197
- .next(new AddLiquidityByStrategyOneSide(ix, userPda, authority, opt))
198
- .next(new AddLiquidityByStrategy2(ix, userPda, authority, undefined, opt))
199
- .next(new RemoveLiquidity(ix, userPda, authority, util.sighash("RemoveLiquidity"), opt))
200
- .next(new RemoveLiquidityByRange(ix, userPda, authority, opt))
201
- .next(new RemoveLiquidity2(ix, userPda, authority, util.sighash("remove_liquidity2", undefined, true), opt))
202
- .next(new RemoveLiquidityByRange2(ix, userPda, authority, opt))
203
- .next(new ClaimFee(ix, userPda, authority, opt))
204
- .next(new ClaimFee2(ix, userPda, authority, opt))
205
- .next(new ClaimReward(ix, userPda, authority, opt))
206
- .next(new ClaimReward2(ix, userPda, authority, opt))
207
- .next(new ClosePosition(ix, userPda, authority, opt))
208
- .next(new ClosePosition2(ix, userPda, authority, opt))
209
- .next(new ClosePositionIfEmpty(ix, userPda, authority, opt))
210
- .next(new MeteoraDlmmDeposit2(ix, userPda, authority, opt));
211
- return chain;
212
- }
213
- /**
214
- * Factory method to create and link a chain of CPIs starting from `InitializePosition`.
215
- * Subsequent CPIs include operations like adding liquidity, removing liquidity, claiming fees, and rewards, and closing the position.
216
- * @param ix The initial transaction instruction.
217
- * @param userPda The user's public key.
218
- * @param authority The authority public key.
219
- * @returns The first CPI in the chain.
220
- */
221
- static labeledFactory(ix, userPda, authority, classification, opt) {
222
- const chain = new InitializePosition(ix, userPda, authority, opt);
223
- chain
224
- .next(new AddLiquidityByWeight(ix, userPda, authority, opt, 'Deposit liquidity to Meteora', classification))
225
- .next(new AddLiquidityOneSide(ix, userPda, authority, opt, 'Deposit liquidity to Meteora (One-side)', classification))
226
- .next(new AddLiquidityOneSidePrecise(ix, userPda, authority, opt, 'Deposit liquidity to Meteora (One-side)', classification))
227
- .next(new AddLiquidityOneSidePrecise2(ix, userPda, authority, opt, 'Deposit liquidity to Meteora (One-side)', classification))
228
- .next(new AddLiquidityByStrategy(ix, userPda, authority, undefined, opt, 'Deposit liquidity to Meteora', classification))
229
- .next(new AddLiquidityByStrategyOneSide(ix, userPda, authority, opt, 'Deposit liquidity to Meteora (One-side)', classification))
230
- .next(new AddLiquidityByStrategy2(ix, userPda, authority, undefined, opt, 'Deposit liquidity to Meteora', classification))
231
- .next(new RemoveLiquidity(ix, userPda, authority, util.sighash("RemoveLiquidity"), opt, 'Withdraw liquidity from Meteora', classification))
232
- .next(new RemoveLiquidityByRange(ix, userPda, authority, opt, 'Withdraw liquidity from Meteora', classification))
233
- .next(new RemoveLiquidity2(ix, userPda, authority, util.sighash("remove_liquidity2", undefined, true), opt, 'Withdraw liquidity from Meteora', classification))
234
- .next(new RemoveLiquidityByRange2(ix, userPda, authority, opt, 'Withdraw liquidity from Meteora', classification))
235
- .next(new ClaimFee(ix, userPda, authority, opt, util.sighash("claim_fee", undefined, true), 'Claim fee from Meteora', classification))
236
- .next(new ClaimFee2(ix, userPda, authority, opt, util.sighash("claim_fee2", undefined, true), 'Claim fee from Meteora', classification))
237
- .next(new ClaimReward(ix, userPda, authority, opt, util.sighash("claim_reward", undefined, true), 'Claim reward from Meteora', classification))
238
- .next(new ClaimReward2(ix, userPda, authority, opt, util.sighash("claim_reward2", undefined, true), 'Claim reward from Meteora', classification))
239
- .next(new ClosePosition(ix, userPda, authority, opt, util.sighash("close_position", undefined, true), 'Close Meteora position', classification))
240
- .next(new ClosePosition2(ix, userPda, authority, opt, util.sighash("close_position2", undefined, true), 'Close Meteora position', classification))
241
- .next(new ClosePositionIfEmpty(ix, userPda, authority, opt, util.sighash("ClosePositionIfEmpty"), 'Close Meteora position if it\'s empty', classification))
242
- .next(new MeteoraDlmmDeposit2(ix, userPda, authority, opt, 'Deposit liquidity to Meteora', classification));
243
- return chain;
244
- }
245
- /**
246
- * Retrieves and possibly modifies the transaction instruction based on matching conditions.
247
- * If a matching CPI is found in the chain, it performs modifications and returns the updated instruction.
248
- * @returns The (possibly modified) transaction instruction.
249
- */
250
- getInstruction() {
251
- return __awaiter(this, void 0, void 0, function* () {
252
- const matchInstance = this.sighashMatch();
253
- if (this.programIdMatch() && matchInstance !== undefined) {
254
- matchInstance.replace();
255
- yield matchInstance.addHawksightCpi();
256
- return this.ix;
257
- }
258
- return this.ix;
259
- });
260
- }
261
- /**
262
- * Retrieves and possibly modifies the transaction instruction based on matching conditions.
263
- * If a matching CPI is found in the chain, it performs modifications and returns the updated instruction.
264
- * @returns The (possibly modified) transaction instruction.
265
- */
266
- getLabeledInstruction() {
267
- return __awaiter(this, void 0, void 0, function* () {
268
- var _a, _b, _c, _d;
269
- const matchInstance = this.sighashMatch();
270
- if (this.programIdMatch() && matchInstance !== undefined) {
271
- matchInstance.replace();
272
- yield matchInstance.addHawksightCpi();
273
- return {
274
- instruction: this.ix,
275
- label: (_a = matchInstance.label) !== null && _a !== void 0 ? _a : "",
276
- class: (_b = matchInstance.classification) !== null && _b !== void 0 ? _b : "",
277
- };
278
- }
279
- return {
280
- instruction: this.ix,
281
- label: (_c = this.label) !== null && _c !== void 0 ? _c : "",
282
- class: (_d = this.classification) !== null && _d !== void 0 ? _d : "",
283
- };
284
- });
285
- }
286
- /**
287
- * Modifies the transaction instruction to include specific Hawksight CPI details.
288
- * Prepares the instruction for execution by adjusting its program ID and data based on Hawksight criteria.
289
- */
290
- addHawksightCpi() {
291
- return __awaiter(this, void 0, void 0, function* () {
292
- const METEORA_PROGRAM = addresses_1.METEORA_DLMM_PROGRAM;
293
- const size = Buffer.alloc(4);
294
- size.writeUint32LE(this.ix.data.length);
295
- const data = Buffer.concat([
296
- new Uint8Array(util.sighash('meteora_dynamic_cpi')),
297
- new Uint8Array(size),
298
- new Uint8Array(this.ix.data),
299
- ]);
300
- this.ix.programId = addresses_1.IYF_MAIN;
301
- this.ix.data = data;
302
- this.ix.keys.unshift(...[
303
- { pubkey: this.userPda, isSigner: false, isWritable: false },
304
- { pubkey: this.authority, isSigner: true, isWritable: true },
305
- { pubkey: METEORA_PROGRAM, isSigner: false, isWritable: false },
306
- ]);
307
- });
308
- }
309
- /**
310
- * Adds a subsequent CPI to the chain.
311
- * @param next The next CPI object to link.
312
- * @returns The added CPI object, allowing for method chaining.
313
- */
314
- next(next) {
315
- this._next = next;
316
- return this._next;
317
- }
318
- /**
319
- * Recursively checks this CPI and subsequent ones for a sighash match in the transaction data.
320
- * @returns The first CPI instance in the chain that matches the sighash, or undefined if no match is found.
321
- */
322
- sighashMatch() {
323
- var _a, _b;
324
- try {
325
- const match = util.sighashMatch(this.ix.data, this.sighash);
326
- if (match) {
327
- return this;
328
- }
329
- else if (this._next !== undefined) {
330
- return (_a = this._next) === null || _a === void 0 ? void 0 : _a.sighashMatch();
331
- }
332
- }
333
- catch (_c) {
334
- if (this._next !== undefined) {
335
- return (_b = this._next) === null || _b === void 0 ? void 0 : _b.sighashMatch();
336
- }
337
- }
338
- return undefined;
339
- }
340
- /**
341
- * Checks if the program ID of the transaction instruction matches the expected program ID.
342
- * @returns True if the program ID matches, otherwise false.
343
- */
344
- programIdMatch() {
345
- return this.ix.programId.equals(addresses_1.METEORA_DLMM_PROGRAM);
346
- }
347
- }
348
- /**
349
- * Handles the initialization of a position in a blockchain transaction.
350
- * This class extends the HawksightMeteoraCpi and provides specific logic to modify the transaction instruction for position initialization.
351
- */
352
- class InitializePosition extends HawksightMeteoraCpi {
353
- /**
354
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
355
- *
356
- * @param ix The core transaction instruction.
357
- * @param userPda The user's program-derived address (PDA) as a public key.
358
- * @param authority The authority public key that has signing capabilities over the transaction.
359
- */
360
- constructor(ix, userPda, authority, opt) {
361
- super(ix, userPda, authority, util.sighash("InitializePosition"), opt);
362
- }
363
- /**
364
- * Modifies the transaction keys to set the correct public keys for an initial position setup.
365
- */
366
- replace() {
367
- this.ix.keys[0].pubkey = this.authority;
368
- this.ix.keys[3].pubkey = this.userPda;
369
- this.ix.keys[3].isSigner = false;
370
- }
371
- }
372
- /**
373
- * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
374
- * This class is designed for blockchain operations that manage liquidity pools.
375
- */
376
- class AddLiquidityByWeight extends HawksightMeteoraCpi {
377
- /**
378
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
379
- *
380
- * @param ix The core transaction instruction.
381
- * @param userPda The user's program-derived address (PDA) as a public key.
382
- * @param authority The authority public key that has signing capabilities over the transaction.
383
- */
384
- constructor(ix, userPda, authority, opt, label, classification) {
385
- super(ix, userPda, authority, util.sighash("AddLiquidityByWeight"), opt, label, classification);
386
- }
387
- /**
388
- * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
389
- */
390
- replace() {
391
- var _a;
392
- this.ix.keys[11].pubkey = this.userPda;
393
- this.ix.keys[11].isSigner = false;
394
- const mintAInfo = AccountCache_1.AccountCache.get(this.ix.keys[7].pubkey);
395
- const mintBInfo = AccountCache_1.AccountCache.get(this.ix.keys[8].pubkey);
396
- if (!!mintAInfo && !!mintBInfo) {
397
- const tokenProgramA = mintAInfo.info.owner;
398
- const tokenProgramB = mintBInfo.info.owner;
399
- // Adjust by token type
400
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
401
- if (pdaTokenType === types_1.TokenType.LTA) {
402
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
403
- this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
404
- }
405
- else if (pdaTokenType === types_1.TokenType.STA) {
406
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
407
- this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
408
- }
409
- else {
410
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey, tokenProgramA);
411
- this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey, tokenProgramB);
412
- }
413
- }
414
- else {
415
- throw new Error("Unexpected error: Mint A or B not found in cache.");
416
- }
417
- }
418
- }
419
- /**
420
- * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
421
- * This class is designed for blockchain operations that manage liquidity pools.
422
- */
423
- class AddLiquidityByStrategy extends HawksightMeteoraCpi {
424
- /**
425
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
426
- *
427
- * @param ix The core transaction instruction.
428
- * @param userPda The user's program-derived address (PDA) as a public key.
429
- * @param authority The authority public key that has signing capabilities over the transaction.
430
- */
431
- constructor(ix, userPda, authority, sighash = util.sighash("AddLiquidityByStrategy"), opt, label, classification) {
432
- super(ix, userPda, authority, sighash, opt, label, classification);
433
- }
434
- replaceSender() {
435
- this.ix.keys[11].pubkey = this.userPda;
436
- this.ix.keys[11].isSigner = false;
437
- }
438
- /**
439
- * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
440
- */
441
- replace() {
442
- var _a;
443
- this.replaceSender();
444
- const mintAInfo = AccountCache_1.AccountCache.get(this.ix.keys[7].pubkey);
445
- const mintBInfo = AccountCache_1.AccountCache.get(this.ix.keys[8].pubkey);
446
- if (!!mintAInfo && !!mintBInfo) {
447
- const tokenProgramA = mintAInfo.info.owner;
448
- const tokenProgramB = mintBInfo.info.owner;
449
- // Adjust by token type
450
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
451
- if (pdaTokenType === types_1.TokenType.LTA) {
452
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
453
- this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
454
- }
455
- else if (pdaTokenType === types_1.TokenType.STA) {
456
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
457
- this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
458
- }
459
- else {
460
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey, tokenProgramA);
461
- this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey, tokenProgramB);
462
- }
463
- }
464
- else {
465
- throw new Error("Unexpected error: Mint A or B not found in cache.");
466
- }
467
- }
468
- }
469
- /**
470
- * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
471
- * This class is designed for blockchain operations that manage liquidity pools.
472
- */
473
- class AddLiquidityByStrategy2 extends AddLiquidityByStrategy {
474
- /**
475
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
476
- *
477
- * @param ix The core transaction instruction.
478
- * @param userPda The user's program-derived address (PDA) as a public key.
479
- * @param authority The authority public key that has signing capabilities over the transaction.
480
- */
481
- constructor(ix, userPda, authority, sighash = util.sighash("add_liquidity_by_strategy2", undefined, true), opt, label, classification) {
482
- super(ix, userPda, authority, sighash, opt, label, classification);
483
- }
484
- replaceSender() {
485
- this.ix.keys[9].pubkey = this.userPda;
486
- this.ix.keys[9].isSigner = false;
487
- }
488
- }
489
- /**
490
- * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
491
- * This class is designed for blockchain operations that manage liquidity pools.
492
- */
493
- class AddLiquidityOneSide extends HawksightMeteoraCpi {
494
- /**
495
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
496
- *
497
- * @param ix The core transaction instruction.
498
- * @param userPda The user's program-derived address (PDA) as a public key.
499
- * @param authority The authority public key that has signing capabilities over the transaction.
500
- */
501
- constructor(ix, userPda, authority, opt, label, classification) {
502
- super(ix, userPda, authority, util.sighash("AddLiquidityOneSide"), opt, label, classification);
503
- }
504
- /**
505
- * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
506
- */
507
- replace() {
508
- var _a;
509
- this.ix.keys[8].pubkey = this.userPda;
510
- this.ix.keys[8].isSigner = false;
511
- const mintInfo = AccountCache_1.AccountCache.get(this.ix.keys[5].pubkey);
512
- if (!!mintInfo) {
513
- const tokenProgram = mintInfo.info.owner;
514
- // Adjust by token type
515
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
516
- if (pdaTokenType === types_1.TokenType.LTA) {
517
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
518
- }
519
- else if (pdaTokenType === types_1.TokenType.STA) {
520
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
521
- }
522
- else {
523
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[5].pubkey, tokenProgram);
524
- }
525
- }
526
- else {
527
- throw new Error("Unexpected error: Mint not found in cache.");
528
- }
529
- }
530
- }
531
- /**
532
- * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
533
- * This class is designed for blockchain operations that manage liquidity pools.
534
- */
535
- class AddLiquidityOneSidePrecise extends HawksightMeteoraCpi {
536
- /**
537
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
538
- *
539
- * @param ix The core transaction instruction.
540
- * @param userPda The user's program-derived address (PDA) as a public key.
541
- * @param authority The authority public key that has signing capabilities over the transaction.
542
- */
543
- constructor(ix, userPda, authority, opt, label, classification) {
544
- super(ix, userPda, authority, util.sighash("AddLiquidityOneSidePrecise"), opt, label, classification);
545
- }
546
- /**
547
- * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
548
- */
549
- replace() {
550
- var _a;
551
- this.ix.keys[8].pubkey = this.userPda;
552
- this.ix.keys[8].isSigner = false;
553
- const mintInfo = AccountCache_1.AccountCache.get(this.ix.keys[5].pubkey);
554
- if (!!mintInfo) {
555
- const tokenProgram = mintInfo.info.owner;
556
- // Adjust by token type
557
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
558
- if (pdaTokenType === types_1.TokenType.LTA) {
559
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
560
- }
561
- else if (pdaTokenType === types_1.TokenType.STA) {
562
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
563
- }
564
- else {
565
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[5].pubkey, tokenProgram);
566
- }
567
- }
568
- else {
569
- throw new Error("Unexpected error: Mint not found in cache.");
570
- }
571
- }
572
- }
573
- /**
574
- * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
575
- * This class is designed for blockchain operations that manage liquidity pools.
576
- */
577
- class AddLiquidityOneSidePrecise2 extends HawksightMeteoraCpi {
578
- /**
579
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
580
- *
581
- * @param ix The core transaction instruction.
582
- * @param userPda The user's program-derived address (PDA) as a public key.
583
- * @param authority The authority public key that has signing capabilities over the transaction.
584
- */
585
- constructor(ix, userPda, authority, opt, label, classification) {
586
- super(ix, userPda, authority, util.sighash("add_liquidity_one_side_precise2", undefined, true), opt, label, classification);
587
- }
588
- /**
589
- * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
590
- */
591
- replace() {
592
- var _a;
593
- this.ix.keys[8].pubkey = this.userPda;
594
- this.ix.keys[8].isSigner = false;
595
- const mintInfo = AccountCache_1.AccountCache.get(this.ix.keys[5].pubkey);
596
- if (!!mintInfo) {
597
- const tokenProgram = mintInfo.info.owner;
598
- // Adjust by token type
599
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
600
- if (pdaTokenType === types_1.TokenType.LTA) {
601
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
602
- }
603
- else if (pdaTokenType === types_1.TokenType.STA) {
604
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
605
- }
606
- else {
607
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[5].pubkey, tokenProgram);
608
- }
609
- }
610
- else {
611
- throw new Error("Unexpected error: Mint not found in cache.");
612
- }
613
- }
614
- }
615
- /**
616
- * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
617
- * This class is designed for blockchain operations that manage liquidity pools.
618
- */
619
- class AddLiquidityByStrategyOneSide extends HawksightMeteoraCpi {
620
- /**
621
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
622
- *
623
- * @param ix The core transaction instruction.
624
- * @param userPda The user's program-derived address (PDA) as a public key.
625
- * @param authority The authority public key that has signing capabilities over the transaction.
626
- */
627
- constructor(ix, userPda, authority, opt, label, classification) {
628
- super(ix, userPda, authority, util.sighash("AddLiquidityByStrategyOneSide"), opt, label, classification);
629
- }
630
- /**
631
- * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
632
- */
633
- replace() {
634
- var _a;
635
- this.ix.keys[8].pubkey = this.userPda;
636
- this.ix.keys[8].isSigner = false;
637
- const mintInfo = AccountCache_1.AccountCache.get(this.ix.keys[5].pubkey);
638
- if (!!mintInfo) {
639
- const tokenProgram = mintInfo.info.owner;
640
- // Adjust by token type
641
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
642
- if (pdaTokenType === types_1.TokenType.LTA) {
643
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
644
- }
645
- else if (pdaTokenType === types_1.TokenType.STA) {
646
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
647
- }
648
- else {
649
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[5].pubkey, tokenProgram);
650
- }
651
- }
652
- else {
653
- throw new Error("Unexpected error: Mint not found in cache.");
654
- }
655
- }
656
- }
657
- /**
658
- * Facilitates the removal of liquidity from a blockchain-based financial system.
659
- */
660
- class RemoveLiquidity extends HawksightMeteoraCpi {
661
- /**
662
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
663
- *
664
- * @param ix The core transaction instruction.
665
- * @param userPda The user's program-derived address (PDA) as a public key.
666
- * @param authority The authority public key that has signing capabilities over the transaction.
667
- */
668
- constructor(ix, userPda, authority, sighash = util.sighash("RemoveLiquidity"), opt, label, classification) {
669
- super(ix, userPda, authority, sighash, opt, label, classification);
670
- }
671
- replaceSigner() {
672
- this.ix.keys[11].pubkey = this.userPda;
673
- this.ix.keys[11].isSigner = false;
674
- }
675
- /**
676
- * Customizes the transaction keys to correctly handle the removal of liquidity.
677
- */
678
- replace() {
679
- var _a;
680
- this.replaceSigner();
681
- const mintAInfo = AccountCache_1.AccountCache.get(this.ix.keys[7].pubkey);
682
- const mintBInfo = AccountCache_1.AccountCache.get(this.ix.keys[8].pubkey);
683
- if (!!mintAInfo && !!mintBInfo) {
684
- const tokenProgramA = mintAInfo.info.owner;
685
- const tokenProgramB = mintBInfo.info.owner;
686
- // Adjust by token type
687
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
688
- if (pdaTokenType === types_1.TokenType.LTA) {
689
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
690
- this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
691
- }
692
- else if (pdaTokenType === types_1.TokenType.STA) {
693
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
694
- this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
695
- }
696
- else {
697
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey, tokenProgramA);
698
- this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey, tokenProgramB);
699
- }
700
- }
701
- else {
702
- throw new Error("Unexpected error: Mint A or B not found in cache.");
703
- }
704
- }
705
- }
706
- class RemoveLiquidity2 extends RemoveLiquidity {
707
- /**
708
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
709
- *
710
- * @param ix The core transaction instruction.
711
- * @param userPda The user's program-derived address (PDA) as a public key.
712
- * @param authority The authority public key that has signing capabilities over the transaction.
713
- */
714
- constructor(ix, userPda, authority, sighash = util.sighash("remove_liquidity2", undefined, true), opt, label, classification) {
715
- super(ix, userPda, authority, sighash, opt, label, classification);
716
- }
717
- replaceSigner() {
718
- this.ix.keys[9].pubkey = this.userPda;
719
- this.ix.keys[9].isSigner = false;
720
- }
721
- }
722
- /**
723
- * Facilitates the removal of liquidity from a blockchain-based financial system.
724
- */
725
- class RemoveLiquidityByRange extends RemoveLiquidity {
726
- /**
727
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
728
- *
729
- * @param ix The core transaction instruction.
730
- * @param userPda The user's program-derived address (PDA) as a public key.
731
- * @param authority The authority public key that has signing capabilities over the transaction.
732
- */
733
- constructor(ix, userPda, authority, opt, label, classification) {
734
- super(ix, userPda, authority, util.sighash("RemoveLiquidityByRange"), opt, label, classification);
735
- }
736
- }
737
- /**
738
- * Facilitates the removal of liquidity from a blockchain-based financial system.
739
- */
740
- class RemoveLiquidityByRange2 extends RemoveLiquidity2 {
741
- /**
742
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
743
- *
744
- * @param ix The core transaction instruction.
745
- * @param userPda The user's program-derived address (PDA) as a public key.
746
- * @param authority The authority public key that has signing capabilities over the transaction.
747
- */
748
- constructor(ix, userPda, authority, opt, label, classification) {
749
- super(ix, userPda, authority, util.sighash("remove_liquidity_by_range2", undefined, true), opt, label, classification);
750
- }
751
- }
752
- /**
753
- * Enables the claiming of fees generated from transactions within a blockchain protocol.
754
- */
755
- class ClaimFee extends HawksightMeteoraCpi {
756
- /**
757
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
758
- *
759
- * @param ix The core transaction instruction.
760
- * @param userPda The user's program-derived address (PDA) as a public key.
761
- * @param authority The authority public key that has signing capabilities over the transaction.
762
- */
763
- constructor(ix, userPda, authority, opt, sighash = util.sighash("ClaimFee"), label, classification) {
764
- super(ix, userPda, authority, sighash, opt, label, classification);
765
- }
766
- getMints() {
767
- return [
768
- this.ix.keys[9].pubkey,
769
- this.ix.keys[10].pubkey,
770
- ];
771
- }
772
- replaceSigner() {
773
- this.ix.keys[4].pubkey = this.userPda;
774
- this.ix.keys[4].isSigner = false;
775
- }
776
- replaceTokenInputs(tokenA, tokenB) {
777
- this.ix.keys[7].pubkey = tokenA;
778
- this.ix.keys[8].pubkey = tokenB;
779
- }
780
- /**
781
- * Modifies transaction keys for the purpose of claiming transaction fees.
782
- */
783
- replace() {
784
- var _a;
785
- this.replaceSigner();
786
- const [mintA, mintB] = this.getMints();
787
- const mintAInfo = AccountCache_1.AccountCache.get(mintA);
788
- const mintBInfo = AccountCache_1.AccountCache.get(mintB);
789
- if (!!mintAInfo && !!mintBInfo) {
790
- const tokenProgramA = mintAInfo.info.owner;
791
- const tokenProgramB = mintBInfo.info.owner;
792
- // Adjust by token type
793
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
794
- if (pdaTokenType === types_1.TokenType.LTA) {
795
- this.replaceTokenInputs(util.generateLimitToken(this.userPda, mintA), util.generateLimitToken(this.userPda, mintB));
796
- }
797
- else if (pdaTokenType === types_1.TokenType.STA) {
798
- this.replaceTokenInputs(util.generateUserPdaStorageAccount(this.userPda, mintA), util.generateUserPdaStorageAccount(this.userPda, mintB));
799
- }
800
- else {
801
- this.replaceTokenInputs(util.generateAta(this.userPda, mintA, tokenProgramA), util.generateAta(this.userPda, mintB, tokenProgramB));
802
- }
803
- }
804
- else {
805
- throw new Error("Unexpected error: Mint A or B not found in cache.");
806
- }
807
- }
808
- generateMeteoraDlmmClaimFeeIx(ownerFeeX, ownerFeeY) {
809
- return __awaiter(this, void 0, void 0, function* () {
810
- // Common parameters
811
- const farm = addresses_1.USDC_FARM;
812
- const userPda = this.userPda;
813
- const authority = this.authority;
814
- const iyfProgram = addresses_1.IYF_MAIN;
815
- // Generate IX via extension contract
816
- // @ts-ignore
817
- const claimFeeIx = yield anchor_1.Anchor.instance().iyfExtension.methods
818
- .meteoraDlmmClaimFee()
819
- .accounts({
820
- farm,
821
- userPda,
822
- authority,
823
- iyfProgram,
824
- lbPair: this.ix.keys[0].pubkey,
825
- position: this.ix.keys[1].pubkey,
826
- binArrayLower: this.ix.keys[2].pubkey,
827
- binArrayUpper: this.ix.keys[3].pubkey,
828
- reserveX: this.ix.keys[5].pubkey,
829
- reserveY: this.ix.keys[6].pubkey,
830
- userTokenX: this.ix.keys[7].pubkey,
831
- userTokenY: this.ix.keys[8].pubkey,
832
- tokenXMint: this.ix.keys[9].pubkey,
833
- tokenYMint: this.ix.keys[10].pubkey,
834
- tokenProgram: this.ix.keys[11].pubkey,
835
- eventAuthority: this.ix.keys[12].pubkey,
836
- meteoraDlmmProgram: this.ix.keys[13].pubkey,
837
- ownerFeeX,
838
- ownerFeeY,
839
- }).instruction();
840
- // @ts-ignore
841
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
842
- .iyfExtensionExecute(claimFeeIx.data)
843
- .accounts({
844
- farm,
845
- userPda,
846
- authority,
847
- iyfProgram,
848
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
849
- })
850
- .remainingAccounts([
851
- claimFeeIx.keys[4],
852
- claimFeeIx.keys[5],
853
- claimFeeIx.keys[6],
854
- claimFeeIx.keys[7],
855
- claimFeeIx.keys[8],
856
- claimFeeIx.keys[9],
857
- claimFeeIx.keys[10],
858
- claimFeeIx.keys[11],
859
- claimFeeIx.keys[12],
860
- claimFeeIx.keys[13],
861
- claimFeeIx.keys[14],
862
- claimFeeIx.keys[15],
863
- claimFeeIx.keys[16],
864
- claimFeeIx.keys[17],
865
- claimFeeIx.keys[18],
866
- ])
867
- .instruction();
868
- return ix;
869
- });
870
- }
871
- /**
872
- * Overrides default add hawksight cpi to use meteoraDlmmClaimFee instead of meteoraDynamicCpi
873
- */
874
- addHawksightCpi() {
875
- return __awaiter(this, void 0, void 0, function* () {
876
- // Get token mints X and Y
877
- const [tokenXMint, tokenYMint] = this.getMints();
878
- const tokenXMintInfo = AccountCache_1.AccountCache.get(tokenXMint);
879
- const tokenYMintInfo = AccountCache_1.AccountCache.get(tokenYMint);
880
- if (!(!!tokenXMintInfo && !!tokenYMintInfo)) {
881
- throw new Error("Unexpected error: Mint X or Y not found in cache.");
882
- }
883
- // Generate owner fee X and Y ATA
884
- const ownerFeeX = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenXMint, tokenXMintInfo.info.owner);
885
- const ownerFeeY = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenYMint, tokenYMintInfo.info.owner);
886
- // Generate claim fee instruction
887
- // @ts-ignore
888
- const ix = yield this.generateMeteoraDlmmClaimFeeIx(ownerFeeX, ownerFeeY);
889
- // Override the instruction
890
- this.ix.programId = ix.programId;
891
- this.ix.data = ix.data;
892
- this.ix.keys = ix.keys;
893
- });
894
- }
895
- }
896
- /**
897
- * Enables the claiming of fees generated from transactions within a blockchain protocol.
898
- */
899
- /**
900
- * Enables the claiming of fees generated from transactions within a blockchain protocol.
901
- */
902
- class ClaimFee2 extends ClaimFee {
903
- /**
904
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
905
- *
906
- * @param ix The core transaction instruction.
907
- * @param userPda The user's program-derived address (PDA) as a public key.
908
- * @param authority The authority public key that has signing capabilities over the transaction.
909
- */
910
- constructor(ix, userPda, authority, opt, sighash = util.sighash("claim_fee2", undefined, true), label, classification) {
911
- super(ix, userPda, authority, opt, sighash, label, classification);
912
- }
913
- getMints() {
914
- return [
915
- this.ix.keys[7].pubkey,
916
- this.ix.keys[8].pubkey,
917
- ];
918
- }
919
- replaceSigner() {
920
- this.ix.keys[2].pubkey = this.userPda;
921
- this.ix.keys[2].isSigner = false;
922
- }
923
- replaceTokenInputs(tokenA, tokenB) {
924
- this.ix.keys[5].pubkey = tokenA;
925
- this.ix.keys[6].pubkey = tokenB;
926
- }
927
- generateMeteoraDlmmClaimFeeIx(ownerFeeX, ownerFeeY) {
928
- return __awaiter(this, void 0, void 0, function* () {
929
- // Common parameters
930
- const userPda = this.userPda;
931
- const authority = this.authority;
932
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
933
- const minBinId = this.ix.data.readInt32LE(8);
934
- const maxBinId = this.ix.data.readInt32LE(12);
935
- const remainingAccountsInfo = this.ix.data.subarray(16);
936
- // Generate IX via extension contract
937
- // @ts-ignore
938
- const claimFeeIx = yield anchor_1.Anchor.instance().iyfExtension.methods
939
- .meteoraDlmmClaimFee2(minBinId, maxBinId, remainingAccountsInfo)
940
- .accounts({
941
- userPda,
942
- meteoraDlmmProgram: this.ix.keys[13].pubkey,
943
- lbPair: this.ix.keys[0].pubkey,
944
- position: this.ix.keys[1].pubkey,
945
- reserveX: this.ix.keys[3].pubkey,
946
- reserveY: this.ix.keys[4].pubkey,
947
- userTokenX: this.ix.keys[5].pubkey,
948
- userTokenY: this.ix.keys[6].pubkey,
949
- tokenXMint: this.ix.keys[7].pubkey,
950
- tokenYMint: this.ix.keys[8].pubkey,
951
- tokenProgramX: this.ix.keys[9].pubkey,
952
- tokenProgramY: this.ix.keys[10].pubkey,
953
- memoProgram: this.ix.keys[11].pubkey,
954
- eventAuthority: this.ix.keys[12].pubkey,
955
- ownerFeeX,
956
- ownerFeeY,
957
- }).remainingAccounts(this.ix.keys.slice(14)).instruction();
958
- const sighash = util.sighash("meteora_dlmm_claim_fee_2");
959
- claimFeeIx.data.set(sighash, 0);
960
- // @ts-ignore
961
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
962
- .iyfExtensionExecuteV2(claimFeeIx.data)
963
- .accounts({
964
- userPda,
965
- authority,
966
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
967
- })
968
- .remainingAccounts(claimFeeIx.keys.slice(2))
969
- .instruction();
970
- return ix;
971
- });
972
- }
973
- }
974
- /**
975
- * Manages the claiming of rewards in blockchain operations, typically associated with staking or similar activities.
976
- */
977
- class ClaimReward extends HawksightMeteoraCpi {
978
- /**
979
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
980
- *
981
- * @param ix The core transaction instruction.
982
- * @param userPda The user's program-derived address (PDA) as a public key.
983
- * @param authority The authority public key that has signing capabilities over the transaction.
984
- */
985
- constructor(ix, userPda, authority, opt, sighash = util.sighash("ClaimReward"), label, classification) {
986
- super(ix, userPda, authority, sighash, opt, label, classification);
987
- }
988
- getMint() {
989
- return this.ix.keys[6].pubkey;
990
- }
991
- replaceSigner() {
992
- this.ix.keys[4].pubkey = this.userPda;
993
- this.ix.keys[4].isSigner = false;
994
- }
995
- replaceTokenInputs(token) {
996
- this.ix.keys[5].pubkey = token;
997
- }
998
- /**
999
- * Adjusts transaction keys to facilitate the claiming of rewards.
1000
- */
1001
- replace() {
1002
- var _a;
1003
- this.replaceSigner();
1004
- const rewardMint = this.getMint();
1005
- const mintInfo = AccountCache_1.AccountCache.get(rewardMint);
1006
- if (!!mintInfo) {
1007
- const tokenProgram = mintInfo.info.owner;
1008
- // Adjust by token type
1009
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
1010
- if (pdaTokenType === types_1.TokenType.LTA) {
1011
- this.replaceTokenInputs(util.generateLimitToken(this.userPda, rewardMint));
1012
- }
1013
- else if (pdaTokenType === types_1.TokenType.STA) {
1014
- this.replaceTokenInputs(util.generateUserPdaStorageAccount(this.userPda, rewardMint));
1015
- }
1016
- else {
1017
- this.replaceTokenInputs(util.generateAta(this.userPda, rewardMint, tokenProgram));
1018
- }
1019
- }
1020
- else {
1021
- throw new Error("Unexpected error: Mint not found in cache.");
1022
- }
1023
- }
1024
- generateMeteoraDlmmClaimRewardIx(ownerFee) {
1025
- return __awaiter(this, void 0, void 0, function* () {
1026
- // Common parameters
1027
- const userPda = this.userPda;
1028
- const authority = this.authority;
1029
- // Get reward index from parameter
1030
- const rewardIndex = new bn_js_1.default(this.ix.data.readBigInt64LE(8).toString());
1031
- // Generate IX via extension contract
1032
- // @ts-ignore
1033
- const claimReward = yield anchor_1.Anchor.instance().iyfExtension.methods
1034
- .meteoraDlmmClaimReward2(rewardIndex)
1035
- .accounts({
1036
- userPda,
1037
- authority,
1038
- meteoraDlmmProgram: this.ix.keys[10].pubkey,
1039
- lbPair: this.ix.keys[0].pubkey,
1040
- position: this.ix.keys[1].pubkey,
1041
- rewardVault: this.ix.keys[3].pubkey,
1042
- rewardMint: this.ix.keys[4].pubkey,
1043
- userTokenAccount: this.ix.keys[5].pubkey,
1044
- tokenProgram: this.ix.keys[6].pubkey,
1045
- memoProgram: this.ix.keys[7].pubkey,
1046
- eventAuthority: this.ix.keys[8].pubkey,
1047
- program: this.ix.keys[9].pubkey,
1048
- ownerFee,
1049
- })
1050
- .remainingAccounts(this.ix.keys.slice(11))
1051
- .instruction();
1052
- // Instruction via main hawksight contract
1053
- // @ts-ignore
1054
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
1055
- .iyfExtensionExecuteV2(claimReward.data)
1056
- .accounts({
1057
- userPda,
1058
- authority,
1059
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
1060
- })
1061
- .remainingAccounts(claimReward.keys.slice(2))
1062
- .instruction();
1063
- return ix;
1064
- });
1065
- }
1066
- /**
1067
- * Overrides default add hawksight cpi to use meteoraDlmmClaimReward instead of meteoraDynamicCpi
1068
- */
1069
- addHawksightCpi() {
1070
- return __awaiter(this, void 0, void 0, function* () {
1071
- // Get token mint
1072
- const rewardMint = this.getMint();
1073
- const mintInfo = AccountCache_1.AccountCache.get(rewardMint);
1074
- if (!mintInfo) {
1075
- throw new Error("Unexpected error: Reward mint not found in cache.");
1076
- }
1077
- // Generate owner fee X and Y ATA
1078
- const ownerFee = util.generateAta(addresses_1.SITE_FEE_OWNER, rewardMint, mintInfo.info.owner);
1079
- // Create claim reward instruction
1080
- // @ts-ignore
1081
- const ix = yield this.generateMeteoraDlmmClaimRewardIx(ownerFee);
1082
- // Override the instruction
1083
- this.ix.programId = ix.programId;
1084
- this.ix.data = ix.data;
1085
- this.ix.keys = ix.keys;
1086
- });
1087
- }
1088
- }
1089
- /**
1090
- * Manages the claiming of rewards in blockchain operations, typically associated with staking or similar activities.
1091
- */
1092
- class ClaimReward2 extends ClaimReward {
1093
- /**
1094
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
1095
- *
1096
- * @param ix The core transaction instruction.
1097
- * @param userPda The user's program-derived address (PDA) as a public key.
1098
- * @param authority The authority public key that has signing capabilities over the transaction.
1099
- */
1100
- constructor(ix, userPda, authority, opt, sighash = util.sighash("claim_reward2", undefined, true), label, classification) {
1101
- super(ix, userPda, authority, opt, sighash, label, classification);
1102
- }
1103
- getMint() {
1104
- return this.ix.keys[4].pubkey;
1105
- }
1106
- replaceSigner() {
1107
- this.ix.keys[2].pubkey = this.userPda;
1108
- this.ix.keys[2].isSigner = false;
1109
- }
1110
- replaceTokenInputs(token) {
1111
- this.ix.keys[5].pubkey = token;
1112
- }
1113
- generateMeteoraDlmmClaimRewardIx(ownerFee) {
1114
- return __awaiter(this, void 0, void 0, function* () {
1115
- // Common parameters
1116
- const userPda = this.userPda;
1117
- const authority = this.authority;
1118
- // Get reward index from parameter
1119
- const rewardIndex = Number(this.ix.data.readBigInt64LE(8).toString());
1120
- // New meteora parameters
1121
- const minBinId = this.ix.data.readInt32LE(16);
1122
- const maxBinId = this.ix.data.readInt32LE(20);
1123
- const remainingAccountsInfo = this.ix.data.subarray(24);
1124
- // Generate IX via extension contract
1125
- // @ts-ignore
1126
- const claimReward = yield anchor_1.Anchor.instance().iyfExtension.methods
1127
- .meteoraDlmmClaimReward2(rewardIndex, minBinId, maxBinId, remainingAccountsInfo)
1128
- .accounts({
1129
- userPda,
1130
- authority,
1131
- lbPair: this.ix.keys[0].pubkey,
1132
- position: this.ix.keys[1].pubkey,
1133
- rewardVault: this.ix.keys[3].pubkey,
1134
- rewardMint: this.ix.keys[4].pubkey,
1135
- userTokenAccount: this.ix.keys[5].pubkey,
1136
- tokenProgram: this.ix.keys[6].pubkey,
1137
- memoProgram: this.ix.keys[7].pubkey,
1138
- eventAuthority: this.ix.keys[8].pubkey,
1139
- meteoraDlmmProgram: this.ix.keys[9].pubkey,
1140
- ownerFee,
1141
- })
1142
- .remainingAccounts(this.ix.keys.slice(10))
1143
- .instruction();
1144
- const sighash = util.sighash("meteora_dlmm_claim_reward_2");
1145
- claimReward.data.set(sighash, 0);
1146
- // Instruction via main hawksight contract
1147
- // @ts-ignore
1148
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
1149
- .iyfExtensionExecuteV2(claimReward.data)
1150
- .accounts({
1151
- userPda,
1152
- authority,
1153
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
1154
- })
1155
- .remainingAccounts(claimReward.keys.slice(2))
1156
- .instruction();
1157
- return ix;
1158
- });
1159
- }
1160
- }
1161
- /**
1162
- * Handles the closure of a position within a blockchain transaction.
1163
- */
1164
- class ClosePosition extends HawksightMeteoraCpi {
1165
- /**
1166
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
1167
- *
1168
- * @param ix The core transaction instruction.
1169
- * @param userPda The user's program-derived address (PDA) as a public key.
1170
- * @param authority The authority public key that has signing capabilities over the transaction.
1171
- */
1172
- constructor(ix, userPda, authority, opt, sighash = util.sighash("ClosePosition"), label, classification) {
1173
- super(ix, userPda, authority, sighash, opt, label, classification);
1174
- }
1175
- replaceSigner() {
1176
- this.ix.keys[4].pubkey = this.userPda;
1177
- this.ix.keys[4].isSigner = false;
1178
- }
1179
- replaceRefund() {
1180
- this.ix.keys[5].pubkey = this.authority;
1181
- }
1182
- /**
1183
- * Customizes the transaction keys to properly close a position, ensuring all relevant keys are set correctly.
1184
- */
1185
- replace() {
1186
- this.replaceSigner();
1187
- this.replaceRefund();
1188
- }
1189
- }
1190
- /**
1191
- * Handles the closure of a position within a blockchain transaction.
1192
- */
1193
- class ClosePosition2 extends ClosePosition {
1194
- /**
1195
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
1196
- *
1197
- * @param ix The core transaction instruction.
1198
- * @param userPda The user's program-derived address (PDA) as a public key.
1199
- * @param authority The authority public key that has signing capabilities over the transaction.
1200
- */
1201
- constructor(ix, userPda, authority, opt, sighash = util.sighash("close_position2", undefined, true), label, classification) {
1202
- super(ix, userPda, authority, opt, sighash, label, classification);
1203
- }
1204
- replaceSigner() {
1205
- this.ix.keys[1].pubkey = this.userPda;
1206
- this.ix.keys[1].isSigner = false;
1207
- }
1208
- replaceRefund() {
1209
- this.ix.keys[2].pubkey = this.authority;
1210
- }
1211
- }
1212
- /**
1213
- * Handles the closure of a position within a blockchain transaction.
1214
- */
1215
- class ClosePositionIfEmpty extends ClosePosition2 {
1216
- /**
1217
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
1218
- *
1219
- * @param ix The core transaction instruction.
1220
- * @param userPda The user's program-derived address (PDA) as a public key.
1221
- * @param authority The authority public key that has signing capabilities over the transaction.
1222
- */
1223
- constructor(ix, userPda, authority, opt, sighash = util.sighash("ClosePositionIfEmpty"), label, classification) {
1224
- super(ix, userPda, authority, opt, sighash, label, classification);
1225
- }
1226
- }
1227
- class HawksightMeteoraAutomationCpi {
1228
- /**
1229
- * Instruction
1230
- */
1231
- get ix() { return this._ix; }
1232
- /**
1233
- * Constructs an instance of HawksightMeteoraCpi with the necessary transaction parameters.
1234
- *
1235
- * @param ix The core transaction instruction.
1236
- * @param userPda The user's program-derived address (PDA) as a public key.
1237
- * @param authority The authority public key that has signing capabilities over the transaction.
1238
- * @param sighash A Buffer containing the sighash used for matching the transaction instruction.
1239
- */
1240
- constructor(_ix, userPda, authority, sighash, opt) {
1241
- this._ix = _ix;
1242
- this.userPda = userPda;
1243
- this.authority = authority;
1244
- this.sighash = sighash;
1245
- this.opt = opt;
1246
- }
1247
- /**
1248
- * Factory method to create and link a chain of CPIs starting from `InitializePosition`.
1249
- * Subsequent CPIs include operations like adding liquidity, removing liquidity, claiming fees, and rewards, and closing the position.
1250
- * @param ix The initial transaction instruction.
1251
- * @param userPda The user's public key.
1252
- * @param authority The authority public key.
1253
- * @returns The first CPI in the chain.
1254
- */
1255
- static factory(ix, userPda, authority, opt) {
1256
- const chain = new InitializePositionAutomation(ix, userPda, authority, opt);
1257
- chain
1258
- .next(new AddLiquidityByStrategyAutomation(ix, userPda, authority, opt))
1259
- .next(new AddLiquidityByWeightAutomation(ix, userPda, authority, opt))
1260
- .next(new AddLiquidityOneSideAutomation(ix, userPda, authority, opt))
1261
- .next(new RemoveLiquidityAutomation(ix, userPda, authority, util.sighash("RemoveLiquidity"), opt))
1262
- .next(new RemoveLiquidityByRangeAutomation(ix, userPda, authority, opt))
1263
- .next(new ClaimFeeAutomation(ix, userPda, authority, opt))
1264
- .next(new ClaimRewardAutomation(ix, userPda, authority, opt))
1265
- .next(new ClosePositionAutomation(ix, userPda, authority, opt))
1266
- .next(new ClosePositionIfEmptyAutomation(ix, userPda, authority, opt))
1267
- .next(new MeteoraDlmmClaimFee2Automation(ix, userPda, authority, opt))
1268
- .next(new MeteoraDlmmClaimReward2Automation(ix, userPda, authority, opt))
1269
- .next(new MeteoraDlmmDeposit2Automation(ix, userPda, authority, opt))
1270
- .next(new MeteoraDlmmWithdraw2Automation(ix, userPda, authority, opt));
1271
- return chain;
1272
- }
1273
- /**
1274
- * Retrieves and possibly modifies the transaction instruction based on matching conditions.
1275
- * If a matching CPI is found in the chain, it performs modifications and returns the updated instruction.
1276
- * @returns The (possibly modified) transaction instruction.
1277
- */
1278
- getInstruction() {
1279
- return __awaiter(this, void 0, void 0, function* () {
1280
- const matchInstance = this.sighashMatch();
1281
- if (this.programIdMatch() && matchInstance !== undefined) {
1282
- matchInstance.replace();
1283
- yield matchInstance.replaceCpi();
1284
- return matchInstance.ix;
1285
- }
1286
- return this.ix;
1287
- });
1288
- }
1289
- /**
1290
- * Adds a subsequent CPI to the chain.
1291
- * @param next The next CPI object to link.
1292
- * @returns The added CPI object, allowing for method chaining.
1293
- */
1294
- next(next) {
1295
- this._next = next;
1296
- return this._next;
1297
- }
1298
- /**
1299
- * Recursively checks this CPI and subsequent ones for a sighash match in the transaction data.
1300
- * @returns The first CPI instance in the chain that matches the sighash, or undefined if no match is found.
1301
- */
1302
- sighashMatch() {
1303
- try {
1304
- const match = util.sighashMatch(this.ix.data, this.sighash);
1305
- if (match) {
1306
- return this;
1307
- }
1308
- else if (this._next !== undefined) {
1309
- return this._next.sighashMatch();
1310
- }
1311
- }
1312
- catch (_a) {
1313
- if (this._next !== undefined) {
1314
- return this._next.sighashMatch();
1315
- }
1316
- }
1317
- return undefined;
1318
- }
1319
- /**
1320
- * Checks if the program ID of the transaction instruction matches the expected program ID.
1321
- * @returns True if the program ID matches, otherwise false.
1322
- */
1323
- programIdMatch() {
1324
- return this.ix.programId.equals(addresses_1.METEORA_DLMM_PROGRAM);
1325
- }
1326
- }
1327
- /**
1328
- * Handles the initialization of a position in a blockchain transaction.
1329
- * This class extends the HawksightMeteoraCpi and provides specific logic to modify the transaction instruction for position initialization.
1330
- */
1331
- class InitializePositionAutomation extends HawksightMeteoraAutomationCpi {
1332
- /**
1333
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
1334
- *
1335
- * @param ix The core transaction instruction.
1336
- * @param userPda The user's program-derived address (PDA) as a public key.
1337
- * @param authority The authority public key that has signing capabilities over the transaction.
1338
- */
1339
- constructor(ix, userPda, authority, opt) {
1340
- super(ix, userPda, authority, util.sighash("InitializePosition"), opt);
1341
- }
1342
- /**
1343
- * Modifies the transaction keys to set the correct public keys for an initial position setup.
1344
- */
1345
- replace() {
1346
- this._ix.keys[0].pubkey = this.authority;
1347
- this._ix.keys[3].pubkey = this.userPda;
1348
- this._ix.keys[3].isSigner = false;
1349
- }
1350
- /**
1351
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
1352
- */
1353
- replaceCpi() {
1354
- return __awaiter(this, void 0, void 0, function* () {
1355
- var _a, _b;
1356
- // Common parameters
1357
- const farm = addresses_1.USDC_FARM;
1358
- const userPda = this.userPda;
1359
- const authority = this.authority;
1360
- const iyfProgram = addresses_1.IYF_MAIN;
1361
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
1362
- // Generate IX via extension contract
1363
- const data = this.ix.data.subarray(8);
1364
- const lowerBinId = data.subarray(0, 4).readInt32LE();
1365
- const width = data.subarray(4).readInt32LE();
1366
- let remainingAccounts = [];
1367
- let fuelAccount;
1368
- if ((_b = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.fuelAccount) {
1369
- fuelAccount = util.generateFuelAccount(this.authority);
1370
- remainingAccounts.push({
1371
- pubkey: fuelAccount,
1372
- isSigner: false,
1373
- isWritable: true,
1374
- });
1375
- }
1376
- // @ts-ignore
1377
- const initializePositionIx = yield anchor_1.Anchor.instance().iyfExtension.methods
1378
- .meteoraDlmmInitializePositionAutomation(lowerBinId, width)
1379
- .accounts({
1380
- farm,
1381
- userPda,
1382
- authority,
1383
- iyfProgram,
1384
- hawksightAuthority,
1385
- position: this.ix.keys[1].pubkey,
1386
- lbPair: this.ix.keys[2].pubkey,
1387
- systemProgram: this.ix.keys[4].pubkey,
1388
- rent: this.ix.keys[5].pubkey,
1389
- eventAuthority: this.ix.keys[6].pubkey,
1390
- meteoraDlmmProgram: this.ix.keys[7].pubkey,
1391
- }).remainingAccounts(remainingAccounts).instruction();
1392
- // Instruction via main hawksight contract
1393
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
1394
- .iyfExtensionExecute(initializePositionIx.data)
1395
- .accounts({
1396
- farm,
1397
- userPda,
1398
- authority,
1399
- iyfProgram,
1400
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
1401
- })
1402
- .remainingAccounts([
1403
- initializePositionIx.keys[4],
1404
- initializePositionIx.keys[5],
1405
- initializePositionIx.keys[6],
1406
- initializePositionIx.keys[7],
1407
- initializePositionIx.keys[8],
1408
- initializePositionIx.keys[9],
1409
- initializePositionIx.keys[10],
1410
- ...remainingAccounts,
1411
- ])
1412
- .instruction();
1413
- // Override the instruction
1414
- this._ix = ix;
1415
- });
1416
- }
1417
- }
1418
- /**
1419
- * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
1420
- * This class is designed for blockchain operations that manage liquidity pools.
1421
- *
1422
- * PS: Not used by meteora API. It uses addLiquidityByStrategy instead so it's expected that this won't be called.
1423
- */
1424
- class AddLiquidityByWeightAutomation extends HawksightMeteoraAutomationCpi {
1425
- /**
1426
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
1427
- *
1428
- * @param ix The core transaction instruction.
1429
- * @param userPda The user's program-derived address (PDA) as a public key.
1430
- * @param authority The authority public key that has signing capabilities over the transaction.
1431
- */
1432
- constructor(ix, userPda, authority, opt) {
1433
- super(ix, userPda, authority, util.sighash("AddLiquidityByWeight"), opt);
1434
- }
1435
- /**
1436
- * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
1437
- */
1438
- replace() {
1439
- this._ix.keys[11].pubkey = this.userPda;
1440
- this._ix.keys[11].isSigner = false;
1441
- }
1442
- /**
1443
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
1444
- */
1445
- replaceCpi() {
1446
- return __awaiter(this, void 0, void 0, function* () {
1447
- var _a;
1448
- // Common parameters
1449
- const farm = addresses_1.USDC_FARM;
1450
- const userPda = this.userPda;
1451
- const authority = this.authority;
1452
- const iyfProgram = addresses_1.IYF_MAIN;
1453
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
1454
- // Get token mints X and Y
1455
- const tokenXMint = this.ix.keys[7].pubkey;
1456
- const tokenYMint = this.ix.keys[8].pubkey;
1457
- // Generate IX via extension contract
1458
- const data = this.ix.data.subarray(8);
1459
- const activeId = data.subarray(16, 20).readInt32LE();
1460
- const maxActiveBinSlippage = data.subarray(20, 24).readInt32LE();
1461
- const strategyParametersMinBinId = data.subarray(24, 28).readInt32LE();
1462
- const strategyParametersMaxBinId = data.subarray(28, 32).readInt32LE();
1463
- const strategyParametersStrategyType = data[32];
1464
- const strategyParametersParameters = Array.from(data.subarray(33));
1465
- const tokenXMintInfo = AccountCache_1.AccountCache.get(tokenXMint);
1466
- const tokenYMintInfo = AccountCache_1.AccountCache.get(tokenYMint);
1467
- if (!(!!tokenXMintInfo && !!tokenYMintInfo)) {
1468
- throw new Error("Unexpected error: Mint X or Y not found in cache.");
1469
- }
1470
- // Adjust by token type
1471
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
1472
- if (pdaTokenType === types_1.TokenType.LTA) {
1473
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
1474
- this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
1475
- }
1476
- else if (pdaTokenType === types_1.TokenType.STA) {
1477
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
1478
- this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
1479
- }
1480
- else {
1481
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey, tokenXMintInfo.info.owner);
1482
- this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey, tokenYMintInfo.info.owner);
1483
- }
1484
- // @ts-ignore
1485
- const depositIx = yield anchor_1.Anchor.instance().iyfExtension.methods
1486
- .meteoraDlmmDepositAutomation(activeId, maxActiveBinSlippage, strategyParametersMinBinId, strategyParametersMaxBinId, strategyParametersStrategyType, strategyParametersParameters)
1487
- .accounts({
1488
- farm,
1489
- userPda,
1490
- authority,
1491
- iyfProgram,
1492
- hawksightAuthority,
1493
- position: this.ix.keys[0].pubkey,
1494
- lbPair: this.ix.keys[1].pubkey,
1495
- binArrayBitmapExtension: this.ix.keys[2].pubkey,
1496
- userTokenX: this.ix.keys[3].pubkey,
1497
- userTokenY: this.ix.keys[4].pubkey,
1498
- reserveX: this.ix.keys[5].pubkey,
1499
- reserveY: this.ix.keys[6].pubkey,
1500
- tokenXMint,
1501
- tokenYMint,
1502
- binArrayLower: this.ix.keys[9].pubkey,
1503
- binArrayUpper: this.ix.keys[10].pubkey,
1504
- tokenXProgram: this.ix.keys[12].pubkey,
1505
- tokenYProgram: this.ix.keys[13].pubkey,
1506
- eventAuthority: this.ix.keys[14].pubkey,
1507
- meteoraDlmmProgram: this.ix.keys[15].pubkey,
1508
- }).instruction();
1509
- // Instruction via main hawksight contract
1510
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
1511
- .iyfExtensionExecute(depositIx.data)
1512
- .accounts({
1513
- farm,
1514
- userPda,
1515
- authority,
1516
- iyfProgram,
1517
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
1518
- })
1519
- .remainingAccounts([
1520
- depositIx.keys[4],
1521
- depositIx.keys[5],
1522
- depositIx.keys[6],
1523
- depositIx.keys[7],
1524
- depositIx.keys[8],
1525
- depositIx.keys[9],
1526
- depositIx.keys[10],
1527
- depositIx.keys[11],
1528
- depositIx.keys[12],
1529
- depositIx.keys[13],
1530
- depositIx.keys[14],
1531
- depositIx.keys[15],
1532
- depositIx.keys[16],
1533
- depositIx.keys[17],
1534
- depositIx.keys[18],
1535
- depositIx.keys[19],
1536
- ])
1537
- .instruction();
1538
- // Override the instruction
1539
- this._ix = ix;
1540
- });
1541
- }
1542
- }
1543
- /**
1544
- * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
1545
- * This class is designed for blockchain operations that manage liquidity pools.
1546
- */
1547
- class AddLiquidityByStrategyAutomation extends HawksightMeteoraAutomationCpi {
1548
- /**
1549
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
1550
- *
1551
- * @param ix The core transaction instruction.
1552
- * @param userPda The user's program-derived address (PDA) as a public key.
1553
- * @param authority The authority public key that has signing capabilities over the transaction.
1554
- */
1555
- constructor(ix, userPda, authority, opt) {
1556
- super(ix, userPda, authority, util.sighash("AddLiquidityByStrategy"), opt);
1557
- }
1558
- /**
1559
- * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
1560
- */
1561
- replace() {
1562
- // Note: Essentially not needed due to `replaceCpi` function that overrides the instruction.
1563
- // Thus, commenting out the contents of `replace` function.
1564
- // this._ix.keys[11].pubkey = this.userPda;
1565
- // this._ix.keys[11].isSigner = false;
1566
- }
1567
- /**
1568
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
1569
- */
1570
- replaceCpi() {
1571
- return __awaiter(this, void 0, void 0, function* () {
1572
- var _a, _b, _c;
1573
- const generator = new SimpleIxGenerator_1.SimpleIxGenerator();
1574
- // Common parameters
1575
- const authority = this.authority;
1576
- // Get token mints X and Y
1577
- const tokenXMint = this.ix.keys[7].pubkey;
1578
- const tokenYMint = this.ix.keys[8].pubkey;
1579
- // Generate IX via extension contract
1580
- const data = this.ix.data.subarray(8);
1581
- const activeId = data.subarray(16, 20).readInt32LE();
1582
- const maxActiveBinSlippage = data.subarray(20, 24).readInt32LE();
1583
- const strategyParametersMinBinId = data.subarray(24, 28).readInt32LE();
1584
- const strategyParametersMaxBinId = data.subarray(28, 32).readInt32LE();
1585
- const strategyParametersStrategyType = data[32];
1586
- const strategyParametersParameters = Array.from(data.subarray(33));
1587
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
1588
- const withAmount = (_c = (_b = this.opt) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.withAmount;
1589
- if (withAmount !== undefined) {
1590
- const userTokenXAmount = withAmount.userTokenXAmount;
1591
- const userTokenYAmount = withAmount.userTokenYAmount;
1592
- if (userTokenXAmount === undefined) {
1593
- throw new Error("opt.params.withAmount.userTokenXAmount is required");
1594
- }
1595
- if (userTokenYAmount === undefined) {
1596
- throw new Error("opt.params.withAmount.userTokenYAmount is required");
1597
- }
1598
- const ix = yield generator.meteoraDlmm.depositWithAmountAutomation(anchor_1.Anchor.instance().connection, {
1599
- userWallet: authority,
1600
- lbPair: this.ix.keys[1].pubkey,
1601
- position: this.ix.keys[0].pubkey,
1602
- tokenXMint,
1603
- tokenYMint,
1604
- binArrayBitmapExtension: this.ix.keys[2].pubkey,
1605
- binArrayLower: this.ix.keys[9].pubkey,
1606
- binArrayUpper: this.ix.keys[10].pubkey,
1607
- tokenXProgram: this.ix.keys[12].pubkey,
1608
- tokenYProgram: this.ix.keys[13].pubkey,
1609
- reserveX: this.ix.keys[5].pubkey,
1610
- reserveY: this.ix.keys[6].pubkey,
1611
- activeId,
1612
- maxActiveBinSlippage,
1613
- strategyParametersMinBinId,
1614
- strategyParametersMaxBinId,
1615
- strategyParametersStrategyType,
1616
- strategyParametersParameters,
1617
- userTokenXAmount,
1618
- userTokenYAmount,
1619
- tokenType: pdaTokenType,
1620
- });
1621
- // Override the instruction
1622
- this._ix = ix;
1623
- return;
1624
- }
1625
- const tokenXMintInfo = AccountCache_1.AccountCache.get(tokenXMint);
1626
- const tokenYMintInfo = AccountCache_1.AccountCache.get(tokenYMint);
1627
- if (!(!!tokenXMintInfo && !!tokenYMintInfo)) {
1628
- throw new Error("Unexpected error: Mint X or Y not found in cache.");
1629
- }
1630
- // Adjust by token type
1631
- if (pdaTokenType === types_1.TokenType.LTA) {
1632
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
1633
- this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
1634
- }
1635
- else if (pdaTokenType === types_1.TokenType.STA) {
1636
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
1637
- this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
1638
- }
1639
- else {
1640
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey, tokenXMintInfo.info.owner);
1641
- this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey, tokenYMintInfo.info.owner);
1642
- }
1643
- const ix = yield generator.meteoraDlmm.depositAutomation(anchor_1.Anchor.instance().connection, {
1644
- userWallet: authority,
1645
- lbPair: this.ix.keys[1].pubkey,
1646
- position: this.ix.keys[0].pubkey,
1647
- tokenXMint,
1648
- tokenYMint,
1649
- binArrayBitmapExtension: this.ix.keys[2].pubkey,
1650
- binArrayLower: this.ix.keys[9].pubkey,
1651
- binArrayUpper: this.ix.keys[10].pubkey,
1652
- tokenXProgram: this.ix.keys[12].pubkey,
1653
- tokenYProgram: this.ix.keys[13].pubkey,
1654
- reserveX: this.ix.keys[5].pubkey,
1655
- reserveY: this.ix.keys[6].pubkey,
1656
- activeId,
1657
- maxActiveBinSlippage,
1658
- strategyParametersMinBinId,
1659
- strategyParametersMaxBinId,
1660
- strategyParametersStrategyType,
1661
- strategyParametersParameters,
1662
- tokenType: pdaTokenType,
1663
- });
1664
- // Override the instruction
1665
- this._ix = ix;
1666
- });
1667
- }
1668
- }
1669
- /**
1670
- * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
1671
- * This class is designed for blockchain operations that manage liquidity pools.
1672
- */
1673
- class AddLiquidityOneSideAutomation extends HawksightMeteoraAutomationCpi {
1674
- /**
1675
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
1676
- *
1677
- * @param ix The core transaction instruction.
1678
- * @param userPda The user's program-derived address (PDA) as a public key.
1679
- * @param authority The authority public key that has signing capabilities over the transaction.
1680
- */
1681
- constructor(ix, userPda, authority, opt) {
1682
- super(ix, userPda, authority, util.sighash("AddLiquidityByStrategyOneSide"), opt);
1683
- }
1684
- /**
1685
- * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
1686
- */
1687
- replace() {
1688
- this._ix.keys[8].pubkey = this.userPda;
1689
- this._ix.keys[8].isSigner = false;
1690
- }
1691
- /**
1692
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
1693
- */
1694
- replaceCpi() {
1695
- return __awaiter(this, void 0, void 0, function* () {
1696
- var _a;
1697
- // Common parameters
1698
- const farm = addresses_1.USDC_FARM;
1699
- const userPda = this.userPda;
1700
- const authority = this.authority;
1701
- const iyfProgram = addresses_1.IYF_MAIN;
1702
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
1703
- const mintInfo = AccountCache_1.AccountCache.get(this.ix.keys[5].pubkey);
1704
- if (!mintInfo) {
1705
- throw new Error("Unexpected error: Mint not found in cache.");
1706
- }
1707
- // Adjust by token type
1708
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
1709
- if (pdaTokenType === types_1.TokenType.LTA) {
1710
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
1711
- }
1712
- else if (pdaTokenType === types_1.TokenType.STA) {
1713
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
1714
- }
1715
- else {
1716
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[5].pubkey, mintInfo.info.owner);
1717
- }
1718
- // Generate IX via extension contract
1719
- // @ts-ignore
1720
- const depositIx = yield anchor_1.Anchor.instance().iyfExtension.methods
1721
- .meteoraDlmmOneSideDeposit(this.ix.data.subarray(8))
1722
- .accounts({
1723
- farm,
1724
- userPda,
1725
- authority,
1726
- iyfProgram,
1727
- hawksightAuthority,
1728
- position: this.ix.keys[0].pubkey,
1729
- lbPair: this.ix.keys[1].pubkey,
1730
- binArrayBitmapExtension: this.ix.keys[2].pubkey,
1731
- userToken: this.ix.keys[3].pubkey,
1732
- reserve: this.ix.keys[4].pubkey,
1733
- tokenMint: this.ix.keys[5].pubkey,
1734
- binArrayLower: this.ix.keys[6].pubkey,
1735
- binArrayUpper: this.ix.keys[7].pubkey,
1736
- tokenProgram: this.ix.keys[9].pubkey,
1737
- eventAuthority: this.ix.keys[10].pubkey,
1738
- meteoraDlmmProgram: this.ix.keys[11].pubkey,
1739
- }).instruction();
1740
- // Instruction via main hawksight contract
1741
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
1742
- .iyfExtensionExecute(depositIx.data)
1743
- .accounts({
1744
- farm,
1745
- userPda,
1746
- authority,
1747
- iyfProgram,
1748
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
1749
- })
1750
- .remainingAccounts([
1751
- depositIx.keys[4],
1752
- depositIx.keys[5],
1753
- depositIx.keys[6],
1754
- depositIx.keys[7],
1755
- depositIx.keys[8],
1756
- depositIx.keys[9],
1757
- depositIx.keys[10],
1758
- depositIx.keys[11],
1759
- depositIx.keys[12],
1760
- depositIx.keys[13],
1761
- depositIx.keys[14],
1762
- depositIx.keys[15],
1763
- ])
1764
- .instruction();
1765
- // Override the instruction
1766
- this._ix = ix;
1767
- });
1768
- }
1769
- }
1770
- /**
1771
- * Facilitates the removal of liquidity from a blockchain-based financial system.
1772
- */
1773
- class RemoveLiquidityAutomation extends HawksightMeteoraAutomationCpi {
1774
- /**
1775
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
1776
- *
1777
- * @param ix The core transaction instruction.
1778
- * @param userPda The user's program-derived address (PDA) as a public key.
1779
- * @param authority The authority public key that has signing capabilities over the transaction.
1780
- */
1781
- constructor(ix, userPda, authority, sighash = util.sighash("RemoveLiquidity"), opt) {
1782
- super(ix, userPda, authority, sighash, opt);
1783
- }
1784
- /**
1785
- * Customizes the transaction keys to correctly handle the removal of liquidity.
1786
- */
1787
- replace() {
1788
- this._ix.keys[11].pubkey = this.userPda;
1789
- this._ix.keys[11].isSigner = false;
1790
- }
1791
- /**
1792
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
1793
- */
1794
- replaceCpi() {
1795
- return __awaiter(this, void 0, void 0, function* () {
1796
- var _a;
1797
- // Common parameters
1798
- const farm = addresses_1.USDC_FARM;
1799
- const userPda = this.userPda;
1800
- const authority = this.authority;
1801
- const iyfProgram = addresses_1.IYF_MAIN;
1802
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
1803
- // Get token mints X and Y
1804
- const tokenXMint = this.ix.keys[7].pubkey;
1805
- const tokenYMint = this.ix.keys[8].pubkey;
1806
- const tokenXMintInfo = AccountCache_1.AccountCache.get(tokenXMint);
1807
- const tokenYMintInfo = AccountCache_1.AccountCache.get(tokenYMint);
1808
- if (!(!!tokenXMintInfo && !!tokenYMintInfo)) {
1809
- throw new Error("Unexpected error: Mint X or Y not found in cache.");
1810
- }
1811
- // Adjust by token type
1812
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
1813
- if (pdaTokenType === types_1.TokenType.LTA) {
1814
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
1815
- this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
1816
- }
1817
- else if (pdaTokenType === types_1.TokenType.STA) {
1818
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
1819
- this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
1820
- }
1821
- else {
1822
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey, tokenXMintInfo.info.owner);
1823
- this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey, tokenYMintInfo.info.owner);
1824
- }
1825
- // Generate IX via extension contract
1826
- // @ts-ignore
1827
- const withdrawIx = yield anchor_1.Anchor.instance().iyfExtension.methods
1828
- .meteoraDlmmWithdrawAutomation(this.ix.data)
1829
- .accounts({
1830
- farm,
1831
- userPda,
1832
- authority,
1833
- iyfProgram,
1834
- hawksightAuthority,
1835
- position: this.ix.keys[0].pubkey,
1836
- lbPair: this.ix.keys[1].pubkey,
1837
- binArrayBitmapExtension: new web3.PublicKey("LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo"),
1838
- userTokenX: this.ix.keys[3].pubkey,
1839
- userTokenY: this.ix.keys[4].pubkey,
1840
- reserveX: this.ix.keys[5].pubkey,
1841
- reserveY: this.ix.keys[6].pubkey,
1842
- tokenXMint,
1843
- tokenYMint,
1844
- binArrayLower: this.ix.keys[9].pubkey,
1845
- binArrayUpper: this.ix.keys[10].pubkey,
1846
- tokenXProgram: this.ix.keys[12].pubkey,
1847
- tokenYProgram: this.ix.keys[13].pubkey,
1848
- eventAuthority: this.ix.keys[14].pubkey,
1849
- meteoraDlmmProgram: this.ix.keys[15].pubkey,
1850
- }).instruction();
1851
- // Instruction via main hawksight contract
1852
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
1853
- .iyfExtensionExecute(withdrawIx.data)
1854
- .accounts({
1855
- farm,
1856
- userPda,
1857
- authority,
1858
- iyfProgram,
1859
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
1860
- })
1861
- .remainingAccounts([
1862
- withdrawIx.keys[4],
1863
- withdrawIx.keys[5],
1864
- withdrawIx.keys[6],
1865
- withdrawIx.keys[7],
1866
- withdrawIx.keys[8],
1867
- withdrawIx.keys[9],
1868
- withdrawIx.keys[10],
1869
- withdrawIx.keys[11],
1870
- withdrawIx.keys[12],
1871
- withdrawIx.keys[13],
1872
- withdrawIx.keys[14],
1873
- withdrawIx.keys[15],
1874
- withdrawIx.keys[16],
1875
- withdrawIx.keys[17],
1876
- withdrawIx.keys[18],
1877
- withdrawIx.keys[19],
1878
- ])
1879
- .instruction();
1880
- // Override the instruction
1881
- this._ix = ix;
1882
- });
1883
- }
1884
- }
1885
- /**
1886
- * Facilitates the removal of liquidity from a blockchain-based financial system.
1887
- */
1888
- class RemoveLiquidityByRangeAutomation extends RemoveLiquidityAutomation {
1889
- /**
1890
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
1891
- *
1892
- * @param ix The core transaction instruction.
1893
- * @param userPda The user's program-derived address (PDA) as a public key.
1894
- * @param authority The authority public key that has signing capabilities over the transaction.
1895
- */
1896
- constructor(ix, userPda, authority, opt) {
1897
- super(ix, userPda, authority, util.sighash("RemoveLiquidityByRange"), opt);
1898
- }
1899
- }
1900
- /**
1901
- * Enables the claiming of fees generated from transactions within a blockchain protocol.
1902
- */
1903
- class ClaimFeeAutomation extends HawksightMeteoraAutomationCpi {
1904
- /**
1905
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
1906
- *
1907
- * @param ix The core transaction instruction.
1908
- * @param userPda The user's program-derived address (PDA) as a public key.
1909
- * @param authority The authority public key that has signing capabilities over the transaction.
1910
- */
1911
- constructor(ix, userPda, authority, opt) {
1912
- super(ix, userPda, authority, util.sighash("ClaimFee"), opt);
1913
- }
1914
- /**
1915
- * Modifies transaction keys for the purpose of claiming transaction fees.
1916
- */
1917
- replace() {
1918
- this._ix.keys[4].pubkey = this.userPda;
1919
- this._ix.keys[4].isSigner = false;
1920
- }
1921
- /**
1922
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
1923
- */
1924
- replaceCpi() {
1925
- return __awaiter(this, void 0, void 0, function* () {
1926
- var _a;
1927
- // Common parameters
1928
- const farm = addresses_1.USDC_FARM;
1929
- const userPda = this.userPda;
1930
- const authority = this.authority;
1931
- const iyfProgram = addresses_1.IYF_MAIN;
1932
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
1933
- // Get token mints X and Y
1934
- const tokenXMint = this.ix.keys[9].pubkey;
1935
- const tokenYMint = this.ix.keys[10].pubkey;
1936
- const tokenXMintInfo = AccountCache_1.AccountCache.get(tokenXMint);
1937
- const tokenYMintInfo = AccountCache_1.AccountCache.get(tokenYMint);
1938
- if (!(!!tokenXMintInfo && !!tokenYMintInfo)) {
1939
- throw new Error("Unexpected error: Mint X or Y not found in cache.");
1940
- }
1941
- // Generate owner fee X and Y ATA
1942
- const ownerFeeX = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenXMint, tokenXMintInfo.info.owner);
1943
- const ownerFeeY = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenYMint, tokenYMintInfo.info.owner);
1944
- // Adjust by token type
1945
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
1946
- if (pdaTokenType === types_1.TokenType.LTA) {
1947
- this.ix.keys[7].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[9].pubkey);
1948
- this.ix.keys[8].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[10].pubkey);
1949
- }
1950
- else if (pdaTokenType === types_1.TokenType.STA) {
1951
- this.ix.keys[7].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[9].pubkey);
1952
- this.ix.keys[8].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[10].pubkey);
1953
- }
1954
- else {
1955
- this.ix.keys[7].pubkey = util.generateAta(this.userPda, this.ix.keys[9].pubkey, tokenXMintInfo.info.owner);
1956
- this.ix.keys[8].pubkey = util.generateAta(this.userPda, this.ix.keys[10].pubkey, tokenYMintInfo.info.owner);
1957
- }
1958
- // Generate IX via extension contract
1959
- // @ts-ignore
1960
- const claimFeeIx = yield anchor_1.Anchor.instance().iyfExtension.methods
1961
- .meteoraDlmmClaimFeeAutomation()
1962
- .accounts({
1963
- farm,
1964
- userPda,
1965
- authority,
1966
- iyfProgram,
1967
- hawksightAuthority,
1968
- lbPair: this.ix.keys[0].pubkey,
1969
- position: this.ix.keys[1].pubkey,
1970
- binArrayLower: this.ix.keys[2].pubkey,
1971
- binArrayUpper: this.ix.keys[3].pubkey,
1972
- reserveX: this.ix.keys[5].pubkey,
1973
- reserveY: this.ix.keys[6].pubkey,
1974
- userTokenX: this.ix.keys[7].pubkey,
1975
- userTokenY: this.ix.keys[8].pubkey,
1976
- tokenXMint: this.ix.keys[9].pubkey,
1977
- tokenYMint: this.ix.keys[10].pubkey,
1978
- tokenProgram: this.ix.keys[11].pubkey,
1979
- eventAuthority: this.ix.keys[12].pubkey,
1980
- meteoraDlmmProgram: this.ix.keys[13].pubkey,
1981
- ownerFeeX,
1982
- ownerFeeY,
1983
- }).instruction();
1984
- // Instruction via main hawksight contract
1985
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
1986
- .iyfExtensionExecute(claimFeeIx.data)
1987
- .accounts({
1988
- farm,
1989
- userPda,
1990
- authority,
1991
- iyfProgram,
1992
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
1993
- })
1994
- .remainingAccounts([
1995
- claimFeeIx.keys[4],
1996
- claimFeeIx.keys[5],
1997
- claimFeeIx.keys[6],
1998
- claimFeeIx.keys[7],
1999
- claimFeeIx.keys[8],
2000
- claimFeeIx.keys[9],
2001
- claimFeeIx.keys[10],
2002
- claimFeeIx.keys[11],
2003
- claimFeeIx.keys[12],
2004
- claimFeeIx.keys[13],
2005
- claimFeeIx.keys[14],
2006
- claimFeeIx.keys[15],
2007
- claimFeeIx.keys[16],
2008
- claimFeeIx.keys[17],
2009
- claimFeeIx.keys[18],
2010
- claimFeeIx.keys[19],
2011
- ])
2012
- .instruction();
2013
- // Override the instruction
2014
- this._ix = ix;
2015
- });
2016
- }
2017
- }
2018
- /**
2019
- * Manages the claiming of rewards in blockchain operations, typically associated with staking or similar activities.
2020
- */
2021
- class ClaimRewardAutomation extends HawksightMeteoraAutomationCpi {
2022
- /**
2023
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
2024
- *
2025
- * @param ix The core transaction instruction.
2026
- * @param userPda The user's program-derived address (PDA) as a public key.
2027
- * @param authority The authority public key that has signing capabilities over the transaction.
2028
- */
2029
- constructor(ix, userPda, authority, opt) {
2030
- super(ix, userPda, authority, util.sighash("claim_reward", undefined, true), opt);
2031
- }
2032
- /**
2033
- * Adjusts transaction keys to facilitate the claiming of rewards.
2034
- */
2035
- replace() {
2036
- // this._ix.keys[4].pubkey = this.userPda;
2037
- // this._ix.keys[4].isSigner = false;
2038
- }
2039
- /**
2040
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
2041
- */
2042
- replaceCpi() {
2043
- return __awaiter(this, void 0, void 0, function* () {
2044
- var _a;
2045
- const sh = util.sighash('claim_reward', undefined, true);
2046
- const d = this.ix.data.subarray(0, 8);
2047
- // Get reward index from parameter
2048
- const rewardIndex = new bn_js_1.default(this.ix.data.readBigInt64LE(8).toString());
2049
- // Common parameters
2050
- const farm = addresses_1.USDC_FARM;
2051
- const userPda = this.userPda;
2052
- const authority = this.authority;
2053
- const iyfProgram = addresses_1.IYF_MAIN;
2054
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
2055
- // Generate owner fee ATA
2056
- const rewardMint = this.ix.keys[4].pubkey;
2057
- const mintInfo = AccountCache_1.AccountCache.get(rewardMint);
2058
- if (!mintInfo) {
2059
- throw new Error("Unexpected error: Reward mint not found in cache.");
2060
- }
2061
- const ownerFee = util.generateAta(addresses_1.SITE_FEE_OWNER, rewardMint, mintInfo.info.owner);
2062
- // Adjust by token type
2063
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
2064
- if (pdaTokenType === types_1.TokenType.LTA) {
2065
- this.ix.keys[5].pubkey = util.generateLimitToken(this.userPda, rewardMint);
2066
- }
2067
- else if (pdaTokenType === types_1.TokenType.STA) {
2068
- this.ix.keys[5].pubkey = util.generateUserPdaStorageAccount(this.userPda, rewardMint);
2069
- }
2070
- else {
2071
- this.ix.keys[5].pubkey = util.generateAta(this.userPda, rewardMint, mintInfo.info.owner);
2072
- }
2073
- let binArrayLower = this.ix.keys[10].pubkey;
2074
- let binArrayUpper = this.ix.keys.length > 11 ? this.ix.keys[11].pubkey : this.ix.keys[10].pubkey;
2075
- // Generate IX via extension contract
2076
- // @ts-ignore
2077
- const claimRewardIx = yield anchor_1.Anchor.instance().iyfExtension.methods
2078
- .meteoraDlmmClaimRewardAutomation(rewardIndex)
2079
- .accounts({
2080
- farm,
2081
- userPda,
2082
- authority,
2083
- iyfProgram,
2084
- hawksightAuthority,
2085
- lbPair: this.ix.keys[0].pubkey,
2086
- position: this.ix.keys[1].pubkey,
2087
- binArrayLower: binArrayLower,
2088
- binArrayUpper: binArrayUpper,
2089
- rewardVault: this.ix.keys[3].pubkey,
2090
- rewardMint,
2091
- userTokenAccount: this.ix.keys[5].pubkey,
2092
- tokenProgram: this.ix.keys[6].pubkey,
2093
- eventAuthority: this.ix.keys[8].pubkey,
2094
- meteoraDlmmProgram: this.ix.keys[9].pubkey,
2095
- ownerFee,
2096
- }).instruction();
2097
- // Instruction via main hawksight contract
2098
- // @ts-ignore
2099
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
2100
- .iyfExtensionExecute(claimRewardIx.data)
2101
- .accounts({
2102
- farm,
2103
- userPda,
2104
- authority,
2105
- iyfProgram,
2106
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
2107
- })
2108
- .remainingAccounts([
2109
- claimRewardIx.keys[4],
2110
- claimRewardIx.keys[5],
2111
- claimRewardIx.keys[6],
2112
- claimRewardIx.keys[7],
2113
- claimRewardIx.keys[8],
2114
- claimRewardIx.keys[9],
2115
- claimRewardIx.keys[10],
2116
- claimRewardIx.keys[11],
2117
- claimRewardIx.keys[12],
2118
- claimRewardIx.keys[13],
2119
- claimRewardIx.keys[14],
2120
- claimRewardIx.keys[15],
2121
- ])
2122
- .instruction();
2123
- // Override the instruction
2124
- this._ix = ix;
2125
- });
2126
- }
2127
- }
2128
- /**
2129
- * Handles the closure of a position within a blockchain transaction.
2130
- */
2131
- class ClosePositionAutomation extends HawksightMeteoraAutomationCpi {
2132
- /**
2133
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
2134
- *
2135
- * @param ix The core transaction instruction.
2136
- * @param userPda The user's program-derived address (PDA) as a public key.
2137
- * @param authority The authority public key that has signing capabilities over the transaction.
2138
- */
2139
- constructor(ix, userPda, authority, opt) {
2140
- super(ix, userPda, authority, util.sighash("ClosePosition"), opt);
2141
- }
2142
- /**
2143
- * Customizes the transaction keys to properly close a position, ensuring all relevant keys are set correctly.
2144
- */
2145
- replace() {
2146
- this._ix.keys[4].pubkey = this.userPda;
2147
- this._ix.keys[4].isSigner = false;
2148
- this._ix.keys[5].pubkey = this.authority;
2149
- }
2150
- /**
2151
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
2152
- */
2153
- replaceCpi() {
2154
- return __awaiter(this, void 0, void 0, function* () {
2155
- var _a, _b;
2156
- // Common parameters
2157
- const farm = addresses_1.USDC_FARM;
2158
- const userPda = this.userPda;
2159
- const authority = this.authority;
2160
- const iyfProgram = addresses_1.IYF_MAIN;
2161
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
2162
- let remainingAccounts = [];
2163
- if ((_b = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.fuelAccount) {
2164
- const fuelAccount = util.generateFuelAccount(this.authority);
2165
- remainingAccounts.push({
2166
- pubkey: fuelAccount,
2167
- isSigner: false,
2168
- isWritable: true,
2169
- });
2170
- }
2171
- // Generate IX via extension contract
2172
- // @ts-ignore
2173
- const closePositionIx = yield anchor_1.Anchor.instance().iyfExtension.methods
2174
- .meteoraDlmmClosePositionAutomation()
2175
- .accounts({
2176
- farm,
2177
- userPda,
2178
- authority,
2179
- iyfProgram,
2180
- hawksightAuthority,
2181
- position: this.ix.keys[0].pubkey,
2182
- lbPair: this.ix.keys[1].pubkey,
2183
- binArrayLower: this.ix.keys[2].pubkey,
2184
- binArrayUpper: this.ix.keys[3].pubkey,
2185
- eventAuthority: this.ix.keys[6].pubkey,
2186
- meteoraDlmmProgram: this.ix.keys[7].pubkey,
2187
- }).remainingAccounts(remainingAccounts).instruction();
2188
- // Instruction via main hawksight contract
2189
- // @ts-ignore
2190
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
2191
- .iyfExtensionExecute(closePositionIx.data)
2192
- .accounts({
2193
- farm,
2194
- userPda,
2195
- authority,
2196
- iyfProgram,
2197
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
2198
- })
2199
- .remainingAccounts([
2200
- closePositionIx.keys[4],
2201
- closePositionIx.keys[5],
2202
- closePositionIx.keys[6],
2203
- closePositionIx.keys[7],
2204
- closePositionIx.keys[8],
2205
- closePositionIx.keys[9],
2206
- closePositionIx.keys[10],
2207
- ...remainingAccounts,
2208
- ])
2209
- .instruction();
2210
- // Override the instruction
2211
- this._ix = ix;
2212
- });
2213
- }
2214
- }
2215
- /**
2216
- * Handles Meteora DLMM Claim Fee v2 Automation instruction.
2217
- */
2218
- class MeteoraDlmmClaimFee2Automation extends HawksightMeteoraAutomationCpi {
2219
- /**
2220
- * Constructs an instance of MeteoraDlmmClaimFee2Automation with the necessary transaction parameters.
2221
- *
2222
- * @param ix The core transaction instruction.
2223
- * @param userPda The user's program-derived address (PDA) as a public key.
2224
- * @param authority The authority public key that has signing capabilities over the transaction.
2225
- */
2226
- constructor(ix, userPda, authority, opt) {
2227
- super(ix, userPda, authority, util.sighash("claim_fee2", undefined, true), opt);
2228
- }
2229
- /**
2230
- * Modifies transaction keys for the purpose of claiming transaction fees.
2231
- */
2232
- replace() {
2233
- // this._ix.keys[2].pubkey = this.userPda;
2234
- // this._ix.keys[2].isSigner = false;
2235
- }
2236
- /**
2237
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
2238
- */
2239
- replaceCpi() {
2240
- return __awaiter(this, void 0, void 0, function* () {
2241
- var _a;
2242
- // Common parameters
2243
- const userPda = this.userPda;
2244
- // const authority = this.authority;
2245
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
2246
- const minBinId = this.ix.data.readInt32LE(8);
2247
- const maxBinId = this.ix.data.readInt32LE(12);
2248
- const remainingAccountsInfo = this.ix.data.subarray(16);
2249
- // Get token mints X and Y
2250
- const tokenXMint = this.ix.keys[7].pubkey;
2251
- const tokenYMint = this.ix.keys[8].pubkey;
2252
- const tokenXMintInfo = AccountCache_1.AccountCache.get(tokenXMint);
2253
- const tokenYMintInfo = AccountCache_1.AccountCache.get(tokenYMint);
2254
- if (!(!!tokenXMintInfo && !!tokenYMintInfo)) {
2255
- throw new Error("Unexpected error: Mint X or Y not found in cache.");
2256
- }
2257
- // Generate owner fee X and Y ATA
2258
- const ownerFeeX = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenXMint, tokenXMintInfo.info.owner);
2259
- const ownerFeeY = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenYMint, tokenYMintInfo.info.owner);
2260
- // Adjust by token type
2261
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
2262
- if (pdaTokenType === types_1.TokenType.LTA) {
2263
- this.ix.keys[5].pubkey = util.generateLimitToken(this.userPda, tokenXMint);
2264
- this.ix.keys[6].pubkey = util.generateLimitToken(this.userPda, tokenYMint);
2265
- }
2266
- else if (pdaTokenType === types_1.TokenType.STA) {
2267
- this.ix.keys[5].pubkey = util.generateUserPdaStorageAccount(this.userPda, tokenXMint);
2268
- this.ix.keys[6].pubkey = util.generateUserPdaStorageAccount(this.userPda, tokenYMint);
2269
- }
2270
- else {
2271
- this.ix.keys[5].pubkey = util.generateAta(this.userPda, tokenXMint, tokenXMintInfo.info.owner);
2272
- this.ix.keys[6].pubkey = util.generateAta(this.userPda, tokenYMint, tokenYMintInfo.info.owner);
2273
- }
2274
- // Generate IX via extension contract
2275
- // @ts-ignore
2276
- const claimFeeIx = yield anchor_1.Anchor.instance().iyfExtension.methods
2277
- .meteoraDlmmClaimFee2Automation(minBinId, maxBinId, remainingAccountsInfo)
2278
- .accounts({
2279
- userPda,
2280
- hawksightAuthority,
2281
- lbPair: this.ix.keys[0].pubkey,
2282
- position: this.ix.keys[1].pubkey,
2283
- reserveX: this.ix.keys[3].pubkey,
2284
- reserveY: this.ix.keys[4].pubkey,
2285
- userTokenX: this.ix.keys[5].pubkey,
2286
- userTokenY: this.ix.keys[6].pubkey,
2287
- tokenXMint: this.ix.keys[7].pubkey,
2288
- tokenYMint: this.ix.keys[8].pubkey,
2289
- tokenProgramX: this.ix.keys[9].pubkey,
2290
- tokenProgramY: this.ix.keys[10].pubkey,
2291
- memoProgram: this.ix.keys[11].pubkey,
2292
- eventAuthority: this.ix.keys[12].pubkey,
2293
- meteoraDlmmProgram: this.ix.keys[13].pubkey,
2294
- ownerFeeX,
2295
- ownerFeeY,
2296
- }).remainingAccounts(this.ix.keys.slice(14)).instruction();
2297
- const sighash = util.sighash("meteora_dlmm_claim_fee_2_automation");
2298
- claimFeeIx.data.set(sighash, 0);
2299
- // Instruction via main hawksight contract
2300
- // @ts-ignore
2301
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
2302
- .iyfExtensionExecuteV2(claimFeeIx.data)
2303
- .accounts({
2304
- userPda,
2305
- authority: hawksightAuthority,
2306
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
2307
- })
2308
- .remainingAccounts(claimFeeIx.keys.slice(2))
2309
- .instruction();
2310
- // Override the instruction
2311
- this._ix = ix;
2312
- });
2313
- }
2314
- }
2315
- /**
2316
- * Handles Meteora DLMM Claim Fee v2 Automation instruction.
2317
- */
2318
- class MeteoraDlmmClaimReward2Automation extends HawksightMeteoraAutomationCpi {
2319
- /**
2320
- * Constructs an instance of MeteoraDlmmClaimFee2Automation with the necessary transaction parameters.
2321
- *
2322
- * @param ix The core transaction instruction.
2323
- * @param userPda The user's program-derived address (PDA) as a public key.
2324
- * @param authority The authority public key that has signing capabilities over the transaction.
2325
- */
2326
- constructor(ix, userPda, authority, opt) {
2327
- super(ix, userPda, authority, util.sighash("claim_reward2", undefined, true), opt);
2328
- }
2329
- /**
2330
- * Modifies transaction keys for the purpose of claiming transaction fees.
2331
- */
2332
- replace() {
2333
- // this.ix.keys[3].pubkey = this.userPda;
2334
- // this.ix.keys[3].isSigner = false;
2335
- }
2336
- /**
2337
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
2338
- */
2339
- replaceCpi() {
2340
- return __awaiter(this, void 0, void 0, function* () {
2341
- // Common parameters
2342
- const userPda = this.userPda;
2343
- const authority = this.authority;
2344
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
2345
- // New meteora parameters
2346
- const minBinId = this.ix.data.readInt32LE(16);
2347
- const maxBinId = this.ix.data.readInt32LE(20);
2348
- const remainingAccountsInfo = this.ix.data.subarray(24);
2349
- const rewardMint = this.ix.keys[4].pubkey;
2350
- const rewardMintInfo = AccountCache_1.AccountCache.get(rewardMint);
2351
- const ownerFee = util.generateAta(addresses_1.SITE_FEE_OWNER, rewardMint, rewardMintInfo === null || rewardMintInfo === void 0 ? void 0 : rewardMintInfo.info.owner);
2352
- // Get reward index from parameter
2353
- const rewardIndex = new bn_js_1.default(this.ix.data.readBigInt64LE(8).toString());
2354
- // Generate IX via extension contract
2355
- // @ts-ignore
2356
- const claimReward = yield anchor_1.Anchor.instance().iyfExtension.methods
2357
- .meteoraDlmmClaimReward2Automation(rewardIndex, minBinId, maxBinId, remainingAccountsInfo)
2358
- .accounts({
2359
- userPda,
2360
- hawksightAuthority,
2361
- lbPair: this.ix.keys[0].pubkey,
2362
- position: this.ix.keys[1].pubkey,
2363
- rewardVault: this.ix.keys[3].pubkey,
2364
- rewardMint: this.ix.keys[4].pubkey,
2365
- userTokenAccount: this.ix.keys[5].pubkey,
2366
- tokenProgram: this.ix.keys[6].pubkey,
2367
- memoProgram: this.ix.keys[7].pubkey,
2368
- eventAuthority: this.ix.keys[8].pubkey,
2369
- meteoraDlmmProgram: addresses_1.METEORA_DLMM_PROGRAM,
2370
- ownerFee,
2371
- })
2372
- .remainingAccounts(this.ix.keys.slice(10))
2373
- .instruction();
2374
- const sighash = util.sighash("meteora_dlmm_claim_reward_2_automation");
2375
- claimReward.data.set(sighash, 0);
2376
- // Instruction via main hawksight contract
2377
- // @ts-ignore
2378
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
2379
- .iyfExtensionExecuteV2(claimReward.data)
2380
- .accounts({
2381
- userPda,
2382
- authority: hawksightAuthority,
2383
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
2384
- })
2385
- .remainingAccounts(claimReward.keys.slice(2))
2386
- .instruction();
2387
- // Override the instruction
2388
- this._ix = ix;
2389
- });
2390
- }
2391
- }
2392
- /**
2393
- * Handles the closure of a position within a blockchain transaction.
2394
- */
2395
- class ClosePositionIfEmptyAutomation extends HawksightMeteoraAutomationCpi {
2396
- /**
2397
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
2398
- *
2399
- * @param ix The core transaction instruction.
2400
- * @param userPda The user's program-derived address (PDA) as a public key.
2401
- * @param authority The authority public key that has signing capabilities over the transaction.
2402
- */
2403
- constructor(ix, userPda, authority, opt) {
2404
- super(ix, userPda, authority, util.sighash("ClosePositionIfEmpty"), opt);
2405
- }
2406
- /**
2407
- * Customizes the transaction keys to properly close a position, ensuring all relevant keys are set correctly.
2408
- */
2409
- replace() {
2410
- // this.ix.keys[1].pubkey = this.userPda;
2411
- // this.ix.keys[1].isSigner = false;
2412
- // this._ix.keys[5].pubkey = this.authority;
2413
- }
2414
- /**
2415
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
2416
- */
2417
- replaceCpi() {
2418
- return __awaiter(this, void 0, void 0, function* () {
2419
- var _a, _b, _c, _d;
2420
- // Common parameters
2421
- const farm = addresses_1.USDC_FARM;
2422
- const userPda = this.userPda;
2423
- const authority = this.authority;
2424
- const iyfProgram = addresses_1.IYF_MAIN;
2425
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
2426
- // let remainingAccounts: web3.AccountMeta[] = [];
2427
- // Dummy value of fuel account is system program
2428
- let fuelAccount = this.userPda; // using user pda instead of program account
2429
- if ((_b = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.fuelAccount) {
2430
- fuelAccount = util.generateFuelAccount(this.authority);
2431
- }
2432
- const lbPair = (_d = (_c = this.opt) === null || _c === void 0 ? void 0 : _c.params) === null || _d === void 0 ? void 0 : _d.lbPair;
2433
- // Generate IX via extension contract
2434
- // @ts-ignore
2435
- const closePositionIx = yield anchor_1.Anchor.instance().iyfExtension.methods
2436
- .meteoraDlmmClosePositionAutomationV2()
2437
- .accounts({
2438
- userPda,
2439
- hawksightAuthority,
2440
- position: this.ix.keys[0].pubkey,
2441
- lbPair: lbPair,
2442
- eventAuthority: this.ix.keys[3].pubkey,
2443
- meteoraDlmmProgram: addresses_1.METEORA_DLMM_PROGRAM,
2444
- fuelAccount: fuelAccount,
2445
- }).instruction();
2446
- // Instruction via main hawksight contract
2447
- // @ts-ignore
2448
- const ixGen = new SimpleIxGenerator_1.SimpleIxGenerator();
2449
- const ix = yield ixGen.iyfMain.iyfExtensionExecuteV2(anchor_1.Anchor.instance().connection, {
2450
- userPda,
2451
- authority: hawksightAuthority,
2452
- ix: closePositionIx
2453
- });
2454
- // Override the instruction
2455
- this._ix = ix;
2456
- });
2457
- }
2458
- }
2459
- /**
2460
- * Handles Meteora DLMM Deposit v2 Automation instruction.
2461
- */
2462
- class MeteoraDlmmDeposit2Automation extends HawksightMeteoraAutomationCpi {
2463
- /**
2464
- * Constructs an instance of MeteoraDlmmDeposit2Automation with the necessary transaction parameters.
2465
- *
2466
- * @param ix The core transaction instruction.
2467
- * @param userPda The user's program-derived address (PDA) as a public key.
2468
- * @param authority The authority public key that has signing capabilities over the transaction.
2469
- */
2470
- constructor(ix, userPda, authority, opt) {
2471
- super(ix, userPda, authority, Buffer.from([3, 221, 149, 218, 111, 141, 118, 213]), opt);
2472
- // super(ix, userPda, authority, sighash, opt);
2473
- }
2474
- /**
2475
- * Modifies transaction keys for the purpose of depositing liquidity.
2476
- */
2477
- replace() {
2478
- // this.ix.keys[9].pubkey = this.userPda;
2479
- // this.ix.keys[9].isSigner = false;
2480
- }
2481
- /**
2482
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
2483
- */
2484
- replaceCpi() {
2485
- return __awaiter(this, void 0, void 0, function* () {
2486
- var _a;
2487
- // Common parameters
2488
- const farm = addresses_1.USDC_FARM;
2489
- const userPda = this.userPda;
2490
- const authority = this.authority;
2491
- const iyfProgram = addresses_1.IYF_MAIN;
2492
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
2493
- // Get token mints X and Y
2494
- const tokenXMint = this.ix.keys[7].pubkey;
2495
- const tokenYMint = this.ix.keys[8].pubkey;
2496
- // Generate IX via extension contract
2497
- const data = this.ix.data.subarray(8);
2498
- const activeId = data.subarray(16, 20).readInt32LE();
2499
- const maxActiveBinSlippage = data.subarray(20, 24).readInt32LE();
2500
- const strategyParametersMinBinId = data.subarray(24, 28).readInt32LE();
2501
- const strategyParametersMaxBinId = data.subarray(28, 32).readInt32LE();
2502
- const strategyParametersStrategyType = data[32];
2503
- const strategyParametersParameters = Array.from(data.subarray(33, 97));
2504
- const remainingAccountsInfo = this.ix.data.subarray(97);
2505
- const tokenXMintInfo = AccountCache_1.AccountCache.get(tokenXMint);
2506
- const tokenYMintInfo = AccountCache_1.AccountCache.get(tokenYMint);
2507
- if (!(!!tokenXMintInfo && !!tokenYMintInfo)) {
2508
- throw new Error("Unexpected error: Mint X or Y not found in cache.");
2509
- }
2510
- // Adjust by token type
2511
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
2512
- if (pdaTokenType === types_1.TokenType.LTA) {
2513
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, tokenXMint);
2514
- this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, tokenYMint);
2515
- }
2516
- else if (pdaTokenType === types_1.TokenType.STA) {
2517
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, tokenXMint);
2518
- this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, tokenYMint);
2519
- }
2520
- else {
2521
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, tokenXMint, tokenXMintInfo.info.owner);
2522
- this.ix.keys[4].pubkey = util.generateAta(this.userPda, tokenYMint, tokenYMintInfo.info.owner);
2523
- }
2524
- // @ts-ignore
2525
- const depositIx = yield anchor_1.Anchor.instance().iyfExtension.methods
2526
- .meteoraDlmmDeposit2Automation(null, // userTokenXAmount (optional)
2527
- null, // userTokenYAmount (optional)
2528
- activeId, maxActiveBinSlippage, strategyParametersMinBinId, strategyParametersMaxBinId, strategyParametersStrategyType, strategyParametersParameters, remainingAccountsInfo)
2529
- .accounts({
2530
- userPda,
2531
- hawksightAuthority,
2532
- position: this.ix.keys[0].pubkey,
2533
- lbPair: this.ix.keys[1].pubkey,
2534
- binArrayBitmapExtension: this.ix.keys[2].pubkey,
2535
- userTokenX: this.ix.keys[3].pubkey,
2536
- userTokenY: this.ix.keys[4].pubkey,
2537
- reserveX: this.ix.keys[5].pubkey,
2538
- reserveY: this.ix.keys[6].pubkey,
2539
- tokenXMint: this.ix.keys[7].pubkey,
2540
- tokenYMint: this.ix.keys[8].pubkey,
2541
- tokenXProgram: this.ix.keys[10].pubkey,
2542
- tokenYProgram: this.ix.keys[11].pubkey,
2543
- eventAuthority: this.ix.keys[12].pubkey,
2544
- meteoraDlmmProgram: this.ix.keys[13].pubkey,
2545
- memoProgram: addresses_1.MEMO_PROGRAM,
2546
- }).remainingAccounts(this.ix.keys.slice(14)).instruction();
2547
- // Patch binArrayBitmapExtension writable flag: writable only when it's a real PDA, not the program ID placeholder
2548
- const bitmapKey = depositIx.keys.find(k => k.pubkey.equals(this.ix.keys[2].pubkey));
2549
- if (bitmapKey) {
2550
- bitmapKey.isWritable = !this.ix.keys[2].pubkey.equals(addresses_1.METEORA_DLMM_PROGRAM);
2551
- }
2552
- const sighash = util.sighash("meteora_dlmm_deposit_2_automation");
2553
- depositIx.data.set(sighash, 0);
2554
- // Instruction via main hawksight contract
2555
- // @ts-ignore
2556
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
2557
- .iyfExtensionExecuteV2(depositIx.data)
2558
- .accounts({
2559
- userPda,
2560
- authority: hawksightAuthority,
2561
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
2562
- })
2563
- .remainingAccounts(depositIx.keys.slice(2))
2564
- .instruction();
2565
- // Override the instruction
2566
- this._ix = ix;
2567
- });
2568
- }
2569
- }
2570
- /**
2571
- * Handles Meteora DLMM Withdraw v2 Automation instruction.
2572
- */
2573
- class MeteoraDlmmWithdraw2Automation extends HawksightMeteoraAutomationCpi {
2574
- /**
2575
- * Constructs an instance of MeteoraDlmmWithdraw2Automation with the necessary transaction parameters.
2576
- *
2577
- * @param ix The core transaction instruction.
2578
- * @param userPda The user's program-derived address (PDA) as a public key.
2579
- * @param authority The authority public key that has signing capabilities over the transaction.
2580
- */
2581
- constructor(ix, userPda, authority, opt) {
2582
- super(ix, userPda, authority, util.sighash("remove_liquidity_by_range2", undefined, true), opt);
2583
- }
2584
- /**
2585
- * Modifies transaction keys for the purpose of withdrawing liquidity.
2586
- */
2587
- replace() {
2588
- // this._ix.keys[1].pubkey = this.userPda;
2589
- // this._ix.keys[1].isSigner = false;
2590
- }
2591
- /**
2592
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
2593
- */
2594
- replaceCpi() {
2595
- return __awaiter(this, void 0, void 0, function* () {
2596
- var _a;
2597
- // Common parameters
2598
- const farm = addresses_1.USDC_FARM;
2599
- const userPda = this.userPda;
2600
- const authority = this.authority;
2601
- const iyfProgram = addresses_1.IYF_MAIN;
2602
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
2603
- // Get token mints X and Y
2604
- const tokenXMint = this.ix.keys[7].pubkey;
2605
- const tokenYMint = this.ix.keys[8].pubkey;
2606
- const tokenXMintInfo = AccountCache_1.AccountCache.get(tokenXMint);
2607
- const tokenYMintInfo = AccountCache_1.AccountCache.get(tokenYMint);
2608
- if (!(!!tokenXMintInfo && !!tokenYMintInfo)) {
2609
- throw new Error("Unexpected error: Mint X or Y not found in cache.");
2610
- }
2611
- // Adjust by token type
2612
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
2613
- if (pdaTokenType === types_1.TokenType.LTA) {
2614
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, tokenXMint);
2615
- this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, tokenYMint);
2616
- }
2617
- else if (pdaTokenType === types_1.TokenType.STA) {
2618
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, tokenXMint);
2619
- this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, tokenYMint);
2620
- }
2621
- else {
2622
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, tokenXMint, tokenXMintInfo.info.owner);
2623
- this.ix.keys[4].pubkey = util.generateAta(this.userPda, tokenYMint, tokenYMintInfo.info.owner);
2624
- }
2625
- const position = this.ix.keys[0].pubkey;
2626
- const lbPair = this.ix.keys[1].pubkey;
2627
- // Generate IX via extension contract
2628
- // @ts-ignore
2629
- const withdrawIx = yield anchor_1.Anchor.instance().iyfExtension.methods
2630
- .meteoraDlmmWithdraw2Automation(this.ix.data.subarray(8))
2631
- .accounts({
2632
- userPda,
2633
- hawksightAuthority,
2634
- position,
2635
- lbPair,
2636
- binArrayBitmapExtension: this.ix.keys[2].pubkey,
2637
- userTokenX: this.ix.keys[3].pubkey,
2638
- userTokenY: this.ix.keys[4].pubkey,
2639
- reserveX: this.ix.keys[5].pubkey,
2640
- reserveY: this.ix.keys[6].pubkey,
2641
- tokenXMint,
2642
- tokenYMint,
2643
- tokenXProgram: this.ix.keys[10].pubkey,
2644
- tokenYProgram: this.ix.keys[11].pubkey,
2645
- eventAuthority: this.ix.keys[13].pubkey,
2646
- meteoraDlmmProgram: this.ix.keys[14].pubkey,
2647
- memoProgram: this.ix.keys[12].pubkey,
2648
- }).remainingAccounts(this.ix.keys.slice(15)).instruction();
2649
- // Patch binArrayBitmapExtension writable flag: writable only when it's a real PDA, not the program ID placeholder
2650
- const bitmapKey = withdrawIx.keys.find(k => k.pubkey.equals(this.ix.keys[2].pubkey));
2651
- if (bitmapKey) {
2652
- bitmapKey.isWritable = !this.ix.keys[2].pubkey.equals(addresses_1.METEORA_DLMM_PROGRAM);
2653
- }
2654
- const sighash = util.sighash("meteora_dlmm_withdraw_2_automation");
2655
- withdrawIx.data.set(sighash, 0);
2656
- // Instruction via main hawksight contract
2657
- // @ts-ignore
2658
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
2659
- .iyfExtensionExecuteV2(withdrawIx.data)
2660
- .accounts({
2661
- userPda,
2662
- authority: hawksightAuthority,
2663
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
2664
- })
2665
- .remainingAccounts(withdrawIx.keys.slice(2))
2666
- .instruction();
2667
- // Override the instruction
2668
- this._ix = ix;
2669
- });
2670
- }
2671
- }
2672
- /**
2673
- * Abstract base class `HawksightMeteoraCpi` for handling and chaining transaction instructions.
2674
- * This class provides a framework for creating and linking complex transaction processes in a blockchain environment.
2675
- *
2676
- * Attributes:
2677
- * - `ix`: web3.TransactionInstruction - The transaction instruction associated with this CPI.
2678
- * - `userPda`: web3.PublicKey - The public key of the user's program-derived address (PDA).
2679
- * - `authority`: web3.PublicKey - The public key of the authority that can sign transactions.
2680
- * - `_next`: HawksightMeteoraCpi | undefined - Pointer to the next CPI in the chain.
2681
- * - `sighash`: Buffer - A buffer representing the signature hash used for identifying and validating instructions.
2682
- *
2683
- * Methods:
2684
- * - `constructor(ix, userPda, authority, sighash)`: Constructs an instance of the HawksightMeteoraCpi.
2685
- * - `factory(ix, userPda, authority)`: Static factory method to create a chain of CPIs starting with `InitializePosition` and linking subsequent operations.
2686
- * - `getInstruction()`: Returns the modified transaction instruction after processing by matching CPIs in the chain.
2687
- * - `replace()`: Abstract method to be implemented by subclasses to modify the transaction keys or other properties.
2688
- * - `next(next)`: Chains the current CPI instance to the next one.
2689
- * - `sighashMatch()`: Checks if the current transaction instruction matches the provided sighash and recurses through the chain if not.
2690
- * - `programIdMatch()`: Checks if the program ID of the transaction matches the expected ID.
2691
- * - `addHawksightCpi()`: Modifies the transaction instruction to include specific Hawksight CPI details.
2692
- *
2693
- * Usage:
2694
- * This class is intended to be extended by specific CPI implementations like `InitializePosition`, each implementing their own `replace()` method to handle specific transaction modifications.
2695
- */
2696
- class HawksightMeteoraPdaCpi {
2697
- /**
2698
- * Constructs an instance of HawksightMeteoraCpi with the necessary transaction parameters.
2699
- * @param ix The core transaction instruction.
2700
- * @param userPda The user's program-derived address (PDA) as a public key.
2701
- * @param authority The authority public key that has signing capabilities over the transaction.
2702
- * @param sighash A Buffer containing the sighash used for matching the transaction instruction.
2703
- */
2704
- constructor(ix, userPda, authority, sighash, opt) {
2705
- this.ix = ix;
2706
- this.userPda = userPda;
2707
- this.authority = authority;
2708
- this.sighash = sighash;
2709
- this.opt = opt;
2710
- }
2711
- /**
2712
- * Factory method to create and link a chain of CPIs starting from `InitializePosition`.
2713
- * Subsequent CPIs include operations like adding liquidity, removing liquidity, claiming fees, and rewards, and closing the position.
2714
- * @param ix The initial transaction instruction.
2715
- * @param userPda The user's public key.
2716
- * @param authority The authority public key.
2717
- * @returns The first CPI in the chain.
2718
- */
2719
- static factory(ix, userPda, authority, opt) {
2720
- const chain = new InitializePositionPda(ix, userPda, authority, opt);
2721
- chain
2722
- .next(new AddLiquidityByStrategyPda(ix, userPda, authority))
2723
- .next(new AddLiquidityByStrategy2Pda(ix, userPda, authority))
2724
- .next(new AddLiquidityByStrategyOneSidePda(ix, userPda, authority, opt));
2725
- return chain;
2726
- }
2727
- /**
2728
- * Retrieves and possibly modifies the transaction instruction based on matching conditions.
2729
- * If a matching CPI is found in the chain, it performs modifications and returns the updated instruction.
2730
- * @returns The (possibly modified) transaction instruction.
2731
- */
2732
- getInstruction() {
2733
- return __awaiter(this, void 0, void 0, function* () {
2734
- const matchInstance = this.sighashMatch();
2735
- if (this.programIdMatch() && matchInstance !== undefined) {
2736
- matchInstance.replace();
2737
- yield matchInstance.addHawksightCpi();
2738
- return this.ix;
2739
- }
2740
- return this.ix;
2741
- });
2742
- }
2743
- /**
2744
- * Modifies the transaction instruction to include specific Hawksight CPI details.
2745
- * Prepares the instruction for execution by adjusting its program ID and data based on Hawksight criteria.
2746
- */
2747
- addHawksightCpi() {
2748
- return __awaiter(this, void 0, void 0, function* () {
2749
- const METEORA_PROGRAM = addresses_1.METEORA_DLMM_PROGRAM;
2750
- const size = Buffer.alloc(4);
2751
- size.writeUint32LE(this.ix.data.length);
2752
- const data = Buffer.concat([
2753
- new Uint8Array(util.sighash('meteora_dynamic_cpi')),
2754
- new Uint8Array(size),
2755
- new Uint8Array(this.ix.data)
2756
- ]);
2757
- this.ix.programId = addresses_1.IYF_MAIN;
2758
- this.ix.data = data;
2759
- this.ix.keys.unshift(...[
2760
- { pubkey: this.userPda, isSigner: false, isWritable: false },
2761
- { pubkey: this.authority, isSigner: true, isWritable: true },
2762
- { pubkey: METEORA_PROGRAM, isSigner: false, isWritable: false },
2763
- ]);
2764
- });
2765
- }
2766
- /**
2767
- * Adds a subsequent CPI to the chain.
2768
- * @param next The next CPI object to link.
2769
- * @returns The added CPI object, allowing for method chaining.
2770
- */
2771
- next(next) {
2772
- this._next = next;
2773
- return this._next;
2774
- }
2775
- /**
2776
- * Recursively checks this CPI and subsequent ones for a sighash match in the transaction data.
2777
- * @returns The first CPI instance in the chain that matches the sighash, or undefined if no match is found.
2778
- */
2779
- sighashMatch() {
2780
- var _a, _b;
2781
- try {
2782
- const match = util.sighashMatch(this.ix.data, this.sighash);
2783
- if (match) {
2784
- return this;
2785
- }
2786
- else if (this._next !== undefined) {
2787
- return (_a = this._next) === null || _a === void 0 ? void 0 : _a.sighashMatch();
2788
- }
2789
- }
2790
- catch (_c) {
2791
- if (this._next !== undefined) {
2792
- return (_b = this._next) === null || _b === void 0 ? void 0 : _b.sighashMatch();
2793
- }
2794
- }
2795
- return undefined;
2796
- }
2797
- /**
2798
- * Checks if the program ID of the transaction instruction matches the expected program ID.
2799
- * @returns True if the program ID matches, otherwise false.
2800
- */
2801
- programIdMatch() {
2802
- return this.ix.programId.equals(addresses_1.METEORA_DLMM_PROGRAM);
2803
- }
2804
- }
2805
- /**
2806
- * Handles the initialization of a position in a blockchain transaction.
2807
- * This class extends the HawksightMeteoraCpi and provides specific logic to modify the transaction instruction for position initialization.
2808
- */
2809
- class InitializePositionPda extends HawksightMeteoraPdaCpi {
2810
- /**
2811
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
2812
- *
2813
- * @param ix The core transaction instruction.
2814
- * @param userPda The user's program-derived address (PDA) as a public key.
2815
- * @param authority The authority public key that has signing capabilities over the transaction.
2816
- */
2817
- constructor(ix, userPda, authority, opt) {
2818
- super(ix, userPda, authority, util.sighash("InitializePosition"), opt);
2819
- }
2820
- /**
2821
- * Modifies the transaction keys to set the correct public keys for an initial position setup.
2822
- */
2823
- replace() {
2824
- this.ix.keys[0].pubkey = this.authority;
2825
- this.ix.keys[3].pubkey = this.userPda;
2826
- this.ix.keys[3].isSigner = false;
2827
- }
2828
- }
2829
- /**
2830
- * Deposit liquidity via user pda
2831
- */
2832
- class AddLiquidityByStrategyPda extends HawksightMeteoraPdaCpi {
2833
- /**
2834
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
2835
- *
2836
- * @param ix The core transaction instruction.
2837
- * @param userPda The user's program-derived address (PDA) as a public key.
2838
- * @param authority The authority public key that has signing capabilities over the transaction.
2839
- */
2840
- constructor(ix, userPda, authority, sighash = util.sighash("AddLiquidityByStrategyPda")) {
2841
- super(ix, userPda, authority, sighash);
2842
- }
2843
- replaceSender() {
2844
- this.ix.keys[11].pubkey = this.userPda;
2845
- this.ix.keys[11].isSigner = false;
2846
- }
2847
- /**
2848
- * Modifies transaction keys for the purpose of claiming transaction fees.
2849
- */
2850
- replace() {
2851
- var _a;
2852
- this.replaceSender();
2853
- const tokenXMintInfo = AccountCache_1.AccountCache.get(this.ix.keys[7].pubkey);
2854
- const tokenYMintInfo = AccountCache_1.AccountCache.get(this.ix.keys[8].pubkey);
2855
- if (!(!!tokenXMintInfo && !!tokenYMintInfo)) {
2856
- throw new Error("Unexpected error: Mint X or Y not found in cache.");
2857
- }
2858
- // Adjust by token type
2859
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
2860
- if (pdaTokenType === types_1.TokenType.LTA) {
2861
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
2862
- this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
2863
- }
2864
- else if (pdaTokenType === types_1.TokenType.STA) {
2865
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
2866
- this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
2867
- }
2868
- else {
2869
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey, tokenXMintInfo.info.owner);
2870
- this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey, tokenYMintInfo.info.owner);
2871
- }
2872
- }
2873
- /**
2874
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
2875
- */
2876
- addHawksightCpi() {
2877
- return __awaiter(this, void 0, void 0, function* () {
2878
- // Common parameters
2879
- const farm = addresses_1.USDC_FARM;
2880
- const userPda = this.userPda;
2881
- const authority = this.authority;
2882
- const iyfProgram = addresses_1.IYF_MAIN;
2883
- // Get token mints X and Y
2884
- const tokenXMint = this.ix.keys[7].pubkey;
2885
- const tokenYMint = this.ix.keys[8].pubkey;
2886
- // Generate IX via extension contract
2887
- const data = this.ix.data.subarray(8);
2888
- const activeId = data.subarray(16, 20).readInt32LE();
2889
- const maxActiveBinSlippage = data.subarray(20, 24).readInt32LE();
2890
- const strategyParametersMinBinId = data.subarray(24, 28).readInt32LE();
2891
- const strategyParametersMaxBinId = data.subarray(28, 32).readInt32LE();
2892
- const strategyParametersStrategyType = data[32];
2893
- const strategyParametersParameters = Array.from(data.subarray(33));
2894
- // @ts-ignore
2895
- const depositIx = yield anchor_1.Anchor.instance().iyfExtension.methods
2896
- .meteoraDlmmDeposit(activeId, maxActiveBinSlippage, strategyParametersMinBinId, strategyParametersMaxBinId, strategyParametersStrategyType, strategyParametersParameters)
2897
- .accounts({
2898
- farm,
2899
- userPda,
2900
- authority,
2901
- iyfProgram,
2902
- position: this.ix.keys[0].pubkey,
2903
- lbPair: this.ix.keys[1].pubkey,
2904
- binArrayBitmapExtension: this.ix.keys[2].pubkey,
2905
- userTokenX: this.ix.keys[3].pubkey,
2906
- userTokenY: this.ix.keys[4].pubkey,
2907
- reserveX: this.ix.keys[5].pubkey,
2908
- reserveY: this.ix.keys[6].pubkey,
2909
- tokenXMint,
2910
- tokenYMint,
2911
- binArrayLower: this.ix.keys[9].pubkey,
2912
- binArrayUpper: this.ix.keys[10].pubkey,
2913
- tokenXProgram: this.ix.keys[12].pubkey,
2914
- tokenYProgram: this.ix.keys[13].pubkey,
2915
- eventAuthority: this.ix.keys[14].pubkey,
2916
- meteoraDlmmProgram: this.ix.keys[15].pubkey,
2917
- }).instruction();
2918
- // Instruction via main hawksight contract
2919
- // @ts-ignore
2920
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
2921
- .iyfExtensionExecute(depositIx.data)
2922
- .accounts({
2923
- farm,
2924
- userPda,
2925
- authority,
2926
- iyfProgram,
2927
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
2928
- })
2929
- .remainingAccounts([
2930
- depositIx.keys[4],
2931
- depositIx.keys[5],
2932
- depositIx.keys[6],
2933
- depositIx.keys[7],
2934
- depositIx.keys[8],
2935
- depositIx.keys[9],
2936
- depositIx.keys[10],
2937
- depositIx.keys[11],
2938
- depositIx.keys[12],
2939
- depositIx.keys[13],
2940
- depositIx.keys[14],
2941
- depositIx.keys[15],
2942
- depositIx.keys[16],
2943
- depositIx.keys[17],
2944
- depositIx.keys[18],
2945
- ])
2946
- .instruction();
2947
- // Override the instruction
2948
- this.ix.programId = ix.programId;
2949
- this.ix.data = ix.data;
2950
- this.ix.keys = ix.keys;
2951
- });
2952
- }
2953
- }
2954
- /**
2955
- * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
2956
- * This class is designed for blockchain operations that manage liquidity pools.
2957
- */
2958
- class AddLiquidityByStrategy2Pda extends AddLiquidityByStrategyPda {
2959
- /**
2960
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
2961
- *
2962
- * @param ix The core transaction instruction.
2963
- * @param userPda The user's program-derived address (PDA) as a public key.
2964
- * @param authority The authority public key that has signing capabilities over the transaction.
2965
- */
2966
- constructor(ix, userPda, authority) {
2967
- super(ix, userPda, authority);
2968
- }
2969
- replaceSender() {
2970
- this.ix.keys[9].pubkey = this.userPda;
2971
- this.ix.keys[9].isSigner = false;
2972
- }
2973
- }
2974
- /**
2975
- * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
2976
- * This class is designed for blockchain operations that manage liquidity pools.
2977
- */
2978
- class AddLiquidityByStrategyOneSidePda extends HawksightMeteoraPdaCpi {
2979
- /**
2980
- * Constructs an instance of InitializePosition with the necessary transaction parameters.
2981
- *
2982
- * @param ix The core transaction instruction.
2983
- * @param userPda The user's program-derived address (PDA) as a public key.
2984
- * @param authority The authority public key that has signing capabilities over the transaction.
2985
- */
2986
- constructor(ix, userPda, authority, opt) {
2987
- super(ix, userPda, authority, util.sighash("AddLiquidityByStrategyOneSide"), opt);
2988
- }
2989
- /**
2990
- * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
2991
- */
2992
- replace() {
2993
- var _a;
2994
- this.ix.keys[8].pubkey = this.userPda;
2995
- this.ix.keys[8].isSigner = false;
2996
- const tokenMintInfo = AccountCache_1.AccountCache.get(this.ix.keys[5].pubkey);
2997
- if (!tokenMintInfo) {
2998
- throw new Error("Unexpected error: Mint not found in cache.");
2999
- }
3000
- // Adjust by token type
3001
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
3002
- if (pdaTokenType === types_1.TokenType.LTA) {
3003
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
3004
- }
3005
- else if (pdaTokenType === types_1.TokenType.STA) {
3006
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
3007
- }
3008
- else {
3009
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[5].pubkey, tokenMintInfo.info.owner);
3010
- }
3011
- }
3012
- /**
3013
- * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
3014
- */
3015
- addHawksightCpi() {
3016
- return __awaiter(this, void 0, void 0, function* () {
3017
- // Common parameters
3018
- const farm = addresses_1.USDC_FARM;
3019
- const userPda = this.userPda;
3020
- const authority = this.authority;
3021
- const iyfProgram = addresses_1.IYF_MAIN;
3022
- // Generate IX via extension contract
3023
- // @ts-ignore
3024
- const depositIx = yield anchor_1.Anchor.instance().iyfExtension.methods
3025
- .meteoraDlmmOneSideDepositManual(this.ix.data.subarray(8))
3026
- .accounts({
3027
- farm,
3028
- userPda,
3029
- authority,
3030
- iyfProgram,
3031
- position: this.ix.keys[0].pubkey,
3032
- lbPair: this.ix.keys[1].pubkey,
3033
- binArrayBitmapExtension: this.ix.keys[2].pubkey,
3034
- userToken: this.ix.keys[3].pubkey,
3035
- reserve: this.ix.keys[4].pubkey,
3036
- tokenMint: this.ix.keys[5].pubkey,
3037
- binArrayLower: this.ix.keys[6].pubkey,
3038
- binArrayUpper: this.ix.keys[7].pubkey,
3039
- tokenProgram: this.ix.keys[9].pubkey,
3040
- eventAuthority: this.ix.keys[10].pubkey,
3041
- meteoraDlmmProgram: this.ix.keys[11].pubkey,
3042
- }).instruction();
3043
- // Instruction via main hawksight contract
3044
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
3045
- .iyfExtensionExecute(depositIx.data)
3046
- .accounts({
3047
- farm,
3048
- userPda,
3049
- authority,
3050
- iyfProgram,
3051
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
3052
- })
3053
- .remainingAccounts([
3054
- depositIx.keys[4],
3055
- depositIx.keys[5],
3056
- depositIx.keys[6],
3057
- depositIx.keys[7],
3058
- depositIx.keys[8],
3059
- depositIx.keys[9],
3060
- depositIx.keys[10],
3061
- depositIx.keys[11],
3062
- depositIx.keys[12],
3063
- depositIx.keys[13],
3064
- depositIx.keys[14],
3065
- depositIx.keys[15],
3066
- ])
3067
- .instruction();
3068
- // Override the instruction
3069
- this.ix.programId = ix.programId;
3070
- this.ix.data = ix.data;
3071
- this.ix.keys = ix.keys;
3072
- });
3073
- }
3074
- }
3075
- /**
3076
- * Handles Meteora DLMM Deposit v2 instruction (non-automation version).
3077
- */
3078
- class MeteoraDlmmDeposit2 extends HawksightMeteoraCpi {
3079
- /**
3080
- * Constructs an instance of MeteoraDlmmDeposit2 with the necessary transaction parameters.
3081
- *
3082
- * @param ix The core transaction instruction.
3083
- * @param userPda The user's program-derived address (PDA) as a public key.
3084
- * @param authority The authority public key that has signing capabilities over the transaction.
3085
- */
3086
- constructor(ix, userPda, authority, opt, label, classification) {
3087
- super(ix, userPda, authority, Buffer.from([202, 49, 107, 181, 87, 156, 173, 94]), opt, label, classification);
3088
- }
3089
- /**
3090
- * Modifies transaction keys for the purpose of depositing liquidity.
3091
- */
3092
- replace() {
3093
- this.ix.keys[1].pubkey = this.userPda;
3094
- this.ix.keys[1].isSigner = false;
3095
- }
3096
- /**
3097
- * Overrides default add hawksight cpi to use meteoraDlmmDeposit2 instead of meteoraDynamicCpi
3098
- */
3099
- addHawksightCpi() {
3100
- return __awaiter(this, void 0, void 0, function* () {
3101
- var _a;
3102
- // Common parameters
3103
- const userPda = this.userPda;
3104
- const authority = this.authority;
3105
- // Get token mints X and Y
3106
- const tokenXMint = this.ix.keys[8].pubkey;
3107
- const tokenYMint = this.ix.keys[9].pubkey;
3108
- // Generate IX via extension contract
3109
- const data = this.ix.data.subarray(8);
3110
- const activeId = data.subarray(0, 4).readInt32LE();
3111
- const maxActiveBinSlippage = data.subarray(4, 8).readInt32LE();
3112
- const strategyParametersMinBinId = data.subarray(8, 12).readInt32LE();
3113
- const strategyParametersMaxBinId = data.subarray(12, 16).readInt32LE();
3114
- const strategyParametersStrategyType = data[16];
3115
- const strategyParametersParameters = Array.from(data.subarray(17));
3116
- const tokenXMintInfo = AccountCache_1.AccountCache.get(tokenXMint);
3117
- const tokenYMintInfo = AccountCache_1.AccountCache.get(tokenYMint);
3118
- if (!(!!tokenXMintInfo && !!tokenYMintInfo)) {
3119
- throw new Error("Unexpected error: Mint X or Y not found in cache.");
3120
- }
3121
- // Adjust by token type
3122
- const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
3123
- if (pdaTokenType === types_1.TokenType.LTA) {
3124
- this.ix.keys[5].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[9].pubkey);
3125
- this.ix.keys[6].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[10].pubkey);
3126
- }
3127
- else if (pdaTokenType === types_1.TokenType.STA) {
3128
- this.ix.keys[5].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[9].pubkey);
3129
- this.ix.keys[6].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[10].pubkey);
3130
- }
3131
- else {
3132
- this.ix.keys[5].pubkey = util.generateAta(this.userPda, this.ix.keys[9].pubkey, tokenXMintInfo.info.owner);
3133
- this.ix.keys[6].pubkey = util.generateAta(this.userPda, this.ix.keys[10].pubkey, tokenYMintInfo.info.owner);
3134
- }
3135
- // Generate IX via extension contract
3136
- // @ts-ignore
3137
- const depositIx = yield anchor_1.Anchor.instance().iyfExtension.methods
3138
- .meteoraDlmmDeposit2(activeId, maxActiveBinSlippage, strategyParametersMinBinId, strategyParametersMaxBinId, strategyParametersStrategyType, strategyParametersParameters)
3139
- .accounts({
3140
- userPda,
3141
- authority,
3142
- position: this.ix.keys[2].pubkey,
3143
- lbPair: this.ix.keys[3].pubkey,
3144
- binArrayBitmapExtension: this.ix.keys[4].pubkey,
3145
- userTokenX: this.ix.keys[5].pubkey,
3146
- userTokenY: this.ix.keys[6].pubkey,
3147
- reserveX: this.ix.keys[7].pubkey,
3148
- reserveY: this.ix.keys[8].pubkey,
3149
- tokenXMint: this.ix.keys[9].pubkey,
3150
- tokenYMint: this.ix.keys[10].pubkey,
3151
- tokenXProgram: this.ix.keys[11].pubkey,
3152
- tokenYProgram: this.ix.keys[12].pubkey,
3153
- eventAuthority: this.ix.keys[13].pubkey,
3154
- meteoraDlmmProgram: this.ix.keys[14].pubkey,
3155
- }).instruction();
3156
- const sighash = util.sighash("meteora_dlmm_deposit_2");
3157
- depositIx.data.set(sighash, 0);
3158
- // Instruction via main hawksight contract
3159
- // @ts-ignore
3160
- const ix = yield anchor_1.Anchor.instance().iyfMain.methods
3161
- .iyfExtensionExecuteV2(depositIx.data)
3162
- .accounts({
3163
- userPda,
3164
- authority,
3165
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
3166
- })
3167
- .remainingAccounts(depositIx.keys.slice(2))
3168
- .instruction();
3169
- // Override the instruction
3170
- this.ix.programId = ix.programId;
3171
- this.ix.data = ix.data;
3172
- this.ix.keys = ix.keys;
3173
- });
3174
- }
3175
- }