@hawksightco/hawk-sdk 1.1.39 → 1.1.41-hotfix-1

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 (40) hide show
  1. package/dist/src/classes/CreateTxMetadata.d.ts.map +1 -1
  2. package/dist/src/classes/CreateTxMetadata.js +2 -12
  3. package/dist/src/classes/MultiTransaction.d.ts +76 -0
  4. package/dist/src/classes/MultiTransaction.d.ts.map +1 -0
  5. package/dist/src/classes/MultiTransaction.js +286 -0
  6. package/dist/src/classes/Transaction copy.d.ts +162 -0
  7. package/dist/src/classes/Transaction copy.d.ts.map +1 -0
  8. package/dist/src/classes/Transaction copy.js +458 -0
  9. package/dist/src/classes/Transaction.d.ts +42 -12
  10. package/dist/src/classes/Transaction.d.ts.map +1 -1
  11. package/dist/src/classes/Transaction.js +1 -0
  12. package/dist/src/classes/Transaction2.d.ts +108 -0
  13. package/dist/src/classes/Transaction2.d.ts.map +1 -0
  14. package/dist/src/classes/Transaction2.js +239 -0
  15. package/dist/src/classes/Transaction3.d.ts +166 -0
  16. package/dist/src/classes/Transaction3.d.ts.map +1 -0
  17. package/dist/src/classes/Transaction3.js +406 -0
  18. package/dist/src/classes/TransactionBatchExecute2.d.ts +18 -0
  19. package/dist/src/classes/TransactionBatchExecute2.d.ts.map +1 -1
  20. package/dist/src/classes/TransactionBatchExecute2.js +72 -1
  21. package/dist/src/classes/Transactions.d.ts +4 -2
  22. package/dist/src/classes/Transactions.d.ts.map +1 -1
  23. package/dist/src/classes/Transactions.js +17 -11
  24. package/dist/src/classes/TxGenerator.d.ts +2 -1
  25. package/dist/src/classes/TxGenerator.d.ts.map +1 -1
  26. package/dist/src/classes/TxGenerator.js +8 -23
  27. package/dist/src/functions.d.ts +25 -0
  28. package/dist/src/functions.d.ts.map +1 -1
  29. package/dist/src/functions.js +70 -1
  30. package/dist/src/hsToMeteora.d.ts.map +1 -1
  31. package/dist/src/hsToMeteora.js +173 -27
  32. package/dist/src/idl/meteora-idl.d.ts +5251 -0
  33. package/dist/src/idl/meteora-idl.d.ts.map +1 -0
  34. package/dist/src/idl/meteora-idl.js +5252 -0
  35. package/dist/src/meteora.d.ts +1 -1
  36. package/dist/src/meteora.d.ts.map +1 -1
  37. package/dist/src/meteora.js +37 -2
  38. package/dist/src/types.d.ts +6 -7
  39. package/dist/src/types.d.ts.map +1 -1
  40. package/package.json +1 -1
@@ -49,6 +49,8 @@ const anchor_1 = require("../anchor");
49
49
  const hawksight_1 = require("../hawksight");
50
50
  const types_2 = require("../types");
51
51
  const Logging_1 = require("./Logging");
52
+ const TransactionBatchExecute2_1 = require("./TransactionBatchExecute2");
53
+ const CreateTxMetadata_1 = require("./CreateTxMetadata");
52
54
  class Transactions {
53
55
  /**
54
56
  * Generate UserPDA
@@ -319,25 +321,29 @@ class Transactions {
319
321
  * @param connection The Solana web3 connection object for blockchain interactions.
320
322
  * @param payer The public key of the payer for transaction fees.
321
323
  * @param params Parameters required
322
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse.
324
+ * @returns Array of transaction instructions (simplified output)
323
325
  */
324
- meteoraClaimAll(_a) {
325
- return __awaiter(this, arguments, void 0, function* ({ connection, params, }) {
326
+ meteoraClaimAll(_a, payer_1, generalUtility_1) {
327
+ return __awaiter(this, arguments, void 0, function* ({ connection, params, }, payer, generalUtility) {
326
328
  const userPda = (0, functions_1.generateUserPda)(params.userWallet);
327
- const txs = [];
328
329
  const fn = new meteora_1.MeteoraFunctions();
329
330
  // Step 1: Get all user position
330
331
  // This function also downloads pools needed to generate claim all transaction.
331
332
  const positions = yield fn.getAllUserPosition(connection, userPda);
332
333
  // Step 2: Generate claim fee and claim reward transactions
333
- const mainInstructions = yield fn.claimFeeAndRewardIxs2(connection, positions, userPda);
334
- // Step 3: Return the instructions
335
- return yield (0, functions_1.createTransactionMeta)({
336
- payer: params.userWallet,
337
- description: "Claim all fees and rewards across all meteora positions.",
338
- addressLookupTableAddresses: addresses_1.GLOBAL_ALT,
339
- mainInstructions,
334
+ const builder = yield fn.claimFeeAndRewardIxs2(connection, positions, params.userWallet, userPda, hsToMeteora_1.meteoraToHawksight);
335
+ // Step 2.5: Generate transactions
336
+ const mainInstructions = builder.default();
337
+ const latestBlockhash = yield connection.getLatestBlockhash();
338
+ const batchGenerator = new TransactionBatchExecute2_1.TransactionBatchExecute2(addresses_1.GLOBAL_ALT.map(p => new web3.PublicKey(p)), mainInstructions, connection, CreateTxMetadata_1.CreateTxMetadata.instance(), latestBlockhash, payer);
339
+ // Insert nonce advance tx at end of transaction
340
+ batchGenerator.insertNonceAt({
341
+ onlyEndOfTx: true,
340
342
  });
343
+ // Generate batch of transactions
344
+ const txs = yield batchGenerator.buildBatchWithAlts('Claim all fees / rewards from Meteora DLMM position', generalUtility);
345
+ // Simplified return value
346
+ return txs;
341
347
  });
342
348
  }
343
349
  /**
@@ -4,6 +4,7 @@ import * as _client from "@hawksightco/swagger-client";
4
4
  import { ResponseWithStatus, TransactionMetadata, OrcaWithdraw, OrcaDeposit, OrcaClosePosition, OrcaOpenPosition, OrcaClaimRewards, MeteoraClaimAll } from "../types";
5
5
  import { Client } from "./Client";
6
6
  import { GeneralUtility } from "./GeneralUtility";
7
+ import { MultiTransaction } from "./MultiTransaction";
7
8
  /**
8
9
  * The `TxGenerator` class encapsulates methods to generate transactions with various trading operations
9
10
  * on decentralized market making platforms like Meteora and Orca within the Solana ecosystem. It allows
@@ -62,7 +63,7 @@ export declare class TxGenerator {
62
63
  * @param params Parameters required
63
64
  * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
64
65
  */
65
- meteoraClaimAll(connection: web3.Connection, payer: string, params: MeteoraClaimAll): Promise<ResponseWithStatus<TransactionMetadata[]>>;
66
+ meteoraClaimAll(connection: web3.Connection, payer: string, params: MeteoraClaimAll): Promise<MultiTransaction>;
66
67
  /**
67
68
  * Creates meteora instruction that closes position.
68
69
  *
@@ -1 +1 @@
1
- {"version":3,"file":"TxGenerator.d.ts","source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BAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAgChJ;;;;;;;OAOG;IACG,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAkCpI;;;;;;;OAOG;IACG,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAiCtI;;;;;;;OAOG;IACG,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CA+B/I"}
@@ -247,29 +247,14 @@ class TxGenerator {
247
247
  return __awaiter(this, void 0, void 0, function* () {
248
248
  // Initialize anchor
249
249
  anchor_1.Anchor.initialize(connection);
250
- try {
251
- const startTime = new Date().getTime() / 1000;
252
- (0, Logging_1.Log)(`meteoraClaimAll: Benchmarking txgen.meteoraClaimAll`);
253
- const result = yield Transactions_1.txgen.meteoraClaimAll({
254
- connection,
255
- params,
256
- });
257
- (0, Logging_1.Log)(`meteoraClaim: await txgen.meteoraClaimAll elapsed time: ${new Date().getTime() / 1000 - startTime}`);
258
- return {
259
- status: 200,
260
- data: yield (0, functions_1.createTxMetadata2)(this.generalUtility, connection, payer, result),
261
- };
262
- }
263
- catch (e) {
264
- return {
265
- status: 400,
266
- data: {
267
- code: "custom",
268
- message: e,
269
- path: [],
270
- },
271
- };
272
- }
250
+ const startTime = new Date().getTime() / 1000;
251
+ (0, Logging_1.Log)(`meteoraClaimAll: Benchmarking txgen.meteoraClaimAll`);
252
+ const result = yield Transactions_1.txgen.meteoraClaimAll({
253
+ connection,
254
+ params,
255
+ }, new web3.PublicKey(payer), this.generalUtility);
256
+ (0, Logging_1.Log)(`meteoraClaim: await txgen.meteoraClaimAll elapsed time: ${new Date().getTime() / 1000 - startTime}`);
257
+ return result;
273
258
  });
274
259
  }
275
260
  /**
@@ -273,5 +273,30 @@ export declare function stringToAlt(connection: web3.Connection, alts: string[])
273
273
  export declare function getPriorityFeeEstimate(priorityLevel: string, transaction: web3.VersionedTransaction, rpcUrl: string): PriorityFeeEstimate;
274
274
  export declare function getPriorityFeeEstimate2(transaction: string, options: any, url: string): Promise<any>;
275
275
  export declare function mid(min: number, max: number): number;
276
+ /**
277
+ * Find all nonce pubkey owned by given owner and index
278
+ *
279
+ * @param owner
280
+ */
281
+ export declare function generateNonceAddressFromIndex(owner: web3.PublicKey, index: number): Promise<web3.PublicKey>;
282
+ /**
283
+ * Find all nonce pubkey owned by given owner
284
+ *
285
+ * @param owner
286
+ */
287
+ export declare function generateNonceAddressesOwnedBy(owner: web3.PublicKey, count: number): Promise<web3.PublicKey[]>;
288
+ /**
289
+ * Find all nonce pubkey owned by given owner
290
+ *
291
+ * TODO: Put this into a class and the class must serve as cache of nonce accounts (so that we don't query nonce account multiple times)
292
+ *
293
+ * @param owner
294
+ */
295
+ export declare function findNonceOwnedBy(connection: web3.Connection, owner: web3.PublicKey, count: number): Promise<web3.AccountInfo<web3.NonceAccount>[]>;
296
+ export declare const benchmark: ({ end, name, msg }: {
297
+ name: string;
298
+ msg: string;
299
+ end?: boolean | undefined;
300
+ }) => void;
276
301
  export {};
277
302
  //# sourceMappingURL=functions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,gBAAgB,EACh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,MAAM,EACnB,OAAO,EAAE,GAAG,EACZ,GAAG,EAAE,MAAM,gBAmBZ;AAED,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAE3C;AAED;;;;GAIG;AACH,wBAAsB,6BAA6B,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAEjH;AAED;;;;GAIG;AACH,wBAAsB,6BAA6B,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAMnH;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAqBxJ;AAED,eAAO,MAAM,SAAS;UAEZ,MAAM;SACP,MAAM;;UAaX,CAAC"}
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.mid = exports.getPriorityFeeEstimate2 = exports.getPriorityFeeEstimate = exports.stringToAlt = exports.ixStrToWeb3Ix = exports.toVersionedTransaction = exports.getJupiterRouteIxParams = exports.inputTokenExists = exports.unwrapWsolToSol = exports.unwrapSolIfMintIsWsol = exports.wrapSolToWsol = exports.wrapSolIfMintIsWsol = exports.getMintsFromInstruction = exports.createAtaIdempotentIxs = exports.parseTokenAccountData = exports.tokenAccountExists = exports.sighash = exports.sighashMatch = exports.getIxs = exports.generateUserPdaStorageAccount = exports.generateOrcaPositionPDA = exports.generateAta = exports.generateUserPda = exports.createTransactionMeta = exports.getMeteoraPool = exports.getFeeEstimate = exports.resultOrError = exports.createTxMetadata2 = exports.createTxMetadata = exports.METEORA_API_URL = void 0;
38
+ exports.benchmark = exports.findNonceOwnedBy = exports.generateNonceAddressesOwnedBy = exports.generateNonceAddressFromIndex = exports.mid = exports.getPriorityFeeEstimate2 = exports.getPriorityFeeEstimate = exports.stringToAlt = exports.ixStrToWeb3Ix = exports.toVersionedTransaction = exports.getJupiterRouteIxParams = exports.inputTokenExists = exports.unwrapWsolToSol = exports.unwrapSolIfMintIsWsol = exports.wrapSolToWsol = exports.wrapSolIfMintIsWsol = exports.getMintsFromInstruction = exports.createAtaIdempotentIxs = exports.parseTokenAccountData = exports.tokenAccountExists = exports.sighash = exports.sighashMatch = exports.getIxs = exports.generateUserPdaStorageAccount = exports.generateOrcaPositionPDA = exports.generateAta = exports.generateUserPda = exports.createTransactionMeta = exports.getMeteoraPool = exports.getFeeEstimate = exports.resultOrError = exports.createTxMetadata2 = exports.createTxMetadata = exports.METEORA_API_URL = void 0;
39
39
  const client = __importStar(require("@hawksightco/swagger-client"));
40
40
  const web3 = __importStar(require("@solana/web3.js"));
41
41
  const axios_1 = __importDefault(require("axios"));
@@ -47,6 +47,7 @@ const js_sha256_1 = require("js-sha256");
47
47
  const bn_js_1 = __importDefault(require("bn.js"));
48
48
  const spl_token_1 = require("@solana/spl-token");
49
49
  const bs58_1 = __importDefault(require("bs58"));
50
+ const Logging_1 = require("./classes/Logging");
50
51
  exports.METEORA_API_URL = "https://dlmm-api.meteora.ag";
51
52
  /**
52
53
  * Asynchronously creates transaction metadata based on the provided transaction parameters and network state.
@@ -691,3 +692,71 @@ function mid(min, max) {
691
692
  return min + (max - min) / 2;
692
693
  }
693
694
  exports.mid = mid;
695
+ /**
696
+ * Find all nonce pubkey owned by given owner and index
697
+ *
698
+ * @param owner
699
+ */
700
+ function generateNonceAddressFromIndex(owner, index) {
701
+ return __awaiter(this, void 0, void 0, function* () {
702
+ return yield web3.PublicKey.createWithSeed(owner, `hs-nonce-${index}`, web3.SystemProgram.programId);
703
+ });
704
+ }
705
+ exports.generateNonceAddressFromIndex = generateNonceAddressFromIndex;
706
+ /**
707
+ * Find all nonce pubkey owned by given owner
708
+ *
709
+ * @param owner
710
+ */
711
+ function generateNonceAddressesOwnedBy(owner, count) {
712
+ return __awaiter(this, void 0, void 0, function* () {
713
+ const nonceAddresses = [];
714
+ for (let i = 0; i < count; i++) {
715
+ nonceAddresses.push(yield generateNonceAddressFromIndex(owner, i));
716
+ }
717
+ return nonceAddresses;
718
+ });
719
+ }
720
+ exports.generateNonceAddressesOwnedBy = generateNonceAddressesOwnedBy;
721
+ /**
722
+ * Find all nonce pubkey owned by given owner
723
+ *
724
+ * TODO: Put this into a class and the class must serve as cache of nonce accounts (so that we don't query nonce account multiple times)
725
+ *
726
+ * @param owner
727
+ */
728
+ function findNonceOwnedBy(connection, owner, count) {
729
+ return __awaiter(this, void 0, void 0, function* () {
730
+ const nonceAddresses = yield generateNonceAddressesOwnedBy(owner, count);
731
+ const infos = yield connection.getMultipleAccountsInfo(nonceAddresses);
732
+ const result = infos.filter(info => info !== null).map(info => {
733
+ const result = {
734
+ /** `true` if this account's data contains a loaded program */
735
+ executable: info.executable,
736
+ /** Identifier of the program that owns the account */
737
+ owner: info.owner,
738
+ /** Number of lamports assigned to the account */
739
+ lamports: info.lamports,
740
+ /** Optional data assigned to the account */
741
+ data: web3.NonceAccount.fromAccountData(info.data),
742
+ /** Optional rent epoch info for account */
743
+ rentEpoch: info.rentEpoch,
744
+ };
745
+ return result;
746
+ });
747
+ return result;
748
+ });
749
+ }
750
+ exports.findNonceOwnedBy = findNonceOwnedBy;
751
+ exports.benchmark = (() => {
752
+ let startTime;
753
+ return ({ end, name, msg }) => {
754
+ if (end) {
755
+ (0, Logging_1.Log)(`${name}: ${msg} elapsed time: ${new Date().getTime() / 1000 - startTime}`);
756
+ }
757
+ else {
758
+ startTime = new Date().getTime() / 1000;
759
+ (0, Logging_1.Log)(`${name}: Benchmarking ${msg}`);
760
+ }
761
+ };
762
+ })();
@@ -1 +1 @@
1
- {"version":3,"file":"hsToMeteora.d.ts","sourceRoot":"","sources":["../../src/hsToMeteora.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAcnD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,EAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAQpI;AAED;;;;;GAKG;AACH,wBAAsB,+BAA+B,CAAC,EAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAUjJ"}
1
+ {"version":3,"file":"hsToMeteora.d.ts","sourceRoot":"","sources":["../../src/hsToMeteora.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAcnD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,EAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAUpI;AAED;;;;;GAKG;AACH,wBAAsB,+BAA+B,CAAC,EAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAUjJ"}
@@ -45,13 +45,15 @@ const util = __importStar(require("./functions"));
45
45
  */
46
46
  function meteoraToHawksight(_a) {
47
47
  return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority }) {
48
- return ixs.map((ix) => {
49
- ix = HawksightMeteoraCpi.factory(ix, userPda, authority).getInstruction();
48
+ const _ixs = [];
49
+ for (const ix of ixs) {
50
+ const _ix = yield HawksightMeteoraCpi.factory(ix, userPda, authority).getInstruction();
50
51
  if (ix.programId.toString() === addresses_1.ASSOCIATED_TOKEN_PROGRAM.toString() && ix.keys.length === 6) {
51
52
  ix.keys[0] = Object.assign(Object.assign({}, ix.keys[0]), { pubkey: authority });
52
53
  }
53
- return ix;
54
- });
54
+ _ixs.push(_ix);
55
+ }
56
+ return _ixs;
55
57
  });
56
58
  }
57
59
  exports.meteoraToHawksight = meteoraToHawksight;
@@ -141,13 +143,34 @@ class HawksightMeteoraCpi {
141
143
  * @returns The (possibly modified) transaction instruction.
142
144
  */
143
145
  getInstruction() {
144
- const matchInstance = this.sighashMatch();
145
- if (this.programIdMatch() && matchInstance !== undefined) {
146
- matchInstance.replace();
147
- matchInstance.addHawksightCpi();
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ const matchInstance = this.sighashMatch();
148
+ if (this.programIdMatch() && matchInstance !== undefined) {
149
+ matchInstance.replace();
150
+ yield matchInstance.addHawksightCpi();
151
+ return this.ix;
152
+ }
148
153
  return this.ix;
149
- }
150
- return this.ix;
154
+ });
155
+ }
156
+ /**
157
+ * Modifies the transaction instruction to include specific Hawksight CPI details.
158
+ * Prepares the instruction for execution by adjusting its program ID and data based on Hawksight criteria.
159
+ */
160
+ addHawksightCpi() {
161
+ return __awaiter(this, void 0, void 0, function* () {
162
+ const METEORA_PROGRAM = addresses_1.METEORA_DLMM_PROGRAM;
163
+ const size = Buffer.alloc(4);
164
+ size.writeUint32LE(this.ix.data.length);
165
+ const data = Buffer.concat([util.sighash('meteora_dynamic_cpi'), size, this.ix.data]);
166
+ this.ix.programId = addresses_1.IYF_MAIN;
167
+ this.ix.data = data;
168
+ this.ix.keys.unshift(...[
169
+ { pubkey: this.userPda, isSigner: false, isWritable: false },
170
+ { pubkey: this.authority, isSigner: true, isWritable: true },
171
+ { pubkey: METEORA_PROGRAM, isSigner: false, isWritable: false },
172
+ ]);
173
+ });
151
174
  }
152
175
  /**
153
176
  * Adds a subsequent CPI to the chain.
@@ -187,23 +210,6 @@ class HawksightMeteoraCpi {
187
210
  programIdMatch() {
188
211
  return this.ix.programId.equals(addresses_1.METEORA_DLMM_PROGRAM);
189
212
  }
190
- /**
191
- * Modifies the transaction instruction to include specific Hawksight CPI details.
192
- * Prepares the instruction for execution by adjusting its program ID and data based on Hawksight criteria.
193
- */
194
- addHawksightCpi() {
195
- const METEORA_PROGRAM = addresses_1.METEORA_DLMM_PROGRAM;
196
- const size = Buffer.alloc(4);
197
- size.writeUint32LE(this.ix.data.length);
198
- const data = Buffer.concat([util.sighash('meteora_dynamic_cpi'), size, this.ix.data]);
199
- this.ix.programId = addresses_1.IYF_MAIN;
200
- this.ix.data = data;
201
- this.ix.keys.unshift(...[
202
- { pubkey: this.userPda, isSigner: false, isWritable: false },
203
- { pubkey: this.authority, isSigner: true, isWritable: true },
204
- { pubkey: METEORA_PROGRAM, isSigner: false, isWritable: false },
205
- ]);
206
- }
207
213
  }
208
214
  /**
209
215
  * Handles the initialization of a position in a blockchain transaction.
@@ -379,6 +385,80 @@ class ClaimFee extends HawksightMeteoraCpi {
379
385
  this.ix.keys[4].pubkey = this.userPda;
380
386
  this.ix.keys[4].isSigner = false;
381
387
  }
388
+ /**
389
+ * Overrides default add hawksight cpi to use meteoraDlmmClaimFee instead of meteoraDynamicCpi
390
+ */
391
+ addHawksightCpi() {
392
+ return __awaiter(this, void 0, void 0, function* () {
393
+ // Common parameters
394
+ const farm = addresses_1.USDC_FARM;
395
+ const userPda = this.userPda;
396
+ const authority = this.authority;
397
+ const iyfProgram = addresses_1.IYF_MAIN;
398
+ // Get token mints X and Y
399
+ const tokenXMint = this.ix.keys[9].pubkey;
400
+ const tokenYMint = this.ix.keys[10].pubkey;
401
+ // Generate owner fee X and Y ATA
402
+ const ownerFeeX = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenXMint);
403
+ const ownerFeeY = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenYMint);
404
+ // Generate IX via extension contract
405
+ const claimFeeIx = yield anchor_1.Anchor.instance().iyfExtension.methods
406
+ .meteoraDlmmClaimFee()
407
+ .accounts({
408
+ farm,
409
+ userPda,
410
+ authority,
411
+ iyfProgram,
412
+ lbPair: this.ix.keys[0].pubkey,
413
+ position: this.ix.keys[1].pubkey,
414
+ binArrayLower: this.ix.keys[2].pubkey,
415
+ binArrayUpper: this.ix.keys[3].pubkey,
416
+ reserveX: this.ix.keys[5].pubkey,
417
+ reserveY: this.ix.keys[6].pubkey,
418
+ userTokenX: this.ix.keys[7].pubkey,
419
+ userTokenY: this.ix.keys[8].pubkey,
420
+ tokenXMint: this.ix.keys[9].pubkey,
421
+ tokenYMint: this.ix.keys[10].pubkey,
422
+ tokenProgram: this.ix.keys[11].pubkey,
423
+ eventAuthority: this.ix.keys[12].pubkey,
424
+ meteoraDlmmProgram: this.ix.keys[13].pubkey,
425
+ ownerFeeX,
426
+ ownerFeeY,
427
+ }).instruction();
428
+ // Instruction via main hawksight contract
429
+ const ix = yield anchor_1.Anchor.instance().iyfMain.methods
430
+ .iyfExtensionExecute(claimFeeIx.data)
431
+ .accounts({
432
+ farm,
433
+ userPda,
434
+ authority,
435
+ iyfProgram,
436
+ iyfExtensionProgram: addresses_1.IYF_EXTENSION,
437
+ })
438
+ .remainingAccounts([
439
+ claimFeeIx.keys[4],
440
+ claimFeeIx.keys[5],
441
+ claimFeeIx.keys[6],
442
+ claimFeeIx.keys[7],
443
+ claimFeeIx.keys[8],
444
+ claimFeeIx.keys[9],
445
+ claimFeeIx.keys[10],
446
+ claimFeeIx.keys[11],
447
+ claimFeeIx.keys[12],
448
+ claimFeeIx.keys[13],
449
+ claimFeeIx.keys[14],
450
+ claimFeeIx.keys[15],
451
+ claimFeeIx.keys[16],
452
+ claimFeeIx.keys[17],
453
+ claimFeeIx.keys[18],
454
+ ])
455
+ .instruction();
456
+ // Override the instruction
457
+ this.ix.programId = ix.programId;
458
+ this.ix.data = ix.data;
459
+ this.ix.keys = ix.keys;
460
+ });
461
+ }
382
462
  }
383
463
  /**
384
464
  * Manages the claiming of rewards in blockchain operations, typically associated with staking or similar activities.
@@ -401,6 +481,72 @@ class ClaimReward extends HawksightMeteoraCpi {
401
481
  this.ix.keys[4].pubkey = this.userPda;
402
482
  this.ix.keys[4].isSigner = false;
403
483
  }
484
+ /**
485
+ * Overrides default add hawksight cpi to use meteoraDlmmClaimReward instead of meteoraDynamicCpi
486
+ */
487
+ addHawksightCpi() {
488
+ return __awaiter(this, void 0, void 0, function* () {
489
+ // Common parameters
490
+ const farm = addresses_1.USDC_FARM;
491
+ const userPda = this.userPda;
492
+ const authority = this.authority;
493
+ const iyfProgram = addresses_1.IYF_MAIN;
494
+ // Get token mint
495
+ const rewardMint = this.ix.keys[9].pubkey;
496
+ // Generate owner fee X and Y ATA
497
+ const ownerFee = util.generateAta(addresses_1.SITE_FEE_OWNER, rewardMint);
498
+ // Get reward index from parameter
499
+ const rewardIndex = new bn_js_1.BN(this.ix.data.readBigInt64LE(8).toString());
500
+ // Generate IX via extension contract
501
+ const claimReward = yield anchor_1.Anchor.instance().iyfExtension.methods
502
+ .meteoraDlmmClaimReward(rewardIndex)
503
+ .accounts({
504
+ farm,
505
+ userPda,
506
+ authority,
507
+ iyfProgram,
508
+ lbPair: this.ix.keys[4].pubkey,
509
+ position: this.ix.keys[5].pubkey,
510
+ binArrayLower: this.ix.keys[6].pubkey,
511
+ binArrayUpper: this.ix.keys[7].pubkey,
512
+ rewardVault: this.ix.keys[8].pubkey,
513
+ rewardMint: this.ix.keys[9].pubkey,
514
+ userTokenAccount: this.ix.keys[10].pubkey,
515
+ tokenProgram: this.ix.keys[11].pubkey,
516
+ eventAuthority: this.ix.keys[12].pubkey,
517
+ meteoraDlmmProgram: this.ix.keys[13].pubkey,
518
+ ownerFee,
519
+ }).instruction();
520
+ // Instruction via main hawksight contract
521
+ const ix = yield anchor_1.Anchor.instance().iyfMain.methods
522
+ .iyfExtensionExecute(claimReward.data)
523
+ .accounts({
524
+ farm,
525
+ userPda,
526
+ authority,
527
+ iyfProgram,
528
+ iyfExtensionProgram: addresses_1.IYF_EXTENSION,
529
+ })
530
+ .remainingAccounts([
531
+ claimReward.keys[4],
532
+ claimReward.keys[5],
533
+ claimReward.keys[6],
534
+ claimReward.keys[7],
535
+ claimReward.keys[8],
536
+ claimReward.keys[9],
537
+ claimReward.keys[10],
538
+ claimReward.keys[11],
539
+ claimReward.keys[12],
540
+ claimReward.keys[13],
541
+ claimReward.keys[14],
542
+ ])
543
+ .instruction();
544
+ // Override the instruction
545
+ this.ix.programId = ix.programId;
546
+ this.ix.data = ix.data;
547
+ this.ix.keys = ix.keys;
548
+ });
549
+ }
404
550
  }
405
551
  /**
406
552
  * Handles the closure of a position within a blockchain transaction.