@coinbarrel/sdk 1.1.0 → 1.2.0

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/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * CoinBarrel SDK
3
4
  *
@@ -26,20 +27,82 @@
26
27
  *
27
28
  * @packageDocumentation
28
29
  */
29
- import { PROGRAM_IDS, ADMIN_FEE_RECIPIENTS, LAMPORTS_PER_SOL } from "./constants.js";
30
- import * as pda from "./pda.js";
31
- import * as accounts from "./accounts.js";
32
- import * as curve from "./curve.js";
33
- import * as pool from "./pool.js";
34
- import * as metadata from "./metadata.js";
30
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ var desc = Object.getOwnPropertyDescriptor(m, k);
33
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
34
+ desc = { enumerable: true, get: function() { return m[k]; } };
35
+ }
36
+ Object.defineProperty(o, k2, desc);
37
+ }) : (function(o, m, k, k2) {
38
+ if (k2 === undefined) k2 = k;
39
+ o[k2] = m[k];
40
+ }));
41
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
42
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
43
+ }) : function(o, v) {
44
+ o["default"] = v;
45
+ });
46
+ var __importStar = (this && this.__importStar) || (function () {
47
+ var ownKeys = function(o) {
48
+ ownKeys = Object.getOwnPropertyNames || function (o) {
49
+ var ar = [];
50
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
51
+ return ar;
52
+ };
53
+ return ownKeys(o);
54
+ };
55
+ return function (mod) {
56
+ if (mod && mod.__esModule) return mod;
57
+ var result = {};
58
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
59
+ __setModuleDefault(result, mod);
60
+ return result;
61
+ };
62
+ })();
63
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
64
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
65
+ };
66
+ Object.defineProperty(exports, "__esModule", { value: true });
67
+ exports.CoinBarrel = exports.buildClaimHolderRewardsInstruction = exports.buildClaimHolderRewardsCurveInstruction = exports.buildCreateBarrelTokenInstruction = exports.parseMetaplexMetadata = exports.getMetadataPda = exports.batchGetTokenMetadata = exports.getTokenMetadataJson = exports.getTokenMetadata = exports.getSwapTokenToSolQuote = exports.getSwapSolToTokenQuote = exports.getSellQuote = exports.getBuyQuote = exports.getUserTokenBalance = exports.getMarketInfo = exports.getPoolState = exports.getBondingCurveState = void 0;
68
+ exports.solToLamports = solToLamports;
69
+ exports.lamportsToSol = lamportsToSol;
70
+ exports.toRawAmount = toRawAmount;
71
+ exports.toUiAmount = toUiAmount;
72
+ const constants_js_1 = require("./constants.js");
73
+ const pda = __importStar(require("./pda.js"));
74
+ const accounts = __importStar(require("./accounts.js"));
75
+ const curve = __importStar(require("./curve.js"));
76
+ const pool = __importStar(require("./pool.js"));
77
+ const metadata = __importStar(require("./metadata.js"));
78
+ const create = __importStar(require("./create.js"));
79
+ const rewards = __importStar(require("./rewards.js"));
35
80
  // ============= Re-exports =============
36
- export * from "./constants.js";
37
- export * from "./types.js";
38
- export * from "./pda.js";
39
- export { getBondingCurveState, getPoolState, getMarketInfo, getUserTokenBalance } from "./accounts.js";
40
- export { getBuyQuote, getSellQuote } from "./curve.js";
41
- export { getSwapSolToTokenQuote, getSwapTokenToSolQuote } from "./pool.js";
42
- export { getTokenMetadata, getTokenMetadataJson, batchGetTokenMetadata, getMetadataPda, parseMetaplexMetadata, } from "./metadata.js";
81
+ __exportStar(require("./constants.js"), exports);
82
+ __exportStar(require("./types.js"), exports);
83
+ __exportStar(require("./pda.js"), exports);
84
+ var accounts_js_1 = require("./accounts.js");
85
+ Object.defineProperty(exports, "getBondingCurveState", { enumerable: true, get: function () { return accounts_js_1.getBondingCurveState; } });
86
+ Object.defineProperty(exports, "getPoolState", { enumerable: true, get: function () { return accounts_js_1.getPoolState; } });
87
+ Object.defineProperty(exports, "getMarketInfo", { enumerable: true, get: function () { return accounts_js_1.getMarketInfo; } });
88
+ Object.defineProperty(exports, "getUserTokenBalance", { enumerable: true, get: function () { return accounts_js_1.getUserTokenBalance; } });
89
+ var curve_js_1 = require("./curve.js");
90
+ Object.defineProperty(exports, "getBuyQuote", { enumerable: true, get: function () { return curve_js_1.getBuyQuote; } });
91
+ Object.defineProperty(exports, "getSellQuote", { enumerable: true, get: function () { return curve_js_1.getSellQuote; } });
92
+ var pool_js_1 = require("./pool.js");
93
+ Object.defineProperty(exports, "getSwapSolToTokenQuote", { enumerable: true, get: function () { return pool_js_1.getSwapSolToTokenQuote; } });
94
+ Object.defineProperty(exports, "getSwapTokenToSolQuote", { enumerable: true, get: function () { return pool_js_1.getSwapTokenToSolQuote; } });
95
+ var metadata_js_1 = require("./metadata.js");
96
+ Object.defineProperty(exports, "getTokenMetadata", { enumerable: true, get: function () { return metadata_js_1.getTokenMetadata; } });
97
+ Object.defineProperty(exports, "getTokenMetadataJson", { enumerable: true, get: function () { return metadata_js_1.getTokenMetadataJson; } });
98
+ Object.defineProperty(exports, "batchGetTokenMetadata", { enumerable: true, get: function () { return metadata_js_1.batchGetTokenMetadata; } });
99
+ Object.defineProperty(exports, "getMetadataPda", { enumerable: true, get: function () { return metadata_js_1.getMetadataPda; } });
100
+ Object.defineProperty(exports, "parseMetaplexMetadata", { enumerable: true, get: function () { return metadata_js_1.parseMetaplexMetadata; } });
101
+ var create_js_1 = require("./create.js");
102
+ Object.defineProperty(exports, "buildCreateBarrelTokenInstruction", { enumerable: true, get: function () { return create_js_1.buildCreateBarrelTokenInstruction; } });
103
+ var rewards_js_1 = require("./rewards.js");
104
+ Object.defineProperty(exports, "buildClaimHolderRewardsCurveInstruction", { enumerable: true, get: function () { return rewards_js_1.buildClaimHolderRewardsCurveInstruction; } });
105
+ Object.defineProperty(exports, "buildClaimHolderRewardsInstruction", { enumerable: true, get: function () { return rewards_js_1.buildClaimHolderRewardsInstruction; } });
43
106
  // ============= SDK Class =============
44
107
  /**
45
108
  * CoinBarrel SDK - Main entry point
@@ -53,7 +116,7 @@ export { getTokenMetadata, getTokenMetadataJson, batchGetTokenMetadata, getMetad
53
116
  * Fee recipients are read from on-chain state and cannot be modified.
54
117
  * The program enforces that all fees go to the correct recipients.
55
118
  */
56
- export class CoinBarrel {
119
+ class CoinBarrel {
57
120
  /** Solana RPC connection */
58
121
  connection;
59
122
  /** Network (devnet or mainnet) */
@@ -69,8 +132,8 @@ export class CoinBarrel {
69
132
  constructor(config) {
70
133
  this.connection = config.connection;
71
134
  this.network = config.network;
72
- this.programId = PROGRAM_IDS[config.network];
73
- this.adminFeeRecipient = ADMIN_FEE_RECIPIENTS[config.network];
135
+ this.programId = constants_js_1.PROGRAM_IDS[config.network];
136
+ this.adminFeeRecipient = constants_js_1.ADMIN_FEE_RECIPIENTS[config.network];
74
137
  this.curve = new CurveModule(this);
75
138
  this.pool = new PoolModule(this);
76
139
  }
@@ -159,7 +222,48 @@ export class CoinBarrel {
159
222
  getMetadataPda(tokenMint) {
160
223
  return metadata.getMetadataPda(tokenMint);
161
224
  }
225
+ // ============= Token Creation =============
226
+ /**
227
+ * Build create barrel token instruction
228
+ *
229
+ * Creates a new token with atomically revoked mint/freeze authority.
230
+ * Returns the instruction and a mint keypair that must sign the transaction.
231
+ *
232
+ * @example
233
+ * ```typescript
234
+ * const { instructions, mintKeypair } = sdk.buildCreateTokenInstruction({
235
+ * payer: wallet.publicKey,
236
+ * name: "My Token",
237
+ * symbol: "MTK",
238
+ * uri: "https://...",
239
+ * creatorFeeRecipient: wallet.publicKey,
240
+ * });
241
+ *
242
+ * // Add mintKeypair as signer when sending transaction
243
+ * ```
244
+ */
245
+ buildCreateTokenInstruction(params) {
246
+ return create.buildCreateBarrelTokenInstruction(params, this.programId, this.network);
247
+ }
248
+ // ============= Rewards =============
249
+ /**
250
+ * Build claim holder rewards instruction for bonding curve
251
+ *
252
+ * Claims accumulated holder rewards paid in SOL.
253
+ */
254
+ async buildClaimRewardsCurveInstruction(tokenMint, holder) {
255
+ return rewards.buildClaimHolderRewardsCurveInstruction(this.connection, { tokenMint, holder }, this.programId);
256
+ }
257
+ /**
258
+ * Build claim holder rewards instruction for AMM pool
259
+ *
260
+ * Claims accumulated holder rewards (WSOL unwrapped to SOL).
261
+ */
262
+ async buildClaimRewardsPoolInstruction(tokenMint, holder) {
263
+ return rewards.buildClaimHolderRewardsInstruction(this.connection, { tokenMint, holder }, this.programId);
264
+ }
162
265
  }
266
+ exports.CoinBarrel = CoinBarrel;
163
267
  // ============= Curve Module =============
164
268
  /**
165
269
  * Bonding Curve Operations
@@ -273,25 +377,24 @@ class PoolModule {
273
377
  /**
274
378
  * Convert SOL to lamports
275
379
  */
276
- export function solToLamports(sol) {
277
- return BigInt(Math.floor(sol * Number(LAMPORTS_PER_SOL)));
380
+ function solToLamports(sol) {
381
+ return BigInt(Math.floor(sol * Number(constants_js_1.LAMPORTS_PER_SOL)));
278
382
  }
279
383
  /**
280
384
  * Convert lamports to SOL
281
385
  */
282
- export function lamportsToSol(lamports) {
283
- return Number(lamports) / Number(LAMPORTS_PER_SOL);
386
+ function lamportsToSol(lamports) {
387
+ return Number(lamports) / Number(constants_js_1.LAMPORTS_PER_SOL);
284
388
  }
285
389
  /**
286
390
  * Convert token amount to raw (with decimals)
287
391
  */
288
- export function toRawAmount(amount, decimals = 6) {
392
+ function toRawAmount(amount, decimals = 6) {
289
393
  return BigInt(Math.floor(amount * 10 ** decimals));
290
394
  }
291
395
  /**
292
396
  * Convert raw amount to UI (without decimals)
293
397
  */
294
- export function toUiAmount(rawAmount, decimals = 6) {
398
+ function toUiAmount(rawAmount, decimals = 6) {
295
399
  return Number(rawAmount) / 10 ** decimals;
296
400
  }
297
- //# sourceMappingURL=index.js.map
package/dist/metadata.js CHANGED
@@ -1,15 +1,22 @@
1
+ "use strict";
1
2
  /**
2
3
  * Token Metadata Fetching
3
4
  * Read Metaplex token metadata for CoinBarrel tokens
4
5
  */
5
- import { PublicKey } from '@solana/web3.js';
6
- import { TOKEN_METADATA_PROGRAM_ID } from './constants.js';
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getMetadataPda = getMetadataPda;
8
+ exports.parseMetaplexMetadata = parseMetaplexMetadata;
9
+ exports.getTokenMetadata = getTokenMetadata;
10
+ exports.getTokenMetadataJson = getTokenMetadataJson;
11
+ exports.batchGetTokenMetadata = batchGetTokenMetadata;
12
+ const web3_js_1 = require("@solana/web3.js");
13
+ const constants_js_1 = require("./constants.js");
7
14
  // ============= PDA =============
8
15
  /**
9
16
  * Derive Metaplex metadata PDA for a token mint
10
17
  */
11
- export function getMetadataPda(mint) {
12
- const [pda] = PublicKey.findProgramAddressSync([Buffer.from('metadata'), TOKEN_METADATA_PROGRAM_ID.toBuffer(), mint.toBuffer()], TOKEN_METADATA_PROGRAM_ID);
18
+ function getMetadataPda(mint) {
19
+ const [pda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('metadata'), constants_js_1.TOKEN_METADATA_PROGRAM_ID.toBuffer(), mint.toBuffer()], constants_js_1.TOKEN_METADATA_PROGRAM_ID);
13
20
  return pda;
14
21
  }
15
22
  // ============= Parsing =============
@@ -38,7 +45,7 @@ function readLengthPrefixedString(data, offset) {
38
45
  * - symbol: 4 bytes length + string
39
46
  * - uri: 4 bytes length + string
40
47
  */
41
- export function parseMetaplexMetadata(data) {
48
+ function parseMetaplexMetadata(data) {
42
49
  try {
43
50
  if (!data || data.length < 65)
44
51
  return null;
@@ -79,7 +86,7 @@ export function parseMetaplexMetadata(data) {
79
86
  * }
80
87
  * ```
81
88
  */
82
- export async function getTokenMetadata(connection, mint) {
89
+ async function getTokenMetadata(connection, mint) {
83
90
  try {
84
91
  const metadataPda = getMetadataPda(mint);
85
92
  const accountInfo = await connection.getAccountInfo(metadataPda);
@@ -93,103 +100,61 @@ export async function getTokenMetadata(connection, mint) {
93
100
  }
94
101
  }
95
102
  /**
96
- * Fetch full token metadata including off-chain JSON
97
- *
98
- * This fetches the on-chain metadata and then fetches the JSON from the URI
99
- * to get the image, description, and social links.
100
- *
101
- * @param connection - Solana RPC connection
102
- * @param mint - Token mint address
103
- * @param fetchOptions - Optional fetch options (timeout, etc.)
104
- *
105
- * @example
106
- * ```typescript
107
- * const metadata = await getTokenMetadataJson(connection, tokenMint);
108
- * if (metadata) {
109
- * console.log(metadata.name); // "My Token"
110
- * console.log(metadata.image); // "https://..." or "ipfs://..."
111
- * console.log(metadata.description); // "A cool token"
112
- * console.log(metadata.twitter); // "@mytoken"
113
- * }
114
- * ```
103
+ * Fetch on-chain Metaplex metadata and then fetch the off-chain JSON pointed to by the URI.
115
104
  */
116
- export async function getTokenMetadataJson(connection, mint, fetchOptions) {
117
- // First get on-chain metadata
118
- const onChainMetadata = await getTokenMetadata(connection, mint);
119
- if (!onChainMetadata) {
105
+ async function getTokenMetadataJson(connection, mint, options) {
106
+ const meta = await getTokenMetadata(connection, mint);
107
+ if (!meta)
120
108
  return null;
121
- }
122
- // If no URI, return just the on-chain data
123
- if (!onChainMetadata.uri) {
124
- return onChainMetadata;
125
- }
126
- // Fetch JSON from URI
109
+ const uri = (meta.uri ?? '').replace(/\0/g, '').trim();
110
+ if (!uri)
111
+ return { ...meta };
127
112
  try {
128
- const timeoutMs = fetchOptions?.timeoutMs ?? 10000;
129
- const controller = new AbortController();
130
- const timeout = setTimeout(() => controller.abort(), timeoutMs);
131
- // Handle IPFS URLs - convert to gateway URL
132
- let fetchUrl = onChainMetadata.uri;
133
- if (fetchUrl.startsWith('ipfs://')) {
134
- const cid = fetchUrl.replace('ipfs://', '');
135
- fetchUrl = `https://ipfs.io/ipfs/${cid}`;
136
- }
137
- const response = await fetch(fetchUrl, {
138
- signal: controller.signal,
139
- headers: {
140
- 'Accept': 'application/json',
141
- },
113
+ const controller = typeof AbortController !== 'undefined' ? new AbortController() : null;
114
+ const timeoutMs = options?.timeoutMs;
115
+ const timeout = controller && typeof timeoutMs === 'number' && timeoutMs > 0
116
+ ? setTimeout(() => controller.abort(), timeoutMs)
117
+ : null;
118
+ const resp = await fetch(uri, {
119
+ signal: controller?.signal,
120
+ headers: { accept: 'application/json' },
142
121
  });
143
- clearTimeout(timeout);
144
- if (!response.ok) {
145
- // Return on-chain data if JSON fetch fails
146
- return onChainMetadata;
147
- }
148
- const json = await response.json();
149
- // Extract fields from JSON (handles various metadata standards)
122
+ if (!resp.ok)
123
+ return { ...meta };
124
+ const json = (await resp.json());
125
+ if (timeout)
126
+ clearTimeout(timeout);
127
+ // Best-effort map of common social fields
128
+ const properties = json.properties && typeof json.properties === 'object'
129
+ ? json.properties
130
+ : undefined;
131
+ const extensions = (json.extensions && typeof json.extensions === 'object'
132
+ ? json.extensions
133
+ : undefined) ||
134
+ (properties?.extensions && typeof properties.extensions === 'object'
135
+ ? properties.extensions
136
+ : undefined);
137
+ const twitter = (typeof json.twitter === 'string' && json.twitter) ||
138
+ (typeof extensions?.twitter === 'string' && extensions.twitter) ||
139
+ undefined;
140
+ const telegram = (typeof json.telegram === 'string' && json.telegram) ||
141
+ (typeof extensions?.telegram === 'string' && extensions.telegram) ||
142
+ undefined;
143
+ const website = (typeof json.website === 'string' && json.website) ||
144
+ (typeof extensions?.website === 'string' && extensions.website) ||
145
+ undefined;
150
146
  return {
151
- name: onChainMetadata.name,
152
- symbol: onChainMetadata.symbol,
153
- uri: onChainMetadata.uri,
154
- description: typeof json.description === 'string' ? json.description : undefined,
155
- image: typeof json.image === 'string' ? json.image : undefined,
156
- website: extractString(json, ['external_url', 'website']) ||
157
- extractFromExtensions(json, 'website'),
158
- twitter: extractFromExtensions(json, 'twitter'),
159
- telegram: extractFromExtensions(json, 'telegram'),
160
- discord: extractFromExtensions(json, 'discord'),
161
- raw: json,
147
+ ...meta,
148
+ ...json,
149
+ // ensure we always surface these normalized keys when available
150
+ twitter,
151
+ telegram,
152
+ website,
162
153
  };
163
154
  }
164
155
  catch {
165
- // Return on-chain data if JSON fetch fails
166
- return onChainMetadata;
167
- }
168
- }
169
- /**
170
- * Extract a string from an object, trying multiple keys
171
- */
172
- function extractString(obj, keys) {
173
- for (const key of keys) {
174
- const value = obj[key];
175
- if (typeof value === 'string' && value.trim()) {
176
- return value.trim();
177
- }
178
- }
179
- return undefined;
180
- }
181
- /**
182
- * Extract a field from the `extensions` object (common in Metaplex metadata)
183
- */
184
- function extractFromExtensions(obj, key) {
185
- const extensions = obj.extensions;
186
- if (extensions && typeof extensions === 'object' && extensions !== null) {
187
- const value = extensions[key];
188
- if (typeof value === 'string' && value.trim()) {
189
- return value.trim();
190
- }
156
+ return { ...meta };
191
157
  }
192
- return undefined;
193
158
  }
194
159
  /**
195
160
  * Batch fetch metadata for multiple tokens
@@ -210,7 +175,7 @@ function extractFromExtensions(obj, key) {
210
175
  * }
211
176
  * ```
212
177
  */
213
- export async function batchGetTokenMetadata(connection, mints) {
178
+ async function batchGetTokenMetadata(connection, mints) {
214
179
  const results = new Map();
215
180
  if (mints.length === 0) {
216
181
  return results;
@@ -244,4 +209,3 @@ export async function batchGetTokenMetadata(connection, mints) {
244
209
  }
245
210
  return results;
246
211
  }
247
- //# sourceMappingURL=metadata.js.map
package/dist/pda.js CHANGED
@@ -1,77 +1,90 @@
1
+ "use strict";
1
2
  /**
2
3
  * PDA Derivation Helpers
3
4
  * All Program Derived Addresses for CoinBarrel AMM
4
5
  */
5
- import { PublicKey } from '@solana/web3.js';
6
- import { SEEDS, NATIVE_MINT } from './constants.js';
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getBondingCurvePda = getBondingCurvePda;
8
+ exports.getBondingAuthorityPda = getBondingAuthorityPda;
9
+ exports.getSolEscrowPda = getSolEscrowPda;
10
+ exports.getPoolPda = getPoolPda;
11
+ exports.getPoolAuthorityPda = getPoolAuthorityPda;
12
+ exports.getVaultPda = getVaultPda;
13
+ exports.getPoolWsolVaultPda = getPoolWsolVaultPda;
14
+ exports.getPoolTokenVaultPda = getPoolTokenVaultPda;
15
+ exports.getLpMintPda = getLpMintPda;
16
+ exports.getLpVaultPda = getLpVaultPda;
17
+ exports.getHolderRewardPda = getHolderRewardPda;
18
+ const web3_js_1 = require("@solana/web3.js");
19
+ const constants_js_1 = require("./constants.js");
7
20
  // ============= Bonding Curve PDAs =============
8
21
  /**
9
22
  * Derive bonding curve PDA for a token mint
10
23
  */
11
- export function getBondingCurvePda(mint, programId) {
12
- const [pda] = PublicKey.findProgramAddressSync([SEEDS.BONDING, mint.toBuffer()], programId);
24
+ function getBondingCurvePda(mint, programId) {
25
+ const [pda] = web3_js_1.PublicKey.findProgramAddressSync([constants_js_1.SEEDS.BONDING, mint.toBuffer()], programId);
13
26
  return pda;
14
27
  }
15
28
  /**
16
29
  * Derive bonding authority PDA (signs transfers from curve)
17
30
  */
18
- export function getBondingAuthorityPda(bondingCurve, programId) {
19
- const [pda] = PublicKey.findProgramAddressSync([SEEDS.BONDING_AUTHORITY, bondingCurve.toBuffer()], programId);
31
+ function getBondingAuthorityPda(bondingCurve, programId) {
32
+ const [pda] = web3_js_1.PublicKey.findProgramAddressSync([constants_js_1.SEEDS.BONDING_AUTHORITY, bondingCurve.toBuffer()], programId);
20
33
  return pda;
21
34
  }
22
35
  /**
23
36
  * Derive SOL escrow PDA for bonding curve
24
37
  */
25
- export function getSolEscrowPda(bondingCurve, programId) {
26
- const [pda] = PublicKey.findProgramAddressSync([SEEDS.BONDING_SOL, bondingCurve.toBuffer()], programId);
38
+ function getSolEscrowPda(bondingCurve, programId) {
39
+ const [pda] = web3_js_1.PublicKey.findProgramAddressSync([constants_js_1.SEEDS.BONDING_SOL, bondingCurve.toBuffer()], programId);
27
40
  return pda;
28
41
  }
29
42
  // ============= AMM Pool PDAs =============
30
43
  /**
31
44
  * Derive pool PDA for a WSOL <-> Token pair
32
45
  */
33
- export function getPoolPda(tokenMint, programId) {
34
- const [pda] = PublicKey.findProgramAddressSync([SEEDS.POOL, NATIVE_MINT.toBuffer(), tokenMint.toBuffer()], programId);
46
+ function getPoolPda(tokenMint, programId) {
47
+ const [pda] = web3_js_1.PublicKey.findProgramAddressSync([constants_js_1.SEEDS.POOL, constants_js_1.NATIVE_MINT.toBuffer(), tokenMint.toBuffer()], programId);
35
48
  return pda;
36
49
  }
37
50
  /**
38
51
  * Derive pool authority PDA (signs transfers from pool vaults)
39
52
  */
40
- export function getPoolAuthorityPda(pool, programId) {
41
- const [pda] = PublicKey.findProgramAddressSync([SEEDS.AUTHORITY, pool.toBuffer()], programId);
53
+ function getPoolAuthorityPda(pool, programId) {
54
+ const [pda] = web3_js_1.PublicKey.findProgramAddressSync([constants_js_1.SEEDS.AUTHORITY, pool.toBuffer()], programId);
42
55
  return pda;
43
56
  }
44
57
  /**
45
58
  * Derive vault PDA for a pool + mint
46
59
  */
47
- export function getVaultPda(pool, mint, programId) {
48
- const [pda] = PublicKey.findProgramAddressSync([SEEDS.VAULT, pool.toBuffer(), mint.toBuffer()], programId);
60
+ function getVaultPda(pool, mint, programId) {
61
+ const [pda] = web3_js_1.PublicKey.findProgramAddressSync([constants_js_1.SEEDS.VAULT, pool.toBuffer(), mint.toBuffer()], programId);
49
62
  return pda;
50
63
  }
51
64
  /**
52
65
  * Derive WSOL vault PDA for a pool
53
66
  */
54
- export function getPoolWsolVaultPda(pool, programId) {
55
- return getVaultPda(pool, NATIVE_MINT, programId);
67
+ function getPoolWsolVaultPda(pool, programId) {
68
+ return getVaultPda(pool, constants_js_1.NATIVE_MINT, programId);
56
69
  }
57
70
  /**
58
71
  * Derive token vault PDA for a pool
59
72
  */
60
- export function getPoolTokenVaultPda(pool, tokenMint, programId) {
73
+ function getPoolTokenVaultPda(pool, tokenMint, programId) {
61
74
  return getVaultPda(pool, tokenMint, programId);
62
75
  }
63
76
  /**
64
77
  * Derive LP mint PDA for a pool
65
78
  */
66
- export function getLpMintPda(pool, programId) {
67
- const [pda] = PublicKey.findProgramAddressSync([SEEDS.LP_MINT, pool.toBuffer()], programId);
79
+ function getLpMintPda(pool, programId) {
80
+ const [pda] = web3_js_1.PublicKey.findProgramAddressSync([constants_js_1.SEEDS.LP_MINT, pool.toBuffer()], programId);
68
81
  return pda;
69
82
  }
70
83
  /**
71
84
  * Derive LP vault PDA (holds burned/locked LP tokens)
72
85
  */
73
- export function getLpVaultPda(pool, programId) {
74
- const [pda] = PublicKey.findProgramAddressSync([SEEDS.LP_VAULT, pool.toBuffer()], programId);
86
+ function getLpVaultPda(pool, programId) {
87
+ const [pda] = web3_js_1.PublicKey.findProgramAddressSync([constants_js_1.SEEDS.LP_VAULT, pool.toBuffer()], programId);
75
88
  return pda;
76
89
  }
77
90
  // ============= Holder Reward PDAs =============
@@ -79,8 +92,7 @@ export function getLpVaultPda(pool, programId) {
79
92
  * Derive holder reward account PDA for a user + token
80
93
  * Used for tracking holder rewards across buys/sells
81
94
  */
82
- export function getHolderRewardPda(tokenMint, holder, programId) {
83
- const [pda] = PublicKey.findProgramAddressSync([SEEDS.HOLDER_REWARD, tokenMint.toBuffer(), holder.toBuffer()], programId);
95
+ function getHolderRewardPda(tokenMint, holder, programId) {
96
+ const [pda] = web3_js_1.PublicKey.findProgramAddressSync([constants_js_1.SEEDS.HOLDER_REWARD, tokenMint.toBuffer(), holder.toBuffer()], programId);
84
97
  return pda;
85
98
  }
86
- //# sourceMappingURL=pda.js.map