@hawksightco/hawk-sdk 1.3.185 → 1.3.186
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/addresses.d.ts +2 -0
- package/dist/src/addresses.d.ts.map +1 -1
- package/dist/src/addresses.js +4 -1
- package/dist/src/classes/SimpleIxGenerator.d.ts +7 -0
- package/dist/src/classes/SimpleIxGenerator.d.ts.map +1 -1
- package/dist/src/classes/SimpleIxGenerator.js +7 -0
- package/dist/src/classes/SimplePdaGenerator.d.ts +7 -2
- package/dist/src/classes/SimplePdaGenerator.d.ts.map +1 -1
- package/dist/src/classes/SimplePdaGenerator.js +7 -2
- package/dist/src/classes/Transactions.d.ts +46 -14
- package/dist/src/classes/Transactions.d.ts.map +1 -1
- package/dist/src/classes/Transactions.js +235 -198
- package/dist/src/classes/TxGenerator.d.ts +24 -1
- package/dist/src/classes/TxGenerator.d.ts.map +1 -1
- package/dist/src/classes/TxGenerator.js +96 -0
- package/dist/src/classes/TxGeneratorAutomations.d.ts +29 -15
- package/dist/src/classes/TxGeneratorAutomations.d.ts.map +1 -1
- package/dist/src/classes/TxGeneratorAutomations.js +84 -52
- package/dist/src/ixGenerator/HatchIxGenerator.d.ts +104 -0
- package/dist/src/ixGenerator/HatchIxGenerator.d.ts.map +1 -0
- package/dist/src/ixGenerator/HatchIxGenerator.js +326 -0
- package/dist/src/pdaGenerator/HatchPdaGenerator.d.ts +41 -0
- package/dist/src/pdaGenerator/HatchPdaGenerator.d.ts.map +1 -0
- package/dist/src/pdaGenerator/HatchPdaGenerator.js +90 -0
- package/dist/src/types.d.ts +118 -21
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as web3 from "@solana/web3.js";
|
|
2
2
|
import * as _client from "@hawksightco/swagger-client";
|
|
3
|
-
import { MeteoraClose, MeteoraCompound, MeteoraRedeposit, MeteoraLimitCloseAutomation, MeteoraLimitCloseAutomation2, MeteoraRebalance, MeteoraRebalance2,
|
|
3
|
+
import { MeteoraClose, MeteoraCompound, MeteoraRedeposit, MeteoraLimitCloseAutomation, MeteoraLimitCloseAutomation2, MeteoraRebalance, MeteoraRebalance2, OpenAutomationIx, RelativeOpenAutomationIx, ResponseWithStatus, TransactionMetadata, MeteoraRebalanceForLargerPosition, HatchClaimFee, HatchClaimReward } from "../types";
|
|
4
4
|
import { Client } from "./Client";
|
|
5
5
|
import { GeneralUtility } from "./GeneralUtility";
|
|
6
6
|
/**
|
|
@@ -112,20 +112,6 @@ export declare class TxGeneratorAutomations {
|
|
|
112
112
|
* @returns A ResponseWithStatus containing an array of TransactionMetadata (2-3 transactions).
|
|
113
113
|
*/
|
|
114
114
|
meteoraRebalanceLargerPositionAutomation(connection: web3.Connection, payer: string, params: MeteoraRebalanceForLargerPosition): Promise<ResponseWithStatus<TransactionMetadata[]>>;
|
|
115
|
-
/**
|
|
116
|
-
* Creates meteora hybrid rebalance instructions with per-side distribution control.
|
|
117
|
-
*
|
|
118
|
-
* Supports simple mode (single distribution, same as Ixs2) and hybrid mode
|
|
119
|
-
* (multiple layers with different distributions per side).
|
|
120
|
-
*
|
|
121
|
-
* NOTE: For hawksight devs only.
|
|
122
|
-
*
|
|
123
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
124
|
-
* @param payer The public key of the payer for transaction fees.
|
|
125
|
-
* @param params Parameters required (MeteoraRebalance3)
|
|
126
|
-
* @returns A ResponseWithStatus containing an array of TransactionMetadata (1-2 transactions).
|
|
127
|
-
*/
|
|
128
|
-
meteoraRebalanceIxs3(connection: web3.Connection, payer: string, params: MeteoraRebalance3): Promise<ResponseWithStatus<LabeledInstructions>>;
|
|
129
115
|
/**
|
|
130
116
|
* Creates meteora close limit instruction (combination of claim fees/rewards + remove liquidity + close position)
|
|
131
117
|
*
|
|
@@ -181,5 +167,33 @@ export declare class TxGeneratorAutomations {
|
|
|
181
167
|
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
182
168
|
*/
|
|
183
169
|
meteoraRelativeOpenIxs(connection: web3.Connection, payer: string, params: RelativeOpenAutomationIx): Promise<ResponseWithStatus<TransactionMetadata>>;
|
|
170
|
+
/**
|
|
171
|
+
* Claims trading fees from a Hatch locked position.
|
|
172
|
+
*
|
|
173
|
+
* Only the rebalance authority can call this.
|
|
174
|
+
* Fees go to LauncherPda-owned token accounts, with 8% to treasury.
|
|
175
|
+
*
|
|
176
|
+
* NOTE: For hawksight devs only.
|
|
177
|
+
*
|
|
178
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
179
|
+
* @param payer The public key of the payer for transaction fees.
|
|
180
|
+
* @param params Parameters required for claiming fees
|
|
181
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
182
|
+
*/
|
|
183
|
+
hatchClaimFeeIxs(connection: web3.Connection, payer: string, params: HatchClaimFee): Promise<ResponseWithStatus<TransactionMetadata>>;
|
|
184
|
+
/**
|
|
185
|
+
* Claims farming rewards from a Hatch locked position.
|
|
186
|
+
*
|
|
187
|
+
* Only the rebalance authority can call this.
|
|
188
|
+
* Rewards go to LauncherPda-owned token account, with 8% to treasury.
|
|
189
|
+
*
|
|
190
|
+
* NOTE: For hawksight devs only.
|
|
191
|
+
*
|
|
192
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
193
|
+
* @param payer The public key of the payer for transaction fees.
|
|
194
|
+
* @param params Parameters required for claiming rewards
|
|
195
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
196
|
+
*/
|
|
197
|
+
hatchClaimRewardIxs(connection: web3.Connection, payer: string, params: HatchClaimReward): Promise<ResponseWithStatus<TransactionMetadata>>;
|
|
184
198
|
}
|
|
185
199
|
//# sourceMappingURL=TxGeneratorAutomations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxGeneratorAutomations.d.ts","sourceRoot":"","sources":["../../../src/classes/TxGeneratorAutomations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"TxGeneratorAutomations.d.ts","sourceRoot":"","sources":["../../../src/classes/TxGeneratorAutomations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iCAAiC,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACpU,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIlD;;;;;;GAMG;AACH,qBAAa,sBAAsB;IAkB/B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAjBjC;;OAEG;IACH,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;IAE/C;;OAEG;IACH,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IAEjC;;;;OAIG;gBAEgB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc;IAMjD;;;;;;;;;OASG;IACG,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,mB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AAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAyC/J;;;;;;;;;OASG;IACG,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAiCzI;;;;;;;;;OASG;IACG,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAyC5I;;;;;;;;;OASG;IACG,sBAAsB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAyC5J;;;;;;;;;;;;OAYG;IACG,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAgC3I;;;;;;;;;;;;OAYG;IACG,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CA+BlJ"}
|
|
@@ -366,58 +366,6 @@ class TxGeneratorAutomations {
|
|
|
366
366
|
}
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
|
-
/**
|
|
370
|
-
* Creates meteora hybrid rebalance instructions with per-side distribution control.
|
|
371
|
-
*
|
|
372
|
-
* Supports simple mode (single distribution, same as Ixs2) and hybrid mode
|
|
373
|
-
* (multiple layers with different distributions per side).
|
|
374
|
-
*
|
|
375
|
-
* NOTE: For hawksight devs only.
|
|
376
|
-
*
|
|
377
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
378
|
-
* @param payer The public key of the payer for transaction fees.
|
|
379
|
-
* @param params Parameters required (MeteoraRebalance3)
|
|
380
|
-
* @returns A ResponseWithStatus containing an array of TransactionMetadata (1-2 transactions).
|
|
381
|
-
*/
|
|
382
|
-
meteoraRebalanceIxs3(connection, payer, params) {
|
|
383
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
384
|
-
var _a;
|
|
385
|
-
// Initialize anchor
|
|
386
|
-
anchor_1.Anchor.initialize(connection);
|
|
387
|
-
try {
|
|
388
|
-
const result = yield Transactions_1.txgen.rebalanceAutomationIx3({
|
|
389
|
-
connection,
|
|
390
|
-
params,
|
|
391
|
-
fetch: undefined,
|
|
392
|
-
});
|
|
393
|
-
return {
|
|
394
|
-
status: 200,
|
|
395
|
-
data: result,
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
catch (e) {
|
|
399
|
-
if (e instanceof Error) {
|
|
400
|
-
return {
|
|
401
|
-
status: 400,
|
|
402
|
-
data: {
|
|
403
|
-
code: "custom",
|
|
404
|
-
message: e.message,
|
|
405
|
-
stack: (_a = e.stack) === null || _a === void 0 ? void 0 : _a.split('\n'),
|
|
406
|
-
path: [],
|
|
407
|
-
},
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
return {
|
|
411
|
-
status: 400,
|
|
412
|
-
data: {
|
|
413
|
-
code: "custom",
|
|
414
|
-
message: e,
|
|
415
|
-
path: [],
|
|
416
|
-
},
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
369
|
/**
|
|
422
370
|
* Creates meteora close limit instruction (combination of claim fees/rewards + remove liquidity + close position)
|
|
423
371
|
*
|
|
@@ -654,5 +602,89 @@ class TxGeneratorAutomations {
|
|
|
654
602
|
}
|
|
655
603
|
});
|
|
656
604
|
}
|
|
605
|
+
/**
|
|
606
|
+
* Claims trading fees from a Hatch locked position.
|
|
607
|
+
*
|
|
608
|
+
* Only the rebalance authority can call this.
|
|
609
|
+
* Fees go to LauncherPda-owned token accounts, with 8% to treasury.
|
|
610
|
+
*
|
|
611
|
+
* NOTE: For hawksight devs only.
|
|
612
|
+
*
|
|
613
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
614
|
+
* @param payer The public key of the payer for transaction fees.
|
|
615
|
+
* @param params Parameters required for claiming fees
|
|
616
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
617
|
+
*/
|
|
618
|
+
hatchClaimFeeIxs(connection, payer, params) {
|
|
619
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
620
|
+
// Initialize anchor
|
|
621
|
+
anchor_1.Anchor.initialize(connection);
|
|
622
|
+
try {
|
|
623
|
+
const result = yield Transactions_1.txgen.hatchClaimFee({
|
|
624
|
+
connection,
|
|
625
|
+
params,
|
|
626
|
+
fetch: undefined,
|
|
627
|
+
});
|
|
628
|
+
return {
|
|
629
|
+
status: 200,
|
|
630
|
+
data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
catch (e) {
|
|
634
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
635
|
+
console.error('hatchClaimFeeIxs error:', errorMessage, e);
|
|
636
|
+
return {
|
|
637
|
+
status: 400,
|
|
638
|
+
data: {
|
|
639
|
+
code: 'custom',
|
|
640
|
+
message: errorMessage,
|
|
641
|
+
path: [],
|
|
642
|
+
},
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Claims farming rewards from a Hatch locked position.
|
|
649
|
+
*
|
|
650
|
+
* Only the rebalance authority can call this.
|
|
651
|
+
* Rewards go to LauncherPda-owned token account, with 8% to treasury.
|
|
652
|
+
*
|
|
653
|
+
* NOTE: For hawksight devs only.
|
|
654
|
+
*
|
|
655
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
656
|
+
* @param payer The public key of the payer for transaction fees.
|
|
657
|
+
* @param params Parameters required for claiming rewards
|
|
658
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
659
|
+
*/
|
|
660
|
+
hatchClaimRewardIxs(connection, payer, params) {
|
|
661
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
662
|
+
// Initialize anchor
|
|
663
|
+
anchor_1.Anchor.initialize(connection);
|
|
664
|
+
try {
|
|
665
|
+
const result = yield Transactions_1.txgen.hatchClaimReward({
|
|
666
|
+
connection,
|
|
667
|
+
params,
|
|
668
|
+
fetch: undefined,
|
|
669
|
+
});
|
|
670
|
+
return {
|
|
671
|
+
status: 200,
|
|
672
|
+
data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
catch (e) {
|
|
676
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
677
|
+
console.error('hatchClaimRewardIxs error:', errorMessage, e);
|
|
678
|
+
return {
|
|
679
|
+
status: 400,
|
|
680
|
+
data: {
|
|
681
|
+
code: 'custom',
|
|
682
|
+
message: errorMessage,
|
|
683
|
+
path: [],
|
|
684
|
+
},
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
}
|
|
657
689
|
}
|
|
658
690
|
exports.TxGeneratorAutomations = TxGeneratorAutomations;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as web3 from "@solana/web3.js";
|
|
2
|
+
import BN from "bn.js";
|
|
3
|
+
import { SimplePdaGenerator } from "../classes/SimplePdaGenerator";
|
|
4
|
+
import { HatchStrategyType } from "../types";
|
|
5
|
+
type CreatePoolAndLockedPositionParams = {
|
|
6
|
+
connection: web3.Connection;
|
|
7
|
+
authority: web3.PublicKey;
|
|
8
|
+
position: web3.PublicKey;
|
|
9
|
+
base: web3.PublicKey;
|
|
10
|
+
presetParameter: web3.PublicKey;
|
|
11
|
+
tokenMintX: web3.PublicKey;
|
|
12
|
+
tokenMintY: web3.PublicKey;
|
|
13
|
+
tokenProgramX: web3.PublicKey;
|
|
14
|
+
tokenProgramY: web3.PublicKey;
|
|
15
|
+
activeId: number;
|
|
16
|
+
lowerBinId: number;
|
|
17
|
+
upperBinId: number;
|
|
18
|
+
strategyType: HatchStrategyType;
|
|
19
|
+
lockReleasePoint: BN;
|
|
20
|
+
amountX: BN;
|
|
21
|
+
amountY: BN;
|
|
22
|
+
};
|
|
23
|
+
type ClaimFeeParams = {
|
|
24
|
+
connection: web3.Connection;
|
|
25
|
+
rebalanceAuthority: web3.PublicKey;
|
|
26
|
+
launcherAuthority: web3.PublicKey;
|
|
27
|
+
position: web3.PublicKey;
|
|
28
|
+
lbPair: web3.PublicKey;
|
|
29
|
+
minBinId: number;
|
|
30
|
+
maxBinId: number;
|
|
31
|
+
tokenMintX: web3.PublicKey;
|
|
32
|
+
tokenMintY: web3.PublicKey;
|
|
33
|
+
tokenProgramX: web3.PublicKey;
|
|
34
|
+
tokenProgramY: web3.PublicKey;
|
|
35
|
+
};
|
|
36
|
+
type ClaimRewardParams = {
|
|
37
|
+
connection: web3.Connection;
|
|
38
|
+
rebalanceAuthority: web3.PublicKey;
|
|
39
|
+
launcherAuthority: web3.PublicKey;
|
|
40
|
+
position: web3.PublicKey;
|
|
41
|
+
lbPair: web3.PublicKey;
|
|
42
|
+
rewardIndex: number;
|
|
43
|
+
minBinId: number;
|
|
44
|
+
maxBinId: number;
|
|
45
|
+
rewardMint: web3.PublicKey;
|
|
46
|
+
rewardVault: web3.PublicKey;
|
|
47
|
+
tokenProgram: web3.PublicKey;
|
|
48
|
+
};
|
|
49
|
+
type InitializeHawkfiPdaParams = {
|
|
50
|
+
payer: web3.PublicKey;
|
|
51
|
+
};
|
|
52
|
+
type InitializeLauncherPdaParams = {
|
|
53
|
+
authority: web3.PublicKey;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Instruction generator for the Hatch program.
|
|
57
|
+
*
|
|
58
|
+
* Hatch provides a secure interface for:
|
|
59
|
+
* - Creating locked DLMM positions with custom fee owners
|
|
60
|
+
* - Claiming trading fees (via rebalance authority)
|
|
61
|
+
* - Claiming farming rewards (via rebalance authority)
|
|
62
|
+
*/
|
|
63
|
+
export declare class HatchIxGenerator {
|
|
64
|
+
private readonly pda;
|
|
65
|
+
constructor(pda: SimplePdaGenerator);
|
|
66
|
+
/**
|
|
67
|
+
* Create a pool and locked position on Meteora DLMM via Hatch.
|
|
68
|
+
*
|
|
69
|
+
* The position will be:
|
|
70
|
+
* - Owner: HawkfiPda (global)
|
|
71
|
+
* - Operator: HawkfiPda (global)
|
|
72
|
+
* - Fee Owner: LauncherPda (per-launcher)
|
|
73
|
+
*/
|
|
74
|
+
createPoolAndLockedPosition({ connection, authority, position, base, presetParameter, tokenMintX, tokenMintY, tokenProgramX, tokenProgramY, activeId, lowerBinId, upperBinId, strategyType, lockReleasePoint, amountX, amountY, }: CreatePoolAndLockedPositionParams): Promise<web3.TransactionInstruction>;
|
|
75
|
+
/**
|
|
76
|
+
* Claim trading fees from a Hatch position.
|
|
77
|
+
*
|
|
78
|
+
* Only the rebalance authority can call this.
|
|
79
|
+
* Fees go to LauncherPda-owned token accounts, with 8% to treasury.
|
|
80
|
+
*/
|
|
81
|
+
claimFee({ connection, rebalanceAuthority, launcherAuthority, position, lbPair, minBinId, maxBinId, tokenMintX, tokenMintY, tokenProgramX, tokenProgramY, }: ClaimFeeParams): Promise<web3.TransactionInstruction>;
|
|
82
|
+
/**
|
|
83
|
+
* Claim farming rewards from a Hatch position.
|
|
84
|
+
*
|
|
85
|
+
* Only the rebalance authority can call this.
|
|
86
|
+
* Rewards go to LauncherPda-owned token account, with 8% to treasury.
|
|
87
|
+
*/
|
|
88
|
+
claimReward({ connection, rebalanceAuthority, launcherAuthority, position, lbPair, rewardIndex, minBinId, maxBinId, rewardMint, rewardVault, tokenProgram, }: ClaimRewardParams): Promise<web3.TransactionInstruction>;
|
|
89
|
+
/**
|
|
90
|
+
* Initialize the global HawkfiPda (one-time operation).
|
|
91
|
+
*/
|
|
92
|
+
initializeHawkfiPda({ payer, }: InitializeHawkfiPdaParams): web3.TransactionInstruction;
|
|
93
|
+
/**
|
|
94
|
+
* Initialize a LauncherPda for a given authority.
|
|
95
|
+
*
|
|
96
|
+
* Must be called before createPoolAndLockedPosition if the LauncherPda
|
|
97
|
+
* doesn't exist yet. This is a one-time operation per authority wallet.
|
|
98
|
+
*
|
|
99
|
+
* @param authority - The wallet that will own this LauncherPda
|
|
100
|
+
*/
|
|
101
|
+
initializeLauncherPda({ authority, }: InitializeLauncherPdaParams): web3.TransactionInstruction;
|
|
102
|
+
}
|
|
103
|
+
export {};
|
|
104
|
+
//# sourceMappingURL=HatchIxGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HatchIxGenerator.d.ts","sourceRoot":"","sources":["../../../src/ixGenerator/HatchIxGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAWnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAoB7C,KAAK,iCAAiC,GAAG;IACvC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC;IAC5B,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC;IAC1B,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;IACzB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;IACrB,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC;IAChC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC;IAC3B,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC;IAC3B,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC;IAC9B,aAAa,EAAE,IA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|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.HatchIxGenerator = void 0;
|
|
49
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
50
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
51
|
+
const addresses_1 = require("../addresses");
|
|
52
|
+
const functions_1 = require("../functions");
|
|
53
|
+
const meteora_1 = require("../meteora");
|
|
54
|
+
// Anchor discriminators from the IDL
|
|
55
|
+
const DISCRIMINATORS = {
|
|
56
|
+
createPoolAndLockedPosition: Buffer.from([140, 164, 125, 74, 166, 59, 206, 48]),
|
|
57
|
+
claimFee: Buffer.from([169, 32, 79, 137, 136, 232, 70, 137]),
|
|
58
|
+
claimReward: Buffer.from([149, 95, 181, 242, 94, 90, 158, 162]),
|
|
59
|
+
initializeHawkfiPda: Buffer.from([241, 36, 121, 231, 54, 178, 176, 87]),
|
|
60
|
+
// sha256("global:initialize_launcher_pda")[0..8] = 953b562d4a0c890f
|
|
61
|
+
initializeLauncherPda: Buffer.from([149, 59, 86, 45, 74, 12, 137, 15]),
|
|
62
|
+
};
|
|
63
|
+
// Strategy type mapping (same as Meteora)
|
|
64
|
+
const StrategyTypeValue = {
|
|
65
|
+
Spot: 0,
|
|
66
|
+
Curve: 1,
|
|
67
|
+
BidAsk: 2,
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Instruction generator for the Hatch program.
|
|
71
|
+
*
|
|
72
|
+
* Hatch provides a secure interface for:
|
|
73
|
+
* - Creating locked DLMM positions with custom fee owners
|
|
74
|
+
* - Claiming trading fees (via rebalance authority)
|
|
75
|
+
* - Claiming farming rewards (via rebalance authority)
|
|
76
|
+
*/
|
|
77
|
+
class HatchIxGenerator {
|
|
78
|
+
constructor(pda) {
|
|
79
|
+
this.pda = pda;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Create a pool and locked position on Meteora DLMM via Hatch.
|
|
83
|
+
*
|
|
84
|
+
* The position will be:
|
|
85
|
+
* - Owner: HawkfiPda (global)
|
|
86
|
+
* - Operator: HawkfiPda (global)
|
|
87
|
+
* - Fee Owner: LauncherPda (per-launcher)
|
|
88
|
+
*/
|
|
89
|
+
createPoolAndLockedPosition(_a) {
|
|
90
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, authority, position, base, presetParameter, tokenMintX, tokenMintY, tokenProgramX, tokenProgramY, activeId, lowerBinId, upperBinId, strategyType, lockReleasePoint, amountX, amountY, }) {
|
|
91
|
+
// Derive PDAs
|
|
92
|
+
const hawkfiPda = this.pda.hatch.deriveHawkfiPda();
|
|
93
|
+
const launcherPda = this.pda.hatch.deriveLauncherPda(authority);
|
|
94
|
+
// Derive Meteora accounts
|
|
95
|
+
const lbPair = this.pda.meteora.deriveLbPairWithPresetParamWithIndexKey(presetParameter, tokenMintX, tokenMintY);
|
|
96
|
+
const reserveX = this.pda.meteora.deriveReserve(tokenMintX, lbPair);
|
|
97
|
+
const reserveY = this.pda.meteora.deriveReserve(tokenMintY, lbPair);
|
|
98
|
+
const oracle = this.pda.meteora.deriveOracle(lbPair);
|
|
99
|
+
const binArrayBitmapExtension = this.pda.meteora.deriveBinArrayBitmapExtension(lbPair);
|
|
100
|
+
// User token accounts (owned by authority, not PDA)
|
|
101
|
+
const userTokenX = (0, functions_1.generateAta)(authority, tokenMintX, tokenProgramX);
|
|
102
|
+
const userTokenY = (0, functions_1.generateAta)(authority, tokenMintY, tokenProgramY);
|
|
103
|
+
// Derive bin arrays for remaining accounts
|
|
104
|
+
const binArrays = meteora_1.MeteoraFunctions.findMeteoraTickArrays(lbPair, lowerBinId, upperBinId);
|
|
105
|
+
// Serialize instruction data
|
|
106
|
+
const activeIdBuf = Buffer.alloc(4);
|
|
107
|
+
activeIdBuf.writeInt32LE(activeId, 0);
|
|
108
|
+
const lowerBinIdBuf = Buffer.alloc(4);
|
|
109
|
+
lowerBinIdBuf.writeInt32LE(lowerBinId, 0);
|
|
110
|
+
const upperBinIdBuf = Buffer.alloc(4);
|
|
111
|
+
upperBinIdBuf.writeInt32LE(upperBinId, 0);
|
|
112
|
+
const strategyTypeBuf = Buffer.alloc(1);
|
|
113
|
+
strategyTypeBuf.writeUInt8(StrategyTypeValue[strategyType], 0);
|
|
114
|
+
const lockReleasePointBuf = lockReleasePoint.toArrayLike(Buffer, "le", 8);
|
|
115
|
+
const amountXBuf = amountX.toArrayLike(Buffer, "le", 8);
|
|
116
|
+
const amountYBuf = amountY.toArrayLike(Buffer, "le", 8);
|
|
117
|
+
const data = Buffer.concat([
|
|
118
|
+
DISCRIMINATORS.createPoolAndLockedPosition,
|
|
119
|
+
activeIdBuf,
|
|
120
|
+
lowerBinIdBuf,
|
|
121
|
+
upperBinIdBuf,
|
|
122
|
+
strategyTypeBuf,
|
|
123
|
+
lockReleasePointBuf,
|
|
124
|
+
amountXBuf,
|
|
125
|
+
amountYBuf,
|
|
126
|
+
]);
|
|
127
|
+
return new web3.TransactionInstruction({
|
|
128
|
+
programId: addresses_1.HATCH_PROGRAM,
|
|
129
|
+
keys: [
|
|
130
|
+
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
131
|
+
{ pubkey: launcherPda, isSigner: false, isWritable: true },
|
|
132
|
+
{ pubkey: hawkfiPda, isSigner: false, isWritable: false },
|
|
133
|
+
{ pubkey: lbPair, isSigner: false, isWritable: true },
|
|
134
|
+
{ pubkey: reserveX, isSigner: false, isWritable: true },
|
|
135
|
+
{ pubkey: reserveY, isSigner: false, isWritable: true },
|
|
136
|
+
{ pubkey: oracle, isSigner: false, isWritable: true },
|
|
137
|
+
{ pubkey: presetParameter, isSigner: false, isWritable: false },
|
|
138
|
+
{ pubkey: tokenMintX, isSigner: false, isWritable: false },
|
|
139
|
+
{ pubkey: tokenMintY, isSigner: false, isWritable: false },
|
|
140
|
+
{ pubkey: userTokenX, isSigner: false, isWritable: true },
|
|
141
|
+
{ pubkey: userTokenY, isSigner: false, isWritable: true },
|
|
142
|
+
{ pubkey: position, isSigner: false, isWritable: true },
|
|
143
|
+
{ pubkey: base, isSigner: true, isWritable: false },
|
|
144
|
+
{ pubkey: binArrayBitmapExtension, isSigner: false, isWritable: true },
|
|
145
|
+
{ pubkey: tokenProgramX, isSigner: false, isWritable: false },
|
|
146
|
+
{ pubkey: tokenProgramY, isSigner: false, isWritable: false },
|
|
147
|
+
{ pubkey: web3.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
148
|
+
{ pubkey: addresses_1.METEORA_EVENT_AUTHORITY, isSigner: false, isWritable: false },
|
|
149
|
+
{ pubkey: addresses_1.METEORA_DLMM_PROGRAM, isSigner: false, isWritable: false },
|
|
150
|
+
// Remaining accounts: bin arrays
|
|
151
|
+
...binArrays.map((pubkey) => ({
|
|
152
|
+
pubkey,
|
|
153
|
+
isSigner: false,
|
|
154
|
+
isWritable: true,
|
|
155
|
+
})),
|
|
156
|
+
],
|
|
157
|
+
data,
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Claim trading fees from a Hatch position.
|
|
163
|
+
*
|
|
164
|
+
* Only the rebalance authority can call this.
|
|
165
|
+
* Fees go to LauncherPda-owned token accounts, with 8% to treasury.
|
|
166
|
+
*/
|
|
167
|
+
claimFee(_a) {
|
|
168
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, rebalanceAuthority, launcherAuthority, position, lbPair, minBinId, maxBinId, tokenMintX, tokenMintY, tokenProgramX, tokenProgramY, }) {
|
|
169
|
+
// Derive PDAs
|
|
170
|
+
const hawkfiPda = this.pda.hatch.deriveHawkfiPda();
|
|
171
|
+
const launcherPda = this.pda.hatch.deriveLauncherPda(launcherAuthority);
|
|
172
|
+
// Derive Meteora accounts
|
|
173
|
+
const reserveX = this.pda.meteora.deriveReserve(tokenMintX, lbPair);
|
|
174
|
+
const reserveY = this.pda.meteora.deriveReserve(tokenMintY, lbPair);
|
|
175
|
+
// LauncherPda-owned token accounts for fees
|
|
176
|
+
const userTokenX = (0, functions_1.generateAta)(launcherPda, tokenMintX, tokenProgramX);
|
|
177
|
+
const userTokenY = (0, functions_1.generateAta)(launcherPda, tokenMintY, tokenProgramY);
|
|
178
|
+
// Treasury token accounts
|
|
179
|
+
const treasuryTokenX = (0, functions_1.generateAta)(addresses_1.HATCH_TREASURY, tokenMintX, tokenProgramX);
|
|
180
|
+
const treasuryTokenY = (0, functions_1.generateAta)(addresses_1.HATCH_TREASURY, tokenMintY, tokenProgramY);
|
|
181
|
+
// Derive bin arrays for remaining accounts
|
|
182
|
+
const binArrays = this.pda.meteora.deriveBinArrays(lbPair, minBinId, maxBinId);
|
|
183
|
+
// Serialize remaining accounts info (empty for now - Meteora handles internally)
|
|
184
|
+
const remainingAccountsInfo = Buffer.alloc(4); // Empty vec: length = 0
|
|
185
|
+
remainingAccountsInfo.writeUInt32LE(0, 0);
|
|
186
|
+
// Serialize instruction data
|
|
187
|
+
const minBinIdBuf = Buffer.alloc(4);
|
|
188
|
+
minBinIdBuf.writeInt32LE(minBinId, 0);
|
|
189
|
+
const maxBinIdBuf = Buffer.alloc(4);
|
|
190
|
+
maxBinIdBuf.writeInt32LE(maxBinId, 0);
|
|
191
|
+
const data = Buffer.concat([
|
|
192
|
+
DISCRIMINATORS.claimFee,
|
|
193
|
+
minBinIdBuf,
|
|
194
|
+
maxBinIdBuf,
|
|
195
|
+
remainingAccountsInfo,
|
|
196
|
+
]);
|
|
197
|
+
return new web3.TransactionInstruction({
|
|
198
|
+
programId: addresses_1.HATCH_PROGRAM,
|
|
199
|
+
keys: [
|
|
200
|
+
{ pubkey: rebalanceAuthority, isSigner: true, isWritable: false },
|
|
201
|
+
{ pubkey: launcherPda, isSigner: false, isWritable: false },
|
|
202
|
+
{ pubkey: hawkfiPda, isSigner: false, isWritable: false },
|
|
203
|
+
{ pubkey: lbPair, isSigner: false, isWritable: true },
|
|
204
|
+
{ pubkey: position, isSigner: false, isWritable: true },
|
|
205
|
+
{ pubkey: reserveX, isSigner: false, isWritable: true },
|
|
206
|
+
{ pubkey: reserveY, isSigner: false, isWritable: true },
|
|
207
|
+
{ pubkey: userTokenX, isSigner: false, isWritable: true },
|
|
208
|
+
{ pubkey: userTokenY, isSigner: false, isWritable: true },
|
|
209
|
+
{ pubkey: treasuryTokenX, isSigner: false, isWritable: true },
|
|
210
|
+
{ pubkey: treasuryTokenY, isSigner: false, isWritable: true },
|
|
211
|
+
{ pubkey: tokenMintX, isSigner: false, isWritable: false },
|
|
212
|
+
{ pubkey: tokenMintY, isSigner: false, isWritable: false },
|
|
213
|
+
{ pubkey: tokenProgramX, isSigner: false, isWritable: false },
|
|
214
|
+
{ pubkey: tokenProgramY, isSigner: false, isWritable: false },
|
|
215
|
+
{ pubkey: addresses_1.MEMO_PROGRAM, isSigner: false, isWritable: false },
|
|
216
|
+
{ pubkey: addresses_1.METEORA_EVENT_AUTHORITY, isSigner: false, isWritable: false },
|
|
217
|
+
{ pubkey: addresses_1.METEORA_DLMM_PROGRAM, isSigner: false, isWritable: false },
|
|
218
|
+
// Remaining accounts: bin arrays
|
|
219
|
+
...binArrays.map((pubkey) => ({
|
|
220
|
+
pubkey,
|
|
221
|
+
isSigner: false,
|
|
222
|
+
isWritable: true,
|
|
223
|
+
})),
|
|
224
|
+
],
|
|
225
|
+
data,
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Claim farming rewards from a Hatch position.
|
|
231
|
+
*
|
|
232
|
+
* Only the rebalance authority can call this.
|
|
233
|
+
* Rewards go to LauncherPda-owned token account, with 8% to treasury.
|
|
234
|
+
*/
|
|
235
|
+
claimReward(_a) {
|
|
236
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, rebalanceAuthority, launcherAuthority, position, lbPair, rewardIndex, minBinId, maxBinId, rewardMint, rewardVault, tokenProgram, }) {
|
|
237
|
+
// Derive PDAs
|
|
238
|
+
const hawkfiPda = this.pda.hatch.deriveHawkfiPda();
|
|
239
|
+
const launcherPda = this.pda.hatch.deriveLauncherPda(launcherAuthority);
|
|
240
|
+
// LauncherPda-owned token account for rewards
|
|
241
|
+
const userTokenAccount = (0, functions_1.generateAta)(launcherPda, rewardMint, tokenProgram);
|
|
242
|
+
// Treasury token account
|
|
243
|
+
const treasuryTokenAccount = (0, functions_1.generateAta)(addresses_1.HATCH_TREASURY, rewardMint, tokenProgram);
|
|
244
|
+
// Derive bin arrays for remaining accounts
|
|
245
|
+
const binArrays = this.pda.meteora.deriveBinArrays(lbPair, minBinId, maxBinId);
|
|
246
|
+
// Serialize remaining accounts info (empty for now)
|
|
247
|
+
const remainingAccountsInfo = Buffer.alloc(4);
|
|
248
|
+
remainingAccountsInfo.writeUInt32LE(0, 0);
|
|
249
|
+
// Serialize instruction data
|
|
250
|
+
const rewardIndexBuf = Buffer.alloc(8);
|
|
251
|
+
new bn_js_1.default(rewardIndex).toArrayLike(Buffer, "le", 8).copy(rewardIndexBuf);
|
|
252
|
+
const minBinIdBuf = Buffer.alloc(4);
|
|
253
|
+
minBinIdBuf.writeInt32LE(minBinId, 0);
|
|
254
|
+
const maxBinIdBuf = Buffer.alloc(4);
|
|
255
|
+
maxBinIdBuf.writeInt32LE(maxBinId, 0);
|
|
256
|
+
const data = Buffer.concat([
|
|
257
|
+
DISCRIMINATORS.claimReward,
|
|
258
|
+
rewardIndexBuf,
|
|
259
|
+
minBinIdBuf,
|
|
260
|
+
maxBinIdBuf,
|
|
261
|
+
remainingAccountsInfo,
|
|
262
|
+
]);
|
|
263
|
+
return new web3.TransactionInstruction({
|
|
264
|
+
programId: addresses_1.HATCH_PROGRAM,
|
|
265
|
+
keys: [
|
|
266
|
+
{ pubkey: rebalanceAuthority, isSigner: true, isWritable: false },
|
|
267
|
+
{ pubkey: launcherPda, isSigner: false, isWritable: false },
|
|
268
|
+
{ pubkey: hawkfiPda, isSigner: false, isWritable: false },
|
|
269
|
+
{ pubkey: lbPair, isSigner: false, isWritable: true },
|
|
270
|
+
{ pubkey: position, isSigner: false, isWritable: true },
|
|
271
|
+
{ pubkey: rewardVault, isSigner: false, isWritable: true },
|
|
272
|
+
{ pubkey: rewardMint, isSigner: false, isWritable: false },
|
|
273
|
+
{ pubkey: userTokenAccount, isSigner: false, isWritable: true },
|
|
274
|
+
{ pubkey: treasuryTokenAccount, isSigner: false, isWritable: true },
|
|
275
|
+
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
276
|
+
{ pubkey: addresses_1.MEMO_PROGRAM, isSigner: false, isWritable: false },
|
|
277
|
+
{ pubkey: addresses_1.METEORA_EVENT_AUTHORITY, isSigner: false, isWritable: false },
|
|
278
|
+
{ pubkey: addresses_1.METEORA_DLMM_PROGRAM, isSigner: false, isWritable: false },
|
|
279
|
+
// Remaining accounts: bin arrays
|
|
280
|
+
...binArrays.map((pubkey) => ({
|
|
281
|
+
pubkey,
|
|
282
|
+
isSigner: false,
|
|
283
|
+
isWritable: true,
|
|
284
|
+
})),
|
|
285
|
+
],
|
|
286
|
+
data,
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Initialize the global HawkfiPda (one-time operation).
|
|
292
|
+
*/
|
|
293
|
+
initializeHawkfiPda({ payer, }) {
|
|
294
|
+
const hawkfiPda = this.pda.hatch.deriveHawkfiPda();
|
|
295
|
+
return new web3.TransactionInstruction({
|
|
296
|
+
programId: addresses_1.HATCH_PROGRAM,
|
|
297
|
+
keys: [
|
|
298
|
+
{ pubkey: payer, isSigner: true, isWritable: true },
|
|
299
|
+
{ pubkey: hawkfiPda, isSigner: false, isWritable: true },
|
|
300
|
+
{ pubkey: web3.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
301
|
+
],
|
|
302
|
+
data: DISCRIMINATORS.initializeHawkfiPda,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Initialize a LauncherPda for a given authority.
|
|
307
|
+
*
|
|
308
|
+
* Must be called before createPoolAndLockedPosition if the LauncherPda
|
|
309
|
+
* doesn't exist yet. This is a one-time operation per authority wallet.
|
|
310
|
+
*
|
|
311
|
+
* @param authority - The wallet that will own this LauncherPda
|
|
312
|
+
*/
|
|
313
|
+
initializeLauncherPda({ authority, }) {
|
|
314
|
+
const launcherPda = this.pda.hatch.deriveLauncherPda(authority);
|
|
315
|
+
return new web3.TransactionInstruction({
|
|
316
|
+
programId: addresses_1.HATCH_PROGRAM,
|
|
317
|
+
keys: [
|
|
318
|
+
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
319
|
+
{ pubkey: launcherPda, isSigner: false, isWritable: true },
|
|
320
|
+
{ pubkey: web3.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
321
|
+
],
|
|
322
|
+
data: DISCRIMINATORS.initializeLauncherPda,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
exports.HatchIxGenerator = HatchIxGenerator;
|