@hawksightco/hawk-sdk 1.2.13 → 1.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,13 +31,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
32
  });
33
33
  };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
34
37
  Object.defineProperty(exports, "__esModule", { value: true });
35
38
  exports.meteoraToHawksightPdaIxs = exports.meteoraToHawksightAutomationIxs = exports.meteoraToHawksight = void 0;
36
39
  const types_1 = require("./types");
37
40
  const addresses_1 = require("./addresses");
38
41
  const anchor_1 = require("./anchor");
39
- const bn_js_1 = require("bn.js");
42
+ const bn_js_1 = __importDefault(require("bn.js"));
40
43
  const util = __importStar(require("./functions"));
44
+ // import { Log } from "./classes/Logging";
45
+ const SimpleIxGenerator_1 = require("./classes/SimpleIxGenerator");
41
46
  /**
42
47
  * Convert listed meteora instruction to generalized hawksight meteora cpi
43
48
  *
@@ -45,10 +50,10 @@ const util = __importStar(require("./functions"));
45
50
  * @returns
46
51
  */
47
52
  function meteoraToHawksight(_a) {
48
- return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority, pdaTokenType }) {
53
+ return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority, opt }) {
49
54
  const _ixs = [];
50
55
  for (const ix of ixs) {
51
- const _ix = yield HawksightMeteoraCpi.factory(ix, userPda, authority, pdaTokenType).getInstruction();
56
+ const _ix = yield HawksightMeteoraCpi.factory(ix, userPda, authority, opt).getInstruction();
52
57
  if (ix.programId.toString() === addresses_1.ASSOCIATED_TOKEN_PROGRAM.toString() && ix.keys.length === 6) {
53
58
  ix.keys[0] = Object.assign(Object.assign({}, ix.keys[0]), { pubkey: authority });
54
59
  }
@@ -65,10 +70,10 @@ exports.meteoraToHawksight = meteoraToHawksight;
65
70
  * @returns
66
71
  */
67
72
  function meteoraToHawksightAutomationIxs(_a) {
68
- return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority, pdaTokenType }) {
73
+ return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority, opt }) {
69
74
  const _ixs = [];
70
75
  for (const ix of ixs) {
71
- const _ix = yield HawksightMeteoraAutomationCpi.factory(ix, userPda, authority, pdaTokenType).getInstruction();
76
+ const _ix = yield HawksightMeteoraAutomationCpi.factory(ix, userPda, authority, opt).getInstruction();
72
77
  if (ix.programId.toString() === addresses_1.ASSOCIATED_TOKEN_PROGRAM.toString() && ix.keys.length === 6) {
73
78
  ix.keys[0] = Object.assign(Object.assign({}, ix.keys[0]), { pubkey: addresses_1.HS_AUTHORITY });
74
79
  }
@@ -85,10 +90,10 @@ exports.meteoraToHawksightAutomationIxs = meteoraToHawksightAutomationIxs;
85
90
  * @returns
86
91
  */
87
92
  function meteoraToHawksightPdaIxs(_a) {
88
- return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority, pdaTokenType }) {
93
+ return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority, opt }) {
89
94
  const _ixs = [];
90
95
  for (const ix of ixs) {
91
- const _ix = yield HawksightMeteoraPdaCpi.factory(ix, userPda, authority, pdaTokenType).getInstruction();
96
+ const _ix = yield HawksightMeteoraPdaCpi.factory(ix, userPda, authority, opt).getInstruction();
92
97
  if (ix.programId.toString() === addresses_1.ASSOCIATED_TOKEN_PROGRAM.toString() && ix.keys.length === 6) {
93
98
  ix.keys[0] = Object.assign(Object.assign({}, ix.keys[0]), { pubkey: addresses_1.HS_AUTHORITY });
94
99
  }
@@ -130,11 +135,12 @@ class HawksightMeteoraCpi {
130
135
  * @param authority The authority public key that has signing capabilities over the transaction.
131
136
  * @param sighash A Buffer containing the sighash used for matching the transaction instruction.
132
137
  */
133
- constructor(ix, userPda, authority, sighash) {
138
+ constructor(ix, userPda, authority, sighash, opt) {
134
139
  this.ix = ix;
135
140
  this.userPda = userPda;
136
141
  this.authority = authority;
137
142
  this.sighash = sighash;
143
+ this.opt = opt;
138
144
  }
139
145
  /**
140
146
  * Factory method to create and link a chain of CPIs starting from `InitializePosition`.
@@ -144,18 +150,18 @@ class HawksightMeteoraCpi {
144
150
  * @param authority The authority public key.
145
151
  * @returns The first CPI in the chain.
146
152
  */
147
- static factory(ix, userPda, authority, pdaTokenType) {
148
- const chain = new InitializePosition(ix, userPda, authority);
153
+ static factory(ix, userPda, authority, opt) {
154
+ const chain = new InitializePosition(ix, userPda, authority, opt);
149
155
  chain
150
- .next(new AddLiquidityByWeight(ix, userPda, authority, pdaTokenType))
151
- .next(new AddLiquidityOneSide(ix, userPda, authority, pdaTokenType))
152
- .next(new AddLiquidityByStrategy(ix, userPda, authority, pdaTokenType))
153
- .next(new AddLiquidityByStrategyOneSide(ix, userPda, authority, pdaTokenType))
154
- .next(new RemoveLiquidity(ix, userPda, authority, util.sighash("RemoveLiquidity"), pdaTokenType))
155
- .next(new RemoveLiquidityByRange(ix, userPda, authority, pdaTokenType))
156
- .next(new ClaimFee(ix, userPda, authority, pdaTokenType))
157
- .next(new ClaimReward(ix, userPda, authority, pdaTokenType))
158
- .next(new ClosePosition(ix, userPda, authority));
156
+ .next(new AddLiquidityByWeight(ix, userPda, authority, opt))
157
+ .next(new AddLiquidityOneSide(ix, userPda, authority, opt))
158
+ .next(new AddLiquidityByStrategy(ix, userPda, authority, opt))
159
+ .next(new AddLiquidityByStrategyOneSide(ix, userPda, authority, opt))
160
+ .next(new RemoveLiquidity(ix, userPda, authority, util.sighash("RemoveLiquidity"), opt))
161
+ .next(new RemoveLiquidityByRange(ix, userPda, authority, opt))
162
+ .next(new ClaimFee(ix, userPda, authority, opt))
163
+ .next(new ClaimReward(ix, userPda, authority, opt))
164
+ .next(new ClosePosition(ix, userPda, authority, opt));
159
165
  return chain;
160
166
  }
161
167
  /**
@@ -248,8 +254,8 @@ class InitializePosition extends HawksightMeteoraCpi {
248
254
  * @param userPda The user's program-derived address (PDA) as a public key.
249
255
  * @param authority The authority public key that has signing capabilities over the transaction.
250
256
  */
251
- constructor(ix, userPda, authority) {
252
- super(ix, userPda, authority, util.sighash("InitializePosition"));
257
+ constructor(ix, userPda, authority, opt) {
258
+ super(ix, userPda, authority, util.sighash("InitializePosition"), opt);
253
259
  }
254
260
  /**
255
261
  * Modifies the transaction keys to set the correct public keys for an initial position setup.
@@ -272,22 +278,23 @@ class AddLiquidityByWeight extends HawksightMeteoraCpi {
272
278
  * @param userPda The user's program-derived address (PDA) as a public key.
273
279
  * @param authority The authority public key that has signing capabilities over the transaction.
274
280
  */
275
- constructor(ix, userPda, authority, pdaTokenType) {
276
- super(ix, userPda, authority, util.sighash("AddLiquidityByWeight"));
277
- this.pdaTokenType = pdaTokenType;
281
+ constructor(ix, userPda, authority, opt) {
282
+ super(ix, userPda, authority, util.sighash("AddLiquidityByWeight"), opt);
278
283
  }
279
284
  /**
280
285
  * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
281
286
  */
282
287
  replace() {
288
+ var _a;
283
289
  this.ix.keys[11].pubkey = this.userPda;
284
290
  this.ix.keys[11].isSigner = false;
285
291
  // Adjust by token type
286
- if (this.pdaTokenType === types_1.TokenType.LTA) {
292
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
293
+ if (pdaTokenType === types_1.TokenType.LTA) {
287
294
  this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
288
295
  this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
289
296
  }
290
- else if (this.pdaTokenType === types_1.TokenType.STA) {
297
+ else if (pdaTokenType === types_1.TokenType.STA) {
291
298
  this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
292
299
  this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
293
300
  }
@@ -309,22 +316,23 @@ class AddLiquidityByStrategy extends HawksightMeteoraCpi {
309
316
  * @param userPda The user's program-derived address (PDA) as a public key.
310
317
  * @param authority The authority public key that has signing capabilities over the transaction.
311
318
  */
312
- constructor(ix, userPda, authority, pdaTokenType) {
319
+ constructor(ix, userPda, authority, opt) {
313
320
  super(ix, userPda, authority, util.sighash("AddLiquidityByStrategy"));
314
- this.pdaTokenType = pdaTokenType;
315
321
  }
316
322
  /**
317
323
  * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
318
324
  */
319
325
  replace() {
326
+ var _a;
320
327
  this.ix.keys[11].pubkey = this.userPda;
321
328
  this.ix.keys[11].isSigner = false;
322
329
  // Adjust by token type
323
- if (this.pdaTokenType === types_1.TokenType.LTA) {
330
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
331
+ if (pdaTokenType === types_1.TokenType.LTA) {
324
332
  this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
325
333
  this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
326
334
  }
327
- else if (this.pdaTokenType === types_1.TokenType.STA) {
335
+ else if (pdaTokenType === types_1.TokenType.STA) {
328
336
  this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
329
337
  this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
330
338
  }
@@ -346,21 +354,22 @@ class AddLiquidityOneSide extends HawksightMeteoraCpi {
346
354
  * @param userPda The user's program-derived address (PDA) as a public key.
347
355
  * @param authority The authority public key that has signing capabilities over the transaction.
348
356
  */
349
- constructor(ix, userPda, authority, pdaTokenType) {
350
- super(ix, userPda, authority, util.sighash("AddLiquidityOneSide"));
351
- this.pdaTokenType = pdaTokenType;
357
+ constructor(ix, userPda, authority, opt) {
358
+ super(ix, userPda, authority, util.sighash("AddLiquidityOneSide"), opt);
352
359
  }
353
360
  /**
354
361
  * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
355
362
  */
356
363
  replace() {
364
+ var _a;
357
365
  this.ix.keys[8].pubkey = this.userPda;
358
366
  this.ix.keys[8].isSigner = false;
359
367
  // Adjust by token type
360
- if (this.pdaTokenType === types_1.TokenType.LTA) {
368
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
369
+ if (pdaTokenType === types_1.TokenType.LTA) {
361
370
  this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
362
371
  }
363
- else if (this.pdaTokenType === types_1.TokenType.STA) {
372
+ else if (pdaTokenType === types_1.TokenType.STA) {
364
373
  this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
365
374
  }
366
375
  else {
@@ -380,21 +389,22 @@ class AddLiquidityByStrategyOneSide extends HawksightMeteoraCpi {
380
389
  * @param userPda The user's program-derived address (PDA) as a public key.
381
390
  * @param authority The authority public key that has signing capabilities over the transaction.
382
391
  */
383
- constructor(ix, userPda, authority, pdaTokenType) {
384
- super(ix, userPda, authority, util.sighash("AddLiquidityByStrategyOneSide"));
385
- this.pdaTokenType = pdaTokenType;
392
+ constructor(ix, userPda, authority, opt) {
393
+ super(ix, userPda, authority, util.sighash("AddLiquidityByStrategyOneSide"), opt);
386
394
  }
387
395
  /**
388
396
  * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
389
397
  */
390
398
  replace() {
399
+ var _a;
391
400
  this.ix.keys[8].pubkey = this.userPda;
392
401
  this.ix.keys[8].isSigner = false;
393
402
  // Adjust by token type
394
- if (this.pdaTokenType === types_1.TokenType.LTA) {
403
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
404
+ if (pdaTokenType === types_1.TokenType.LTA) {
395
405
  this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
396
406
  }
397
- else if (this.pdaTokenType === types_1.TokenType.STA) {
407
+ else if (pdaTokenType === types_1.TokenType.STA) {
398
408
  this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
399
409
  }
400
410
  else {
@@ -413,22 +423,23 @@ class RemoveLiquidity extends HawksightMeteoraCpi {
413
423
  * @param userPda The user's program-derived address (PDA) as a public key.
414
424
  * @param authority The authority public key that has signing capabilities over the transaction.
415
425
  */
416
- constructor(ix, userPda, authority, sighash = util.sighash("RemoveLiquidity"), pdaTokenType) {
417
- super(ix, userPda, authority, sighash);
418
- this.pdaTokenType = pdaTokenType;
426
+ constructor(ix, userPda, authority, sighash = util.sighash("RemoveLiquidity"), opt) {
427
+ super(ix, userPda, authority, sighash, opt);
419
428
  }
420
429
  /**
421
430
  * Customizes the transaction keys to correctly handle the removal of liquidity.
422
431
  */
423
432
  replace() {
433
+ var _a;
424
434
  this.ix.keys[11].pubkey = this.userPda;
425
435
  this.ix.keys[11].isSigner = false;
426
436
  // Adjust by token type
427
- if (this.pdaTokenType === types_1.TokenType.LTA) {
437
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
438
+ if (pdaTokenType === types_1.TokenType.LTA) {
428
439
  this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
429
440
  this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
430
441
  }
431
- else if (this.pdaTokenType === types_1.TokenType.STA) {
442
+ else if (pdaTokenType === types_1.TokenType.STA) {
432
443
  this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
433
444
  this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
434
445
  }
@@ -449,8 +460,8 @@ class RemoveLiquidityByRange extends RemoveLiquidity {
449
460
  * @param userPda The user's program-derived address (PDA) as a public key.
450
461
  * @param authority The authority public key that has signing capabilities over the transaction.
451
462
  */
452
- constructor(ix, userPda, authority, pdaTokenType) {
453
- super(ix, userPda, authority, util.sighash("RemoveLiquidityByRange"), pdaTokenType);
463
+ constructor(ix, userPda, authority, opt) {
464
+ super(ix, userPda, authority, util.sighash("RemoveLiquidityByRange"), opt);
454
465
  }
455
466
  }
456
467
  /**
@@ -464,22 +475,23 @@ class ClaimFee extends HawksightMeteoraCpi {
464
475
  * @param userPda The user's program-derived address (PDA) as a public key.
465
476
  * @param authority The authority public key that has signing capabilities over the transaction.
466
477
  */
467
- constructor(ix, userPda, authority, pdaTokenType) {
468
- super(ix, userPda, authority, util.sighash("ClaimFee"));
469
- this.pdaTokenType = pdaTokenType;
478
+ constructor(ix, userPda, authority, opt) {
479
+ super(ix, userPda, authority, util.sighash("ClaimFee"), opt);
470
480
  }
471
481
  /**
472
482
  * Modifies transaction keys for the purpose of claiming transaction fees.
473
483
  */
474
484
  replace() {
485
+ var _a;
475
486
  this.ix.keys[4].pubkey = this.userPda;
476
487
  this.ix.keys[4].isSigner = false;
477
488
  // Adjust by token type
478
- if (this.pdaTokenType === types_1.TokenType.LTA) {
489
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
490
+ if (pdaTokenType === types_1.TokenType.LTA) {
479
491
  this.ix.keys[7].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[9].pubkey);
480
492
  this.ix.keys[8].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[10].pubkey);
481
493
  }
482
- else if (this.pdaTokenType === types_1.TokenType.STA) {
494
+ else if (pdaTokenType === types_1.TokenType.STA) {
483
495
  this.ix.keys[7].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[9].pubkey);
484
496
  this.ix.keys[8].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[10].pubkey);
485
497
  }
@@ -575,21 +587,22 @@ class ClaimReward extends HawksightMeteoraCpi {
575
587
  * @param userPda The user's program-derived address (PDA) as a public key.
576
588
  * @param authority The authority public key that has signing capabilities over the transaction.
577
589
  */
578
- constructor(ix, userPda, authority, pdaTokenType) {
579
- super(ix, userPda, authority, util.sighash("ClaimReward"));
580
- this.pdaTokenType = pdaTokenType;
590
+ constructor(ix, userPda, authority, opt) {
591
+ super(ix, userPda, authority, util.sighash("ClaimReward"), opt);
581
592
  }
582
593
  /**
583
594
  * Adjusts transaction keys to facilitate the claiming of rewards.
584
595
  */
585
596
  replace() {
597
+ var _a;
586
598
  this.ix.keys[4].pubkey = this.userPda;
587
599
  this.ix.keys[4].isSigner = false;
588
600
  // Adjust by token type
589
- if (this.pdaTokenType === types_1.TokenType.LTA) {
601
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
602
+ if (pdaTokenType === types_1.TokenType.LTA) {
590
603
  this.ix.keys[7].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[6].pubkey);
591
604
  }
592
- else if (this.pdaTokenType === types_1.TokenType.STA) {
605
+ else if (pdaTokenType === types_1.TokenType.STA) {
593
606
  this.ix.keys[7].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[6].pubkey);
594
607
  }
595
608
  else {
@@ -611,7 +624,7 @@ class ClaimReward extends HawksightMeteoraCpi {
611
624
  // Generate owner fee X and Y ATA
612
625
  const ownerFee = util.generateAta(addresses_1.SITE_FEE_OWNER, rewardMint);
613
626
  // Get reward index from parameter
614
- const rewardIndex = new bn_js_1.BN(this.ix.data.readBigInt64LE(8).toString());
627
+ const rewardIndex = new bn_js_1.default(this.ix.data.readBigInt64LE(8).toString());
615
628
  // Generate IX via extension contract
616
629
  // @ts-ignore
617
630
  const claimReward = yield anchor_1.Anchor.instance().iyfExtension.methods
@@ -675,8 +688,8 @@ class ClosePosition extends HawksightMeteoraCpi {
675
688
  * @param userPda The user's program-derived address (PDA) as a public key.
676
689
  * @param authority The authority public key that has signing capabilities over the transaction.
677
690
  */
678
- constructor(ix, userPda, authority) {
679
- super(ix, userPda, authority, util.sighash("ClosePosition"));
691
+ constructor(ix, userPda, authority, opt) {
692
+ super(ix, userPda, authority, util.sighash("ClosePosition"), opt);
680
693
  }
681
694
  /**
682
695
  * Customizes the transaction keys to properly close a position, ensuring all relevant keys are set correctly.
@@ -700,11 +713,12 @@ class HawksightMeteoraAutomationCpi {
700
713
  * @param authority The authority public key that has signing capabilities over the transaction.
701
714
  * @param sighash A Buffer containing the sighash used for matching the transaction instruction.
702
715
  */
703
- constructor(_ix, userPda, authority, sighash) {
716
+ constructor(_ix, userPda, authority, sighash, opt) {
704
717
  this._ix = _ix;
705
718
  this.userPda = userPda;
706
719
  this.authority = authority;
707
720
  this.sighash = sighash;
721
+ this.opt = opt;
708
722
  }
709
723
  /**
710
724
  * Factory method to create and link a chain of CPIs starting from `InitializePosition`.
@@ -714,16 +728,17 @@ class HawksightMeteoraAutomationCpi {
714
728
  * @param authority The authority public key.
715
729
  * @returns The first CPI in the chain.
716
730
  */
717
- static factory(ix, userPda, authority, pdaTokenType) {
718
- const chain = new InitializePositionAutomation(ix, userPda, authority);
731
+ static factory(ix, userPda, authority, opt) {
732
+ const chain = new InitializePositionAutomation(ix, userPda, authority, opt);
719
733
  chain
720
- .next(new AddLiquidityByWeightAutomation(ix, userPda, authority, pdaTokenType))
721
- .next(new AddLiquidityOneSideAutomation(ix, userPda, authority, pdaTokenType))
722
- .next(new RemoveLiquidityAutomation(ix, userPda, authority, util.sighash("RemoveLiquidity"), pdaTokenType))
723
- .next(new RemoveLiquidityByRangeAutomation(ix, userPda, authority, pdaTokenType))
724
- .next(new ClaimFeeAutomation(ix, userPda, authority, pdaTokenType))
725
- .next(new ClaimRewardAutomation(ix, userPda, authority, pdaTokenType))
726
- .next(new ClosePositionAutomation(ix, userPda, authority));
734
+ .next(new AddLiquidityByStrategyAutomation(ix, userPda, authority, opt))
735
+ .next(new AddLiquidityByWeightAutomation(ix, userPda, authority, opt))
736
+ .next(new AddLiquidityOneSideAutomation(ix, userPda, authority, opt))
737
+ .next(new RemoveLiquidityAutomation(ix, userPda, authority, util.sighash("RemoveLiquidity"), opt))
738
+ .next(new RemoveLiquidityByRangeAutomation(ix, userPda, authority, opt))
739
+ .next(new ClaimFeeAutomation(ix, userPda, authority, opt))
740
+ .next(new ClaimRewardAutomation(ix, userPda, authority, opt))
741
+ .next(new ClosePositionAutomation(ix, userPda, authority, opt));
727
742
  return chain;
728
743
  }
729
744
  /**
@@ -792,8 +807,8 @@ class InitializePositionAutomation extends HawksightMeteoraAutomationCpi {
792
807
  * @param userPda The user's program-derived address (PDA) as a public key.
793
808
  * @param authority The authority public key that has signing capabilities over the transaction.
794
809
  */
795
- constructor(ix, userPda, authority) {
796
- super(ix, userPda, authority, util.sighash("InitializePosition"));
810
+ constructor(ix, userPda, authority, opt) {
811
+ super(ix, userPda, authority, util.sighash("InitializePosition"), opt);
797
812
  }
798
813
  /**
799
814
  * Modifies the transaction keys to set the correct public keys for an initial position setup.
@@ -862,6 +877,8 @@ class InitializePositionAutomation extends HawksightMeteoraAutomationCpi {
862
877
  /**
863
878
  * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
864
879
  * This class is designed for blockchain operations that manage liquidity pools.
880
+ *
881
+ * PS: Not used by meteora API. It uses addLiquidityByStrategy instead so it's expected that this won't be called.
865
882
  */
866
883
  class AddLiquidityByWeightAutomation extends HawksightMeteoraAutomationCpi {
867
884
  /**
@@ -871,9 +888,8 @@ class AddLiquidityByWeightAutomation extends HawksightMeteoraAutomationCpi {
871
888
  * @param userPda The user's program-derived address (PDA) as a public key.
872
889
  * @param authority The authority public key that has signing capabilities over the transaction.
873
890
  */
874
- constructor(ix, userPda, authority, pdaTokenType) {
875
- super(ix, userPda, authority, util.sighash("AddLiquidityByWeight"));
876
- this.pdaTokenType = pdaTokenType;
891
+ constructor(ix, userPda, authority, opt) {
892
+ super(ix, userPda, authority, util.sighash("AddLiquidityByWeight"), opt);
877
893
  }
878
894
  /**
879
895
  * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
@@ -881,25 +897,13 @@ class AddLiquidityByWeightAutomation extends HawksightMeteoraAutomationCpi {
881
897
  replace() {
882
898
  this._ix.keys[11].pubkey = this.userPda;
883
899
  this._ix.keys[11].isSigner = false;
884
- // Adjust by token type
885
- if (this.pdaTokenType === types_1.TokenType.LTA) {
886
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
887
- this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
888
- }
889
- else if (this.pdaTokenType === types_1.TokenType.STA) {
890
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
891
- this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
892
- }
893
- else {
894
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey);
895
- this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey);
896
- }
897
900
  }
898
901
  /**
899
902
  * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
900
903
  */
901
904
  replaceCpi() {
902
905
  return __awaiter(this, void 0, void 0, function* () {
906
+ var _a;
903
907
  // Common parameters
904
908
  const farm = addresses_1.USDC_FARM;
905
909
  const userPda = this.userPda;
@@ -917,6 +921,20 @@ class AddLiquidityByWeightAutomation extends HawksightMeteoraAutomationCpi {
917
921
  const strategyParametersMaxBinId = data.subarray(28, 32).readInt32LE();
918
922
  const strategyParametersStrategyType = data[32];
919
923
  const strategyParametersParameters = Array.from(data.subarray(33));
924
+ // Adjust by token type
925
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
926
+ if (pdaTokenType === types_1.TokenType.LTA) {
927
+ this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
928
+ this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
929
+ }
930
+ else if (pdaTokenType === types_1.TokenType.STA) {
931
+ this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
932
+ this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
933
+ }
934
+ else {
935
+ this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey);
936
+ this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey);
937
+ }
920
938
  // @ts-ignore
921
939
  const depositIx = yield anchor_1.Anchor.instance().iyfExtension.methods
922
940
  .meteoraDlmmDepositAutomation(activeId, maxActiveBinSlippage, strategyParametersMinBinId, strategyParametersMaxBinId, strategyParametersStrategyType, strategyParametersParameters)
@@ -976,6 +994,123 @@ class AddLiquidityByWeightAutomation extends HawksightMeteoraAutomationCpi {
976
994
  });
977
995
  }
978
996
  }
997
+ /**
998
+ * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
999
+ * This class is designed for blockchain operations that manage liquidity pools.
1000
+ */
1001
+ class AddLiquidityByStrategyAutomation extends HawksightMeteoraAutomationCpi {
1002
+ /**
1003
+ * Constructs an instance of InitializePosition with the necessary transaction parameters.
1004
+ *
1005
+ * @param ix The core transaction instruction.
1006
+ * @param userPda The user's program-derived address (PDA) as a public key.
1007
+ * @param authority The authority public key that has signing capabilities over the transaction.
1008
+ */
1009
+ constructor(ix, userPda, authority, opt) {
1010
+ super(ix, userPda, authority, util.sighash("AddLiquidityByStrategy"), opt);
1011
+ }
1012
+ /**
1013
+ * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
1014
+ */
1015
+ replace() {
1016
+ // Note: Essentially not needed due to `replaceCpi` function that overrides the instruction.
1017
+ // Thus, commenting out the contents of `replace` function.
1018
+ // this._ix.keys[11].pubkey = this.userPda;
1019
+ // this._ix.keys[11].isSigner = false;
1020
+ }
1021
+ /**
1022
+ * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
1023
+ */
1024
+ replaceCpi() {
1025
+ return __awaiter(this, void 0, void 0, function* () {
1026
+ var _a, _b, _c;
1027
+ const generator = new SimpleIxGenerator_1.SimpleIxGenerator();
1028
+ // Common parameters
1029
+ const authority = this.authority;
1030
+ // Get token mints X and Y
1031
+ const tokenXMint = this.ix.keys[7].pubkey;
1032
+ const tokenYMint = this.ix.keys[8].pubkey;
1033
+ // Generate IX via extension contract
1034
+ const data = this.ix.data.subarray(8);
1035
+ const activeId = data.subarray(16, 20).readInt32LE();
1036
+ const maxActiveBinSlippage = data.subarray(20, 24).readInt32LE();
1037
+ const strategyParametersMinBinId = data.subarray(24, 28).readInt32LE();
1038
+ const strategyParametersMaxBinId = data.subarray(28, 32).readInt32LE();
1039
+ const strategyParametersStrategyType = data[32];
1040
+ const strategyParametersParameters = Array.from(data.subarray(33));
1041
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
1042
+ const withAmount = (_c = (_b = this.opt) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.withAmount;
1043
+ if (withAmount !== undefined) {
1044
+ const userTokenXAmount = withAmount.userTokenXAmount;
1045
+ const userTokenYAmount = withAmount.userTokenYAmount;
1046
+ if (userTokenXAmount === undefined) {
1047
+ throw new Error("opt.params.withAmount.userTokenXAmount is required");
1048
+ }
1049
+ if (userTokenYAmount === undefined) {
1050
+ throw new Error("opt.params.withAmount.userTokenYAmount is required");
1051
+ }
1052
+ const ix = yield generator.meteoraDlmm.depositWithAmountAutomation(anchor_1.Anchor.instance().connection, {
1053
+ userWallet: authority,
1054
+ lbPair: this.ix.keys[1].pubkey,
1055
+ position: this.ix.keys[0].pubkey,
1056
+ tokenXMint,
1057
+ tokenYMint,
1058
+ binArrayBitmapExtension: this.ix.keys[2].pubkey,
1059
+ binArrayLower: this.ix.keys[9].pubkey,
1060
+ binArrayUpper: this.ix.keys[10].pubkey,
1061
+ tokenXProgram: this.ix.keys[12].pubkey,
1062
+ tokenYProgram: this.ix.keys[13].pubkey,
1063
+ activeId,
1064
+ maxActiveBinSlippage,
1065
+ strategyParametersMinBinId,
1066
+ strategyParametersMaxBinId,
1067
+ strategyParametersStrategyType,
1068
+ strategyParametersParameters,
1069
+ userTokenXAmount,
1070
+ userTokenYAmount,
1071
+ tokenType: pdaTokenType,
1072
+ });
1073
+ // Override the instruction
1074
+ this._ix = ix;
1075
+ return;
1076
+ }
1077
+ // Adjust by token type
1078
+ if (pdaTokenType === types_1.TokenType.LTA) {
1079
+ this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
1080
+ this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
1081
+ }
1082
+ else if (pdaTokenType === types_1.TokenType.STA) {
1083
+ this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
1084
+ this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
1085
+ }
1086
+ else {
1087
+ this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey);
1088
+ this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey);
1089
+ }
1090
+ const ix = yield generator.meteoraDlmm.depositAutomation(anchor_1.Anchor.instance().connection, {
1091
+ userWallet: authority,
1092
+ lbPair: this.ix.keys[1].pubkey,
1093
+ position: this.ix.keys[0].pubkey,
1094
+ tokenXMint,
1095
+ tokenYMint,
1096
+ binArrayBitmapExtension: this.ix.keys[2].pubkey,
1097
+ binArrayLower: this.ix.keys[9].pubkey,
1098
+ binArrayUpper: this.ix.keys[10].pubkey,
1099
+ tokenXProgram: this.ix.keys[12].pubkey,
1100
+ tokenYProgram: this.ix.keys[13].pubkey,
1101
+ activeId,
1102
+ maxActiveBinSlippage,
1103
+ strategyParametersMinBinId,
1104
+ strategyParametersMaxBinId,
1105
+ strategyParametersStrategyType,
1106
+ strategyParametersParameters,
1107
+ tokenType: pdaTokenType,
1108
+ });
1109
+ // Override the instruction
1110
+ this._ix = ix;
1111
+ });
1112
+ }
1113
+ }
979
1114
  /**
980
1115
  * Adjusts transaction instructions to add liquidity based on a specific weight in a financial application.
981
1116
  * This class is designed for blockchain operations that manage liquidity pools.
@@ -988,9 +1123,8 @@ class AddLiquidityOneSideAutomation extends HawksightMeteoraAutomationCpi {
988
1123
  * @param userPda The user's program-derived address (PDA) as a public key.
989
1124
  * @param authority The authority public key that has signing capabilities over the transaction.
990
1125
  */
991
- constructor(ix, userPda, authority, pdaTokenType) {
992
- super(ix, userPda, authority, util.sighash("AddLiquidityByStrategyOneSide"));
993
- this.pdaTokenType = pdaTokenType;
1126
+ constructor(ix, userPda, authority, opt) {
1127
+ super(ix, userPda, authority, util.sighash("AddLiquidityByStrategyOneSide"), opt);
994
1128
  }
995
1129
  /**
996
1130
  * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
@@ -998,28 +1132,30 @@ class AddLiquidityOneSideAutomation extends HawksightMeteoraAutomationCpi {
998
1132
  replace() {
999
1133
  this._ix.keys[8].pubkey = this.userPda;
1000
1134
  this._ix.keys[8].isSigner = false;
1001
- // Adjust by token type
1002
- if (this.pdaTokenType === types_1.TokenType.LTA) {
1003
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
1004
- }
1005
- else if (this.pdaTokenType === types_1.TokenType.STA) {
1006
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
1007
- }
1008
- else {
1009
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[5].pubkey);
1010
- }
1011
1135
  }
1012
1136
  /**
1013
1137
  * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
1014
1138
  */
1015
1139
  replaceCpi() {
1016
1140
  return __awaiter(this, void 0, void 0, function* () {
1141
+ var _a;
1017
1142
  // Common parameters
1018
1143
  const farm = addresses_1.USDC_FARM;
1019
1144
  const userPda = this.userPda;
1020
1145
  const authority = this.authority;
1021
1146
  const iyfProgram = addresses_1.IYF_MAIN;
1022
1147
  const hawksightAuthority = addresses_1.HS_AUTHORITY;
1148
+ // Adjust by token type
1149
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
1150
+ if (pdaTokenType === types_1.TokenType.LTA) {
1151
+ this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
1152
+ }
1153
+ else if (pdaTokenType === types_1.TokenType.STA) {
1154
+ this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
1155
+ }
1156
+ else {
1157
+ this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[5].pubkey);
1158
+ }
1023
1159
  // Generate IX via extension contract
1024
1160
  // @ts-ignore
1025
1161
  const depositIx = yield anchor_1.Anchor.instance().iyfExtension.methods
@@ -1083,9 +1219,8 @@ class RemoveLiquidityAutomation extends HawksightMeteoraAutomationCpi {
1083
1219
  * @param userPda The user's program-derived address (PDA) as a public key.
1084
1220
  * @param authority The authority public key that has signing capabilities over the transaction.
1085
1221
  */
1086
- constructor(ix, userPda, authority, sighash = util.sighash("RemoveLiquidity"), pdaTokenType) {
1087
- super(ix, userPda, authority, sighash);
1088
- this.pdaTokenType = pdaTokenType;
1222
+ constructor(ix, userPda, authority, sighash = util.sighash("RemoveLiquidity"), opt) {
1223
+ super(ix, userPda, authority, sighash, opt);
1089
1224
  }
1090
1225
  /**
1091
1226
  * Customizes the transaction keys to correctly handle the removal of liquidity.
@@ -1093,25 +1228,13 @@ class RemoveLiquidityAutomation extends HawksightMeteoraAutomationCpi {
1093
1228
  replace() {
1094
1229
  this._ix.keys[11].pubkey = this.userPda;
1095
1230
  this._ix.keys[11].isSigner = false;
1096
- // Adjust by token type
1097
- if (this.pdaTokenType === types_1.TokenType.LTA) {
1098
- this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
1099
- this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
1100
- }
1101
- else if (this.pdaTokenType === types_1.TokenType.STA) {
1102
- this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
1103
- this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
1104
- }
1105
- else {
1106
- this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey);
1107
- this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey);
1108
- }
1109
1231
  }
1110
1232
  /**
1111
1233
  * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
1112
1234
  */
1113
1235
  replaceCpi() {
1114
1236
  return __awaiter(this, void 0, void 0, function* () {
1237
+ var _a;
1115
1238
  // Common parameters
1116
1239
  const farm = addresses_1.USDC_FARM;
1117
1240
  const userPda = this.userPda;
@@ -1121,6 +1244,20 @@ class RemoveLiquidityAutomation extends HawksightMeteoraAutomationCpi {
1121
1244
  // Get token mints X and Y
1122
1245
  const tokenXMint = this.ix.keys[7].pubkey;
1123
1246
  const tokenYMint = this.ix.keys[8].pubkey;
1247
+ // Adjust by token type
1248
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
1249
+ if (pdaTokenType === types_1.TokenType.LTA) {
1250
+ this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
1251
+ this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
1252
+ }
1253
+ else if (pdaTokenType === types_1.TokenType.STA) {
1254
+ this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
1255
+ this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
1256
+ }
1257
+ else {
1258
+ this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey);
1259
+ this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey);
1260
+ }
1124
1261
  // Generate IX via extension contract
1125
1262
  // @ts-ignore
1126
1263
  const withdrawIx = yield anchor_1.Anchor.instance().iyfExtension.methods
@@ -1192,8 +1329,8 @@ class RemoveLiquidityByRangeAutomation extends RemoveLiquidityAutomation {
1192
1329
  * @param userPda The user's program-derived address (PDA) as a public key.
1193
1330
  * @param authority The authority public key that has signing capabilities over the transaction.
1194
1331
  */
1195
- constructor(ix, userPda, authority, pdaTokenType) {
1196
- super(ix, userPda, authority, util.sighash("RemoveLiquidityByRange"), pdaTokenType);
1332
+ constructor(ix, userPda, authority, opt) {
1333
+ super(ix, userPda, authority, util.sighash("RemoveLiquidityByRange"), opt);
1197
1334
  }
1198
1335
  }
1199
1336
  /**
@@ -1207,9 +1344,8 @@ class ClaimFeeAutomation extends HawksightMeteoraAutomationCpi {
1207
1344
  * @param userPda The user's program-derived address (PDA) as a public key.
1208
1345
  * @param authority The authority public key that has signing capabilities over the transaction.
1209
1346
  */
1210
- constructor(ix, userPda, authority, pdaTokenType) {
1211
- super(ix, userPda, authority, util.sighash("ClaimFee"));
1212
- this.pdaTokenType = pdaTokenType;
1347
+ constructor(ix, userPda, authority, opt) {
1348
+ super(ix, userPda, authority, util.sighash("ClaimFee"), opt);
1213
1349
  }
1214
1350
  /**
1215
1351
  * Modifies transaction keys for the purpose of claiming transaction fees.
@@ -1217,25 +1353,13 @@ class ClaimFeeAutomation extends HawksightMeteoraAutomationCpi {
1217
1353
  replace() {
1218
1354
  this._ix.keys[4].pubkey = this.userPda;
1219
1355
  this._ix.keys[4].isSigner = false;
1220
- // Adjust by token type
1221
- if (this.pdaTokenType === types_1.TokenType.LTA) {
1222
- this.ix.keys[7].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[9].pubkey);
1223
- this.ix.keys[8].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[10].pubkey);
1224
- }
1225
- else if (this.pdaTokenType === types_1.TokenType.STA) {
1226
- this.ix.keys[7].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[9].pubkey);
1227
- this.ix.keys[8].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[10].pubkey);
1228
- }
1229
- else {
1230
- this.ix.keys[7].pubkey = util.generateAta(this.userPda, this.ix.keys[9].pubkey);
1231
- this.ix.keys[8].pubkey = util.generateAta(this.userPda, this.ix.keys[10].pubkey);
1232
- }
1233
1356
  }
1234
1357
  /**
1235
1358
  * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
1236
1359
  */
1237
1360
  replaceCpi() {
1238
1361
  return __awaiter(this, void 0, void 0, function* () {
1362
+ var _a;
1239
1363
  // Common parameters
1240
1364
  const farm = addresses_1.USDC_FARM;
1241
1365
  const userPda = this.userPda;
@@ -1248,6 +1372,20 @@ class ClaimFeeAutomation extends HawksightMeteoraAutomationCpi {
1248
1372
  // Generate owner fee X and Y ATA
1249
1373
  const ownerFeeX = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenXMint);
1250
1374
  const ownerFeeY = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenYMint);
1375
+ // Adjust by token type
1376
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
1377
+ if (pdaTokenType === types_1.TokenType.LTA) {
1378
+ this.ix.keys[7].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[9].pubkey);
1379
+ this.ix.keys[8].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[10].pubkey);
1380
+ }
1381
+ else if (pdaTokenType === types_1.TokenType.STA) {
1382
+ this.ix.keys[7].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[9].pubkey);
1383
+ this.ix.keys[8].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[10].pubkey);
1384
+ }
1385
+ else {
1386
+ this.ix.keys[7].pubkey = util.generateAta(this.userPda, this.ix.keys[9].pubkey);
1387
+ this.ix.keys[8].pubkey = util.generateAta(this.userPda, this.ix.keys[10].pubkey);
1388
+ }
1251
1389
  // Generate IX via extension contract
1252
1390
  // @ts-ignore
1253
1391
  const claimFeeIx = yield anchor_1.Anchor.instance().iyfExtension.methods
@@ -1319,9 +1457,8 @@ class ClaimRewardAutomation extends HawksightMeteoraAutomationCpi {
1319
1457
  * @param userPda The user's program-derived address (PDA) as a public key.
1320
1458
  * @param authority The authority public key that has signing capabilities over the transaction.
1321
1459
  */
1322
- constructor(ix, userPda, authority, pdaTokenType) {
1323
- super(ix, userPda, authority, util.sighash("ClaimReward"));
1324
- this.pdaTokenType = pdaTokenType;
1460
+ constructor(ix, userPda, authority, opt) {
1461
+ super(ix, userPda, authority, util.sighash("ClaimReward"), opt);
1325
1462
  }
1326
1463
  /**
1327
1464
  * Adjusts transaction keys to facilitate the claiming of rewards.
@@ -1329,24 +1466,15 @@ class ClaimRewardAutomation extends HawksightMeteoraAutomationCpi {
1329
1466
  replace() {
1330
1467
  this._ix.keys[4].pubkey = this.userPda;
1331
1468
  this._ix.keys[4].isSigner = false;
1332
- // Adjust by token type
1333
- if (this.pdaTokenType === types_1.TokenType.LTA) {
1334
- this.ix.keys[7].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[6].pubkey);
1335
- }
1336
- else if (this.pdaTokenType === types_1.TokenType.STA) {
1337
- this.ix.keys[7].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[6].pubkey);
1338
- }
1339
- else {
1340
- this.ix.keys[7].pubkey = util.generateAta(this.userPda, this.ix.keys[6].pubkey);
1341
- }
1342
1469
  }
1343
1470
  /**
1344
1471
  * Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
1345
1472
  */
1346
1473
  replaceCpi() {
1347
1474
  return __awaiter(this, void 0, void 0, function* () {
1475
+ var _a;
1348
1476
  // Get reward index from parameter
1349
- const rewardIndex = new bn_js_1.BN(this.ix.data.readBigInt64LE(8).toString());
1477
+ const rewardIndex = new bn_js_1.default(this.ix.data.readBigInt64LE(8).toString());
1350
1478
  // Common parameters
1351
1479
  const farm = addresses_1.USDC_FARM;
1352
1480
  const userPda = this.userPda;
@@ -1356,6 +1484,17 @@ class ClaimRewardAutomation extends HawksightMeteoraAutomationCpi {
1356
1484
  // Generate owner fee ATA
1357
1485
  const rewardMint = this.ix.keys[6].pubkey;
1358
1486
  const ownerFee = util.generateAta(addresses_1.SITE_FEE_OWNER, rewardMint);
1487
+ // Adjust by token type
1488
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
1489
+ if (pdaTokenType === types_1.TokenType.LTA) {
1490
+ this.ix.keys[7].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[6].pubkey);
1491
+ }
1492
+ else if (pdaTokenType === types_1.TokenType.STA) {
1493
+ this.ix.keys[7].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[6].pubkey);
1494
+ }
1495
+ else {
1496
+ this.ix.keys[7].pubkey = util.generateAta(this.userPda, this.ix.keys[6].pubkey);
1497
+ }
1359
1498
  // Generate IX via extension contract
1360
1499
  // @ts-ignore
1361
1500
  const claimRewardIx = yield anchor_1.Anchor.instance().iyfExtension.methods
@@ -1419,8 +1558,8 @@ class ClosePositionAutomation extends HawksightMeteoraAutomationCpi {
1419
1558
  * @param userPda The user's program-derived address (PDA) as a public key.
1420
1559
  * @param authority The authority public key that has signing capabilities over the transaction.
1421
1560
  */
1422
- constructor(ix, userPda, authority) {
1423
- super(ix, userPda, authority, util.sighash("ClosePosition"));
1561
+ constructor(ix, userPda, authority, opt) {
1562
+ super(ix, userPda, authority, util.sighash("ClosePosition"), opt);
1424
1563
  }
1425
1564
  /**
1426
1565
  * Customizes the transaction keys to properly close a position, ensuring all relevant keys are set correctly.
@@ -1515,11 +1654,12 @@ class HawksightMeteoraPdaCpi {
1515
1654
  * @param authority The authority public key that has signing capabilities over the transaction.
1516
1655
  * @param sighash A Buffer containing the sighash used for matching the transaction instruction.
1517
1656
  */
1518
- constructor(ix, userPda, authority, sighash) {
1657
+ constructor(ix, userPda, authority, sighash, opt) {
1519
1658
  this.ix = ix;
1520
1659
  this.userPda = userPda;
1521
1660
  this.authority = authority;
1522
1661
  this.sighash = sighash;
1662
+ this.opt = opt;
1523
1663
  }
1524
1664
  /**
1525
1665
  * Factory method to create and link a chain of CPIs starting from `InitializePosition`.
@@ -1529,11 +1669,11 @@ class HawksightMeteoraPdaCpi {
1529
1669
  * @param authority The authority public key.
1530
1670
  * @returns The first CPI in the chain.
1531
1671
  */
1532
- static factory(ix, userPda, authority, pdaTokenType) {
1533
- const chain = new InitializePositionPda(ix, userPda, authority);
1672
+ static factory(ix, userPda, authority, opt) {
1673
+ const chain = new InitializePositionPda(ix, userPda, authority, opt);
1534
1674
  chain
1535
- .next(new AddLiquidityByStrategyPda(ix, userPda, authority, pdaTokenType))
1536
- .next(new AddLiquidityByStrategyOneSidePda(ix, userPda, authority, pdaTokenType));
1675
+ .next(new AddLiquidityByStrategyPda(ix, userPda, authority, opt))
1676
+ .next(new AddLiquidityByStrategyOneSidePda(ix, userPda, authority, opt));
1537
1677
  return chain;
1538
1678
  }
1539
1679
  /**
@@ -1626,8 +1766,8 @@ class InitializePositionPda extends HawksightMeteoraPdaCpi {
1626
1766
  * @param userPda The user's program-derived address (PDA) as a public key.
1627
1767
  * @param authority The authority public key that has signing capabilities over the transaction.
1628
1768
  */
1629
- constructor(ix, userPda, authority) {
1630
- super(ix, userPda, authority, util.sighash("InitializePosition"));
1769
+ constructor(ix, userPda, authority, opt) {
1770
+ super(ix, userPda, authority, util.sighash("InitializePosition"), opt);
1631
1771
  }
1632
1772
  /**
1633
1773
  * Modifies the transaction keys to set the correct public keys for an initial position setup.
@@ -1649,22 +1789,23 @@ class AddLiquidityByStrategyPda extends HawksightMeteoraPdaCpi {
1649
1789
  * @param userPda The user's program-derived address (PDA) as a public key.
1650
1790
  * @param authority The authority public key that has signing capabilities over the transaction.
1651
1791
  */
1652
- constructor(ix, userPda, authority, pdaTokenType) {
1653
- super(ix, userPda, authority, util.sighash("AddLiquidityByStrategy"));
1654
- this.pdaTokenType = pdaTokenType;
1792
+ constructor(ix, userPda, authority, opt) {
1793
+ super(ix, userPda, authority, util.sighash("AddLiquidityByStrategy"), opt);
1655
1794
  }
1656
1795
  /**
1657
1796
  * Modifies transaction keys for the purpose of claiming transaction fees.
1658
1797
  */
1659
1798
  replace() {
1799
+ var _a;
1660
1800
  this.ix.keys[11].pubkey = this.userPda;
1661
1801
  this.ix.keys[11].isSigner = false;
1662
1802
  // Adjust by token type
1663
- if (this.pdaTokenType === types_1.TokenType.LTA) {
1803
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
1804
+ if (pdaTokenType === types_1.TokenType.LTA) {
1664
1805
  this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
1665
1806
  this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
1666
1807
  }
1667
- else if (this.pdaTokenType === types_1.TokenType.STA) {
1808
+ else if (pdaTokenType === types_1.TokenType.STA) {
1668
1809
  this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
1669
1810
  this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
1670
1811
  }
@@ -1766,21 +1907,22 @@ class AddLiquidityByStrategyOneSidePda extends HawksightMeteoraPdaCpi {
1766
1907
  * @param userPda The user's program-derived address (PDA) as a public key.
1767
1908
  * @param authority The authority public key that has signing capabilities over the transaction.
1768
1909
  */
1769
- constructor(ix, userPda, authority, pdaTokenType) {
1770
- super(ix, userPda, authority, util.sighash("AddLiquidityByStrategyOneSide"));
1771
- this.pdaTokenType = pdaTokenType;
1910
+ constructor(ix, userPda, authority, opt) {
1911
+ super(ix, userPda, authority, util.sighash("AddLiquidityByStrategyOneSide"), opt);
1772
1912
  }
1773
1913
  /**
1774
1914
  * Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
1775
1915
  */
1776
1916
  replace() {
1917
+ var _a;
1777
1918
  this.ix.keys[8].pubkey = this.userPda;
1778
1919
  this.ix.keys[8].isSigner = false;
1779
1920
  // Adjust by token type
1780
- if (this.pdaTokenType === types_1.TokenType.LTA) {
1921
+ const pdaTokenType = (_a = this.opt) === null || _a === void 0 ? void 0 : _a.pdaTokenType;
1922
+ if (pdaTokenType === types_1.TokenType.LTA) {
1781
1923
  this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
1782
1924
  }
1783
- else if (this.pdaTokenType === types_1.TokenType.STA) {
1925
+ else if (pdaTokenType === types_1.TokenType.STA) {
1784
1926
  this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
1785
1927
  }
1786
1928
  else {