@hawksightco/hawk-sdk 1.3.192 → 1.3.193

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/src/addresses.d.ts +0 -2
  2. package/dist/src/addresses.d.ts.map +1 -1
  3. package/dist/src/addresses.js +1 -4
  4. package/dist/src/classes/SimpleIxGenerator.d.ts +0 -7
  5. package/dist/src/classes/SimpleIxGenerator.d.ts.map +1 -1
  6. package/dist/src/classes/SimpleIxGenerator.js +0 -7
  7. package/dist/src/classes/SimplePdaGenerator.d.ts +2 -7
  8. package/dist/src/classes/SimplePdaGenerator.d.ts.map +1 -1
  9. package/dist/src/classes/SimplePdaGenerator.js +2 -7
  10. package/dist/src/classes/Transactions.d.ts +14 -40
  11. package/dist/src/classes/Transactions.d.ts.map +1 -1
  12. package/dist/src/classes/Transactions.js +214 -254
  13. package/dist/src/classes/TxGenerator.d.ts +1 -15
  14. package/dist/src/classes/TxGenerator.d.ts.map +1 -1
  15. package/dist/src/classes/TxGenerator.js +0 -52
  16. package/dist/src/classes/TxGeneratorAutomations.d.ts +15 -29
  17. package/dist/src/classes/TxGeneratorAutomations.d.ts.map +1 -1
  18. package/dist/src/classes/TxGeneratorAutomations.js +52 -84
  19. package/dist/src/idl/iyf-extension-idl.d.ts +12 -0
  20. package/dist/src/idl/iyf-extension-idl.d.ts.map +1 -1
  21. package/dist/src/idl/iyf-extension-idl.js +12 -0
  22. package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts +6 -4
  23. package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts.map +1 -1
  24. package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.js +2 -2
  25. package/dist/src/pdaGenerator/MeteoraPdaGenerator.d.ts +0 -13
  26. package/dist/src/pdaGenerator/MeteoraPdaGenerator.d.ts.map +1 -1
  27. package/dist/src/pdaGenerator/MeteoraPdaGenerator.js +0 -26
  28. package/dist/src/types.d.ts +21 -110
  29. package/dist/src/types.d.ts.map +1 -1
  30. package/package.json +1 -1
  31. package/dist/src/ixGenerator/HatchIxGenerator.d.ts +0 -108
  32. package/dist/src/ixGenerator/HatchIxGenerator.d.ts.map +0 -1
  33. package/dist/src/ixGenerator/HatchIxGenerator.js +0 -308
  34. package/dist/src/pdaGenerator/HatchPdaGenerator.d.ts +0 -39
  35. package/dist/src/pdaGenerator/HatchPdaGenerator.d.ts.map +0 -1
  36. package/dist/src/pdaGenerator/HatchPdaGenerator.js +0 -85
@@ -1,308 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- var __importDefault = (this && this.__importDefault) || function (mod) {
45
- return (mod && mod.__esModule) ? mod : { "default": mod };
46
- };
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.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
- initializeLauncherPda: Buffer.from([149, 59, 86, 45, 74, 12, 137, 15]),
60
- };
61
- /**
62
- * Instruction generator for the Hatch program.
63
- *
64
- * Hatch provides a secure interface for:
65
- * - Creating locked DLMM positions (LauncherPda is position owner)
66
- * - Claiming trading fees (via rebalance authority)
67
- * - Claiming farming rewards (via rebalance authority)
68
- *
69
- * Note: Positions are "locked" because only the Hatch program can sign
70
- * for LauncherPda via CPI. There is no unlock mechanism.
71
- */
72
- class HatchIxGenerator {
73
- constructor(pda) {
74
- this.pda = pda;
75
- }
76
- /**
77
- * Create a pool and locked position on Meteora DLMM via Hatch.
78
- *
79
- * The position will be owned by LauncherPda, making it effectively locked
80
- * since only the Hatch program can sign for LauncherPda.
81
- *
82
- * IMPORTANT: Tokens must be in LauncherPda-owned accounts before calling.
83
- * Only the position owner can deposit, and LauncherPda is the owner.
84
- *
85
- * Note: Position is now a keypair (signer), not a derived PDA.
86
- * The caller must generate a new keypair and pass its public key here.
87
- */
88
- createPoolAndLockedPosition(_a) {
89
- return __awaiter(this, arguments, void 0, function* ({ connection, authority, position, presetParameter, tokenMintX, tokenMintY, tokenProgramX, tokenProgramY, activeId, lowerBinId, upperBinId, strategyType, amountX, amountY, }) {
90
- // Derive LauncherPda (now the position owner)
91
- const launcherPda = this.pda.hatch.deriveLauncherPda(authority);
92
- // Derive Meteora accounts
93
- const lbPair = this.pda.meteora.deriveLbPairWithPresetParamWithIndexKey(presetParameter, tokenMintX, tokenMintY);
94
- const reserveX = this.pda.meteora.deriveReserve(tokenMintX, lbPair);
95
- const reserveY = this.pda.meteora.deriveReserve(tokenMintY, lbPair);
96
- const oracle = this.pda.meteora.deriveOracle(lbPair);
97
- const binArrayBitmapExtension = this.pda.meteora.deriveBinArrayBitmapExtension(lbPair);
98
- // Token accounts MUST be owned by LauncherPda (position owner can deposit)
99
- const userTokenX = (0, functions_1.generateAta)(launcherPda, tokenMintX, tokenProgramX);
100
- const userTokenY = (0, functions_1.generateAta)(launcherPda, tokenMintY, tokenProgramY);
101
- // Derive bin arrays for remaining accounts
102
- const binArrays = meteora_1.MeteoraFunctions.findMeteoraTickArrays(lbPair, lowerBinId, upperBinId);
103
- // Serialize instruction data (no lock_release_point - locked by design)
104
- const activeIdBuf = Buffer.alloc(4);
105
- activeIdBuf.writeInt32LE(activeId, 0);
106
- const lowerBinIdBuf = Buffer.alloc(4);
107
- lowerBinIdBuf.writeInt32LE(lowerBinId, 0);
108
- const upperBinIdBuf = Buffer.alloc(4);
109
- upperBinIdBuf.writeInt32LE(upperBinId, 0);
110
- const amountXBuf = amountX.toArrayLike(Buffer, "le", 8);
111
- const amountYBuf = amountY.toArrayLike(Buffer, "le", 8);
112
- const data = Buffer.concat([
113
- DISCRIMINATORS.createPoolAndLockedPosition,
114
- activeIdBuf,
115
- lowerBinIdBuf,
116
- upperBinIdBuf,
117
- Buffer.from([strategyType]), // Same as MeteoraDlmm
118
- amountXBuf,
119
- amountYBuf,
120
- ]);
121
- // Account order: position is now a signer, base removed, rent added
122
- return new web3.TransactionInstruction({
123
- programId: addresses_1.HATCH_PROGRAM,
124
- keys: [
125
- { pubkey: authority, isSigner: true, isWritable: true },
126
- { pubkey: launcherPda, isSigner: false, isWritable: true },
127
- { pubkey: lbPair, isSigner: false, isWritable: true },
128
- { pubkey: reserveX, isSigner: false, isWritable: true },
129
- { pubkey: reserveY, isSigner: false, isWritable: true },
130
- { pubkey: oracle, isSigner: false, isWritable: true },
131
- { pubkey: presetParameter, isSigner: false, isWritable: false },
132
- { pubkey: tokenMintX, isSigner: false, isWritable: false },
133
- { pubkey: tokenMintY, isSigner: false, isWritable: false },
134
- { pubkey: userTokenX, isSigner: false, isWritable: true },
135
- { pubkey: userTokenY, isSigner: false, isWritable: true },
136
- { pubkey: position, isSigner: true, isWritable: true }, // Position is now a signer
137
- { pubkey: binArrayBitmapExtension, isSigner: false, isWritable: true },
138
- { pubkey: tokenProgramX, isSigner: false, isWritable: false },
139
- { pubkey: tokenProgramY, isSigner: false, isWritable: false },
140
- { pubkey: web3.SystemProgram.programId, isSigner: false, isWritable: false },
141
- { pubkey: web3.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false }, // Rent sysvar added
142
- { pubkey: addresses_1.METEORA_EVENT_AUTHORITY, isSigner: false, isWritable: false },
143
- { pubkey: addresses_1.METEORA_DLMM_PROGRAM, isSigner: false, isWritable: false },
144
- // Remaining accounts: bin arrays
145
- ...binArrays.map((pubkey) => ({
146
- pubkey,
147
- isSigner: false,
148
- isWritable: true,
149
- })),
150
- ],
151
- data,
152
- });
153
- });
154
- }
155
- /**
156
- * Claim trading fees from a Hatch position.
157
- *
158
- * Only the rebalance authority can call this.
159
- * Fees go to LauncherPda-owned token accounts, with protocol fee to treasury.
160
- * LauncherPda signs for the claim via CPI.
161
- */
162
- claimFee(_a) {
163
- return __awaiter(this, arguments, void 0, function* ({ connection, rebalanceAuthority, launcherAuthority, position, lbPair, minBinId, maxBinId, tokenMintX, tokenMintY, tokenProgramX, tokenProgramY, }) {
164
- // Derive LauncherPda (position owner)
165
- const launcherPda = this.pda.hatch.deriveLauncherPda(launcherAuthority);
166
- // Derive Meteora accounts
167
- const reserveX = this.pda.meteora.deriveReserve(tokenMintX, lbPair);
168
- const reserveY = this.pda.meteora.deriveReserve(tokenMintY, lbPair);
169
- // LauncherPda-owned token accounts for fees
170
- const userTokenX = (0, functions_1.generateAta)(launcherPda, tokenMintX, tokenProgramX);
171
- const userTokenY = (0, functions_1.generateAta)(launcherPda, tokenMintY, tokenProgramY);
172
- // Treasury token accounts
173
- const treasuryTokenX = (0, functions_1.generateAta)(addresses_1.HATCH_TREASURY, tokenMintX, tokenProgramX);
174
- const treasuryTokenY = (0, functions_1.generateAta)(addresses_1.HATCH_TREASURY, tokenMintY, tokenProgramY);
175
- // Derive bin arrays for remaining accounts
176
- const binArrays = this.pda.meteora.deriveBinArrays(lbPair, minBinId, maxBinId);
177
- // Serialize remaining accounts info (empty for now - Meteora handles internally)
178
- const remainingAccountsInfo = Buffer.alloc(4); // Empty vec: length = 0
179
- remainingAccountsInfo.writeUInt32LE(0, 0);
180
- // Serialize instruction data
181
- const minBinIdBuf = Buffer.alloc(4);
182
- minBinIdBuf.writeInt32LE(minBinId, 0);
183
- const maxBinIdBuf = Buffer.alloc(4);
184
- maxBinIdBuf.writeInt32LE(maxBinId, 0);
185
- const data = Buffer.concat([
186
- DISCRIMINATORS.claimFee,
187
- minBinIdBuf,
188
- maxBinIdBuf,
189
- remainingAccountsInfo,
190
- ]);
191
- // New account order (no HawkfiPda)
192
- return new web3.TransactionInstruction({
193
- programId: addresses_1.HATCH_PROGRAM,
194
- keys: [
195
- { pubkey: rebalanceAuthority, isSigner: true, isWritable: false },
196
- { pubkey: launcherPda, isSigner: false, isWritable: false },
197
- { pubkey: lbPair, isSigner: false, isWritable: true },
198
- { pubkey: position, isSigner: false, isWritable: true },
199
- { pubkey: reserveX, isSigner: false, isWritable: true },
200
- { pubkey: reserveY, isSigner: false, isWritable: true },
201
- { pubkey: userTokenX, isSigner: false, isWritable: true },
202
- { pubkey: userTokenY, isSigner: false, isWritable: true },
203
- { pubkey: treasuryTokenX, isSigner: false, isWritable: true },
204
- { pubkey: treasuryTokenY, isSigner: false, isWritable: true },
205
- { pubkey: tokenMintX, isSigner: false, isWritable: false },
206
- { pubkey: tokenMintY, isSigner: false, isWritable: false },
207
- { pubkey: tokenProgramX, isSigner: false, isWritable: false },
208
- { pubkey: tokenProgramY, isSigner: false, isWritable: false },
209
- { pubkey: addresses_1.MEMO_PROGRAM, isSigner: false, isWritable: false },
210
- { pubkey: addresses_1.METEORA_EVENT_AUTHORITY, isSigner: false, isWritable: false },
211
- { pubkey: addresses_1.METEORA_DLMM_PROGRAM, isSigner: false, isWritable: false },
212
- // Remaining accounts: bin arrays
213
- ...binArrays.map((pubkey) => ({
214
- pubkey,
215
- isSigner: false,
216
- isWritable: true,
217
- })),
218
- ],
219
- data,
220
- });
221
- });
222
- }
223
- /**
224
- * Claim farming rewards from a Hatch position.
225
- *
226
- * Only the rebalance authority can call this.
227
- * Rewards go to LauncherPda-owned token account, with protocol fee to treasury.
228
- * LauncherPda signs for the claim via CPI.
229
- */
230
- claimReward(_a) {
231
- return __awaiter(this, arguments, void 0, function* ({ connection, rebalanceAuthority, launcherAuthority, position, lbPair, rewardIndex, minBinId, maxBinId, rewardMint, rewardVault, tokenProgram, }) {
232
- // Derive LauncherPda (position owner)
233
- const launcherPda = this.pda.hatch.deriveLauncherPda(launcherAuthority);
234
- // LauncherPda-owned token account for rewards
235
- const userTokenAccount = (0, functions_1.generateAta)(launcherPda, rewardMint, tokenProgram);
236
- // Treasury token account
237
- const treasuryTokenAccount = (0, functions_1.generateAta)(addresses_1.HATCH_TREASURY, rewardMint, tokenProgram);
238
- // Derive bin arrays for remaining accounts
239
- const binArrays = this.pda.meteora.deriveBinArrays(lbPair, minBinId, maxBinId);
240
- // Serialize remaining accounts info (empty for now)
241
- const remainingAccountsInfo = Buffer.alloc(4);
242
- remainingAccountsInfo.writeUInt32LE(0, 0);
243
- // Serialize instruction data
244
- const rewardIndexBuf = Buffer.alloc(8);
245
- new bn_js_1.default(rewardIndex).toArrayLike(Buffer, "le", 8).copy(rewardIndexBuf);
246
- const minBinIdBuf = Buffer.alloc(4);
247
- minBinIdBuf.writeInt32LE(minBinId, 0);
248
- const maxBinIdBuf = Buffer.alloc(4);
249
- maxBinIdBuf.writeInt32LE(maxBinId, 0);
250
- const data = Buffer.concat([
251
- DISCRIMINATORS.claimReward,
252
- rewardIndexBuf,
253
- minBinIdBuf,
254
- maxBinIdBuf,
255
- remainingAccountsInfo,
256
- ]);
257
- // New account order (no HawkfiPda)
258
- return new web3.TransactionInstruction({
259
- programId: addresses_1.HATCH_PROGRAM,
260
- keys: [
261
- { pubkey: rebalanceAuthority, isSigner: true, isWritable: false },
262
- { pubkey: launcherPda, isSigner: false, isWritable: false },
263
- { pubkey: lbPair, isSigner: false, isWritable: true },
264
- { pubkey: position, isSigner: false, isWritable: true },
265
- { pubkey: rewardVault, isSigner: false, isWritable: true },
266
- { pubkey: rewardMint, isSigner: false, isWritable: false },
267
- { pubkey: userTokenAccount, isSigner: false, isWritable: true },
268
- { pubkey: treasuryTokenAccount, isSigner: false, isWritable: true },
269
- { pubkey: tokenProgram, isSigner: false, isWritable: false },
270
- { pubkey: addresses_1.MEMO_PROGRAM, isSigner: false, isWritable: false },
271
- { pubkey: addresses_1.METEORA_EVENT_AUTHORITY, isSigner: false, isWritable: false },
272
- { pubkey: addresses_1.METEORA_DLMM_PROGRAM, isSigner: false, isWritable: false },
273
- // Remaining accounts: bin arrays
274
- ...binArrays.map((pubkey) => ({
275
- pubkey,
276
- isSigner: false,
277
- isWritable: true,
278
- })),
279
- ],
280
- data,
281
- });
282
- });
283
- }
284
- /**
285
- * Initialize a LauncherPda for a given authority.
286
- *
287
- * Must be called before createPoolAndLockedPosition if the LauncherPda
288
- * doesn't exist yet. This is a one-time operation per authority wallet.
289
- *
290
- * The LauncherPda becomes the position owner for all positions created
291
- * by this authority.
292
- *
293
- * @param authority - The wallet that will own this LauncherPda
294
- */
295
- initializeLauncherPda({ authority, }) {
296
- const launcherPda = this.pda.hatch.deriveLauncherPda(authority);
297
- return new web3.TransactionInstruction({
298
- programId: addresses_1.HATCH_PROGRAM,
299
- keys: [
300
- { pubkey: authority, isSigner: true, isWritable: true },
301
- { pubkey: launcherPda, isSigner: false, isWritable: true },
302
- { pubkey: web3.SystemProgram.programId, isSigner: false, isWritable: false },
303
- ],
304
- data: DISCRIMINATORS.initializeLauncherPda,
305
- });
306
- }
307
- }
308
- exports.HatchIxGenerator = HatchIxGenerator;
@@ -1,39 +0,0 @@
1
- import * as web3 from "@solana/web3.js";
2
- /**
3
- * PDA Generator for the Hatch program.
4
- *
5
- * Derives program-derived addresses for:
6
- * - LauncherPda: Per-launcher PDA that owns positions (and receives fees)
7
- *
8
- * Note: LauncherPda is the position owner. Positions are "locked" because
9
- * only the Hatch program can sign for LauncherPda via CPI.
10
- */
11
- export declare class HatchPdaGenerator {
12
- /**
13
- * Derive a LauncherPda for a specific authority.
14
- *
15
- * Seeds: ["launcher", authority]
16
- * Each launcher authority gets their own LauncherPda which:
17
- * - Owns the position (signs for position operations via CPI)
18
- * - Receives trading fees (after protocol fee deduction)
19
- *
20
- * The position is effectively "locked" because only the Hatch program
21
- * can sign for LauncherPda.
22
- *
23
- * @param authority - The launcher authority wallet
24
- * @returns The LauncherPda public key
25
- */
26
- deriveLauncherPda(authority: web3.PublicKey): web3.PublicKey;
27
- /**
28
- * Derive position PDA for Meteora DLMM.
29
- *
30
- * Seeds: ["position", lb_pair, base, lower_bin_id (le bytes)]
31
- *
32
- * @param lbPair - The LB pair (pool) address
33
- * @param base - The base keypair public key
34
- * @param lowerBinId - The lower bin ID
35
- * @returns The position PDA public key
36
- */
37
- derivePositionPda(lbPair: web3.PublicKey, base: web3.PublicKey, lowerBinId: number): web3.PublicKey;
38
- }
39
- //# sourceMappingURL=HatchPdaGenerator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HatchPdaGenerator.d.ts","sourceRoot":"","sources":["../../../src/pdaGenerator/HatchPdaGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAGxC;;;;;;;;GAQG;AACH,qBAAa,iBAAiB;IAC5B;;;;;;;;;;;;;OAaG;IACH,iBAAiB,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS;IAQ5D;;;;;;;;;OASG;IACH,iBAAiB,CACf,MAAM,EAAE,IAAI,CAAC,SAAS,EACtB,IAAI,EAAE,IAAI,CAAC,SAAS,EACpB,UAAU,EAAE,MAAM,GACjB,IAAI,CAAC,SAAS;CAWlB"}
@@ -1,85 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.HatchPdaGenerator = void 0;
37
- const web3 = __importStar(require("@solana/web3.js"));
38
- const addresses_1 = require("../addresses");
39
- /**
40
- * PDA Generator for the Hatch program.
41
- *
42
- * Derives program-derived addresses for:
43
- * - LauncherPda: Per-launcher PDA that owns positions (and receives fees)
44
- *
45
- * Note: LauncherPda is the position owner. Positions are "locked" because
46
- * only the Hatch program can sign for LauncherPda via CPI.
47
- */
48
- class HatchPdaGenerator {
49
- /**
50
- * Derive a LauncherPda for a specific authority.
51
- *
52
- * Seeds: ["launcher", authority]
53
- * Each launcher authority gets their own LauncherPda which:
54
- * - Owns the position (signs for position operations via CPI)
55
- * - Receives trading fees (after protocol fee deduction)
56
- *
57
- * The position is effectively "locked" because only the Hatch program
58
- * can sign for LauncherPda.
59
- *
60
- * @param authority - The launcher authority wallet
61
- * @returns The LauncherPda public key
62
- */
63
- deriveLauncherPda(authority) {
64
- const [pda] = web3.PublicKey.findProgramAddressSync([Buffer.from("launcher"), authority.toBuffer()], addresses_1.HATCH_PROGRAM);
65
- return pda;
66
- }
67
- /**
68
- * Derive position PDA for Meteora DLMM.
69
- *
70
- * Seeds: ["position", lb_pair, base, lower_bin_id (le bytes)]
71
- *
72
- * @param lbPair - The LB pair (pool) address
73
- * @param base - The base keypair public key
74
- * @param lowerBinId - The lower bin ID
75
- * @returns The position PDA public key
76
- */
77
- derivePositionPda(lbPair, base, lowerBinId) {
78
- const METEORA_DLMM_PROGRAM = new web3.PublicKey("LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo");
79
- const lowerBinIdBuffer = Buffer.alloc(4);
80
- lowerBinIdBuffer.writeInt32LE(lowerBinId, 0);
81
- const [pda] = web3.PublicKey.findProgramAddressSync([Buffer.from("position"), lbPair.toBuffer(), base.toBuffer(), lowerBinIdBuffer], METEORA_DLMM_PROGRAM);
82
- return pda;
83
- }
84
- }
85
- exports.HatchPdaGenerator = HatchPdaGenerator;