@hawksightco/hawk-sdk 1.2.9 → 1.2.11
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.
- package/dist/src/classes/SimpleIxGenerator.d.ts.map +1 -1
- package/dist/src/classes/SimpleIxGenerator.js +1 -1
- package/dist/src/classes/Transactions.d.ts.map +1 -1
- package/dist/src/classes/Transactions.js +17 -17
- package/dist/src/classes/TxGenerator.d.ts +2 -2
- package/dist/src/classes/TxGenerator.d.ts.map +1 -1
- package/dist/src/classes/TxGenerator.js +8 -1
- package/dist/src/hawksight.d.ts +17 -2
- package/dist/src/hawksight.d.ts.map +1 -1
- package/dist/src/hawksight.js +120 -6
- package/dist/src/hsToMeteora.d.ts +3 -3
- package/dist/src/hsToMeteora.d.ts.map +1 -1
- package/dist/src/hsToMeteora.js +223 -44
- package/dist/src/idl/iyf-main-idl.d.ts +129 -0
- package/dist/src/idl/iyf-main-idl.d.ts.map +1 -1
- package/dist/src/idl/iyf-main-idl.js +129 -0
- package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts +54 -4
- package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts.map +1 -1
- package/dist/src/ixGenerator/IyfMainIxGenerator.js +70 -4
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts +3 -3
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts.map +1 -1
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.js +5 -5
- package/dist/src/meteora.d.ts +9 -1
- package/dist/src/meteora.d.ts.map +1 -1
- package/dist/src/meteora.js +21 -8
- package/dist/src/types.d.ts +8 -1
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/src/hsToMeteora.js
CHANGED
|
@@ -33,6 +33,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.meteoraToHawksightPdaIxs = exports.meteoraToHawksightAutomationIxs = exports.meteoraToHawksight = void 0;
|
|
36
|
+
const types_1 = require("./types");
|
|
36
37
|
const addresses_1 = require("./addresses");
|
|
37
38
|
const anchor_1 = require("./anchor");
|
|
38
39
|
const bn_js_1 = require("bn.js");
|
|
@@ -44,10 +45,10 @@ const util = __importStar(require("./functions"));
|
|
|
44
45
|
* @returns
|
|
45
46
|
*/
|
|
46
47
|
function meteoraToHawksight(_a) {
|
|
47
|
-
return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority }) {
|
|
48
|
+
return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority, pdaTokenType }) {
|
|
48
49
|
const _ixs = [];
|
|
49
50
|
for (const ix of ixs) {
|
|
50
|
-
const _ix = yield HawksightMeteoraCpi.factory(ix, userPda, authority).getInstruction();
|
|
51
|
+
const _ix = yield HawksightMeteoraCpi.factory(ix, userPda, authority, pdaTokenType).getInstruction();
|
|
51
52
|
if (ix.programId.toString() === addresses_1.ASSOCIATED_TOKEN_PROGRAM.toString() && ix.keys.length === 6) {
|
|
52
53
|
ix.keys[0] = Object.assign(Object.assign({}, ix.keys[0]), { pubkey: authority });
|
|
53
54
|
}
|
|
@@ -64,10 +65,10 @@ exports.meteoraToHawksight = meteoraToHawksight;
|
|
|
64
65
|
* @returns
|
|
65
66
|
*/
|
|
66
67
|
function meteoraToHawksightAutomationIxs(_a) {
|
|
67
|
-
return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority }) {
|
|
68
|
+
return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority, pdaTokenType }) {
|
|
68
69
|
const _ixs = [];
|
|
69
70
|
for (const ix of ixs) {
|
|
70
|
-
const _ix = yield HawksightMeteoraAutomationCpi.factory(ix, userPda, authority).getInstruction();
|
|
71
|
+
const _ix = yield HawksightMeteoraAutomationCpi.factory(ix, userPda, authority, pdaTokenType).getInstruction();
|
|
71
72
|
if (ix.programId.toString() === addresses_1.ASSOCIATED_TOKEN_PROGRAM.toString() && ix.keys.length === 6) {
|
|
72
73
|
ix.keys[0] = Object.assign(Object.assign({}, ix.keys[0]), { pubkey: addresses_1.HS_AUTHORITY });
|
|
73
74
|
}
|
|
@@ -84,10 +85,10 @@ exports.meteoraToHawksightAutomationIxs = meteoraToHawksightAutomationIxs;
|
|
|
84
85
|
* @returns
|
|
85
86
|
*/
|
|
86
87
|
function meteoraToHawksightPdaIxs(_a) {
|
|
87
|
-
return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority }) {
|
|
88
|
+
return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority, pdaTokenType }) {
|
|
88
89
|
const _ixs = [];
|
|
89
90
|
for (const ix of ixs) {
|
|
90
|
-
const _ix = yield HawksightMeteoraPdaCpi.factory(ix, userPda, authority).getInstruction();
|
|
91
|
+
const _ix = yield HawksightMeteoraPdaCpi.factory(ix, userPda, authority, pdaTokenType).getInstruction();
|
|
91
92
|
if (ix.programId.toString() === addresses_1.ASSOCIATED_TOKEN_PROGRAM.toString() && ix.keys.length === 6) {
|
|
92
93
|
ix.keys[0] = Object.assign(Object.assign({}, ix.keys[0]), { pubkey: addresses_1.HS_AUTHORITY });
|
|
93
94
|
}
|
|
@@ -143,17 +144,17 @@ class HawksightMeteoraCpi {
|
|
|
143
144
|
* @param authority The authority public key.
|
|
144
145
|
* @returns The first CPI in the chain.
|
|
145
146
|
*/
|
|
146
|
-
static factory(ix, userPda, authority) {
|
|
147
|
+
static factory(ix, userPda, authority, pdaTokenType) {
|
|
147
148
|
const chain = new InitializePosition(ix, userPda, authority);
|
|
148
149
|
chain
|
|
149
|
-
.next(new AddLiquidityByWeight(ix, userPda, authority))
|
|
150
|
-
.next(new AddLiquidityOneSide(ix, userPda, authority))
|
|
151
|
-
.next(new AddLiquidityByStrategy(ix, userPda, authority))
|
|
152
|
-
.next(new AddLiquidityByStrategyOneSide(ix, userPda, authority))
|
|
153
|
-
.next(new RemoveLiquidity(ix, userPda, authority))
|
|
154
|
-
.next(new RemoveLiquidityByRange(ix, userPda, authority))
|
|
155
|
-
.next(new ClaimFee(ix, userPda, authority))
|
|
156
|
-
.next(new ClaimReward(ix, userPda, authority))
|
|
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))
|
|
157
158
|
.next(new ClosePosition(ix, userPda, authority));
|
|
158
159
|
return chain;
|
|
159
160
|
}
|
|
@@ -271,8 +272,9 @@ class AddLiquidityByWeight extends HawksightMeteoraCpi {
|
|
|
271
272
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
272
273
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
273
274
|
*/
|
|
274
|
-
constructor(ix, userPda, authority) {
|
|
275
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
275
276
|
super(ix, userPda, authority, util.sighash("AddLiquidityByWeight"));
|
|
277
|
+
this.pdaTokenType = pdaTokenType;
|
|
276
278
|
}
|
|
277
279
|
/**
|
|
278
280
|
* Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
|
|
@@ -280,6 +282,19 @@ class AddLiquidityByWeight extends HawksightMeteoraCpi {
|
|
|
280
282
|
replace() {
|
|
281
283
|
this.ix.keys[11].pubkey = this.userPda;
|
|
282
284
|
this.ix.keys[11].isSigner = false;
|
|
285
|
+
// Adjust by token type
|
|
286
|
+
if (this.pdaTokenType === types_1.TokenType.LTA) {
|
|
287
|
+
this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
|
|
288
|
+
this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
|
|
289
|
+
}
|
|
290
|
+
else if (this.pdaTokenType === types_1.TokenType.STA) {
|
|
291
|
+
this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
|
|
292
|
+
this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey);
|
|
296
|
+
this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey);
|
|
297
|
+
}
|
|
283
298
|
}
|
|
284
299
|
}
|
|
285
300
|
/**
|
|
@@ -294,8 +309,9 @@ class AddLiquidityByStrategy extends HawksightMeteoraCpi {
|
|
|
294
309
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
295
310
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
296
311
|
*/
|
|
297
|
-
constructor(ix, userPda, authority) {
|
|
312
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
298
313
|
super(ix, userPda, authority, util.sighash("AddLiquidityByStrategy"));
|
|
314
|
+
this.pdaTokenType = pdaTokenType;
|
|
299
315
|
}
|
|
300
316
|
/**
|
|
301
317
|
* Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
|
|
@@ -303,6 +319,19 @@ class AddLiquidityByStrategy extends HawksightMeteoraCpi {
|
|
|
303
319
|
replace() {
|
|
304
320
|
this.ix.keys[11].pubkey = this.userPda;
|
|
305
321
|
this.ix.keys[11].isSigner = false;
|
|
322
|
+
// Adjust by token type
|
|
323
|
+
if (this.pdaTokenType === types_1.TokenType.LTA) {
|
|
324
|
+
this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
|
|
325
|
+
this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
|
|
326
|
+
}
|
|
327
|
+
else if (this.pdaTokenType === types_1.TokenType.STA) {
|
|
328
|
+
this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
|
|
329
|
+
this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey);
|
|
333
|
+
this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey);
|
|
334
|
+
}
|
|
306
335
|
}
|
|
307
336
|
}
|
|
308
337
|
/**
|
|
@@ -317,8 +346,9 @@ class AddLiquidityOneSide extends HawksightMeteoraCpi {
|
|
|
317
346
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
318
347
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
319
348
|
*/
|
|
320
|
-
constructor(ix, userPda, authority) {
|
|
349
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
321
350
|
super(ix, userPda, authority, util.sighash("AddLiquidityOneSide"));
|
|
351
|
+
this.pdaTokenType = pdaTokenType;
|
|
322
352
|
}
|
|
323
353
|
/**
|
|
324
354
|
* Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
|
|
@@ -326,6 +356,16 @@ class AddLiquidityOneSide extends HawksightMeteoraCpi {
|
|
|
326
356
|
replace() {
|
|
327
357
|
this.ix.keys[8].pubkey = this.userPda;
|
|
328
358
|
this.ix.keys[8].isSigner = false;
|
|
359
|
+
// Adjust by token type
|
|
360
|
+
if (this.pdaTokenType === types_1.TokenType.LTA) {
|
|
361
|
+
this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
|
|
362
|
+
}
|
|
363
|
+
else if (this.pdaTokenType === types_1.TokenType.STA) {
|
|
364
|
+
this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[5].pubkey);
|
|
368
|
+
}
|
|
329
369
|
}
|
|
330
370
|
}
|
|
331
371
|
/**
|
|
@@ -340,8 +380,9 @@ class AddLiquidityByStrategyOneSide extends HawksightMeteoraCpi {
|
|
|
340
380
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
341
381
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
342
382
|
*/
|
|
343
|
-
constructor(ix, userPda, authority) {
|
|
383
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
344
384
|
super(ix, userPda, authority, util.sighash("AddLiquidityByStrategyOneSide"));
|
|
385
|
+
this.pdaTokenType = pdaTokenType;
|
|
345
386
|
}
|
|
346
387
|
/**
|
|
347
388
|
* Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
|
|
@@ -349,6 +390,16 @@ class AddLiquidityByStrategyOneSide extends HawksightMeteoraCpi {
|
|
|
349
390
|
replace() {
|
|
350
391
|
this.ix.keys[8].pubkey = this.userPda;
|
|
351
392
|
this.ix.keys[8].isSigner = false;
|
|
393
|
+
// Adjust by token type
|
|
394
|
+
if (this.pdaTokenType === types_1.TokenType.LTA) {
|
|
395
|
+
this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
|
|
396
|
+
}
|
|
397
|
+
else if (this.pdaTokenType === types_1.TokenType.STA) {
|
|
398
|
+
this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[5].pubkey);
|
|
402
|
+
}
|
|
352
403
|
}
|
|
353
404
|
}
|
|
354
405
|
/**
|
|
@@ -362,8 +413,9 @@ class RemoveLiquidity extends HawksightMeteoraCpi {
|
|
|
362
413
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
363
414
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
364
415
|
*/
|
|
365
|
-
constructor(ix, userPda, authority, sighash = util.sighash("RemoveLiquidity")) {
|
|
416
|
+
constructor(ix, userPda, authority, sighash = util.sighash("RemoveLiquidity"), pdaTokenType) {
|
|
366
417
|
super(ix, userPda, authority, sighash);
|
|
418
|
+
this.pdaTokenType = pdaTokenType;
|
|
367
419
|
}
|
|
368
420
|
/**
|
|
369
421
|
* Customizes the transaction keys to correctly handle the removal of liquidity.
|
|
@@ -371,6 +423,19 @@ class RemoveLiquidity extends HawksightMeteoraCpi {
|
|
|
371
423
|
replace() {
|
|
372
424
|
this.ix.keys[11].pubkey = this.userPda;
|
|
373
425
|
this.ix.keys[11].isSigner = false;
|
|
426
|
+
// Adjust by token type
|
|
427
|
+
if (this.pdaTokenType === types_1.TokenType.LTA) {
|
|
428
|
+
this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
|
|
429
|
+
this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
|
|
430
|
+
}
|
|
431
|
+
else if (this.pdaTokenType === types_1.TokenType.STA) {
|
|
432
|
+
this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
|
|
433
|
+
this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey);
|
|
437
|
+
this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey);
|
|
438
|
+
}
|
|
374
439
|
}
|
|
375
440
|
}
|
|
376
441
|
/**
|
|
@@ -384,8 +449,8 @@ class RemoveLiquidityByRange extends RemoveLiquidity {
|
|
|
384
449
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
385
450
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
386
451
|
*/
|
|
387
|
-
constructor(ix, userPda, authority) {
|
|
388
|
-
super(ix, userPda, authority, util.sighash("RemoveLiquidityByRange"));
|
|
452
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
453
|
+
super(ix, userPda, authority, util.sighash("RemoveLiquidityByRange"), pdaTokenType);
|
|
389
454
|
}
|
|
390
455
|
}
|
|
391
456
|
/**
|
|
@@ -399,8 +464,9 @@ class ClaimFee extends HawksightMeteoraCpi {
|
|
|
399
464
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
400
465
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
401
466
|
*/
|
|
402
|
-
constructor(ix, userPda, authority) {
|
|
467
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
403
468
|
super(ix, userPda, authority, util.sighash("ClaimFee"));
|
|
469
|
+
this.pdaTokenType = pdaTokenType;
|
|
404
470
|
}
|
|
405
471
|
/**
|
|
406
472
|
* Modifies transaction keys for the purpose of claiming transaction fees.
|
|
@@ -408,6 +474,19 @@ class ClaimFee extends HawksightMeteoraCpi {
|
|
|
408
474
|
replace() {
|
|
409
475
|
this.ix.keys[4].pubkey = this.userPda;
|
|
410
476
|
this.ix.keys[4].isSigner = false;
|
|
477
|
+
// Adjust by token type
|
|
478
|
+
if (this.pdaTokenType === types_1.TokenType.LTA) {
|
|
479
|
+
this.ix.keys[7].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[9].pubkey);
|
|
480
|
+
this.ix.keys[8].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[10].pubkey);
|
|
481
|
+
}
|
|
482
|
+
else if (this.pdaTokenType === types_1.TokenType.STA) {
|
|
483
|
+
this.ix.keys[7].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[9].pubkey);
|
|
484
|
+
this.ix.keys[8].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[10].pubkey);
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
this.ix.keys[7].pubkey = util.generateAta(this.userPda, this.ix.keys[9].pubkey);
|
|
488
|
+
this.ix.keys[8].pubkey = util.generateAta(this.userPda, this.ix.keys[10].pubkey);
|
|
489
|
+
}
|
|
411
490
|
}
|
|
412
491
|
/**
|
|
413
492
|
* Overrides default add hawksight cpi to use meteoraDlmmClaimFee instead of meteoraDynamicCpi
|
|
@@ -496,8 +575,9 @@ class ClaimReward extends HawksightMeteoraCpi {
|
|
|
496
575
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
497
576
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
498
577
|
*/
|
|
499
|
-
constructor(ix, userPda, authority) {
|
|
578
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
500
579
|
super(ix, userPda, authority, util.sighash("ClaimReward"));
|
|
580
|
+
this.pdaTokenType = pdaTokenType;
|
|
501
581
|
}
|
|
502
582
|
/**
|
|
503
583
|
* Adjusts transaction keys to facilitate the claiming of rewards.
|
|
@@ -505,6 +585,16 @@ class ClaimReward extends HawksightMeteoraCpi {
|
|
|
505
585
|
replace() {
|
|
506
586
|
this.ix.keys[4].pubkey = this.userPda;
|
|
507
587
|
this.ix.keys[4].isSigner = false;
|
|
588
|
+
// Adjust by token type
|
|
589
|
+
if (this.pdaTokenType === types_1.TokenType.LTA) {
|
|
590
|
+
this.ix.keys[7].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[6].pubkey);
|
|
591
|
+
}
|
|
592
|
+
else if (this.pdaTokenType === types_1.TokenType.STA) {
|
|
593
|
+
this.ix.keys[7].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[6].pubkey);
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
this.ix.keys[7].pubkey = util.generateAta(this.userPda, this.ix.keys[6].pubkey);
|
|
597
|
+
}
|
|
508
598
|
}
|
|
509
599
|
/**
|
|
510
600
|
* Overrides default add hawksight cpi to use meteoraDlmmClaimReward instead of meteoraDynamicCpi
|
|
@@ -624,15 +714,15 @@ class HawksightMeteoraAutomationCpi {
|
|
|
624
714
|
* @param authority The authority public key.
|
|
625
715
|
* @returns The first CPI in the chain.
|
|
626
716
|
*/
|
|
627
|
-
static factory(ix, userPda, authority) {
|
|
717
|
+
static factory(ix, userPda, authority, pdaTokenType) {
|
|
628
718
|
const chain = new InitializePositionAutomation(ix, userPda, authority);
|
|
629
719
|
chain
|
|
630
|
-
.next(new AddLiquidityByWeightAutomation(ix, userPda, authority))
|
|
631
|
-
.next(new AddLiquidityOneSideAutomation(ix, userPda, authority))
|
|
632
|
-
.next(new RemoveLiquidityAutomation(ix, userPda, authority))
|
|
633
|
-
.next(new RemoveLiquidityByRangeAutomation(ix, userPda, authority))
|
|
634
|
-
.next(new ClaimFeeAutomation(ix, userPda, authority))
|
|
635
|
-
.next(new ClaimRewardAutomation(ix, userPda, authority))
|
|
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))
|
|
636
726
|
.next(new ClosePositionAutomation(ix, userPda, authority));
|
|
637
727
|
return chain;
|
|
638
728
|
}
|
|
@@ -781,8 +871,9 @@ class AddLiquidityByWeightAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
781
871
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
782
872
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
783
873
|
*/
|
|
784
|
-
constructor(ix, userPda, authority) {
|
|
785
|
-
super(ix, userPda, authority, util.sighash("
|
|
874
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
875
|
+
super(ix, userPda, authority, util.sighash("AddLiquidityByWeight"));
|
|
876
|
+
this.pdaTokenType = pdaTokenType;
|
|
786
877
|
}
|
|
787
878
|
/**
|
|
788
879
|
* Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
|
|
@@ -790,6 +881,19 @@ class AddLiquidityByWeightAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
790
881
|
replace() {
|
|
791
882
|
this._ix.keys[11].pubkey = this.userPda;
|
|
792
883
|
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
|
+
}
|
|
793
897
|
}
|
|
794
898
|
/**
|
|
795
899
|
* Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
|
|
@@ -884,8 +988,9 @@ class AddLiquidityOneSideAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
884
988
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
885
989
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
886
990
|
*/
|
|
887
|
-
constructor(ix, userPda, authority) {
|
|
991
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
888
992
|
super(ix, userPda, authority, util.sighash("AddLiquidityByStrategyOneSide"));
|
|
993
|
+
this.pdaTokenType = pdaTokenType;
|
|
889
994
|
}
|
|
890
995
|
/**
|
|
891
996
|
* Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
|
|
@@ -893,6 +998,16 @@ class AddLiquidityOneSideAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
893
998
|
replace() {
|
|
894
999
|
this._ix.keys[8].pubkey = this.userPda;
|
|
895
1000
|
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
|
+
}
|
|
896
1011
|
}
|
|
897
1012
|
/**
|
|
898
1013
|
* Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
|
|
@@ -968,8 +1083,9 @@ class RemoveLiquidityAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
968
1083
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
969
1084
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
970
1085
|
*/
|
|
971
|
-
constructor(ix, userPda, authority, sighash = util.sighash("RemoveLiquidity")) {
|
|
1086
|
+
constructor(ix, userPda, authority, sighash = util.sighash("RemoveLiquidity"), pdaTokenType) {
|
|
972
1087
|
super(ix, userPda, authority, sighash);
|
|
1088
|
+
this.pdaTokenType = pdaTokenType;
|
|
973
1089
|
}
|
|
974
1090
|
/**
|
|
975
1091
|
* Customizes the transaction keys to correctly handle the removal of liquidity.
|
|
@@ -977,6 +1093,19 @@ class RemoveLiquidityAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
977
1093
|
replace() {
|
|
978
1094
|
this._ix.keys[11].pubkey = this.userPda;
|
|
979
1095
|
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
|
+
}
|
|
980
1109
|
}
|
|
981
1110
|
/**
|
|
982
1111
|
* Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
|
|
@@ -1063,8 +1192,8 @@ class RemoveLiquidityByRangeAutomation extends RemoveLiquidityAutomation {
|
|
|
1063
1192
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
1064
1193
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
1065
1194
|
*/
|
|
1066
|
-
constructor(ix, userPda, authority) {
|
|
1067
|
-
super(ix, userPda, authority, util.sighash("RemoveLiquidityByRange"));
|
|
1195
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
1196
|
+
super(ix, userPda, authority, util.sighash("RemoveLiquidityByRange"), pdaTokenType);
|
|
1068
1197
|
}
|
|
1069
1198
|
}
|
|
1070
1199
|
/**
|
|
@@ -1078,8 +1207,9 @@ class ClaimFeeAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
1078
1207
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
1079
1208
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
1080
1209
|
*/
|
|
1081
|
-
constructor(ix, userPda, authority) {
|
|
1210
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
1082
1211
|
super(ix, userPda, authority, util.sighash("ClaimFee"));
|
|
1212
|
+
this.pdaTokenType = pdaTokenType;
|
|
1083
1213
|
}
|
|
1084
1214
|
/**
|
|
1085
1215
|
* Modifies transaction keys for the purpose of claiming transaction fees.
|
|
@@ -1087,6 +1217,19 @@ class ClaimFeeAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
1087
1217
|
replace() {
|
|
1088
1218
|
this._ix.keys[4].pubkey = this.userPda;
|
|
1089
1219
|
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
|
+
}
|
|
1090
1233
|
}
|
|
1091
1234
|
/**
|
|
1092
1235
|
* Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
|
|
@@ -1176,8 +1319,9 @@ class ClaimRewardAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
1176
1319
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
1177
1320
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
1178
1321
|
*/
|
|
1179
|
-
constructor(ix, userPda, authority) {
|
|
1322
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
1180
1323
|
super(ix, userPda, authority, util.sighash("ClaimReward"));
|
|
1324
|
+
this.pdaTokenType = pdaTokenType;
|
|
1181
1325
|
}
|
|
1182
1326
|
/**
|
|
1183
1327
|
* Adjusts transaction keys to facilitate the claiming of rewards.
|
|
@@ -1185,6 +1329,16 @@ class ClaimRewardAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
1185
1329
|
replace() {
|
|
1186
1330
|
this._ix.keys[4].pubkey = this.userPda;
|
|
1187
1331
|
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
|
+
}
|
|
1188
1342
|
}
|
|
1189
1343
|
/**
|
|
1190
1344
|
* Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
|
|
@@ -1375,11 +1529,11 @@ class HawksightMeteoraPdaCpi {
|
|
|
1375
1529
|
* @param authority The authority public key.
|
|
1376
1530
|
* @returns The first CPI in the chain.
|
|
1377
1531
|
*/
|
|
1378
|
-
static factory(ix, userPda, authority) {
|
|
1532
|
+
static factory(ix, userPda, authority, pdaTokenType) {
|
|
1379
1533
|
const chain = new InitializePositionPda(ix, userPda, authority);
|
|
1380
1534
|
chain
|
|
1381
|
-
.next(new AddLiquidityByStrategyPda(ix, userPda, authority))
|
|
1382
|
-
.next(new AddLiquidityByStrategyOneSidePda(ix, userPda, authority));
|
|
1535
|
+
.next(new AddLiquidityByStrategyPda(ix, userPda, authority, pdaTokenType))
|
|
1536
|
+
.next(new AddLiquidityByStrategyOneSidePda(ix, userPda, authority, pdaTokenType));
|
|
1383
1537
|
return chain;
|
|
1384
1538
|
}
|
|
1385
1539
|
/**
|
|
@@ -1495,8 +1649,9 @@ class AddLiquidityByStrategyPda extends HawksightMeteoraPdaCpi {
|
|
|
1495
1649
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
1496
1650
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
1497
1651
|
*/
|
|
1498
|
-
constructor(ix, userPda, authority) {
|
|
1652
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
1499
1653
|
super(ix, userPda, authority, util.sighash("AddLiquidityByStrategy"));
|
|
1654
|
+
this.pdaTokenType = pdaTokenType;
|
|
1500
1655
|
}
|
|
1501
1656
|
/**
|
|
1502
1657
|
* Modifies transaction keys for the purpose of claiming transaction fees.
|
|
@@ -1504,6 +1659,19 @@ class AddLiquidityByStrategyPda extends HawksightMeteoraPdaCpi {
|
|
|
1504
1659
|
replace() {
|
|
1505
1660
|
this.ix.keys[11].pubkey = this.userPda;
|
|
1506
1661
|
this.ix.keys[11].isSigner = false;
|
|
1662
|
+
// Adjust by token type
|
|
1663
|
+
if (this.pdaTokenType === types_1.TokenType.LTA) {
|
|
1664
|
+
this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[7].pubkey);
|
|
1665
|
+
this.ix.keys[4].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[8].pubkey);
|
|
1666
|
+
}
|
|
1667
|
+
else if (this.pdaTokenType === types_1.TokenType.STA) {
|
|
1668
|
+
this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[7].pubkey);
|
|
1669
|
+
this.ix.keys[4].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[8].pubkey);
|
|
1670
|
+
}
|
|
1671
|
+
else {
|
|
1672
|
+
this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[7].pubkey);
|
|
1673
|
+
this.ix.keys[4].pubkey = util.generateAta(this.userPda, this.ix.keys[8].pubkey);
|
|
1674
|
+
}
|
|
1507
1675
|
}
|
|
1508
1676
|
/**
|
|
1509
1677
|
* Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
|
|
@@ -1598,8 +1766,9 @@ class AddLiquidityByStrategyOneSidePda extends HawksightMeteoraPdaCpi {
|
|
|
1598
1766
|
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
1599
1767
|
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
1600
1768
|
*/
|
|
1601
|
-
constructor(ix, userPda, authority) {
|
|
1769
|
+
constructor(ix, userPda, authority, pdaTokenType) {
|
|
1602
1770
|
super(ix, userPda, authority, util.sighash("AddLiquidityByStrategyOneSide"));
|
|
1771
|
+
this.pdaTokenType = pdaTokenType;
|
|
1603
1772
|
}
|
|
1604
1773
|
/**
|
|
1605
1774
|
* Alters the transaction keys for adding liquidity, ensuring the user's PDA is correctly configured.
|
|
@@ -1607,6 +1776,16 @@ class AddLiquidityByStrategyOneSidePda extends HawksightMeteoraPdaCpi {
|
|
|
1607
1776
|
replace() {
|
|
1608
1777
|
this.ix.keys[8].pubkey = this.userPda;
|
|
1609
1778
|
this.ix.keys[8].isSigner = false;
|
|
1779
|
+
// Adjust by token type
|
|
1780
|
+
if (this.pdaTokenType === types_1.TokenType.LTA) {
|
|
1781
|
+
this.ix.keys[3].pubkey = util.generateLimitToken(this.userPda, this.ix.keys[5].pubkey);
|
|
1782
|
+
}
|
|
1783
|
+
else if (this.pdaTokenType === types_1.TokenType.STA) {
|
|
1784
|
+
this.ix.keys[3].pubkey = util.generateUserPdaStorageAccount(this.userPda, this.ix.keys[5].pubkey);
|
|
1785
|
+
}
|
|
1786
|
+
else {
|
|
1787
|
+
this.ix.keys[3].pubkey = util.generateAta(this.userPda, this.ix.keys[5].pubkey);
|
|
1788
|
+
}
|
|
1610
1789
|
}
|
|
1611
1790
|
/**
|
|
1612
1791
|
* Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
|