@whetstone-research/doppler-sdk 1.0.2 → 1.0.5

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.
@@ -0,0 +1,4981 @@
1
+ 'use strict';
2
+
3
+ var chunkBXATWUGJ_cjs = require('../chunk-BXATWUGJ.cjs');
4
+ var chunkDPKVNI6Q_cjs = require('../chunk-DPKVNI6Q.cjs');
5
+ var chunkQ7SFCCGT_cjs = require('../chunk-Q7SFCCGT.cjs');
6
+ var kit = require('@solana/kit');
7
+ var programClientCore = require('@solana/program-client-core');
8
+ var sha3_js = require('@noble/hashes/sha3.js');
9
+
10
+ // src/solana/cpmm/index.ts
11
+ var cpmm_exports = {};
12
+ chunkQ7SFCCGT_cjs.__export(cpmm_exports, {
13
+ ACCOUNT_DISCRIMINATORS: () => chunkDPKVNI6Q_cjs.ACCOUNT_DISCRIMINATORS,
14
+ ACCOUNT_VERSION: () => chunkDPKVNI6Q_cjs.ACCOUNT_VERSION,
15
+ BPS_DENOM: () => chunkDPKVNI6Q_cjs.BPS_DENOM,
16
+ CPMM_ERROR_MESSAGES: () => CPMM_ERROR_MESSAGES,
17
+ CPMM_PROGRAM_ID: () => chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID,
18
+ CpmmError: () => CpmmError,
19
+ CpmmErrorCode: () => CpmmErrorCode,
20
+ INSTRUCTION_DISCRIMINATORS: () => chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS,
21
+ MAX_FEE_AMOUNT: () => chunkBXATWUGJ_cjs.MAX_FEE_AMOUNT,
22
+ MAX_ORACLE_OBSERVATIONS: () => chunkDPKVNI6Q_cjs.MAX_ORACLE_OBSERVATIONS,
23
+ MAX_SENTINEL_ALLOWLIST: () => chunkDPKVNI6Q_cjs.MAX_SENTINEL_ALLOWLIST,
24
+ Q64_ONE: () => chunkDPKVNI6Q_cjs.Q64_ONE,
25
+ SEED_AUTHORITY: () => chunkDPKVNI6Q_cjs.SEED_AUTHORITY,
26
+ SEED_CONFIG: () => chunkDPKVNI6Q_cjs.SEED_CONFIG,
27
+ SEED_ORACLE: () => chunkDPKVNI6Q_cjs.SEED_ORACLE,
28
+ SEED_POOL: () => chunkDPKVNI6Q_cjs.SEED_POOL,
29
+ SEED_POSITION: () => chunkDPKVNI6Q_cjs.SEED_POSITION,
30
+ SEED_PROTOCOL_POSITION: () => chunkDPKVNI6Q_cjs.SEED_PROTOCOL_POSITION,
31
+ SENTINEL_NO_CHANGE: () => chunkDPKVNI6Q_cjs.SENTINEL_NO_CHANGE,
32
+ SF_AFTER_ADD_LIQ: () => chunkDPKVNI6Q_cjs.SF_AFTER_ADD_LIQ,
33
+ SF_AFTER_REMOVE_LIQ: () => chunkDPKVNI6Q_cjs.SF_AFTER_REMOVE_LIQ,
34
+ SF_AFTER_SWAP: () => chunkDPKVNI6Q_cjs.SF_AFTER_SWAP,
35
+ SF_BEFORE_ADD_LIQ: () => chunkDPKVNI6Q_cjs.SF_BEFORE_ADD_LIQ,
36
+ SF_BEFORE_REMOVE_LIQ: () => chunkDPKVNI6Q_cjs.SF_BEFORE_REMOVE_LIQ,
37
+ SF_BEFORE_SWAP: () => chunkDPKVNI6Q_cjs.SF_BEFORE_SWAP,
38
+ TOKEN_METADATA_PROGRAM_ID: () => chunkDPKVNI6Q_cjs.TOKEN_METADATA_PROGRAM_ID,
39
+ addLiquidityArgsCodec: () => chunkBXATWUGJ_cjs.addLiquidityArgsCodec,
40
+ ammConfigDataCodec: () => chunkBXATWUGJ_cjs.ammConfigDataCodec,
41
+ areMintsOrdered: () => chunkDPKVNI6Q_cjs.areMintsOrdered,
42
+ calculateAccruedFees: () => chunkBXATWUGJ_cjs.calculateAccruedFees,
43
+ calculateTwap: () => chunkBXATWUGJ_cjs.calculateTwap,
44
+ calculateTwapNumber: () => chunkBXATWUGJ_cjs.calculateTwapNumber,
45
+ ceilDiv: () => chunkBXATWUGJ_cjs.ceilDiv,
46
+ collectFeesArgsCodec: () => chunkBXATWUGJ_cjs.collectFeesArgsCodec,
47
+ collectProtocolFeesArgsCodec: () => chunkBXATWUGJ_cjs.collectProtocolFeesArgsCodec,
48
+ comparePoolAndOraclePrices: () => chunkBXATWUGJ_cjs.comparePoolAndOraclePrices,
49
+ computePrice0Q64: () => chunkBXATWUGJ_cjs.computePrice0Q64,
50
+ computePrice1Q64: () => chunkBXATWUGJ_cjs.computePrice1Q64,
51
+ consultTwap: () => chunkBXATWUGJ_cjs.consultTwap,
52
+ createAddLiquidityInstruction: () => createAddLiquidityInstruction,
53
+ createClosePositionInstruction: () => createClosePositionInstruction,
54
+ createCollectFeesInstruction: () => chunkBXATWUGJ_cjs.createCollectFeesInstruction,
55
+ createCollectProtocolFeesInstruction: () => createCollectProtocolFeesInstruction,
56
+ createCreatePositionInstruction: () => createCreatePositionInstruction,
57
+ createInitializeConfigInstruction: () => createInitializeConfigInstruction,
58
+ createInitializeOracleInstruction: () => createInitializeOracleInstruction,
59
+ createInitializePoolInstruction: () => createInitializePoolInstruction,
60
+ createOracleConsultInstruction: () => createOracleConsultInstruction,
61
+ createOracleUpdateInstruction: () => createOracleUpdateInstruction,
62
+ createPauseInstruction: () => createPauseInstruction,
63
+ createPositionArgsCodec: () => chunkBXATWUGJ_cjs.createPositionArgsCodec,
64
+ createQuoteToNumeraireInstruction: () => createQuoteToNumeraireInstruction,
65
+ createRemoveLiquidityInstruction: () => createRemoveLiquidityInstruction,
66
+ createSetFeesInstruction: () => createSetFeesInstruction,
67
+ createSetRouteInstruction: () => createSetRouteInstruction,
68
+ createSetSentinelInstruction: () => createSetSentinelInstruction,
69
+ createSkimInstruction: () => createSkimInstruction,
70
+ createSwapExactInInstruction: () => createSwapExactInInstruction,
71
+ createSwapInstruction: () => createSwapInstruction,
72
+ createTransferAdminInstruction: () => createTransferAdminInstruction,
73
+ createUnpauseInstruction: () => createUnpauseInstruction,
74
+ curveParamsToMarketCap: () => curveParamsToMarketCap,
75
+ decodeAmmConfig: () => chunkBXATWUGJ_cjs.decodeAmmConfig,
76
+ decodeOracleConsultResult: () => decodeOracleConsultResult,
77
+ decodeOracleState: () => chunkBXATWUGJ_cjs.decodeOracleState,
78
+ decodePool: () => chunkBXATWUGJ_cjs.decodePool,
79
+ decodePosition: () => chunkBXATWUGJ_cjs.decodePosition,
80
+ decodeQuoteToNumeraireResult: () => decodeQuoteToNumeraireResult,
81
+ encodeAddLiquidityArgs: () => chunkBXATWUGJ_cjs.encodeAddLiquidityArgs,
82
+ encodeCollectFeesArgs: () => chunkBXATWUGJ_cjs.encodeCollectFeesArgs,
83
+ encodeCollectProtocolFeesArgs: () => chunkBXATWUGJ_cjs.encodeCollectProtocolFeesArgs,
84
+ encodeCreatePositionArgs: () => chunkBXATWUGJ_cjs.encodeCreatePositionArgs,
85
+ encodeInitializeConfigArgs: () => chunkBXATWUGJ_cjs.encodeInitializeConfigArgs,
86
+ encodeInitializeOracleArgs: () => chunkBXATWUGJ_cjs.encodeInitializeOracleArgs,
87
+ encodeInitializePoolArgs: () => chunkBXATWUGJ_cjs.encodeInitializePoolArgs,
88
+ encodeInstructionData: () => chunkBXATWUGJ_cjs.encodeInstructionData,
89
+ encodeOracleConsultArgs: () => chunkBXATWUGJ_cjs.encodeOracleConsultArgs,
90
+ encodeQuoteToNumeraireArgs: () => chunkBXATWUGJ_cjs.encodeQuoteToNumeraireArgs,
91
+ encodeRemoveLiquidityArgs: () => chunkBXATWUGJ_cjs.encodeRemoveLiquidityArgs,
92
+ encodeSetFeesArgs: () => chunkBXATWUGJ_cjs.encodeSetFeesArgs,
93
+ encodeSetRouteArgs: () => chunkBXATWUGJ_cjs.encodeSetRouteArgs,
94
+ encodeSetSentinelArgs: () => chunkBXATWUGJ_cjs.encodeSetSentinelArgs,
95
+ encodeSwapExactInArgs: () => chunkBXATWUGJ_cjs.encodeSwapExactInArgs,
96
+ encodeTransferAdminArgs: () => chunkBXATWUGJ_cjs.encodeTransferAdminArgs,
97
+ fetchAllPools: () => chunkBXATWUGJ_cjs.fetchAllPools,
98
+ fetchConfig: () => fetchConfig,
99
+ fetchConfigWithAddress: () => fetchConfigWithAddress,
100
+ fetchOracle: () => chunkBXATWUGJ_cjs.fetchOracle,
101
+ fetchOraclesBatch: () => chunkBXATWUGJ_cjs.fetchOraclesBatch,
102
+ fetchPool: () => chunkBXATWUGJ_cjs.fetchPool,
103
+ fetchPoolPositions: () => chunkBXATWUGJ_cjs.fetchPoolPositions,
104
+ fetchPoolsBatch: () => chunkBXATWUGJ_cjs.fetchPoolsBatch,
105
+ fetchPosition: () => chunkBXATWUGJ_cjs.fetchPosition,
106
+ fetchPositionByParams: () => chunkBXATWUGJ_cjs.fetchPositionByParams,
107
+ fetchPositionsBatch: () => chunkBXATWUGJ_cjs.fetchPositionsBatch,
108
+ fetchUserPositions: () => chunkBXATWUGJ_cjs.fetchUserPositions,
109
+ filterActivePositions: () => chunkBXATWUGJ_cjs.filterActivePositions,
110
+ filterPoolsByMint: () => chunkBXATWUGJ_cjs.filterPoolsByMint,
111
+ getAddLiquidityQuote: () => chunkBXATWUGJ_cjs.getAddLiquidityQuote,
112
+ getConfigAddress: () => chunkDPKVNI6Q_cjs.getConfigAddress,
113
+ getErrorMessage: () => getErrorMessage,
114
+ getK: () => chunkBXATWUGJ_cjs.getK,
115
+ getLiquidityAddresses: () => chunkDPKVNI6Q_cjs.getLiquidityAddresses,
116
+ getMetadataAddress: () => getMetadataAddress,
117
+ getOracleAddress: () => chunkDPKVNI6Q_cjs.getOracleAddress,
118
+ getOracleAddressFromPool: () => chunkBXATWUGJ_cjs.getOracleAddressFromPool,
119
+ getOracleAge: () => chunkBXATWUGJ_cjs.getOracleAge,
120
+ getOracleBufferStats: () => chunkBXATWUGJ_cjs.getOracleBufferStats,
121
+ getOracleDeviation: () => chunkBXATWUGJ_cjs.getOracleDeviation,
122
+ getOracleForPool: () => chunkBXATWUGJ_cjs.getOracleForPool,
123
+ getOracleSpotPrices: () => chunkBXATWUGJ_cjs.getOracleSpotPrices,
124
+ getPendingFees: () => chunkBXATWUGJ_cjs.getPendingFees,
125
+ getPoolAddress: () => chunkDPKVNI6Q_cjs.getPoolAddress,
126
+ getPoolAddressFromMints: () => chunkBXATWUGJ_cjs.getPoolAddressFromMints,
127
+ getPoolAuthorityAddress: () => chunkDPKVNI6Q_cjs.getPoolAuthorityAddress,
128
+ getPoolByMints: () => chunkBXATWUGJ_cjs.getPoolByMints,
129
+ getPoolInitAddresses: () => chunkDPKVNI6Q_cjs.getPoolInitAddresses,
130
+ getPositionAddress: () => chunkDPKVNI6Q_cjs.getPositionAddress,
131
+ getPositionAddressFromParams: () => chunkBXATWUGJ_cjs.getPositionAddressFromParams,
132
+ getPositionValue: () => chunkBXATWUGJ_cjs.getPositionValue,
133
+ getProtocolPositionAddress: () => chunkDPKVNI6Q_cjs.getProtocolPositionAddress,
134
+ getRemoveLiquidityQuote: () => chunkBXATWUGJ_cjs.getRemoveLiquidityQuote,
135
+ getSpotPrice0: () => chunkBXATWUGJ_cjs.getSpotPrice0,
136
+ getSpotPrice1: () => chunkBXATWUGJ_cjs.getSpotPrice1,
137
+ getSwapAddresses: () => chunkDPKVNI6Q_cjs.getSwapAddresses,
138
+ getSwapQuote: () => chunkBXATWUGJ_cjs.getSwapQuote,
139
+ getSwapQuoteExactOut: () => chunkBXATWUGJ_cjs.getSwapQuoteExactOut,
140
+ getTvl: () => chunkBXATWUGJ_cjs.getTvl,
141
+ initializeConfigArgsCodec: () => chunkBXATWUGJ_cjs.initializeConfigArgsCodec,
142
+ initializeOracleArgsCodec: () => chunkBXATWUGJ_cjs.initializeOracleArgsCodec,
143
+ initializePoolArgsCodec: () => chunkBXATWUGJ_cjs.initializePoolArgsCodec,
144
+ isCpmmError: () => isCpmmError,
145
+ isOracleStale: () => chunkBXATWUGJ_cjs.isOracleStale,
146
+ isqrt: () => chunkBXATWUGJ_cjs.isqrt,
147
+ marketCapToCurveParams: () => marketCapToCurveParams,
148
+ marketCapToSingleCurveParams: () => marketCapToSingleCurveParams,
149
+ marketCapToTokenPrice: () => marketCapToTokenPrice,
150
+ maxBigInt: () => chunkBXATWUGJ_cjs.maxBigInt,
151
+ minBigInt: () => chunkBXATWUGJ_cjs.minBigInt,
152
+ numberToQ64: () => chunkBXATWUGJ_cjs.numberToQ64,
153
+ observationCodec: () => chunkBXATWUGJ_cjs.observationCodec,
154
+ oracleConsultArgsCodec: () => chunkBXATWUGJ_cjs.oracleConsultArgsCodec,
155
+ oracleStateDataCodec: () => chunkBXATWUGJ_cjs.oracleStateDataCodec,
156
+ parseErrorFromLogs: () => parseErrorFromLogs,
157
+ poolDataCodec: () => chunkBXATWUGJ_cjs.poolDataCodec,
158
+ poolExists: () => chunkBXATWUGJ_cjs.poolExists,
159
+ positionDataCodec: () => chunkBXATWUGJ_cjs.positionDataCodec,
160
+ q64Div: () => chunkBXATWUGJ_cjs.q64Div,
161
+ q64Mul: () => chunkBXATWUGJ_cjs.q64Mul,
162
+ q64ToNumber: () => chunkBXATWUGJ_cjs.q64ToNumber,
163
+ quoteToNumeraireArgsCodec: () => chunkBXATWUGJ_cjs.quoteToNumeraireArgsCodec,
164
+ ratioToNumber: () => chunkBXATWUGJ_cjs.ratioToNumber,
165
+ removeLiquidityArgsCodec: () => chunkBXATWUGJ_cjs.removeLiquidityArgsCodec,
166
+ setFeesArgsCodec: () => chunkBXATWUGJ_cjs.setFeesArgsCodec,
167
+ setRouteArgsCodec: () => chunkBXATWUGJ_cjs.setRouteArgsCodec,
168
+ setSentinelArgsCodec: () => chunkBXATWUGJ_cjs.setSentinelArgsCodec,
169
+ sortMints: () => chunkDPKVNI6Q_cjs.sortMints,
170
+ sortPoolsByReserves: () => chunkBXATWUGJ_cjs.sortPoolsByReserves,
171
+ sortPositionsByShares: () => chunkBXATWUGJ_cjs.sortPositionsByShares,
172
+ swapExactInArgsCodec: () => chunkBXATWUGJ_cjs.swapExactInArgsCodec,
173
+ transferAdminArgsCodec: () => chunkBXATWUGJ_cjs.transferAdminArgsCodec,
174
+ validateMarketCapParameters: () => validateMarketCapParameters
175
+ });
176
+ var addressCodec = kit.getAddressCodec();
177
+ var textEncoder = new TextEncoder();
178
+ async function getMetadataAddress(mint) {
179
+ return kit.getProgramDerivedAddress({
180
+ programAddress: chunkDPKVNI6Q_cjs.TOKEN_METADATA_PROGRAM_ID,
181
+ seeds: [
182
+ textEncoder.encode("metadata"),
183
+ addressCodec.encode(chunkDPKVNI6Q_cjs.TOKEN_METADATA_PROGRAM_ID),
184
+ addressCodec.encode(mint)
185
+ ]
186
+ });
187
+ }
188
+
189
+ // src/solana/core/marketCapHelpers.ts
190
+ function marketCapToTokenPrice(marketCapUSD, baseTotalSupply, baseDecimals) {
191
+ if (marketCapUSD <= 0) {
192
+ throw new Error("Market cap must be positive");
193
+ }
194
+ if (baseTotalSupply <= 0n) {
195
+ throw new Error("Token supply must be positive");
196
+ }
197
+ const supplyNum = Number(baseTotalSupply) / 10 ** baseDecimals;
198
+ return marketCapUSD / supplyNum;
199
+ }
200
+ function validateMarketCapParameters(marketCapUSD, baseTotalSupply, baseDecimals) {
201
+ const warnings = [];
202
+ if (marketCapUSD < 1e3) {
203
+ warnings.push(
204
+ `Market cap $${marketCapUSD.toLocaleString()} is very small. Verify this is intentional.`
205
+ );
206
+ }
207
+ if (marketCapUSD > 1e12) {
208
+ warnings.push(
209
+ `Market cap $${marketCapUSD.toLocaleString()} exceeds $1T. Verify this is correct.`
210
+ );
211
+ }
212
+ const tokenPriceUSD = marketCapToTokenPrice(
213
+ marketCapUSD,
214
+ baseTotalSupply,
215
+ baseDecimals
216
+ );
217
+ if (tokenPriceUSD < 1e-6) {
218
+ warnings.push(
219
+ `Implied token price $${tokenPriceUSD.toExponential(2)} is very small. This may cause precision issues.`
220
+ );
221
+ }
222
+ if (tokenPriceUSD > 1e6) {
223
+ warnings.push(
224
+ `Implied token price $${tokenPriceUSD.toLocaleString()} is very large. Verify token supply and market cap.`
225
+ );
226
+ }
227
+ return { valid: warnings.length === 0, warnings };
228
+ }
229
+ function marketCapToCurveParams(input) {
230
+ const {
231
+ startMarketCapUSD,
232
+ endMarketCapUSD,
233
+ baseTotalSupply,
234
+ baseForCurve,
235
+ baseDecimals,
236
+ quoteDecimals,
237
+ numerairePriceUSD,
238
+ virtualBase
239
+ } = input;
240
+ if (startMarketCapUSD <= 0)
241
+ throw new Error("startMarketCapUSD must be positive");
242
+ if (endMarketCapUSD <= 0) throw new Error("endMarketCapUSD must be positive");
243
+ if (startMarketCapUSD >= endMarketCapUSD) {
244
+ throw new Error("startMarketCapUSD must be less than endMarketCapUSD");
245
+ }
246
+ if (baseForCurve <= 0n) throw new Error("baseForCurve must be positive");
247
+ if (baseForCurve > baseTotalSupply)
248
+ throw new Error("baseForCurve cannot exceed baseTotalSupply");
249
+ if (numerairePriceUSD <= 0)
250
+ throw new Error("numerairePriceUSD must be positive");
251
+ const canonicalVirtualBase = virtualBase !== void 0 && virtualBase > 0n ? virtualBase : baseForCurve;
252
+ return {
253
+ start: _marketCapToCurveParams(
254
+ startMarketCapUSD,
255
+ baseTotalSupply,
256
+ baseForCurve,
257
+ baseDecimals,
258
+ quoteDecimals,
259
+ numerairePriceUSD,
260
+ canonicalVirtualBase
261
+ ),
262
+ end: _marketCapToCurveParams(
263
+ endMarketCapUSD,
264
+ baseTotalSupply,
265
+ baseForCurve,
266
+ baseDecimals,
267
+ quoteDecimals,
268
+ numerairePriceUSD,
269
+ canonicalVirtualBase
270
+ )
271
+ };
272
+ }
273
+ function marketCapToSingleCurveParams(marketCapUSD, baseTotalSupply, baseForCurve, baseDecimals, quoteDecimals, numerairePriceUSD, virtualBase) {
274
+ if (marketCapUSD <= 0) throw new Error("marketCapUSD must be positive");
275
+ if (baseForCurve <= 0n) throw new Error("baseForCurve must be positive");
276
+ if (baseForCurve > baseTotalSupply)
277
+ throw new Error("baseForCurve cannot exceed baseTotalSupply");
278
+ if (numerairePriceUSD <= 0)
279
+ throw new Error("numerairePriceUSD must be positive");
280
+ const canonicalVirtualBase = virtualBase !== void 0 && virtualBase > 0n ? virtualBase : baseForCurve;
281
+ return _marketCapToCurveParams(
282
+ marketCapUSD,
283
+ baseTotalSupply,
284
+ baseForCurve,
285
+ baseDecimals,
286
+ quoteDecimals,
287
+ numerairePriceUSD,
288
+ canonicalVirtualBase
289
+ );
290
+ }
291
+ function curveParamsToMarketCap(input) {
292
+ const {
293
+ curveVirtualBase,
294
+ curveVirtualQuote,
295
+ baseReserve,
296
+ quoteReserve,
297
+ baseTotalSupply,
298
+ baseDecimals,
299
+ quoteDecimals,
300
+ numerairePriceUSD
301
+ } = input;
302
+ if (curveVirtualBase <= 0n)
303
+ throw new Error("curveVirtualBase must be positive");
304
+ if (curveVirtualQuote <= 0n)
305
+ throw new Error("curveVirtualQuote must be positive");
306
+ if (baseReserve < 0n) throw new Error("baseReserve must be non-negative");
307
+ if (quoteReserve < 0n) throw new Error("quoteReserve must be non-negative");
308
+ const spotPriceUSD = _spotPriceUSD(
309
+ curveVirtualBase,
310
+ curveVirtualQuote,
311
+ baseReserve,
312
+ quoteReserve,
313
+ baseDecimals,
314
+ quoteDecimals,
315
+ numerairePriceUSD
316
+ );
317
+ const supplyHuman = Number(baseTotalSupply) / 10 ** baseDecimals;
318
+ return spotPriceUSD * supplyHuman;
319
+ }
320
+ function _marketCapToCurveParams(marketCapUSD, baseTotalSupply, baseForCurve, baseDecimals, quoteDecimals, numerairePriceUSD, curveVirtualBase) {
321
+ const tokenPriceUSD = marketCapToTokenPrice(
322
+ marketCapUSD,
323
+ baseTotalSupply,
324
+ baseDecimals
325
+ );
326
+ const priceInNumeraire = tokenPriceUSD / numerairePriceUSD;
327
+ const decimalScale = 10 ** (quoteDecimals - baseDecimals);
328
+ const rawPriceQuotePerBase = priceInNumeraire * decimalScale;
329
+ const effectiveDenominator = baseForCurve + curveVirtualBase;
330
+ const PRECISION = 1000000000n;
331
+ const rawPriceScaled = BigInt(
332
+ Math.round(rawPriceQuotePerBase * Number(PRECISION))
333
+ );
334
+ const curveVirtualQuote = effectiveDenominator * rawPriceScaled / PRECISION;
335
+ if (curveVirtualQuote <= 0n) {
336
+ throw new Error(
337
+ `Computed curveVirtualQuote is zero or negative for marketCap=$${marketCapUSD.toLocaleString()}. Try a higher market cap or larger virtualBase.`
338
+ );
339
+ }
340
+ return { curveVirtualBase, curveVirtualQuote };
341
+ }
342
+ function _spotPriceUSD(curveVirtualBase, curveVirtualQuote, baseReserve, quoteReserve, baseDecimals, quoteDecimals, numerairePriceUSD) {
343
+ const effBase = Number(baseReserve + curveVirtualBase);
344
+ const effQuote = Number(quoteReserve + curveVirtualQuote);
345
+ const rawRatio = effQuote / effBase;
346
+ const decimalScale = 10 ** (baseDecimals - quoteDecimals);
347
+ return rawRatio * decimalScale * numerairePriceUSD;
348
+ }
349
+
350
+ // src/solana/core/errors.ts
351
+ var CpmmErrorCode = /* @__PURE__ */ ((CpmmErrorCode2) => {
352
+ CpmmErrorCode2[CpmmErrorCode2["Unauthorized"] = 6e3] = "Unauthorized";
353
+ CpmmErrorCode2[CpmmErrorCode2["PoolLocked"] = 6001] = "PoolLocked";
354
+ CpmmErrorCode2[CpmmErrorCode2["InvalidFee"] = 6002] = "InvalidFee";
355
+ CpmmErrorCode2[CpmmErrorCode2["InvalidFeeSplit"] = 6003] = "InvalidFeeSplit";
356
+ CpmmErrorCode2[CpmmErrorCode2["InvalidDirection"] = 6004] = "InvalidDirection";
357
+ CpmmErrorCode2[CpmmErrorCode2["InsufficientLiquidity"] = 6005] = "InsufficientLiquidity";
358
+ CpmmErrorCode2[CpmmErrorCode2["SlippageExceeded"] = 6006] = "SlippageExceeded";
359
+ CpmmErrorCode2[CpmmErrorCode2["MathOverflow"] = 6007] = "MathOverflow";
360
+ CpmmErrorCode2[CpmmErrorCode2["InvalidMintOrder"] = 6008] = "InvalidMintOrder";
361
+ CpmmErrorCode2[CpmmErrorCode2["SameMintPair"] = 6009] = "SameMintPair";
362
+ CpmmErrorCode2[CpmmErrorCode2["InvalidVault"] = 6010] = "InvalidVault";
363
+ CpmmErrorCode2[CpmmErrorCode2["InvalidPosition"] = 6011] = "InvalidPosition";
364
+ CpmmErrorCode2[CpmmErrorCode2["PositionNotEmpty"] = 6012] = "PositionNotEmpty";
365
+ CpmmErrorCode2[CpmmErrorCode2["InvalidRoute"] = 6013] = "InvalidRoute";
366
+ CpmmErrorCode2[CpmmErrorCode2["NotSupportedInV0_1"] = 6014] = "NotSupportedInV0_1";
367
+ CpmmErrorCode2[CpmmErrorCode2["OracleNotInitialized"] = 6015] = "OracleNotInitialized";
368
+ CpmmErrorCode2[CpmmErrorCode2["ZeroSharesOut"] = 6016] = "ZeroSharesOut";
369
+ CpmmErrorCode2[CpmmErrorCode2["SentinelRejected"] = 6017] = "SentinelRejected";
370
+ CpmmErrorCode2[CpmmErrorCode2["SentinelCpiFailed"] = 6018] = "SentinelCpiFailed";
371
+ CpmmErrorCode2[CpmmErrorCode2["SentinelProgramNotProvided"] = 6019] = "SentinelProgramNotProvided";
372
+ CpmmErrorCode2[CpmmErrorCode2["SentinelProgramNotExecutable"] = 6020] = "SentinelProgramNotExecutable";
373
+ CpmmErrorCode2[CpmmErrorCode2["SentinelReturnDataMissing"] = 6021] = "SentinelReturnDataMissing";
374
+ CpmmErrorCode2[CpmmErrorCode2["SentinelReturnDataInvalid"] = 6022] = "SentinelReturnDataInvalid";
375
+ CpmmErrorCode2[CpmmErrorCode2["SentinelNotAllowlisted"] = 6023] = "SentinelNotAllowlisted";
376
+ CpmmErrorCode2[CpmmErrorCode2["TotalSharesZero"] = 6024] = "TotalSharesZero";
377
+ CpmmErrorCode2[CpmmErrorCode2["AmountZero"] = 6025] = "AmountZero";
378
+ CpmmErrorCode2[CpmmErrorCode2["Paused"] = 6026] = "Paused";
379
+ CpmmErrorCode2[CpmmErrorCode2["InvariantViolation"] = 6027] = "InvariantViolation";
380
+ CpmmErrorCode2[CpmmErrorCode2["InvalidMint"] = 6028] = "InvalidMint";
381
+ CpmmErrorCode2[CpmmErrorCode2["InvalidInput"] = 6029] = "InvalidInput";
382
+ CpmmErrorCode2[CpmmErrorCode2["Reentrancy"] = 6030] = "Reentrancy";
383
+ return CpmmErrorCode2;
384
+ })(CpmmErrorCode || {});
385
+ var CPMM_ERROR_MESSAGES = {
386
+ [6e3 /* Unauthorized */]: "Unauthorized: Caller lacks required authority",
387
+ [6001 /* PoolLocked */]: "Pool is currently locked (reentrancy protection)",
388
+ [6002 /* InvalidFee */]: "Invalid fee value (exceeds max or invalid range)",
389
+ [6003 /* InvalidFeeSplit */]: "Invalid fee split value (exceeds max or invalid range)",
390
+ [6004 /* InvalidDirection */]: "Invalid swap direction (must be 0 or 1)",
391
+ [6005 /* InsufficientLiquidity */]: "Insufficient liquidity for this operation",
392
+ [6006 /* SlippageExceeded */]: "Slippage exceeded: Output amount less than minimum",
393
+ [6007 /* MathOverflow */]: "Math operation overflowed",
394
+ [6008 /* InvalidMintOrder */]: "Token mints not in canonical order",
395
+ [6009 /* SameMintPair */]: "Cannot create pool with identical tokens",
396
+ [6010 /* InvalidVault */]: "Vault account is invalid or does not match",
397
+ [6011 /* InvalidPosition */]: "Position account is invalid or does not match",
398
+ [6012 /* PositionNotEmpty */]: "Cannot close position with non-zero shares or fees",
399
+ [6013 /* InvalidRoute */]: "Invalid route configuration",
400
+ [6014 /* NotSupportedInV0_1 */]: "Not supported in v0.1",
401
+ [6015 /* OracleNotInitialized */]: "Oracle not initialized for this pool",
402
+ [6016 /* ZeroSharesOut */]: "Zero shares out",
403
+ [6017 /* SentinelRejected */]: "Sentinel program rejected the operation",
404
+ [6018 /* SentinelCpiFailed */]: "Sentinel CPI call failed",
405
+ [6019 /* SentinelProgramNotProvided */]: "Sentinel program account not provided",
406
+ [6020 /* SentinelProgramNotExecutable */]: "Sentinel program account is not executable",
407
+ [6021 /* SentinelReturnDataMissing */]: "Sentinel return data missing or wrong program id",
408
+ [6022 /* SentinelReturnDataInvalid */]: "Sentinel return data invalid length or could not deserialize",
409
+ [6023 /* SentinelNotAllowlisted */]: "Sentinel program not in allowlist",
410
+ [6024 /* TotalSharesZero */]: "Pool has zero shares (no liquidity)",
411
+ [6025 /* AmountZero */]: "Amount cannot be zero",
412
+ [6026 /* Paused */]: "Pool is paused by admin",
413
+ [6027 /* InvariantViolation */]: "Internal invariant violation",
414
+ [6028 /* InvalidMint */]: "Invalid mint address",
415
+ [6029 /* InvalidInput */]: "Invalid input parameter",
416
+ [6030 /* Reentrancy */]: "Reentrancy detected"
417
+ };
418
+ var CpmmError = class extends Error {
419
+ constructor(code, logs) {
420
+ super(CPMM_ERROR_MESSAGES[code] || `Unknown CPMM error: ${code}`);
421
+ this.code = code;
422
+ this.logs = logs;
423
+ this.name = "CpmmError";
424
+ }
425
+ /**
426
+ * Get the error code name
427
+ */
428
+ get codeName() {
429
+ return CpmmErrorCode[this.code] || "Unknown";
430
+ }
431
+ };
432
+ function parseErrorFromLogs(logs) {
433
+ for (const log of logs) {
434
+ const anchorMatch = log.match(
435
+ /AnchorError.*Error Code:\s*(\w+)\.\s*Error Number:\s*(\d+)/
436
+ );
437
+ if (anchorMatch) {
438
+ const errorNumber = parseInt(anchorMatch[2], 10);
439
+ if (errorNumber >= 6e3 && errorNumber <= 6030) {
440
+ return new CpmmError(errorNumber, logs);
441
+ }
442
+ }
443
+ const hexMatch = log.match(/Error Number:\s*0x([0-9a-fA-F]+)/);
444
+ if (hexMatch) {
445
+ const errorNumber = parseInt(hexMatch[1], 16);
446
+ if (errorNumber >= 6e3 && errorNumber <= 6030) {
447
+ return new CpmmError(errorNumber, logs);
448
+ }
449
+ }
450
+ const customMatch = log.match(/Error Message:\s*(.+)/);
451
+ if (customMatch) {
452
+ const message = customMatch[1].toLowerCase();
453
+ for (const [code, msg] of Object.entries(CPMM_ERROR_MESSAGES)) {
454
+ if (msg.toLowerCase().includes(message) || message.includes(msg.toLowerCase())) {
455
+ return new CpmmError(parseInt(code), logs);
456
+ }
457
+ }
458
+ }
459
+ }
460
+ return null;
461
+ }
462
+ function isCpmmError(code) {
463
+ return code >= 6e3 && code <= 6030;
464
+ }
465
+ function getErrorMessage(code) {
466
+ if (isCpmmError(code)) {
467
+ return CPMM_ERROR_MESSAGES[code];
468
+ }
469
+ return `Unknown error code: ${code}`;
470
+ }
471
+ function createInitializeConfigInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
472
+ const { config, payer, systemProgram = chunkDPKVNI6Q_cjs.SYSTEM_PROGRAM_ADDRESS } = accounts;
473
+ const keys = [
474
+ { address: config, role: kit.AccountRole.WRITABLE },
475
+ { address: payer, role: kit.AccountRole.WRITABLE_SIGNER },
476
+ { address: systemProgram, role: kit.AccountRole.READONLY }
477
+ ];
478
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
479
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.initializeConfig,
480
+ chunkBXATWUGJ_cjs.initializeConfigArgsCodec,
481
+ args
482
+ );
483
+ return {
484
+ programAddress: programId,
485
+ accounts: keys,
486
+ data
487
+ };
488
+ }
489
+ function isTransactionSigner(value) {
490
+ return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
491
+ }
492
+ function createSignerAccountMeta(value, role) {
493
+ if (isTransactionSigner(value)) {
494
+ return {
495
+ address: value.address,
496
+ role,
497
+ signer: value
498
+ };
499
+ }
500
+ return { address: value, role };
501
+ }
502
+ function createInitializePoolInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
503
+ const {
504
+ config,
505
+ pool,
506
+ protocolPosition,
507
+ authority,
508
+ vault0,
509
+ vault1,
510
+ token0Mint,
511
+ token1Mint,
512
+ payer,
513
+ tokenProgram = chunkDPKVNI6Q_cjs.TOKEN_PROGRAM_ADDRESS,
514
+ systemProgram = chunkDPKVNI6Q_cjs.SYSTEM_PROGRAM_ADDRESS,
515
+ rent
516
+ } = accounts;
517
+ const keys = [
518
+ { address: config, role: kit.AccountRole.READONLY },
519
+ { address: pool, role: kit.AccountRole.WRITABLE },
520
+ { address: protocolPosition, role: kit.AccountRole.WRITABLE },
521
+ { address: authority, role: kit.AccountRole.READONLY },
522
+ createSignerAccountMeta(vault0, kit.AccountRole.WRITABLE_SIGNER),
523
+ createSignerAccountMeta(vault1, kit.AccountRole.WRITABLE_SIGNER),
524
+ { address: token0Mint, role: kit.AccountRole.READONLY },
525
+ { address: token1Mint, role: kit.AccountRole.READONLY },
526
+ createSignerAccountMeta(payer, kit.AccountRole.WRITABLE_SIGNER),
527
+ { address: tokenProgram, role: kit.AccountRole.READONLY },
528
+ { address: systemProgram, role: kit.AccountRole.READONLY },
529
+ { address: rent, role: kit.AccountRole.READONLY }
530
+ ];
531
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
532
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.initializePool,
533
+ chunkBXATWUGJ_cjs.initializePoolArgsCodec,
534
+ args
535
+ );
536
+ return {
537
+ programAddress: programId,
538
+ accounts: keys,
539
+ data
540
+ };
541
+ }
542
+ function createInitializeOracleInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
543
+ const {
544
+ config,
545
+ pool,
546
+ oracle,
547
+ admin,
548
+ payer,
549
+ systemProgram = chunkDPKVNI6Q_cjs.SYSTEM_PROGRAM_ADDRESS
550
+ } = accounts;
551
+ const keys = [
552
+ { address: config, role: kit.AccountRole.READONLY },
553
+ { address: pool, role: kit.AccountRole.READONLY },
554
+ { address: oracle, role: kit.AccountRole.WRITABLE },
555
+ { address: admin, role: kit.AccountRole.READONLY_SIGNER },
556
+ { address: payer, role: kit.AccountRole.WRITABLE_SIGNER },
557
+ { address: systemProgram, role: kit.AccountRole.READONLY }
558
+ ];
559
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
560
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.initializeOracle,
561
+ chunkBXATWUGJ_cjs.initializeOracleArgsCodec,
562
+ args
563
+ );
564
+ return {
565
+ programAddress: programId,
566
+ accounts: keys,
567
+ data
568
+ };
569
+ }
570
+ function createSetFeesInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
571
+ const { config, pool, admin } = accounts;
572
+ const keys = [
573
+ { address: config, role: kit.AccountRole.READONLY },
574
+ { address: pool, role: kit.AccountRole.WRITABLE },
575
+ { address: admin, role: kit.AccountRole.READONLY_SIGNER }
576
+ ];
577
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
578
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.setFees,
579
+ chunkBXATWUGJ_cjs.setFeesArgsCodec,
580
+ args
581
+ );
582
+ return {
583
+ programAddress: programId,
584
+ accounts: keys,
585
+ data
586
+ };
587
+ }
588
+ function createSetSentinelInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
589
+ const { config, pool, admin } = accounts;
590
+ const keys = [
591
+ { address: config, role: kit.AccountRole.READONLY },
592
+ { address: pool, role: kit.AccountRole.WRITABLE },
593
+ { address: admin, role: kit.AccountRole.READONLY_SIGNER }
594
+ ];
595
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
596
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.setSentinel,
597
+ chunkBXATWUGJ_cjs.setSentinelArgsCodec,
598
+ args
599
+ );
600
+ return {
601
+ programAddress: programId,
602
+ accounts: keys,
603
+ data
604
+ };
605
+ }
606
+ function createSetRouteInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
607
+ const { config, pool, nextPool, admin } = accounts;
608
+ const keys = [
609
+ { address: config, role: kit.AccountRole.READONLY },
610
+ { address: pool, role: kit.AccountRole.WRITABLE }
611
+ ];
612
+ if (nextPool) {
613
+ keys.push({ address: nextPool, role: kit.AccountRole.READONLY });
614
+ }
615
+ keys.push({ address: admin, role: kit.AccountRole.READONLY_SIGNER });
616
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
617
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.setRoute,
618
+ chunkBXATWUGJ_cjs.setRouteArgsCodec,
619
+ args
620
+ );
621
+ return {
622
+ programAddress: programId,
623
+ accounts: keys,
624
+ data
625
+ };
626
+ }
627
+ function createPauseInstruction(accounts, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
628
+ const { config, admin } = accounts;
629
+ const keys = [
630
+ { address: config, role: kit.AccountRole.WRITABLE },
631
+ { address: admin, role: kit.AccountRole.READONLY_SIGNER }
632
+ ];
633
+ const data = chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.pause;
634
+ return {
635
+ programAddress: programId,
636
+ accounts: keys,
637
+ data
638
+ };
639
+ }
640
+ function createUnpauseInstruction(accounts, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
641
+ const { config, admin } = accounts;
642
+ const keys = [
643
+ { address: config, role: kit.AccountRole.WRITABLE },
644
+ { address: admin, role: kit.AccountRole.READONLY_SIGNER }
645
+ ];
646
+ const data = chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.unpause;
647
+ return {
648
+ programAddress: programId,
649
+ accounts: keys,
650
+ data
651
+ };
652
+ }
653
+ function createTransferAdminInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
654
+ const { config, admin } = accounts;
655
+ const keys = [
656
+ { address: config, role: kit.AccountRole.WRITABLE },
657
+ { address: admin, role: kit.AccountRole.READONLY_SIGNER }
658
+ ];
659
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
660
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.transferAdmin,
661
+ chunkBXATWUGJ_cjs.transferAdminArgsCodec,
662
+ args
663
+ );
664
+ return {
665
+ programAddress: programId,
666
+ accounts: keys,
667
+ data
668
+ };
669
+ }
670
+ function createSkimInstruction(accounts, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
671
+ const {
672
+ config,
673
+ pool,
674
+ admin,
675
+ authority,
676
+ vault0,
677
+ vault1,
678
+ token0Mint,
679
+ token1Mint,
680
+ adminAta0,
681
+ adminAta1,
682
+ tokenProgram = chunkDPKVNI6Q_cjs.TOKEN_PROGRAM_ADDRESS
683
+ } = accounts;
684
+ const keys = [
685
+ { address: config, role: kit.AccountRole.READONLY },
686
+ { address: pool, role: kit.AccountRole.READONLY },
687
+ { address: admin, role: kit.AccountRole.READONLY_SIGNER },
688
+ { address: authority, role: kit.AccountRole.READONLY },
689
+ { address: vault0, role: kit.AccountRole.WRITABLE },
690
+ { address: vault1, role: kit.AccountRole.WRITABLE },
691
+ { address: token0Mint, role: kit.AccountRole.READONLY },
692
+ { address: token1Mint, role: kit.AccountRole.READONLY },
693
+ { address: adminAta0, role: kit.AccountRole.WRITABLE },
694
+ { address: adminAta1, role: kit.AccountRole.WRITABLE },
695
+ { address: tokenProgram, role: kit.AccountRole.READONLY }
696
+ ];
697
+ const data = chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.skim;
698
+ return {
699
+ programAddress: programId,
700
+ accounts: keys,
701
+ data
702
+ };
703
+ }
704
+ function createSwapExactInInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
705
+ const {
706
+ config,
707
+ pool,
708
+ authority,
709
+ vaultIn,
710
+ vaultOut,
711
+ token0Mint,
712
+ token1Mint,
713
+ userIn,
714
+ userOut,
715
+ user,
716
+ tokenProgram = chunkDPKVNI6Q_cjs.TOKEN_PROGRAM_ADDRESS,
717
+ oracle,
718
+ remainingAccounts = []
719
+ } = accounts;
720
+ const keys = [
721
+ { address: config, role: kit.AccountRole.READONLY },
722
+ { address: pool, role: kit.AccountRole.WRITABLE },
723
+ { address: authority, role: kit.AccountRole.READONLY },
724
+ { address: vaultIn, role: kit.AccountRole.WRITABLE },
725
+ { address: vaultOut, role: kit.AccountRole.WRITABLE },
726
+ { address: token0Mint, role: kit.AccountRole.READONLY },
727
+ { address: token1Mint, role: kit.AccountRole.READONLY },
728
+ { address: userIn, role: kit.AccountRole.WRITABLE },
729
+ { address: userOut, role: kit.AccountRole.WRITABLE },
730
+ { address: user, role: kit.AccountRole.READONLY_SIGNER },
731
+ { address: tokenProgram, role: kit.AccountRole.READONLY }
732
+ ];
733
+ if (oracle) {
734
+ keys.push({ address: oracle, role: kit.AccountRole.WRITABLE });
735
+ }
736
+ for (const account of remainingAccounts) {
737
+ keys.push({ address: account, role: kit.AccountRole.READONLY });
738
+ }
739
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
740
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.swapExactIn,
741
+ chunkBXATWUGJ_cjs.swapExactInArgsCodec,
742
+ args
743
+ );
744
+ return {
745
+ programAddress: programId,
746
+ accounts: keys,
747
+ data
748
+ };
749
+ }
750
+ function createSwapInstruction(params) {
751
+ const {
752
+ config,
753
+ pool,
754
+ authority,
755
+ vault0,
756
+ vault1,
757
+ token0Mint,
758
+ token1Mint,
759
+ userToken0,
760
+ userToken1,
761
+ user,
762
+ amountIn,
763
+ minAmountOut,
764
+ direction,
765
+ oracle,
766
+ remainingAccounts,
767
+ updateOracle = false,
768
+ programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID
769
+ } = params;
770
+ const [vaultIn, vaultOut] = direction === 0 ? [vault0, vault1] : [vault1, vault0];
771
+ const [userIn, userOut] = direction === 0 ? [userToken0, userToken1] : [userToken1, userToken0];
772
+ return createSwapExactInInstruction(
773
+ {
774
+ config,
775
+ pool,
776
+ authority,
777
+ vaultIn,
778
+ vaultOut,
779
+ token0Mint,
780
+ token1Mint,
781
+ userIn,
782
+ userOut,
783
+ user,
784
+ oracle,
785
+ remainingAccounts
786
+ },
787
+ {
788
+ amountIn,
789
+ minAmountOut,
790
+ direction,
791
+ updateOracle
792
+ },
793
+ programId
794
+ );
795
+ }
796
+ function createCreatePositionInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
797
+ const {
798
+ pool,
799
+ position,
800
+ owner,
801
+ payer,
802
+ systemProgram = chunkDPKVNI6Q_cjs.SYSTEM_PROGRAM_ADDRESS
803
+ } = accounts;
804
+ const keys = [
805
+ { address: pool, role: kit.AccountRole.READONLY },
806
+ { address: position, role: kit.AccountRole.WRITABLE },
807
+ { address: owner, role: kit.AccountRole.READONLY_SIGNER },
808
+ { address: payer, role: kit.AccountRole.WRITABLE_SIGNER },
809
+ { address: systemProgram, role: kit.AccountRole.READONLY }
810
+ ];
811
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
812
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.createPosition,
813
+ chunkBXATWUGJ_cjs.createPositionArgsCodec,
814
+ args
815
+ );
816
+ return {
817
+ programAddress: programId,
818
+ accounts: keys,
819
+ data
820
+ };
821
+ }
822
+ function createClosePositionInstruction(accounts, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
823
+ const { pool, position, owner, rentRecipient } = accounts;
824
+ const keys = [
825
+ { address: pool, role: kit.AccountRole.READONLY },
826
+ { address: position, role: kit.AccountRole.WRITABLE },
827
+ { address: owner, role: kit.AccountRole.READONLY_SIGNER },
828
+ { address: rentRecipient, role: kit.AccountRole.WRITABLE }
829
+ ];
830
+ const data = chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.closePosition;
831
+ return {
832
+ programAddress: programId,
833
+ accounts: keys,
834
+ data
835
+ };
836
+ }
837
+ var addLiquidityArgsWithOracleCodec = kit.getStructCodec([
838
+ ["amount0Max", kit.getU64Codec()],
839
+ ["amount1Max", kit.getU64Codec()],
840
+ ["minSharesOut", kit.getU128Codec()],
841
+ ["updateOracle", kit.getBooleanCodec()]
842
+ ]);
843
+ function createAddLiquidityInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
844
+ const {
845
+ config,
846
+ pool,
847
+ position,
848
+ protocolPosition,
849
+ owner,
850
+ authority,
851
+ vault0,
852
+ vault1,
853
+ token0Mint,
854
+ token1Mint,
855
+ user0,
856
+ user1,
857
+ tokenProgram = chunkDPKVNI6Q_cjs.TOKEN_PROGRAM_ADDRESS,
858
+ oracle,
859
+ remainingAccounts = []
860
+ } = accounts;
861
+ const keys = [
862
+ { address: config, role: kit.AccountRole.READONLY },
863
+ { address: pool, role: kit.AccountRole.WRITABLE },
864
+ { address: position, role: kit.AccountRole.WRITABLE },
865
+ { address: protocolPosition, role: kit.AccountRole.WRITABLE },
866
+ { address: owner, role: kit.AccountRole.READONLY_SIGNER },
867
+ { address: authority, role: kit.AccountRole.READONLY },
868
+ { address: vault0, role: kit.AccountRole.WRITABLE },
869
+ { address: vault1, role: kit.AccountRole.WRITABLE },
870
+ { address: token0Mint, role: kit.AccountRole.READONLY },
871
+ { address: token1Mint, role: kit.AccountRole.READONLY },
872
+ { address: user0, role: kit.AccountRole.WRITABLE },
873
+ { address: user1, role: kit.AccountRole.WRITABLE },
874
+ { address: tokenProgram, role: kit.AccountRole.READONLY }
875
+ ];
876
+ if (oracle) {
877
+ keys.push({ address: oracle, role: kit.AccountRole.WRITABLE });
878
+ }
879
+ for (const account of remainingAccounts) {
880
+ keys.push({ address: account, role: kit.AccountRole.READONLY });
881
+ }
882
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
883
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.addLiquidity,
884
+ addLiquidityArgsWithOracleCodec,
885
+ args
886
+ );
887
+ return {
888
+ programAddress: programId,
889
+ accounts: keys,
890
+ data
891
+ };
892
+ }
893
+ function createRemoveLiquidityInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
894
+ const {
895
+ config,
896
+ pool,
897
+ position,
898
+ protocolPosition,
899
+ owner,
900
+ authority,
901
+ vault0,
902
+ vault1,
903
+ token0Mint,
904
+ token1Mint,
905
+ user0,
906
+ user1,
907
+ tokenProgram = chunkDPKVNI6Q_cjs.TOKEN_PROGRAM_ADDRESS,
908
+ oracle,
909
+ remainingAccounts = []
910
+ } = accounts;
911
+ const keys = [
912
+ { address: config, role: kit.AccountRole.READONLY },
913
+ { address: pool, role: kit.AccountRole.WRITABLE },
914
+ { address: position, role: kit.AccountRole.WRITABLE },
915
+ { address: protocolPosition, role: kit.AccountRole.WRITABLE },
916
+ { address: owner, role: kit.AccountRole.READONLY_SIGNER },
917
+ { address: authority, role: kit.AccountRole.READONLY },
918
+ { address: vault0, role: kit.AccountRole.WRITABLE },
919
+ { address: vault1, role: kit.AccountRole.WRITABLE },
920
+ { address: token0Mint, role: kit.AccountRole.READONLY },
921
+ { address: token1Mint, role: kit.AccountRole.READONLY },
922
+ { address: user0, role: kit.AccountRole.WRITABLE },
923
+ { address: user1, role: kit.AccountRole.WRITABLE },
924
+ { address: tokenProgram, role: kit.AccountRole.READONLY }
925
+ ];
926
+ if (oracle) {
927
+ keys.push({ address: oracle, role: kit.AccountRole.WRITABLE });
928
+ }
929
+ for (const account of remainingAccounts) {
930
+ keys.push({ address: account, role: kit.AccountRole.READONLY });
931
+ }
932
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
933
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.removeLiquidity,
934
+ chunkBXATWUGJ_cjs.removeLiquidityArgsCodec,
935
+ args
936
+ );
937
+ return {
938
+ programAddress: programId,
939
+ accounts: keys,
940
+ data
941
+ };
942
+ }
943
+ function createCollectProtocolFeesInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
944
+ const {
945
+ config,
946
+ pool,
947
+ protocolPosition,
948
+ admin,
949
+ authority,
950
+ vault0,
951
+ vault1,
952
+ token0Mint,
953
+ token1Mint,
954
+ recipient0,
955
+ recipient1,
956
+ tokenProgram = chunkDPKVNI6Q_cjs.TOKEN_PROGRAM_ADDRESS
957
+ } = accounts;
958
+ const keys = [
959
+ { address: config, role: kit.AccountRole.READONLY },
960
+ { address: pool, role: kit.AccountRole.WRITABLE },
961
+ { address: protocolPosition, role: kit.AccountRole.WRITABLE },
962
+ { address: admin, role: kit.AccountRole.READONLY_SIGNER },
963
+ { address: authority, role: kit.AccountRole.READONLY },
964
+ { address: vault0, role: kit.AccountRole.WRITABLE },
965
+ { address: vault1, role: kit.AccountRole.WRITABLE },
966
+ { address: token0Mint, role: kit.AccountRole.READONLY },
967
+ { address: token1Mint, role: kit.AccountRole.READONLY },
968
+ { address: recipient0, role: kit.AccountRole.WRITABLE },
969
+ { address: recipient1, role: kit.AccountRole.WRITABLE },
970
+ { address: tokenProgram, role: kit.AccountRole.READONLY }
971
+ ];
972
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
973
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.collectProtocolFees,
974
+ chunkBXATWUGJ_cjs.collectProtocolFeesArgsCodec,
975
+ args
976
+ );
977
+ return {
978
+ programAddress: programId,
979
+ accounts: keys,
980
+ data
981
+ };
982
+ }
983
+ function createOracleUpdateInstruction(accounts, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
984
+ const { pool, oracle } = accounts;
985
+ const keys = [
986
+ { address: pool, role: kit.AccountRole.READONLY },
987
+ { address: oracle, role: kit.AccountRole.WRITABLE }
988
+ ];
989
+ const data = chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.oracleUpdate;
990
+ return {
991
+ programAddress: programId,
992
+ accounts: keys,
993
+ data
994
+ };
995
+ }
996
+ var oracleConsultResultCodec = kit.getStructCodec([
997
+ ["price0Q64", kit.getU128Codec()],
998
+ ["price1Q64", kit.getU128Codec()]
999
+ ]);
1000
+ function decodeOracleConsultResult(data) {
1001
+ return oracleConsultResultCodec.decode(data);
1002
+ }
1003
+ function createOracleConsultInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
1004
+ const { pool, oracle } = accounts;
1005
+ const keys = [
1006
+ { address: pool, role: kit.AccountRole.READONLY },
1007
+ { address: oracle, role: kit.AccountRole.READONLY }
1008
+ ];
1009
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
1010
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.oracleConsult,
1011
+ chunkBXATWUGJ_cjs.oracleConsultArgsCodec,
1012
+ args
1013
+ );
1014
+ return {
1015
+ programAddress: programId,
1016
+ accounts: keys,
1017
+ data
1018
+ };
1019
+ }
1020
+ var quoteToNumeraireResultCodec = kit.getStructCodec([
1021
+ ["amountInNumeraire", kit.getU128Codec()],
1022
+ ["endMint", kit.getAddressCodec()],
1023
+ ["hopsUsed", kit.getU8Codec()]
1024
+ ]);
1025
+ function decodeQuoteToNumeraireResult(data) {
1026
+ return quoteToNumeraireResultCodec.decode(data);
1027
+ }
1028
+ function createQuoteToNumeraireInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
1029
+ const { config, startPool, remainingAccounts = [] } = accounts;
1030
+ const keys = [
1031
+ { address: config, role: kit.AccountRole.READONLY },
1032
+ { address: startPool, role: kit.AccountRole.READONLY }
1033
+ ];
1034
+ for (const account of remainingAccounts) {
1035
+ keys.push({ address: account, role: kit.AccountRole.READONLY });
1036
+ }
1037
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
1038
+ chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.quoteToNumeraire,
1039
+ chunkBXATWUGJ_cjs.quoteToNumeraireArgsCodec,
1040
+ args
1041
+ );
1042
+ return {
1043
+ programAddress: programId,
1044
+ accounts: keys,
1045
+ data
1046
+ };
1047
+ }
1048
+
1049
+ // src/solana/client/config.ts
1050
+ function base64ToBytes(base64) {
1051
+ const binary = atob(base64);
1052
+ const bytes = new Uint8Array(binary.length);
1053
+ for (let i = 0; i < binary.length; i++) {
1054
+ bytes[i] = binary.charCodeAt(i);
1055
+ }
1056
+ return bytes;
1057
+ }
1058
+ async function fetchConfig(rpc, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID, commitment) {
1059
+ const [configAddress] = await chunkDPKVNI6Q_cjs.getConfigAddress(programId);
1060
+ const response = await rpc.getAccountInfo(configAddress, {
1061
+ encoding: "base64",
1062
+ commitment
1063
+ }).send();
1064
+ if (!response.value) {
1065
+ return null;
1066
+ }
1067
+ return chunkBXATWUGJ_cjs.decodeAmmConfig(base64ToBytes(response.value.data[0]));
1068
+ }
1069
+ async function fetchConfigWithAddress(rpc, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID, commitment) {
1070
+ const [configAddress] = await chunkDPKVNI6Q_cjs.getConfigAddress(programId);
1071
+ const account = await fetchConfig(rpc, programId, commitment);
1072
+ if (!account) {
1073
+ return null;
1074
+ }
1075
+ return { address: configAddress, account };
1076
+ }
1077
+
1078
+ // src/solana/initializer/index.ts
1079
+ var initializer_exports = {};
1080
+ chunkQ7SFCCGT_cjs.__export(initializer_exports, {
1081
+ BPF_LOADER_UPGRADEABLE_PROGRAM_ID: () => BPF_LOADER_UPGRADEABLE_PROGRAM_ID,
1082
+ CPMM_SENTINEL_PROGRAM_ID: () => CPMM_SENTINEL_PROGRAM_ID,
1083
+ CURVE_KIND_XYK: () => CURVE_KIND_XYK,
1084
+ CURVE_PARAMS_FORMAT_XYK_V0: () => CURVE_PARAMS_FORMAT_XYK_V0,
1085
+ DIRECTION_BUY: () => DIRECTION_BUY,
1086
+ DIRECTION_SELL: () => DIRECTION_SELL,
1087
+ DOPPLER_DEVNET_ALT: () => DOPPLER_DEVNET_ALT,
1088
+ EMPTY_REMAINING_ACCOUNTS_HASH: () => EMPTY_REMAINING_ACCOUNTS_HASH,
1089
+ INITIALIZER_ACCOUNT_DISCRIMINATORS: () => INITIALIZER_ACCOUNT_DISCRIMINATORS,
1090
+ INITIALIZER_INSTRUCTION_DISCRIMINATORS: () => INITIALIZER_INSTRUCTION_DISCRIMINATORS,
1091
+ INITIALIZER_PROGRAM_ID: () => INITIALIZER_PROGRAM_ID,
1092
+ MAX_CALLDATA: () => MAX_CALLDATA,
1093
+ MAX_MIGRATOR_ALLOWLIST: () => MAX_MIGRATOR_ALLOWLIST,
1094
+ MAX_SENTINEL_ALLOWLIST: () => MAX_SENTINEL_ALLOWLIST2,
1095
+ PHASE_ABORTED: () => PHASE_ABORTED,
1096
+ PHASE_MIGRATED: () => PHASE_MIGRATED,
1097
+ PHASE_TRADING: () => PHASE_TRADING,
1098
+ PREDICTION_SENTINEL_PROGRAM_ID: () => PREDICTION_SENTINEL_PROGRAM_ID,
1099
+ SEED_CONFIG: () => SEED_CONFIG2,
1100
+ SEED_LAUNCH: () => SEED_LAUNCH,
1101
+ SEED_LAUNCH_AUTHORITY: () => SEED_LAUNCH_AUTHORITY,
1102
+ SENTINEL_NO_CHANGE: () => SENTINEL_NO_CHANGE2,
1103
+ SF_AFTER_SWAP: () => SF_AFTER_SWAP2,
1104
+ SF_BEFORE_SWAP: () => SF_BEFORE_SWAP2,
1105
+ computeRemainingAccountsHash: () => computeRemainingAccountsHash,
1106
+ createAbortLaunchInstruction: () => createAbortLaunchInstruction,
1107
+ createCurveSwapExactInInstruction: () => createCurveSwapExactInInstruction,
1108
+ createInitializeConfigInstruction: () => createInitializeConfigInstruction2,
1109
+ createInitializeLaunchInstruction: () => createInitializeLaunchInstruction,
1110
+ createMigrateLaunchInstruction: () => createMigrateLaunchInstruction,
1111
+ createPreviewMigrationInstruction: () => createPreviewMigrationInstruction,
1112
+ createPreviewSwapExactInInstruction: () => createPreviewSwapExactInInstruction,
1113
+ createSetMigratorAllowlistInstruction: () => createSetMigratorAllowlistInstruction,
1114
+ createSetSentinelAllowlistInstruction: () => createSetSentinelAllowlistInstruction,
1115
+ decodePreviewMigrationResult: () => decodePreviewMigrationResult,
1116
+ decodePreviewSwapExactInResult: () => decodePreviewSwapExactInResult,
1117
+ encodeU64LE: () => encodeU64LE,
1118
+ fetchAllLaunches: () => fetchAllLaunches,
1119
+ fetchLaunch: () => fetchLaunch2,
1120
+ fetchLaunchesByAuthority: () => fetchLaunchesByAuthority,
1121
+ getConfigAddress: () => getConfigAddress2,
1122
+ getInitConfigCodec: () => getInitConfigCodec,
1123
+ getInitConfigDecoder: () => getInitConfigDecoder,
1124
+ getInitConfigEncoder: () => getInitConfigEncoder,
1125
+ getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec,
1126
+ getInitializeConfigArgsDecoder: () => getInitializeConfigArgsDecoder,
1127
+ getInitializeConfigArgsEncoder: () => getInitializeConfigArgsEncoder,
1128
+ getInitializeLaunchArgsCodec: () => getInitializeLaunchArgsCodec,
1129
+ getInitializeLaunchArgsDecoder: () => getInitializeLaunchArgsDecoder,
1130
+ getInitializeLaunchArgsEncoder: () => getInitializeLaunchArgsEncoder,
1131
+ getLaunchAddress: () => getLaunchAddress,
1132
+ getLaunchAuthorityAddress: () => getLaunchAuthorityAddress,
1133
+ getLaunchCodec: () => getLaunchCodec,
1134
+ getLaunchDecoder: () => getLaunchDecoder,
1135
+ getLaunchEncoder: () => getLaunchEncoder,
1136
+ getProgramDataAddress: () => getProgramDataAddress,
1137
+ getTokenMetadataAddress: () => getTokenMetadataAddress,
1138
+ launchExists: () => launchExists,
1139
+ launchIdFromU64: () => launchIdFromU64,
1140
+ phaseLabel: () => phaseLabel
1141
+ });
1142
+ var INITIALIZER_PROGRAM_ID = kit.address(
1143
+ "4h3Dqyo5qmteJoMxXt3tdtfXELDB6pdRTPU9mWruiKp1"
1144
+ );
1145
+ var BPF_LOADER_UPGRADEABLE_PROGRAM_ID = kit.address(
1146
+ "BPFLoaderUpgradeab1e11111111111111111111111"
1147
+ );
1148
+ var CPMM_SENTINEL_PROGRAM_ID = kit.address(
1149
+ "2vJ1c62knEwZbxp3XdHB4RSmCfz55pA6tRkCho63gW7u"
1150
+ );
1151
+ var PREDICTION_SENTINEL_PROGRAM_ID = kit.address(
1152
+ "7QcQDANJVC17Jgc6KjjeagSkm2zAphgHVPK5agJzyihB"
1153
+ );
1154
+ var SEED_CONFIG2 = "config_v3";
1155
+ var SEED_LAUNCH = "launch_v3";
1156
+ var SEED_LAUNCH_AUTHORITY = "launch_authority_v3";
1157
+ var EMPTY_REMAINING_ACCOUNTS_HASH = new Uint8Array([
1158
+ 232,
1159
+ 231,
1160
+ 118,
1161
+ 38,
1162
+ 88,
1163
+ 111,
1164
+ 115,
1165
+ 185,
1166
+ 85,
1167
+ 54,
1168
+ 76,
1169
+ 123,
1170
+ 75,
1171
+ 191,
1172
+ 11,
1173
+ 183,
1174
+ 247,
1175
+ 104,
1176
+ 94,
1177
+ 189,
1178
+ 64,
1179
+ 232,
1180
+ 82,
1181
+ 177,
1182
+ 100,
1183
+ 99,
1184
+ 58,
1185
+ 74,
1186
+ 203,
1187
+ 211,
1188
+ 36,
1189
+ 76
1190
+ ]);
1191
+ var DOPPLER_DEVNET_ALT = kit.address(
1192
+ "7r5rdLkGMzTq5Q2kBhkePw4ZTeZEooHgTXktYoamNmVq"
1193
+ );
1194
+ var MAX_MIGRATOR_ALLOWLIST = 32;
1195
+ var MAX_SENTINEL_ALLOWLIST2 = 32;
1196
+ var MAX_CALLDATA = 256;
1197
+ var PHASE_TRADING = 0;
1198
+ var PHASE_MIGRATED = 1;
1199
+ var PHASE_ABORTED = 2;
1200
+ var DIRECTION_BUY = 0;
1201
+ var DIRECTION_SELL = 1;
1202
+ var CURVE_KIND_XYK = 0;
1203
+ var CURVE_PARAMS_FORMAT_XYK_V0 = 0;
1204
+ var SF_BEFORE_SWAP2 = 1 << 0;
1205
+ var SF_AFTER_SWAP2 = 1 << 1;
1206
+ var SENTINEL_NO_CHANGE2 = 65535;
1207
+ var INITIALIZER_INSTRUCTION_DISCRIMINATORS = {
1208
+ // SHA256("global:initialize_config")[0:8]
1209
+ initializeConfig: new Uint8Array([
1210
+ 208,
1211
+ 127,
1212
+ 21,
1213
+ 1,
1214
+ 194,
1215
+ 190,
1216
+ 196,
1217
+ 70
1218
+ ]),
1219
+ // SHA256("global:set_migrator_allowlist")[0:8]
1220
+ setMigratorAllowlist: new Uint8Array([
1221
+ 209,
1222
+ 90,
1223
+ 181,
1224
+ 104,
1225
+ 99,
1226
+ 108,
1227
+ 233,
1228
+ 168
1229
+ ]),
1230
+ // SHA256("global:set_sentinel_allowlist")[0:8]
1231
+ setSentinelAllowlist: new Uint8Array([
1232
+ 233,
1233
+ 72,
1234
+ 180,
1235
+ 246,
1236
+ 171,
1237
+ 117,
1238
+ 21,
1239
+ 50
1240
+ ]),
1241
+ // SHA256("global:initialize_launch")[0:8]
1242
+ initializeLaunch: new Uint8Array([
1243
+ 90,
1244
+ 201,
1245
+ 220,
1246
+ 142,
1247
+ 112,
1248
+ 253,
1249
+ 100,
1250
+ 13
1251
+ ]),
1252
+ // SHA256("global:curve_swap_exact_in")[0:8]
1253
+ curveSwapExactIn: new Uint8Array([
1254
+ 196,
1255
+ 247,
1256
+ 195,
1257
+ 126,
1258
+ 227,
1259
+ 27,
1260
+ 166,
1261
+ 93
1262
+ ]),
1263
+ // SHA256("global:migrate_launch")[0:8]
1264
+ migrateLaunch: new Uint8Array([
1265
+ 19,
1266
+ 199,
1267
+ 119,
1268
+ 103,
1269
+ 13,
1270
+ 30,
1271
+ 12,
1272
+ 205
1273
+ ]),
1274
+ // SHA256("global:abort_launch")[0:8]
1275
+ abortLaunch: new Uint8Array([44, 112, 192, 235, 227, 61, 179, 7]),
1276
+ // SHA256("global:preview_swap_exact_in")[0:8]
1277
+ previewSwapExactIn: new Uint8Array([
1278
+ 50,
1279
+ 130,
1280
+ 31,
1281
+ 69,
1282
+ 147,
1283
+ 58,
1284
+ 222,
1285
+ 178
1286
+ ]),
1287
+ // SHA256("global:preview_migration")[0:8]
1288
+ previewMigration: new Uint8Array([
1289
+ 216,
1290
+ 180,
1291
+ 209,
1292
+ 112,
1293
+ 62,
1294
+ 16,
1295
+ 15,
1296
+ 63
1297
+ ])
1298
+ };
1299
+ var INITIALIZER_ACCOUNT_DISCRIMINATORS = {
1300
+ // SHA256("account:InitConfig")[0:8]
1301
+ InitConfig: new Uint8Array([97, 166, 35, 7, 20, 2, 164, 126]),
1302
+ // SHA256("account:Launch")[0:8]
1303
+ Launch: new Uint8Array([144, 51, 51, 163, 206, 85, 213, 38])
1304
+ };
1305
+ var INIT_CONFIG_DISCRIMINATOR = new Uint8Array([
1306
+ 97,
1307
+ 166,
1308
+ 35,
1309
+ 7,
1310
+ 20,
1311
+ 2,
1312
+ 164,
1313
+ 126
1314
+ ]);
1315
+ function getInitConfigEncoder() {
1316
+ return kit.transformEncoder(
1317
+ kit.getStructEncoder([
1318
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
1319
+ ["admin", kit.getAddressEncoder()],
1320
+ ["migratorAllowlistLen", kit.getU8Encoder()],
1321
+ ["migratorAllowlist", kit.getArrayEncoder(kit.getAddressEncoder(), { size: 32 })],
1322
+ ["sentinelAllowlistLen", kit.getU8Encoder()],
1323
+ ["sentinelAllowlist", kit.getArrayEncoder(kit.getAddressEncoder(), { size: 32 })],
1324
+ ["bump", kit.getU8Encoder()],
1325
+ ["version", kit.getU8Encoder()],
1326
+ ["reserved", kit.fixEncoderSize(kit.getBytesEncoder(), 31)]
1327
+ ]),
1328
+ (value) => ({ ...value, discriminator: INIT_CONFIG_DISCRIMINATOR })
1329
+ );
1330
+ }
1331
+ function getInitConfigDecoder() {
1332
+ return kit.getStructDecoder([
1333
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
1334
+ ["admin", kit.getAddressDecoder()],
1335
+ ["migratorAllowlistLen", kit.getU8Decoder()],
1336
+ ["migratorAllowlist", kit.getArrayDecoder(kit.getAddressDecoder(), { size: 32 })],
1337
+ ["sentinelAllowlistLen", kit.getU8Decoder()],
1338
+ ["sentinelAllowlist", kit.getArrayDecoder(kit.getAddressDecoder(), { size: 32 })],
1339
+ ["bump", kit.getU8Decoder()],
1340
+ ["version", kit.getU8Decoder()],
1341
+ ["reserved", kit.fixDecoderSize(kit.getBytesDecoder(), 31)]
1342
+ ]);
1343
+ }
1344
+ function getInitConfigCodec() {
1345
+ return kit.combineCodec(getInitConfigEncoder(), getInitConfigDecoder());
1346
+ }
1347
+ function getCalldataBufEncoder() {
1348
+ return kit.getStructEncoder([
1349
+ ["len", kit.getU16Encoder()],
1350
+ ["bytes", kit.fixEncoderSize(kit.getBytesEncoder(), 256)]
1351
+ ]);
1352
+ }
1353
+ function getCalldataBufDecoder() {
1354
+ return kit.getStructDecoder([
1355
+ ["len", kit.getU16Decoder()],
1356
+ ["bytes", kit.fixDecoderSize(kit.getBytesDecoder(), 256)]
1357
+ ]);
1358
+ }
1359
+ function getInitializeConfigArgsEncoder() {
1360
+ return kit.getStructEncoder([
1361
+ ["migratorAllowlist", kit.getArrayEncoder(kit.getAddressEncoder())],
1362
+ ["sentinelAllowlist", kit.getArrayEncoder(kit.getAddressEncoder())]
1363
+ ]);
1364
+ }
1365
+ function getInitializeConfigArgsDecoder() {
1366
+ return kit.getStructDecoder([
1367
+ ["migratorAllowlist", kit.getArrayDecoder(kit.getAddressDecoder())],
1368
+ ["sentinelAllowlist", kit.getArrayDecoder(kit.getAddressDecoder())]
1369
+ ]);
1370
+ }
1371
+ function getInitializeConfigArgsCodec() {
1372
+ return kit.combineCodec(
1373
+ getInitializeConfigArgsEncoder(),
1374
+ getInitializeConfigArgsDecoder()
1375
+ );
1376
+ }
1377
+ function getInitializeLaunchArgsEncoder() {
1378
+ return kit.getStructEncoder([
1379
+ ["namespace", kit.getAddressEncoder()],
1380
+ ["launchId", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
1381
+ ["baseDecimals", kit.getU8Encoder()],
1382
+ ["baseTotalSupply", kit.getU64Encoder()],
1383
+ ["baseForDistribution", kit.getU64Encoder()],
1384
+ ["baseForLiquidity", kit.getU64Encoder()],
1385
+ ["curveVirtualBase", kit.getU64Encoder()],
1386
+ ["curveVirtualQuote", kit.getU64Encoder()],
1387
+ ["curveFeeBps", kit.getU16Encoder()],
1388
+ ["curveKind", kit.getU8Encoder()],
1389
+ ["curveParams", kit.addEncoderSizePrefix(kit.getBytesEncoder(), kit.getU32Encoder())],
1390
+ ["allowBuy", kit.getU8Encoder()],
1391
+ ["allowSell", kit.getU8Encoder()],
1392
+ ["sentinelProgram", kit.getAddressEncoder()],
1393
+ ["sentinelFlags", kit.getU32Encoder()],
1394
+ [
1395
+ "sentinelCalldata",
1396
+ kit.addEncoderSizePrefix(kit.getBytesEncoder(), kit.getU32Encoder())
1397
+ ],
1398
+ ["migratorProgram", kit.getAddressEncoder()],
1399
+ [
1400
+ "migratorInitCalldata",
1401
+ kit.addEncoderSizePrefix(kit.getBytesEncoder(), kit.getU32Encoder())
1402
+ ],
1403
+ [
1404
+ "migratorMigrateCalldata",
1405
+ kit.addEncoderSizePrefix(kit.getBytesEncoder(), kit.getU32Encoder())
1406
+ ],
1407
+ ["sentinelRemainingAccountsHash", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
1408
+ ["migratorRemainingAccountsHash", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
1409
+ ["metadataName", kit.addEncoderSizePrefix(kit.getUtf8Encoder(), kit.getU32Encoder())],
1410
+ ["metadataSymbol", kit.addEncoderSizePrefix(kit.getUtf8Encoder(), kit.getU32Encoder())],
1411
+ ["metadataUri", kit.addEncoderSizePrefix(kit.getUtf8Encoder(), kit.getU32Encoder())]
1412
+ ]);
1413
+ }
1414
+ function getInitializeLaunchArgsDecoder() {
1415
+ return kit.getStructDecoder([
1416
+ ["namespace", kit.getAddressDecoder()],
1417
+ ["launchId", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
1418
+ ["baseDecimals", kit.getU8Decoder()],
1419
+ ["baseTotalSupply", kit.getU64Decoder()],
1420
+ ["baseForDistribution", kit.getU64Decoder()],
1421
+ ["baseForLiquidity", kit.getU64Decoder()],
1422
+ ["curveVirtualBase", kit.getU64Decoder()],
1423
+ ["curveVirtualQuote", kit.getU64Decoder()],
1424
+ ["curveFeeBps", kit.getU16Decoder()],
1425
+ ["curveKind", kit.getU8Decoder()],
1426
+ ["curveParams", kit.addDecoderSizePrefix(kit.getBytesDecoder(), kit.getU32Decoder())],
1427
+ ["allowBuy", kit.getU8Decoder()],
1428
+ ["allowSell", kit.getU8Decoder()],
1429
+ ["sentinelProgram", kit.getAddressDecoder()],
1430
+ ["sentinelFlags", kit.getU32Decoder()],
1431
+ [
1432
+ "sentinelCalldata",
1433
+ kit.addDecoderSizePrefix(kit.getBytesDecoder(), kit.getU32Decoder())
1434
+ ],
1435
+ ["migratorProgram", kit.getAddressDecoder()],
1436
+ [
1437
+ "migratorInitCalldata",
1438
+ kit.addDecoderSizePrefix(kit.getBytesDecoder(), kit.getU32Decoder())
1439
+ ],
1440
+ [
1441
+ "migratorMigrateCalldata",
1442
+ kit.addDecoderSizePrefix(kit.getBytesDecoder(), kit.getU32Decoder())
1443
+ ],
1444
+ ["sentinelRemainingAccountsHash", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
1445
+ ["migratorRemainingAccountsHash", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
1446
+ ["metadataName", kit.addDecoderSizePrefix(kit.getUtf8Decoder(), kit.getU32Decoder())],
1447
+ ["metadataSymbol", kit.addDecoderSizePrefix(kit.getUtf8Decoder(), kit.getU32Decoder())],
1448
+ ["metadataUri", kit.addDecoderSizePrefix(kit.getUtf8Decoder(), kit.getU32Decoder())]
1449
+ ]);
1450
+ }
1451
+ function getInitializeLaunchArgsCodec() {
1452
+ return kit.combineCodec(
1453
+ getInitializeLaunchArgsEncoder(),
1454
+ getInitializeLaunchArgsDecoder()
1455
+ );
1456
+ }
1457
+
1458
+ // src/solana/generated/initializer/accounts/launch.ts
1459
+ var LAUNCH_DISCRIMINATOR = new Uint8Array([
1460
+ 144,
1461
+ 51,
1462
+ 51,
1463
+ 163,
1464
+ 206,
1465
+ 85,
1466
+ 213,
1467
+ 38
1468
+ ]);
1469
+ function getLaunchEncoder() {
1470
+ return kit.transformEncoder(
1471
+ kit.getStructEncoder([
1472
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
1473
+ ["authority", kit.getAddressEncoder()],
1474
+ ["namespace", kit.getAddressEncoder()],
1475
+ ["launchId", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
1476
+ ["phase", kit.getU8Encoder()],
1477
+ ["bump", kit.getU8Encoder()],
1478
+ ["launchAuthorityBump", kit.getU8Encoder()],
1479
+ ["pad0", kit.fixEncoderSize(kit.getBytesEncoder(), 5)],
1480
+ ["baseMint", kit.getAddressEncoder()],
1481
+ ["quoteMint", kit.getAddressEncoder()],
1482
+ ["baseVault", kit.getAddressEncoder()],
1483
+ ["quoteVault", kit.getAddressEncoder()],
1484
+ ["baseTotalSupply", kit.getU64Encoder()],
1485
+ ["baseForDistribution", kit.getU64Encoder()],
1486
+ ["baseForLiquidity", kit.getU64Encoder()],
1487
+ ["baseForCurve", kit.getU64Encoder()],
1488
+ ["curveVirtualBase", kit.getU64Encoder()],
1489
+ ["curveVirtualQuote", kit.getU64Encoder()],
1490
+ ["curveFeeBps", kit.getU16Encoder()],
1491
+ ["pad1", kit.fixEncoderSize(kit.getBytesEncoder(), 6)],
1492
+ ["allowBuy", kit.getU8Encoder()],
1493
+ ["allowSell", kit.getU8Encoder()],
1494
+ ["pad2", kit.fixEncoderSize(kit.getBytesEncoder(), 6)],
1495
+ ["sentinelProgram", kit.getAddressEncoder()],
1496
+ ["sentinelFlags", kit.getU32Encoder()],
1497
+ ["pad3", kit.fixEncoderSize(kit.getBytesEncoder(), 4)],
1498
+ ["sentinelCalldata", getCalldataBufEncoder()],
1499
+ ["migratorProgram", kit.getAddressEncoder()],
1500
+ ["migratorInitCalldata", getCalldataBufEncoder()],
1501
+ ["migratorMigrateCalldata", getCalldataBufEncoder()],
1502
+ ["curveKind", kit.getU8Encoder()],
1503
+ ["swapLock", kit.getU8Encoder()],
1504
+ ["pad4", kit.fixEncoderSize(kit.getBytesEncoder(), 6)],
1505
+ ["curveParams", getCalldataBufEncoder()],
1506
+ ["quoteDeposited", kit.getU64Encoder()],
1507
+ ["reserved", kit.fixEncoderSize(kit.getBytesEncoder(), 64)]
1508
+ ]),
1509
+ (value) => ({ ...value, discriminator: LAUNCH_DISCRIMINATOR })
1510
+ );
1511
+ }
1512
+ function getLaunchDecoder() {
1513
+ return kit.getStructDecoder([
1514
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
1515
+ ["authority", kit.getAddressDecoder()],
1516
+ ["namespace", kit.getAddressDecoder()],
1517
+ ["launchId", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
1518
+ ["phase", kit.getU8Decoder()],
1519
+ ["bump", kit.getU8Decoder()],
1520
+ ["launchAuthorityBump", kit.getU8Decoder()],
1521
+ ["pad0", kit.fixDecoderSize(kit.getBytesDecoder(), 5)],
1522
+ ["baseMint", kit.getAddressDecoder()],
1523
+ ["quoteMint", kit.getAddressDecoder()],
1524
+ ["baseVault", kit.getAddressDecoder()],
1525
+ ["quoteVault", kit.getAddressDecoder()],
1526
+ ["baseTotalSupply", kit.getU64Decoder()],
1527
+ ["baseForDistribution", kit.getU64Decoder()],
1528
+ ["baseForLiquidity", kit.getU64Decoder()],
1529
+ ["baseForCurve", kit.getU64Decoder()],
1530
+ ["curveVirtualBase", kit.getU64Decoder()],
1531
+ ["curveVirtualQuote", kit.getU64Decoder()],
1532
+ ["curveFeeBps", kit.getU16Decoder()],
1533
+ ["pad1", kit.fixDecoderSize(kit.getBytesDecoder(), 6)],
1534
+ ["allowBuy", kit.getU8Decoder()],
1535
+ ["allowSell", kit.getU8Decoder()],
1536
+ ["pad2", kit.fixDecoderSize(kit.getBytesDecoder(), 6)],
1537
+ ["sentinelProgram", kit.getAddressDecoder()],
1538
+ ["sentinelFlags", kit.getU32Decoder()],
1539
+ ["pad3", kit.fixDecoderSize(kit.getBytesDecoder(), 4)],
1540
+ ["sentinelCalldata", getCalldataBufDecoder()],
1541
+ ["migratorProgram", kit.getAddressDecoder()],
1542
+ ["migratorInitCalldata", getCalldataBufDecoder()],
1543
+ ["migratorMigrateCalldata", getCalldataBufDecoder()],
1544
+ ["curveKind", kit.getU8Decoder()],
1545
+ ["swapLock", kit.getU8Decoder()],
1546
+ ["pad4", kit.fixDecoderSize(kit.getBytesDecoder(), 6)],
1547
+ ["curveParams", getCalldataBufDecoder()],
1548
+ ["quoteDeposited", kit.getU64Decoder()],
1549
+ ["reserved", kit.fixDecoderSize(kit.getBytesDecoder(), 64)]
1550
+ ]);
1551
+ }
1552
+ function getLaunchCodec() {
1553
+ return kit.combineCodec(getLaunchEncoder(), getLaunchDecoder());
1554
+ }
1555
+ var CURVE_SWAP_EXACT_IN_DISCRIMINATOR = new Uint8Array([
1556
+ 196,
1557
+ 247,
1558
+ 195,
1559
+ 126,
1560
+ 227,
1561
+ 27,
1562
+ 166,
1563
+ 93
1564
+ ]);
1565
+ function getCurveSwapExactInInstructionDataEncoder() {
1566
+ return kit.transformEncoder(
1567
+ kit.getStructEncoder([
1568
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
1569
+ ["amountIn", kit.getU64Encoder()],
1570
+ ["minAmountOut", kit.getU64Encoder()],
1571
+ ["direction", kit.getU8Encoder()]
1572
+ ]),
1573
+ (value) => ({ ...value, discriminator: CURVE_SWAP_EXACT_IN_DISCRIMINATOR })
1574
+ );
1575
+ }
1576
+ var INITIALIZE_CONFIG_DISCRIMINATOR = new Uint8Array([
1577
+ 208,
1578
+ 127,
1579
+ 21,
1580
+ 1,
1581
+ 194,
1582
+ 190,
1583
+ 196,
1584
+ 70
1585
+ ]);
1586
+ function getInitializeConfigInstructionDataEncoder() {
1587
+ return kit.transformEncoder(
1588
+ kit.getStructEncoder([
1589
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
1590
+ ["migratorAllowlist", kit.getArrayEncoder(kit.getAddressEncoder())],
1591
+ ["sentinelAllowlist", kit.getArrayEncoder(kit.getAddressEncoder())]
1592
+ ]),
1593
+ (value) => ({ ...value, discriminator: INITIALIZE_CONFIG_DISCRIMINATOR })
1594
+ );
1595
+ }
1596
+ var INITIALIZE_LAUNCH_DISCRIMINATOR = new Uint8Array([
1597
+ 90,
1598
+ 201,
1599
+ 220,
1600
+ 142,
1601
+ 112,
1602
+ 253,
1603
+ 100,
1604
+ 13
1605
+ ]);
1606
+ function getInitializeLaunchInstructionDataEncoder() {
1607
+ return kit.transformEncoder(
1608
+ kit.getStructEncoder([
1609
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
1610
+ ["namespace", kit.getAddressEncoder()],
1611
+ ["launchId", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
1612
+ ["baseDecimals", kit.getU8Encoder()],
1613
+ ["baseTotalSupply", kit.getU64Encoder()],
1614
+ ["baseForDistribution", kit.getU64Encoder()],
1615
+ ["baseForLiquidity", kit.getU64Encoder()],
1616
+ ["curveVirtualBase", kit.getU64Encoder()],
1617
+ ["curveVirtualQuote", kit.getU64Encoder()],
1618
+ ["curveFeeBps", kit.getU16Encoder()],
1619
+ ["curveKind", kit.getU8Encoder()],
1620
+ ["curveParams", kit.addEncoderSizePrefix(kit.getBytesEncoder(), kit.getU32Encoder())],
1621
+ ["allowBuy", kit.getU8Encoder()],
1622
+ ["allowSell", kit.getU8Encoder()],
1623
+ ["sentinelProgram", kit.getAddressEncoder()],
1624
+ ["sentinelFlags", kit.getU32Encoder()],
1625
+ [
1626
+ "sentinelCalldata",
1627
+ kit.addEncoderSizePrefix(kit.getBytesEncoder(), kit.getU32Encoder())
1628
+ ],
1629
+ ["migratorProgram", kit.getAddressEncoder()],
1630
+ [
1631
+ "migratorInitCalldata",
1632
+ kit.addEncoderSizePrefix(kit.getBytesEncoder(), kit.getU32Encoder())
1633
+ ],
1634
+ [
1635
+ "migratorMigrateCalldata",
1636
+ kit.addEncoderSizePrefix(kit.getBytesEncoder(), kit.getU32Encoder())
1637
+ ],
1638
+ ["sentinelRemainingAccountsHash", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
1639
+ ["migratorRemainingAccountsHash", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
1640
+ ["metadataName", kit.addEncoderSizePrefix(kit.getUtf8Encoder(), kit.getU32Encoder())],
1641
+ [
1642
+ "metadataSymbol",
1643
+ kit.addEncoderSizePrefix(kit.getUtf8Encoder(), kit.getU32Encoder())
1644
+ ],
1645
+ ["metadataUri", kit.addEncoderSizePrefix(kit.getUtf8Encoder(), kit.getU32Encoder())]
1646
+ ]),
1647
+ (value) => ({ ...value, discriminator: INITIALIZE_LAUNCH_DISCRIMINATOR })
1648
+ );
1649
+ }
1650
+ var PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR = new Uint8Array([
1651
+ 50,
1652
+ 130,
1653
+ 31,
1654
+ 69,
1655
+ 147,
1656
+ 58,
1657
+ 222,
1658
+ 178
1659
+ ]);
1660
+ function getPreviewSwapExactInInstructionDataEncoder() {
1661
+ return kit.transformEncoder(
1662
+ kit.getStructEncoder([
1663
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
1664
+ ["amountIn", kit.getU64Encoder()],
1665
+ ["direction", kit.getU8Encoder()]
1666
+ ]),
1667
+ (value) => ({
1668
+ ...value,
1669
+ discriminator: PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR
1670
+ })
1671
+ );
1672
+ }
1673
+ var SET_MIGRATOR_ALLOWLIST_DISCRIMINATOR = new Uint8Array([
1674
+ 209,
1675
+ 90,
1676
+ 181,
1677
+ 104,
1678
+ 99,
1679
+ 108,
1680
+ 233,
1681
+ 168
1682
+ ]);
1683
+ function getSetMigratorAllowlistInstructionDataEncoder() {
1684
+ return kit.transformEncoder(
1685
+ kit.getStructEncoder([
1686
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
1687
+ ["allowlist", kit.getArrayEncoder(kit.getAddressEncoder())]
1688
+ ]),
1689
+ (value) => ({
1690
+ ...value,
1691
+ discriminator: SET_MIGRATOR_ALLOWLIST_DISCRIMINATOR
1692
+ })
1693
+ );
1694
+ }
1695
+ var SET_SENTINEL_ALLOWLIST_DISCRIMINATOR = new Uint8Array([
1696
+ 233,
1697
+ 72,
1698
+ 180,
1699
+ 246,
1700
+ 171,
1701
+ 117,
1702
+ 21,
1703
+ 50
1704
+ ]);
1705
+ function getSetSentinelAllowlistInstructionDataEncoder() {
1706
+ return kit.transformEncoder(
1707
+ kit.getStructEncoder([
1708
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
1709
+ ["allowlist", kit.getArrayEncoder(kit.getAddressEncoder())]
1710
+ ]),
1711
+ (value) => ({
1712
+ ...value,
1713
+ discriminator: SET_SENTINEL_ALLOWLIST_DISCRIMINATOR
1714
+ })
1715
+ );
1716
+ }
1717
+ if (process.env.NODE_ENV !== "production") ;
1718
+ var addressCodec2 = kit.getAddressCodec();
1719
+ var textEncoder2 = new TextEncoder();
1720
+ function encodeU64LE(value) {
1721
+ const bytes = new Uint8Array(8);
1722
+ const view = new DataView(bytes.buffer);
1723
+ view.setBigUint64(0, value, true);
1724
+ return bytes;
1725
+ }
1726
+ async function getConfigAddress2(programId = INITIALIZER_PROGRAM_ID) {
1727
+ return kit.getProgramDerivedAddress({
1728
+ programAddress: programId,
1729
+ seeds: [textEncoder2.encode(SEED_CONFIG2)]
1730
+ });
1731
+ }
1732
+ async function getProgramDataAddress(programId = INITIALIZER_PROGRAM_ID) {
1733
+ return kit.getProgramDerivedAddress({
1734
+ programAddress: BPF_LOADER_UPGRADEABLE_PROGRAM_ID,
1735
+ seeds: [addressCodec2.encode(programId)]
1736
+ });
1737
+ }
1738
+ async function getLaunchAddress(namespace, launchId, programId = INITIALIZER_PROGRAM_ID) {
1739
+ if (launchId.length !== 32) {
1740
+ throw new Error("launchId must be 32 bytes");
1741
+ }
1742
+ return kit.getProgramDerivedAddress({
1743
+ programAddress: programId,
1744
+ seeds: [
1745
+ textEncoder2.encode(SEED_LAUNCH),
1746
+ addressCodec2.encode(namespace),
1747
+ launchId
1748
+ ]
1749
+ });
1750
+ }
1751
+ async function getLaunchAuthorityAddress(launch, programId = INITIALIZER_PROGRAM_ID) {
1752
+ return kit.getProgramDerivedAddress({
1753
+ programAddress: programId,
1754
+ seeds: [
1755
+ textEncoder2.encode(SEED_LAUNCH_AUTHORITY),
1756
+ addressCodec2.encode(launch)
1757
+ ]
1758
+ });
1759
+ }
1760
+ function launchIdFromU64(launchId) {
1761
+ const out = new Uint8Array(32);
1762
+ out.set(encodeU64LE(launchId), 0);
1763
+ return out;
1764
+ }
1765
+ function isTransactionSigner2(value) {
1766
+ return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
1767
+ }
1768
+ function createSignerAccountMeta2(value, role) {
1769
+ if (isTransactionSigner2(value)) {
1770
+ return { address: value.address, role, signer: value };
1771
+ }
1772
+ return { address: value, role };
1773
+ }
1774
+ function createInitializeConfigInstruction2(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
1775
+ const {
1776
+ admin,
1777
+ config,
1778
+ programData,
1779
+ systemProgram = chunkDPKVNI6Q_cjs.SYSTEM_PROGRAM_ADDRESS
1780
+ } = accounts;
1781
+ const keys = [
1782
+ createSignerAccountMeta2(admin, kit.AccountRole.WRITABLE_SIGNER),
1783
+ { address: config, role: kit.AccountRole.WRITABLE },
1784
+ { address: programData, role: kit.AccountRole.READONLY },
1785
+ { address: systemProgram, role: kit.AccountRole.READONLY }
1786
+ ];
1787
+ const data = new Uint8Array(
1788
+ getInitializeConfigInstructionDataEncoder().encode(args)
1789
+ );
1790
+ return { programAddress: programId, accounts: keys, data };
1791
+ }
1792
+ function isTransactionSigner3(value) {
1793
+ return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
1794
+ }
1795
+ function createSignerAccountMeta3(value, role) {
1796
+ if (isTransactionSigner3(value)) {
1797
+ return { address: value.address, role, signer: value };
1798
+ }
1799
+ return { address: value, role };
1800
+ }
1801
+ function createSetMigratorAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
1802
+ const { admin, config } = accounts;
1803
+ const keys = [
1804
+ createSignerAccountMeta3(admin, kit.AccountRole.WRITABLE_SIGNER),
1805
+ { address: config, role: kit.AccountRole.WRITABLE }
1806
+ ];
1807
+ const data = new Uint8Array(
1808
+ getSetMigratorAllowlistInstructionDataEncoder().encode({ allowlist })
1809
+ );
1810
+ return { programAddress: programId, accounts: keys, data };
1811
+ }
1812
+ function isTransactionSigner4(value) {
1813
+ return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
1814
+ }
1815
+ function createSignerAccountMeta4(value, role) {
1816
+ if (isTransactionSigner4(value)) {
1817
+ return { address: value.address, role, signer: value };
1818
+ }
1819
+ return { address: value, role };
1820
+ }
1821
+ function createSetSentinelAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
1822
+ const { admin, config } = accounts;
1823
+ const keys = [
1824
+ createSignerAccountMeta4(admin, kit.AccountRole.WRITABLE_SIGNER),
1825
+ { address: config, role: kit.AccountRole.WRITABLE }
1826
+ ];
1827
+ const data = new Uint8Array(
1828
+ getSetSentinelAllowlistInstructionDataEncoder().encode({ allowlist })
1829
+ );
1830
+ return { programAddress: programId, accounts: keys, data };
1831
+ }
1832
+ var CPMM_MIGRATOR_PROGRAM_ID = kit.address(
1833
+ "7WMUTNC41eMCo6eGH5Sy2xbgE3AycvLbFPo95AU9CSUd"
1834
+ );
1835
+ var SEED_STATE = "state";
1836
+ var MAX_RECIPIENTS = 2;
1837
+ var CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS = {
1838
+ // SHA256("global:register_launch")[0:8]
1839
+ registerLaunch: new Uint8Array([
1840
+ 114,
1841
+ 114,
1842
+ 67,
1843
+ 23,
1844
+ 41,
1845
+ 70,
1846
+ 0,
1847
+ 225
1848
+ ]),
1849
+ // SHA256("global:migrate")[0:8]
1850
+ migrate: new Uint8Array([155, 234, 231, 146, 236, 158, 162, 30])
1851
+ };
1852
+ var CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS = {
1853
+ // SHA256("account:CpmmMigratorState")[0:8]
1854
+ CpmmMigratorState: new Uint8Array([
1855
+ 169,
1856
+ 86,
1857
+ 255,
1858
+ 187,
1859
+ 37,
1860
+ 248,
1861
+ 11,
1862
+ 176
1863
+ ])
1864
+ };
1865
+ var addressCodec3 = kit.getAddressCodec();
1866
+ var textEncoder3 = new TextEncoder();
1867
+ async function getCpmmMigratorStateAddress(launch, programId = CPMM_MIGRATOR_PROGRAM_ID) {
1868
+ return kit.getProgramDerivedAddress({
1869
+ programAddress: programId,
1870
+ seeds: [textEncoder3.encode(SEED_STATE), addressCodec3.encode(launch)]
1871
+ });
1872
+ }
1873
+ var CLAIM_RECEIPT_DISCRIMINATOR = new Uint8Array([
1874
+ 223,
1875
+ 233,
1876
+ 11,
1877
+ 229,
1878
+ 124,
1879
+ 165,
1880
+ 207,
1881
+ 28
1882
+ ]);
1883
+ function getClaimReceiptDiscriminatorBytes() {
1884
+ return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
1885
+ CLAIM_RECEIPT_DISCRIMINATOR
1886
+ );
1887
+ }
1888
+ function getClaimReceiptEncoder() {
1889
+ return kit.transformEncoder(
1890
+ kit.getStructEncoder([
1891
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
1892
+ ["market", kit.getAddressEncoder()],
1893
+ ["claimer", kit.getAddressEncoder()],
1894
+ ["burnedAmount", kit.getU64Encoder()],
1895
+ ["rewardDebt", kit.getU128Encoder()],
1896
+ ["bump", kit.getU8Encoder()],
1897
+ ["reserved", kit.fixEncoderSize(kit.getBytesEncoder(), 7)]
1898
+ ]),
1899
+ (value) => ({ ...value, discriminator: CLAIM_RECEIPT_DISCRIMINATOR })
1900
+ );
1901
+ }
1902
+ function getClaimReceiptDecoder() {
1903
+ return kit.getStructDecoder([
1904
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
1905
+ ["market", kit.getAddressDecoder()],
1906
+ ["claimer", kit.getAddressDecoder()],
1907
+ ["burnedAmount", kit.getU64Decoder()],
1908
+ ["rewardDebt", kit.getU128Decoder()],
1909
+ ["bump", kit.getU8Decoder()],
1910
+ ["reserved", kit.fixDecoderSize(kit.getBytesDecoder(), 7)]
1911
+ ]);
1912
+ }
1913
+ function getClaimReceiptCodec() {
1914
+ return kit.combineCodec(getClaimReceiptEncoder(), getClaimReceiptDecoder());
1915
+ }
1916
+ function decodeClaimReceipt(encodedAccount) {
1917
+ return kit.decodeAccount(
1918
+ encodedAccount,
1919
+ getClaimReceiptDecoder()
1920
+ );
1921
+ }
1922
+ async function fetchClaimReceipt(rpc, address3, config) {
1923
+ const maybeAccount = await fetchMaybeClaimReceipt(rpc, address3, config);
1924
+ kit.assertAccountExists(maybeAccount);
1925
+ return maybeAccount;
1926
+ }
1927
+ async function fetchMaybeClaimReceipt(rpc, address3, config) {
1928
+ const maybeAccount = await kit.fetchEncodedAccount(rpc, address3, config);
1929
+ return decodeClaimReceipt(maybeAccount);
1930
+ }
1931
+ async function fetchAllClaimReceipt(rpc, addresses, config) {
1932
+ const maybeAccounts = await fetchAllMaybeClaimReceipt(rpc, addresses, config);
1933
+ kit.assertAccountsExist(maybeAccounts);
1934
+ return maybeAccounts;
1935
+ }
1936
+ async function fetchAllMaybeClaimReceipt(rpc, addresses, config) {
1937
+ const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
1938
+ return maybeAccounts.map((maybeAccount) => decodeClaimReceipt(maybeAccount));
1939
+ }
1940
+ function getClaimReceiptSize() {
1941
+ return 104;
1942
+ }
1943
+ var ENTRY_DISCRIMINATOR = new Uint8Array([
1944
+ 63,
1945
+ 18,
1946
+ 152,
1947
+ 113,
1948
+ 215,
1949
+ 246,
1950
+ 221,
1951
+ 250
1952
+ ]);
1953
+ function getEntryDiscriminatorBytes() {
1954
+ return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(ENTRY_DISCRIMINATOR);
1955
+ }
1956
+ function getEntryEncoder() {
1957
+ return kit.transformEncoder(
1958
+ kit.getStructEncoder([
1959
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
1960
+ ["oracle", kit.getAddressEncoder()],
1961
+ ["entryId", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
1962
+ ["baseMint", kit.getAddressEncoder()],
1963
+ ["contribution", kit.getU64Encoder()],
1964
+ ["isMigrated", kit.getBooleanEncoder()],
1965
+ ["bump", kit.getU8Encoder()],
1966
+ ["reserved", kit.fixEncoderSize(kit.getBytesEncoder(), 14)]
1967
+ ]),
1968
+ (value) => ({ ...value, discriminator: ENTRY_DISCRIMINATOR })
1969
+ );
1970
+ }
1971
+ function getEntryDecoder() {
1972
+ return kit.getStructDecoder([
1973
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
1974
+ ["oracle", kit.getAddressDecoder()],
1975
+ ["entryId", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
1976
+ ["baseMint", kit.getAddressDecoder()],
1977
+ ["contribution", kit.getU64Decoder()],
1978
+ ["isMigrated", kit.getBooleanDecoder()],
1979
+ ["bump", kit.getU8Decoder()],
1980
+ ["reserved", kit.fixDecoderSize(kit.getBytesDecoder(), 14)]
1981
+ ]);
1982
+ }
1983
+ function getEntryCodec() {
1984
+ return kit.combineCodec(getEntryEncoder(), getEntryDecoder());
1985
+ }
1986
+ function decodeEntry(encodedAccount) {
1987
+ return kit.decodeAccount(
1988
+ encodedAccount,
1989
+ getEntryDecoder()
1990
+ );
1991
+ }
1992
+ async function fetchEntry(rpc, address3, config) {
1993
+ const maybeAccount = await fetchMaybeEntry(rpc, address3, config);
1994
+ kit.assertAccountExists(maybeAccount);
1995
+ return maybeAccount;
1996
+ }
1997
+ async function fetchMaybeEntry(rpc, address3, config) {
1998
+ const maybeAccount = await kit.fetchEncodedAccount(rpc, address3, config);
1999
+ return decodeEntry(maybeAccount);
2000
+ }
2001
+ async function fetchAllEntry(rpc, addresses, config) {
2002
+ const maybeAccounts = await fetchAllMaybeEntry(rpc, addresses, config);
2003
+ kit.assertAccountsExist(maybeAccounts);
2004
+ return maybeAccounts;
2005
+ }
2006
+ async function fetchAllMaybeEntry(rpc, addresses, config) {
2007
+ const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
2008
+ return maybeAccounts.map((maybeAccount) => decodeEntry(maybeAccount));
2009
+ }
2010
+ function getEntrySize() {
2011
+ return 128;
2012
+ }
2013
+ var ENTRY_BY_MINT_DISCRIMINATOR = new Uint8Array([
2014
+ 188,
2015
+ 191,
2016
+ 157,
2017
+ 194,
2018
+ 68,
2019
+ 82,
2020
+ 181,
2021
+ 126
2022
+ ]);
2023
+ function getEntryByMintDiscriminatorBytes() {
2024
+ return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
2025
+ ENTRY_BY_MINT_DISCRIMINATOR
2026
+ );
2027
+ }
2028
+ function getEntryByMintEncoder() {
2029
+ return kit.transformEncoder(
2030
+ kit.getStructEncoder([
2031
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
2032
+ ["oracle", kit.getAddressEncoder()],
2033
+ ["baseMint", kit.getAddressEncoder()],
2034
+ ["entryId", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
2035
+ ["bump", kit.getU8Encoder()],
2036
+ ["reserved", kit.fixEncoderSize(kit.getBytesEncoder(), 7)]
2037
+ ]),
2038
+ (value) => ({ ...value, discriminator: ENTRY_BY_MINT_DISCRIMINATOR })
2039
+ );
2040
+ }
2041
+ function getEntryByMintDecoder() {
2042
+ return kit.getStructDecoder([
2043
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
2044
+ ["oracle", kit.getAddressDecoder()],
2045
+ ["baseMint", kit.getAddressDecoder()],
2046
+ ["entryId", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
2047
+ ["bump", kit.getU8Decoder()],
2048
+ ["reserved", kit.fixDecoderSize(kit.getBytesDecoder(), 7)]
2049
+ ]);
2050
+ }
2051
+ function getEntryByMintCodec() {
2052
+ return kit.combineCodec(getEntryByMintEncoder(), getEntryByMintDecoder());
2053
+ }
2054
+ function decodeEntryByMint(encodedAccount) {
2055
+ return kit.decodeAccount(
2056
+ encodedAccount,
2057
+ getEntryByMintDecoder()
2058
+ );
2059
+ }
2060
+ async function fetchEntryByMint(rpc, address3, config) {
2061
+ const maybeAccount = await fetchMaybeEntryByMint(rpc, address3, config);
2062
+ kit.assertAccountExists(maybeAccount);
2063
+ return maybeAccount;
2064
+ }
2065
+ async function fetchMaybeEntryByMint(rpc, address3, config) {
2066
+ const maybeAccount = await kit.fetchEncodedAccount(rpc, address3, config);
2067
+ return decodeEntryByMint(maybeAccount);
2068
+ }
2069
+ async function fetchAllEntryByMint(rpc, addresses, config) {
2070
+ const maybeAccounts = await fetchAllMaybeEntryByMint(rpc, addresses, config);
2071
+ kit.assertAccountsExist(maybeAccounts);
2072
+ return maybeAccounts;
2073
+ }
2074
+ async function fetchAllMaybeEntryByMint(rpc, addresses, config) {
2075
+ const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
2076
+ return maybeAccounts.map((maybeAccount) => decodeEntryByMint(maybeAccount));
2077
+ }
2078
+ function getEntryByMintSize() {
2079
+ return 112;
2080
+ }
2081
+ function getAccumulatorUpdatedEncoder() {
2082
+ return kit.getStructEncoder([
2083
+ ["market", kit.getAddressEncoder()],
2084
+ ["newTotalPot", kit.getU64Encoder()],
2085
+ ["newAccQuotePerToken", kit.getU128Encoder()]
2086
+ ]);
2087
+ }
2088
+ function getAccumulatorUpdatedDecoder() {
2089
+ return kit.getStructDecoder([
2090
+ ["market", kit.getAddressDecoder()],
2091
+ ["newTotalPot", kit.getU64Decoder()],
2092
+ ["newAccQuotePerToken", kit.getU128Decoder()]
2093
+ ]);
2094
+ }
2095
+ function getAccumulatorUpdatedCodec() {
2096
+ return kit.combineCodec(
2097
+ getAccumulatorUpdatedEncoder(),
2098
+ getAccumulatorUpdatedDecoder()
2099
+ );
2100
+ }
2101
+ function getCalldataBufEncoder2() {
2102
+ return kit.getStructEncoder([
2103
+ ["len", kit.getU16Encoder()],
2104
+ ["bytes", kit.fixEncoderSize(kit.getBytesEncoder(), 256)]
2105
+ ]);
2106
+ }
2107
+ function getCalldataBufDecoder2() {
2108
+ return kit.getStructDecoder([
2109
+ ["len", kit.getU16Decoder()],
2110
+ ["bytes", kit.fixDecoderSize(kit.getBytesDecoder(), 256)]
2111
+ ]);
2112
+ }
2113
+ function getCalldataBufCodec() {
2114
+ return kit.combineCodec(getCalldataBufEncoder2(), getCalldataBufDecoder2());
2115
+ }
2116
+ function getEntryMigratedEncoder() {
2117
+ return kit.getStructEncoder([
2118
+ ["market", kit.getAddressEncoder()],
2119
+ ["oracle", kit.getAddressEncoder()],
2120
+ ["entryId", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
2121
+ ["baseMint", kit.getAddressEncoder()],
2122
+ ["contribution", kit.getU64Encoder()],
2123
+ ["isWinner", kit.getBooleanEncoder()]
2124
+ ]);
2125
+ }
2126
+ function getEntryMigratedDecoder() {
2127
+ return kit.getStructDecoder([
2128
+ ["market", kit.getAddressDecoder()],
2129
+ ["oracle", kit.getAddressDecoder()],
2130
+ ["entryId", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
2131
+ ["baseMint", kit.getAddressDecoder()],
2132
+ ["contribution", kit.getU64Decoder()],
2133
+ ["isWinner", kit.getBooleanDecoder()]
2134
+ ]);
2135
+ }
2136
+ function getEntryMigratedCodec() {
2137
+ return kit.combineCodec(getEntryMigratedEncoder(), getEntryMigratedDecoder());
2138
+ }
2139
+ function getEntryRegisteredEncoder() {
2140
+ return kit.getStructEncoder([
2141
+ ["market", kit.getAddressEncoder()],
2142
+ ["oracle", kit.getAddressEncoder()],
2143
+ ["entryId", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
2144
+ ["baseMint", kit.getAddressEncoder()]
2145
+ ]);
2146
+ }
2147
+ function getEntryRegisteredDecoder() {
2148
+ return kit.getStructDecoder([
2149
+ ["market", kit.getAddressDecoder()],
2150
+ ["oracle", kit.getAddressDecoder()],
2151
+ ["entryId", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
2152
+ ["baseMint", kit.getAddressDecoder()]
2153
+ ]);
2154
+ }
2155
+ function getEntryRegisteredCodec() {
2156
+ return kit.combineCodec(getEntryRegisteredEncoder(), getEntryRegisteredDecoder());
2157
+ }
2158
+ function getMarketCreatedEncoder() {
2159
+ return kit.getStructEncoder([
2160
+ ["market", kit.getAddressEncoder()],
2161
+ ["oracle", kit.getAddressEncoder()],
2162
+ ["quoteMint", kit.getAddressEncoder()]
2163
+ ]);
2164
+ }
2165
+ function getMarketCreatedDecoder() {
2166
+ return kit.getStructDecoder([
2167
+ ["market", kit.getAddressDecoder()],
2168
+ ["oracle", kit.getAddressDecoder()],
2169
+ ["quoteMint", kit.getAddressDecoder()]
2170
+ ]);
2171
+ }
2172
+ function getMarketCreatedCodec() {
2173
+ return kit.combineCodec(getMarketCreatedEncoder(), getMarketCreatedDecoder());
2174
+ }
2175
+ function getMarketResolvedEncoder() {
2176
+ return kit.getStructEncoder([
2177
+ ["market", kit.getAddressEncoder()],
2178
+ ["oracle", kit.getAddressEncoder()],
2179
+ ["winnerMint", kit.getAddressEncoder()],
2180
+ ["claimableSupply", kit.getU64Encoder()],
2181
+ ["totalPot", kit.getU64Encoder()]
2182
+ ]);
2183
+ }
2184
+ function getMarketResolvedDecoder() {
2185
+ return kit.getStructDecoder([
2186
+ ["market", kit.getAddressDecoder()],
2187
+ ["oracle", kit.getAddressDecoder()],
2188
+ ["winnerMint", kit.getAddressDecoder()],
2189
+ ["claimableSupply", kit.getU64Decoder()],
2190
+ ["totalPot", kit.getU64Decoder()]
2191
+ ]);
2192
+ }
2193
+ function getMarketResolvedCodec() {
2194
+ return kit.combineCodec(getMarketResolvedEncoder(), getMarketResolvedDecoder());
2195
+ }
2196
+ function getMigrateEntryArgsEncoder() {
2197
+ return kit.getStructEncoder([["entryId", kit.fixEncoderSize(kit.getBytesEncoder(), 32)]]);
2198
+ }
2199
+ function getMigrateEntryArgsDecoder() {
2200
+ return kit.getStructDecoder([["entryId", kit.fixDecoderSize(kit.getBytesDecoder(), 32)]]);
2201
+ }
2202
+ function getMigrateEntryArgsCodec() {
2203
+ return kit.combineCodec(
2204
+ getMigrateEntryArgsEncoder(),
2205
+ getMigrateEntryArgsDecoder()
2206
+ );
2207
+ }
2208
+ function getPreviewPayoutIfWinnerArgsEncoder() {
2209
+ return kit.getStructEncoder([
2210
+ ["candidateWinnerMint", kit.getAddressEncoder()],
2211
+ ["tokenAmount", kit.getU64Encoder()]
2212
+ ]);
2213
+ }
2214
+ function getPreviewPayoutIfWinnerArgsDecoder() {
2215
+ return kit.getStructDecoder([
2216
+ ["candidateWinnerMint", kit.getAddressDecoder()],
2217
+ ["tokenAmount", kit.getU64Decoder()]
2218
+ ]);
2219
+ }
2220
+ function getPreviewPayoutIfWinnerArgsCodec() {
2221
+ return kit.combineCodec(
2222
+ getPreviewPayoutIfWinnerArgsEncoder(),
2223
+ getPreviewPayoutIfWinnerArgsDecoder()
2224
+ );
2225
+ }
2226
+ function getRegisterEntryArgsEncoder() {
2227
+ return kit.getStructEncoder([["entryId", kit.fixEncoderSize(kit.getBytesEncoder(), 32)]]);
2228
+ }
2229
+ function getRegisterEntryArgsDecoder() {
2230
+ return kit.getStructDecoder([["entryId", kit.fixDecoderSize(kit.getBytesDecoder(), 32)]]);
2231
+ }
2232
+ function getRegisterEntryArgsCodec() {
2233
+ return kit.combineCodec(
2234
+ getRegisterEntryArgsEncoder(),
2235
+ getRegisterEntryArgsDecoder()
2236
+ );
2237
+ }
2238
+ function getRewardsClaimedEncoder() {
2239
+ return kit.getStructEncoder([
2240
+ ["market", kit.getAddressEncoder()],
2241
+ ["claimer", kit.getAddressEncoder()],
2242
+ ["burnedAmount", kit.getU64Encoder()],
2243
+ ["rewardAmount", kit.getU64Encoder()],
2244
+ ["totalBurned", kit.getU64Encoder()]
2245
+ ]);
2246
+ }
2247
+ function getRewardsClaimedDecoder() {
2248
+ return kit.getStructDecoder([
2249
+ ["market", kit.getAddressDecoder()],
2250
+ ["claimer", kit.getAddressDecoder()],
2251
+ ["burnedAmount", kit.getU64Decoder()],
2252
+ ["rewardAmount", kit.getU64Decoder()],
2253
+ ["totalBurned", kit.getU64Decoder()]
2254
+ ]);
2255
+ }
2256
+ function getRewardsClaimedCodec() {
2257
+ return kit.combineCodec(getRewardsClaimedEncoder(), getRewardsClaimedDecoder());
2258
+ }
2259
+
2260
+ // src/solana/generated/predictionMigrator/accounts/launch.ts
2261
+ var LAUNCH_DISCRIMINATOR2 = new Uint8Array([
2262
+ 144,
2263
+ 51,
2264
+ 51,
2265
+ 163,
2266
+ 206,
2267
+ 85,
2268
+ 213,
2269
+ 38
2270
+ ]);
2271
+ function getLaunchDiscriminatorBytes() {
2272
+ return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(LAUNCH_DISCRIMINATOR2);
2273
+ }
2274
+ function getLaunchEncoder2() {
2275
+ return kit.transformEncoder(
2276
+ kit.getStructEncoder([
2277
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
2278
+ ["authority", kit.getAddressEncoder()],
2279
+ ["namespace", kit.getAddressEncoder()],
2280
+ ["launchId", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
2281
+ ["phase", kit.getU8Encoder()],
2282
+ ["bump", kit.getU8Encoder()],
2283
+ ["launchAuthorityBump", kit.getU8Encoder()],
2284
+ ["pad0", kit.fixEncoderSize(kit.getBytesEncoder(), 5)],
2285
+ ["baseMint", kit.getAddressEncoder()],
2286
+ ["quoteMint", kit.getAddressEncoder()],
2287
+ ["baseVault", kit.getAddressEncoder()],
2288
+ ["quoteVault", kit.getAddressEncoder()],
2289
+ ["baseTotalSupply", kit.getU64Encoder()],
2290
+ ["baseForDistribution", kit.getU64Encoder()],
2291
+ ["baseForLiquidity", kit.getU64Encoder()],
2292
+ ["baseForCurve", kit.getU64Encoder()],
2293
+ ["curveVirtualBase", kit.getU64Encoder()],
2294
+ ["curveVirtualQuote", kit.getU64Encoder()],
2295
+ ["curveFeeBps", kit.getU16Encoder()],
2296
+ ["pad1", kit.fixEncoderSize(kit.getBytesEncoder(), 6)],
2297
+ ["allowBuy", kit.getU8Encoder()],
2298
+ ["allowSell", kit.getU8Encoder()],
2299
+ ["pad2", kit.fixEncoderSize(kit.getBytesEncoder(), 6)],
2300
+ ["sentinelProgram", kit.getAddressEncoder()],
2301
+ ["sentinelFlags", kit.getU32Encoder()],
2302
+ ["pad3", kit.fixEncoderSize(kit.getBytesEncoder(), 4)],
2303
+ ["sentinelCalldata", getCalldataBufEncoder2()],
2304
+ ["migratorProgram", kit.getAddressEncoder()],
2305
+ ["migratorInitCalldata", getCalldataBufEncoder2()],
2306
+ ["migratorMigrateCalldata", getCalldataBufEncoder2()],
2307
+ ["reserved", kit.fixEncoderSize(kit.getBytesEncoder(), 64)]
2308
+ ]),
2309
+ (value) => ({ ...value, discriminator: LAUNCH_DISCRIMINATOR2 })
2310
+ );
2311
+ }
2312
+ function getLaunchDecoder2() {
2313
+ return kit.getStructDecoder([
2314
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
2315
+ ["authority", kit.getAddressDecoder()],
2316
+ ["namespace", kit.getAddressDecoder()],
2317
+ ["launchId", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
2318
+ ["phase", kit.getU8Decoder()],
2319
+ ["bump", kit.getU8Decoder()],
2320
+ ["launchAuthorityBump", kit.getU8Decoder()],
2321
+ ["pad0", kit.fixDecoderSize(kit.getBytesDecoder(), 5)],
2322
+ ["baseMint", kit.getAddressDecoder()],
2323
+ ["quoteMint", kit.getAddressDecoder()],
2324
+ ["baseVault", kit.getAddressDecoder()],
2325
+ ["quoteVault", kit.getAddressDecoder()],
2326
+ ["baseTotalSupply", kit.getU64Decoder()],
2327
+ ["baseForDistribution", kit.getU64Decoder()],
2328
+ ["baseForLiquidity", kit.getU64Decoder()],
2329
+ ["baseForCurve", kit.getU64Decoder()],
2330
+ ["curveVirtualBase", kit.getU64Decoder()],
2331
+ ["curveVirtualQuote", kit.getU64Decoder()],
2332
+ ["curveFeeBps", kit.getU16Decoder()],
2333
+ ["pad1", kit.fixDecoderSize(kit.getBytesDecoder(), 6)],
2334
+ ["allowBuy", kit.getU8Decoder()],
2335
+ ["allowSell", kit.getU8Decoder()],
2336
+ ["pad2", kit.fixDecoderSize(kit.getBytesDecoder(), 6)],
2337
+ ["sentinelProgram", kit.getAddressDecoder()],
2338
+ ["sentinelFlags", kit.getU32Decoder()],
2339
+ ["pad3", kit.fixDecoderSize(kit.getBytesDecoder(), 4)],
2340
+ ["sentinelCalldata", getCalldataBufDecoder2()],
2341
+ ["migratorProgram", kit.getAddressDecoder()],
2342
+ ["migratorInitCalldata", getCalldataBufDecoder2()],
2343
+ ["migratorMigrateCalldata", getCalldataBufDecoder2()],
2344
+ ["reserved", kit.fixDecoderSize(kit.getBytesDecoder(), 64)]
2345
+ ]);
2346
+ }
2347
+ function getLaunchCodec2() {
2348
+ return kit.combineCodec(getLaunchEncoder2(), getLaunchDecoder2());
2349
+ }
2350
+ function decodeLaunch(encodedAccount) {
2351
+ return kit.decodeAccount(
2352
+ encodedAccount,
2353
+ getLaunchDecoder2()
2354
+ );
2355
+ }
2356
+ async function fetchLaunch(rpc, address3, config) {
2357
+ const maybeAccount = await fetchMaybeLaunch(rpc, address3, config);
2358
+ kit.assertAccountExists(maybeAccount);
2359
+ return maybeAccount;
2360
+ }
2361
+ async function fetchMaybeLaunch(rpc, address3, config) {
2362
+ const maybeAccount = await kit.fetchEncodedAccount(rpc, address3, config);
2363
+ return decodeLaunch(maybeAccount);
2364
+ }
2365
+ async function fetchAllLaunch(rpc, addresses, config) {
2366
+ const maybeAccounts = await fetchAllMaybeLaunch(rpc, addresses, config);
2367
+ kit.assertAccountsExist(maybeAccounts);
2368
+ return maybeAccounts;
2369
+ }
2370
+ async function fetchAllMaybeLaunch(rpc, addresses, config) {
2371
+ const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
2372
+ return maybeAccounts.map((maybeAccount) => decodeLaunch(maybeAccount));
2373
+ }
2374
+ function getLaunchSize() {
2375
+ return 1214;
2376
+ }
2377
+ var MARKET_DISCRIMINATOR = new Uint8Array([
2378
+ 219,
2379
+ 190,
2380
+ 213,
2381
+ 55,
2382
+ 0,
2383
+ 227,
2384
+ 198,
2385
+ 154
2386
+ ]);
2387
+ function getMarketDiscriminatorBytes() {
2388
+ return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(MARKET_DISCRIMINATOR);
2389
+ }
2390
+ function getMarketEncoder() {
2391
+ return kit.transformEncoder(
2392
+ kit.getStructEncoder([
2393
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
2394
+ ["oracle", kit.getAddressEncoder()],
2395
+ ["quoteMint", kit.getAddressEncoder()],
2396
+ ["potVault", kit.getAddressEncoder()],
2397
+ ["totalPot", kit.getU64Encoder()],
2398
+ ["totalClaimed", kit.getU64Encoder()],
2399
+ ["winnerMint", kit.getAddressEncoder()],
2400
+ ["claimableSupply", kit.getU64Encoder()],
2401
+ ["accQuotePerToken", kit.getU128Encoder()],
2402
+ ["isResolved", kit.getBooleanEncoder()],
2403
+ ["bump", kit.getU8Encoder()],
2404
+ ["marketAuthorityBump", kit.getU8Encoder()],
2405
+ ["reserved", kit.fixEncoderSize(kit.getBytesEncoder(), 29)]
2406
+ ]),
2407
+ (value) => ({ ...value, discriminator: MARKET_DISCRIMINATOR })
2408
+ );
2409
+ }
2410
+ function getMarketDecoder() {
2411
+ return kit.getStructDecoder([
2412
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
2413
+ ["oracle", kit.getAddressDecoder()],
2414
+ ["quoteMint", kit.getAddressDecoder()],
2415
+ ["potVault", kit.getAddressDecoder()],
2416
+ ["totalPot", kit.getU64Decoder()],
2417
+ ["totalClaimed", kit.getU64Decoder()],
2418
+ ["winnerMint", kit.getAddressDecoder()],
2419
+ ["claimableSupply", kit.getU64Decoder()],
2420
+ ["accQuotePerToken", kit.getU128Decoder()],
2421
+ ["isResolved", kit.getBooleanDecoder()],
2422
+ ["bump", kit.getU8Decoder()],
2423
+ ["marketAuthorityBump", kit.getU8Decoder()],
2424
+ ["reserved", kit.fixDecoderSize(kit.getBytesDecoder(), 29)]
2425
+ ]);
2426
+ }
2427
+ function getMarketCodec() {
2428
+ return kit.combineCodec(getMarketEncoder(), getMarketDecoder());
2429
+ }
2430
+ function decodeMarket(encodedAccount) {
2431
+ return kit.decodeAccount(
2432
+ encodedAccount,
2433
+ getMarketDecoder()
2434
+ );
2435
+ }
2436
+ async function fetchMarket(rpc, address3, config) {
2437
+ const maybeAccount = await fetchMaybeMarket(rpc, address3, config);
2438
+ kit.assertAccountExists(maybeAccount);
2439
+ return maybeAccount;
2440
+ }
2441
+ async function fetchMaybeMarket(rpc, address3, config) {
2442
+ const maybeAccount = await kit.fetchEncodedAccount(rpc, address3, config);
2443
+ return decodeMarket(maybeAccount);
2444
+ }
2445
+ async function fetchAllMarket(rpc, addresses, config) {
2446
+ const maybeAccounts = await fetchAllMaybeMarket(rpc, addresses, config);
2447
+ kit.assertAccountsExist(maybeAccounts);
2448
+ return maybeAccounts;
2449
+ }
2450
+ async function fetchAllMaybeMarket(rpc, addresses, config) {
2451
+ const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
2452
+ return maybeAccounts.map((maybeAccount) => decodeMarket(maybeAccount));
2453
+ }
2454
+ function getMarketSize() {
2455
+ return 208;
2456
+ }
2457
+ var ORACLE_STATE_DISCRIMINATOR = new Uint8Array([
2458
+ 97,
2459
+ 156,
2460
+ 157,
2461
+ 189,
2462
+ 194,
2463
+ 73,
2464
+ 8,
2465
+ 15
2466
+ ]);
2467
+ function getOracleStateDiscriminatorBytes() {
2468
+ return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
2469
+ ORACLE_STATE_DISCRIMINATOR
2470
+ );
2471
+ }
2472
+ function getOracleStateEncoder() {
2473
+ return kit.transformEncoder(
2474
+ kit.getStructEncoder([
2475
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
2476
+ ["oracleAuthority", kit.getAddressEncoder()],
2477
+ ["quoteMint", kit.getAddressEncoder()],
2478
+ ["isFinalized", kit.getBooleanEncoder()],
2479
+ ["winningMint", kit.getAddressEncoder()],
2480
+ ["nonce", kit.getU64Encoder()],
2481
+ ["bump", kit.getU8Encoder()],
2482
+ ["reserved", kit.fixEncoderSize(kit.getBytesEncoder(), 31)]
2483
+ ]),
2484
+ (value) => ({ ...value, discriminator: ORACLE_STATE_DISCRIMINATOR })
2485
+ );
2486
+ }
2487
+ function getOracleStateDecoder() {
2488
+ return kit.getStructDecoder([
2489
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
2490
+ ["oracleAuthority", kit.getAddressDecoder()],
2491
+ ["quoteMint", kit.getAddressDecoder()],
2492
+ ["isFinalized", kit.getBooleanDecoder()],
2493
+ ["winningMint", kit.getAddressDecoder()],
2494
+ ["nonce", kit.getU64Decoder()],
2495
+ ["bump", kit.getU8Decoder()],
2496
+ ["reserved", kit.fixDecoderSize(kit.getBytesDecoder(), 31)]
2497
+ ]);
2498
+ }
2499
+ function getOracleStateCodec() {
2500
+ return kit.combineCodec(getOracleStateEncoder(), getOracleStateDecoder());
2501
+ }
2502
+ function decodeOracleState2(encodedAccount) {
2503
+ return kit.decodeAccount(
2504
+ encodedAccount,
2505
+ getOracleStateDecoder()
2506
+ );
2507
+ }
2508
+ async function fetchOracleState(rpc, address3, config) {
2509
+ const maybeAccount = await fetchMaybeOracleState(rpc, address3, config);
2510
+ kit.assertAccountExists(maybeAccount);
2511
+ return maybeAccount;
2512
+ }
2513
+ async function fetchMaybeOracleState(rpc, address3, config) {
2514
+ const maybeAccount = await kit.fetchEncodedAccount(rpc, address3, config);
2515
+ return decodeOracleState2(maybeAccount);
2516
+ }
2517
+ async function fetchAllOracleState(rpc, addresses, config) {
2518
+ const maybeAccounts = await fetchAllMaybeOracleState(rpc, addresses, config);
2519
+ kit.assertAccountsExist(maybeAccounts);
2520
+ return maybeAccounts;
2521
+ }
2522
+ async function fetchAllMaybeOracleState(rpc, addresses, config) {
2523
+ const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
2524
+ return maybeAccounts.map((maybeAccount) => decodeOracleState2(maybeAccount));
2525
+ }
2526
+ function getOracleStateSize() {
2527
+ return 145;
2528
+ }
2529
+ var CLAIM_DISCRIMINATOR = new Uint8Array([
2530
+ 62,
2531
+ 198,
2532
+ 214,
2533
+ 193,
2534
+ 213,
2535
+ 159,
2536
+ 108,
2537
+ 210
2538
+ ]);
2539
+ function getClaimDiscriminatorBytes() {
2540
+ return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(CLAIM_DISCRIMINATOR);
2541
+ }
2542
+ function getClaimInstructionDataEncoder() {
2543
+ return kit.transformEncoder(
2544
+ kit.getStructEncoder([
2545
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
2546
+ ["burnAmount", kit.getU64Encoder()]
2547
+ ]),
2548
+ (value) => ({ ...value, discriminator: CLAIM_DISCRIMINATOR })
2549
+ );
2550
+ }
2551
+ function getClaimInstructionDataDecoder() {
2552
+ return kit.getStructDecoder([
2553
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
2554
+ ["burnAmount", kit.getU64Decoder()]
2555
+ ]);
2556
+ }
2557
+ function getClaimInstructionDataCodec() {
2558
+ return kit.combineCodec(
2559
+ getClaimInstructionDataEncoder(),
2560
+ getClaimInstructionDataDecoder()
2561
+ );
2562
+ }
2563
+ async function getClaimInstructionAsync(input, config) {
2564
+ const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
2565
+ const originalAccounts = {
2566
+ market: { value: input.market ?? null, isWritable: true },
2567
+ marketAuthority: {
2568
+ value: input.marketAuthority ?? null,
2569
+ isWritable: false
2570
+ },
2571
+ potVault: { value: input.potVault ?? null, isWritable: true },
2572
+ winnerMint: { value: input.winnerMint ?? null, isWritable: true },
2573
+ entryByMint: { value: input.entryByMint ?? null, isWritable: false },
2574
+ claimerWinnerAta: {
2575
+ value: input.claimerWinnerAta ?? null,
2576
+ isWritable: true
2577
+ },
2578
+ claimerQuoteAta: { value: input.claimerQuoteAta ?? null, isWritable: true },
2579
+ claimer: { value: input.claimer ?? null, isWritable: false },
2580
+ receipt: { value: input.receipt ?? null, isWritable: true },
2581
+ payer: { value: input.payer ?? null, isWritable: true },
2582
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
2583
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
2584
+ };
2585
+ const accounts = originalAccounts;
2586
+ const args = { ...input };
2587
+ if (!accounts.marketAuthority.value) {
2588
+ accounts.marketAuthority.value = await kit.getProgramDerivedAddress({
2589
+ programAddress,
2590
+ seeds: [
2591
+ kit.getBytesEncoder().encode(
2592
+ new Uint8Array([
2593
+ 109,
2594
+ 97,
2595
+ 114,
2596
+ 107,
2597
+ 101,
2598
+ 116,
2599
+ 95,
2600
+ 97,
2601
+ 117,
2602
+ 116,
2603
+ 104,
2604
+ 111,
2605
+ 114,
2606
+ 105,
2607
+ 116,
2608
+ 121
2609
+ ])
2610
+ ),
2611
+ kit.getAddressEncoder().encode(
2612
+ programClientCore.getAddressFromResolvedInstructionAccount(
2613
+ "market",
2614
+ accounts.market.value
2615
+ )
2616
+ )
2617
+ ]
2618
+ });
2619
+ }
2620
+ if (!accounts.receipt.value) {
2621
+ accounts.receipt.value = await kit.getProgramDerivedAddress({
2622
+ programAddress,
2623
+ seeds: [
2624
+ kit.getBytesEncoder().encode(
2625
+ new Uint8Array([114, 101, 99, 101, 105, 112, 116])
2626
+ ),
2627
+ kit.getAddressEncoder().encode(
2628
+ programClientCore.getAddressFromResolvedInstructionAccount(
2629
+ "market",
2630
+ accounts.market.value
2631
+ )
2632
+ ),
2633
+ kit.getAddressEncoder().encode(
2634
+ programClientCore.getAddressFromResolvedInstructionAccount(
2635
+ "claimer",
2636
+ accounts.claimer.value
2637
+ )
2638
+ )
2639
+ ]
2640
+ });
2641
+ }
2642
+ if (!accounts.tokenProgram.value) {
2643
+ accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2644
+ }
2645
+ if (!accounts.systemProgram.value) {
2646
+ accounts.systemProgram.value = "11111111111111111111111111111111";
2647
+ }
2648
+ const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
2649
+ return Object.freeze({
2650
+ accounts: [
2651
+ getAccountMeta("market", accounts.market),
2652
+ getAccountMeta("marketAuthority", accounts.marketAuthority),
2653
+ getAccountMeta("potVault", accounts.potVault),
2654
+ getAccountMeta("winnerMint", accounts.winnerMint),
2655
+ getAccountMeta("entryByMint", accounts.entryByMint),
2656
+ getAccountMeta("claimerWinnerAta", accounts.claimerWinnerAta),
2657
+ getAccountMeta("claimerQuoteAta", accounts.claimerQuoteAta),
2658
+ getAccountMeta("claimer", accounts.claimer),
2659
+ getAccountMeta("receipt", accounts.receipt),
2660
+ getAccountMeta("payer", accounts.payer),
2661
+ getAccountMeta("tokenProgram", accounts.tokenProgram),
2662
+ getAccountMeta("systemProgram", accounts.systemProgram)
2663
+ ],
2664
+ data: getClaimInstructionDataEncoder().encode(
2665
+ args
2666
+ ),
2667
+ programAddress
2668
+ });
2669
+ }
2670
+ function getClaimInstruction(input, config) {
2671
+ const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
2672
+ const originalAccounts = {
2673
+ market: { value: input.market ?? null, isWritable: true },
2674
+ marketAuthority: {
2675
+ value: input.marketAuthority ?? null,
2676
+ isWritable: false
2677
+ },
2678
+ potVault: { value: input.potVault ?? null, isWritable: true },
2679
+ winnerMint: { value: input.winnerMint ?? null, isWritable: true },
2680
+ entryByMint: { value: input.entryByMint ?? null, isWritable: false },
2681
+ claimerWinnerAta: {
2682
+ value: input.claimerWinnerAta ?? null,
2683
+ isWritable: true
2684
+ },
2685
+ claimerQuoteAta: { value: input.claimerQuoteAta ?? null, isWritable: true },
2686
+ claimer: { value: input.claimer ?? null, isWritable: false },
2687
+ receipt: { value: input.receipt ?? null, isWritable: true },
2688
+ payer: { value: input.payer ?? null, isWritable: true },
2689
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
2690
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
2691
+ };
2692
+ const accounts = originalAccounts;
2693
+ const args = { ...input };
2694
+ if (!accounts.tokenProgram.value) {
2695
+ accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2696
+ }
2697
+ if (!accounts.systemProgram.value) {
2698
+ accounts.systemProgram.value = "11111111111111111111111111111111";
2699
+ }
2700
+ const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
2701
+ return Object.freeze({
2702
+ accounts: [
2703
+ getAccountMeta("market", accounts.market),
2704
+ getAccountMeta("marketAuthority", accounts.marketAuthority),
2705
+ getAccountMeta("potVault", accounts.potVault),
2706
+ getAccountMeta("winnerMint", accounts.winnerMint),
2707
+ getAccountMeta("entryByMint", accounts.entryByMint),
2708
+ getAccountMeta("claimerWinnerAta", accounts.claimerWinnerAta),
2709
+ getAccountMeta("claimerQuoteAta", accounts.claimerQuoteAta),
2710
+ getAccountMeta("claimer", accounts.claimer),
2711
+ getAccountMeta("receipt", accounts.receipt),
2712
+ getAccountMeta("payer", accounts.payer),
2713
+ getAccountMeta("tokenProgram", accounts.tokenProgram),
2714
+ getAccountMeta("systemProgram", accounts.systemProgram)
2715
+ ],
2716
+ data: getClaimInstructionDataEncoder().encode(
2717
+ args
2718
+ ),
2719
+ programAddress
2720
+ });
2721
+ }
2722
+ function parseClaimInstruction(instruction) {
2723
+ if (instruction.accounts.length < 12) {
2724
+ throw new kit.SolanaError(
2725
+ kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2726
+ {
2727
+ actualAccountMetas: instruction.accounts.length,
2728
+ expectedAccountMetas: 12
2729
+ }
2730
+ );
2731
+ }
2732
+ let accountIndex = 0;
2733
+ const getNextAccount = () => {
2734
+ const accountMeta = instruction.accounts[accountIndex];
2735
+ accountIndex += 1;
2736
+ return accountMeta;
2737
+ };
2738
+ return {
2739
+ programAddress: instruction.programAddress,
2740
+ accounts: {
2741
+ market: getNextAccount(),
2742
+ marketAuthority: getNextAccount(),
2743
+ potVault: getNextAccount(),
2744
+ winnerMint: getNextAccount(),
2745
+ entryByMint: getNextAccount(),
2746
+ claimerWinnerAta: getNextAccount(),
2747
+ claimerQuoteAta: getNextAccount(),
2748
+ claimer: getNextAccount(),
2749
+ receipt: getNextAccount(),
2750
+ payer: getNextAccount(),
2751
+ tokenProgram: getNextAccount(),
2752
+ systemProgram: getNextAccount()
2753
+ },
2754
+ data: getClaimInstructionDataDecoder().decode(instruction.data)
2755
+ };
2756
+ }
2757
+ var MIGRATE_ENTRY_DISCRIMINATOR = new Uint8Array([
2758
+ 239,
2759
+ 154,
2760
+ 55,
2761
+ 173,
2762
+ 110,
2763
+ 36,
2764
+ 188,
2765
+ 214
2766
+ ]);
2767
+ function getMigrateEntryDiscriminatorBytes() {
2768
+ return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
2769
+ MIGRATE_ENTRY_DISCRIMINATOR
2770
+ );
2771
+ }
2772
+ function getMigrateEntryInstructionDataEncoder() {
2773
+ return kit.transformEncoder(
2774
+ kit.getStructEncoder([
2775
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
2776
+ ["entryId", kit.fixEncoderSize(kit.getBytesEncoder(), 32)]
2777
+ ]),
2778
+ (value) => ({ ...value, discriminator: MIGRATE_ENTRY_DISCRIMINATOR })
2779
+ );
2780
+ }
2781
+ function getMigrateEntryInstructionDataDecoder() {
2782
+ return kit.getStructDecoder([
2783
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
2784
+ ["entryId", kit.fixDecoderSize(kit.getBytesDecoder(), 32)]
2785
+ ]);
2786
+ }
2787
+ function getMigrateEntryInstructionDataCodec() {
2788
+ return kit.combineCodec(
2789
+ getMigrateEntryInstructionDataEncoder(),
2790
+ getMigrateEntryInstructionDataDecoder()
2791
+ );
2792
+ }
2793
+ async function getMigrateEntryInstructionAsync(input, config) {
2794
+ const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
2795
+ const originalAccounts = {
2796
+ initializerConfig: {
2797
+ value: input.initializerConfig ?? null,
2798
+ isWritable: false
2799
+ },
2800
+ launch: { value: input.launch ?? null, isWritable: false },
2801
+ launchAuthority: {
2802
+ value: input.launchAuthority ?? null,
2803
+ isWritable: false
2804
+ },
2805
+ baseMint: { value: input.baseMint ?? null, isWritable: true },
2806
+ quoteMint: { value: input.quoteMint ?? null, isWritable: false },
2807
+ baseVault: { value: input.baseVault ?? null, isWritable: true },
2808
+ quoteVault: { value: input.quoteVault ?? null, isWritable: true },
2809
+ payer: { value: input.payer ?? null, isWritable: true },
2810
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
2811
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
2812
+ rent: { value: input.rent ?? null, isWritable: false },
2813
+ oracle: { value: input.oracle ?? null, isWritable: false },
2814
+ market: { value: input.market ?? null, isWritable: true },
2815
+ potVault: { value: input.potVault ?? null, isWritable: true },
2816
+ marketAuthority: {
2817
+ value: input.marketAuthority ?? null,
2818
+ isWritable: false
2819
+ },
2820
+ entry: { value: input.entry ?? null, isWritable: true },
2821
+ entryByMint: { value: input.entryByMint ?? null, isWritable: false }
2822
+ };
2823
+ const accounts = originalAccounts;
2824
+ const args = { ...input };
2825
+ if (!accounts.tokenProgram.value) {
2826
+ accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2827
+ }
2828
+ if (!accounts.systemProgram.value) {
2829
+ accounts.systemProgram.value = "11111111111111111111111111111111";
2830
+ }
2831
+ if (!accounts.rent.value) {
2832
+ accounts.rent.value = "SysvarRent111111111111111111111111111111111";
2833
+ }
2834
+ if (!accounts.market.value) {
2835
+ accounts.market.value = await kit.getProgramDerivedAddress({
2836
+ programAddress,
2837
+ seeds: [
2838
+ kit.getBytesEncoder().encode(new Uint8Array([109, 97, 114, 107, 101, 116])),
2839
+ kit.getAddressEncoder().encode(
2840
+ programClientCore.getAddressFromResolvedInstructionAccount(
2841
+ "oracle",
2842
+ accounts.oracle.value
2843
+ )
2844
+ )
2845
+ ]
2846
+ });
2847
+ }
2848
+ if (!accounts.marketAuthority.value) {
2849
+ accounts.marketAuthority.value = await kit.getProgramDerivedAddress({
2850
+ programAddress,
2851
+ seeds: [
2852
+ kit.getBytesEncoder().encode(
2853
+ new Uint8Array([
2854
+ 109,
2855
+ 97,
2856
+ 114,
2857
+ 107,
2858
+ 101,
2859
+ 116,
2860
+ 95,
2861
+ 97,
2862
+ 117,
2863
+ 116,
2864
+ 104,
2865
+ 111,
2866
+ 114,
2867
+ 105,
2868
+ 116,
2869
+ 121
2870
+ ])
2871
+ ),
2872
+ kit.getAddressEncoder().encode(
2873
+ programClientCore.getAddressFromResolvedInstructionAccount(
2874
+ "market",
2875
+ accounts.market.value
2876
+ )
2877
+ )
2878
+ ]
2879
+ });
2880
+ }
2881
+ if (!accounts.entryByMint.value) {
2882
+ accounts.entryByMint.value = await kit.getProgramDerivedAddress({
2883
+ programAddress,
2884
+ seeds: [
2885
+ kit.getBytesEncoder().encode(
2886
+ new Uint8Array([
2887
+ 101,
2888
+ 110,
2889
+ 116,
2890
+ 114,
2891
+ 121,
2892
+ 95,
2893
+ 98,
2894
+ 121,
2895
+ 95,
2896
+ 109,
2897
+ 105,
2898
+ 110,
2899
+ 116
2900
+ ])
2901
+ ),
2902
+ kit.getAddressEncoder().encode(
2903
+ programClientCore.getAddressFromResolvedInstructionAccount(
2904
+ "oracle",
2905
+ accounts.oracle.value
2906
+ )
2907
+ ),
2908
+ kit.getAddressEncoder().encode(
2909
+ programClientCore.getAddressFromResolvedInstructionAccount(
2910
+ "baseMint",
2911
+ accounts.baseMint.value
2912
+ )
2913
+ )
2914
+ ]
2915
+ });
2916
+ }
2917
+ const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
2918
+ return Object.freeze({
2919
+ accounts: [
2920
+ getAccountMeta("initializerConfig", accounts.initializerConfig),
2921
+ getAccountMeta("launch", accounts.launch),
2922
+ getAccountMeta("launchAuthority", accounts.launchAuthority),
2923
+ getAccountMeta("baseMint", accounts.baseMint),
2924
+ getAccountMeta("quoteMint", accounts.quoteMint),
2925
+ getAccountMeta("baseVault", accounts.baseVault),
2926
+ getAccountMeta("quoteVault", accounts.quoteVault),
2927
+ getAccountMeta("payer", accounts.payer),
2928
+ getAccountMeta("tokenProgram", accounts.tokenProgram),
2929
+ getAccountMeta("systemProgram", accounts.systemProgram),
2930
+ getAccountMeta("rent", accounts.rent),
2931
+ getAccountMeta("oracle", accounts.oracle),
2932
+ getAccountMeta("market", accounts.market),
2933
+ getAccountMeta("potVault", accounts.potVault),
2934
+ getAccountMeta("marketAuthority", accounts.marketAuthority),
2935
+ getAccountMeta("entry", accounts.entry),
2936
+ getAccountMeta("entryByMint", accounts.entryByMint)
2937
+ ],
2938
+ data: getMigrateEntryInstructionDataEncoder().encode(
2939
+ args
2940
+ ),
2941
+ programAddress
2942
+ });
2943
+ }
2944
+ function getMigrateEntryInstruction(input, config) {
2945
+ const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
2946
+ const originalAccounts = {
2947
+ initializerConfig: {
2948
+ value: input.initializerConfig ?? null,
2949
+ isWritable: false
2950
+ },
2951
+ launch: { value: input.launch ?? null, isWritable: false },
2952
+ launchAuthority: {
2953
+ value: input.launchAuthority ?? null,
2954
+ isWritable: false
2955
+ },
2956
+ baseMint: { value: input.baseMint ?? null, isWritable: true },
2957
+ quoteMint: { value: input.quoteMint ?? null, isWritable: false },
2958
+ baseVault: { value: input.baseVault ?? null, isWritable: true },
2959
+ quoteVault: { value: input.quoteVault ?? null, isWritable: true },
2960
+ payer: { value: input.payer ?? null, isWritable: true },
2961
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
2962
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
2963
+ rent: { value: input.rent ?? null, isWritable: false },
2964
+ oracle: { value: input.oracle ?? null, isWritable: false },
2965
+ market: { value: input.market ?? null, isWritable: true },
2966
+ potVault: { value: input.potVault ?? null, isWritable: true },
2967
+ marketAuthority: {
2968
+ value: input.marketAuthority ?? null,
2969
+ isWritable: false
2970
+ },
2971
+ entry: { value: input.entry ?? null, isWritable: true },
2972
+ entryByMint: { value: input.entryByMint ?? null, isWritable: false }
2973
+ };
2974
+ const accounts = originalAccounts;
2975
+ const args = { ...input };
2976
+ if (!accounts.tokenProgram.value) {
2977
+ accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2978
+ }
2979
+ if (!accounts.systemProgram.value) {
2980
+ accounts.systemProgram.value = "11111111111111111111111111111111";
2981
+ }
2982
+ if (!accounts.rent.value) {
2983
+ accounts.rent.value = "SysvarRent111111111111111111111111111111111";
2984
+ }
2985
+ const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
2986
+ return Object.freeze({
2987
+ accounts: [
2988
+ getAccountMeta("initializerConfig", accounts.initializerConfig),
2989
+ getAccountMeta("launch", accounts.launch),
2990
+ getAccountMeta("launchAuthority", accounts.launchAuthority),
2991
+ getAccountMeta("baseMint", accounts.baseMint),
2992
+ getAccountMeta("quoteMint", accounts.quoteMint),
2993
+ getAccountMeta("baseVault", accounts.baseVault),
2994
+ getAccountMeta("quoteVault", accounts.quoteVault),
2995
+ getAccountMeta("payer", accounts.payer),
2996
+ getAccountMeta("tokenProgram", accounts.tokenProgram),
2997
+ getAccountMeta("systemProgram", accounts.systemProgram),
2998
+ getAccountMeta("rent", accounts.rent),
2999
+ getAccountMeta("oracle", accounts.oracle),
3000
+ getAccountMeta("market", accounts.market),
3001
+ getAccountMeta("potVault", accounts.potVault),
3002
+ getAccountMeta("marketAuthority", accounts.marketAuthority),
3003
+ getAccountMeta("entry", accounts.entry),
3004
+ getAccountMeta("entryByMint", accounts.entryByMint)
3005
+ ],
3006
+ data: getMigrateEntryInstructionDataEncoder().encode(
3007
+ args
3008
+ ),
3009
+ programAddress
3010
+ });
3011
+ }
3012
+ function parseMigrateEntryInstruction(instruction) {
3013
+ if (instruction.accounts.length < 17) {
3014
+ throw new kit.SolanaError(
3015
+ kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3016
+ {
3017
+ actualAccountMetas: instruction.accounts.length,
3018
+ expectedAccountMetas: 17
3019
+ }
3020
+ );
3021
+ }
3022
+ let accountIndex = 0;
3023
+ const getNextAccount = () => {
3024
+ const accountMeta = instruction.accounts[accountIndex];
3025
+ accountIndex += 1;
3026
+ return accountMeta;
3027
+ };
3028
+ return {
3029
+ programAddress: instruction.programAddress,
3030
+ accounts: {
3031
+ initializerConfig: getNextAccount(),
3032
+ launch: getNextAccount(),
3033
+ launchAuthority: getNextAccount(),
3034
+ baseMint: getNextAccount(),
3035
+ quoteMint: getNextAccount(),
3036
+ baseVault: getNextAccount(),
3037
+ quoteVault: getNextAccount(),
3038
+ payer: getNextAccount(),
3039
+ tokenProgram: getNextAccount(),
3040
+ systemProgram: getNextAccount(),
3041
+ rent: getNextAccount(),
3042
+ oracle: getNextAccount(),
3043
+ market: getNextAccount(),
3044
+ potVault: getNextAccount(),
3045
+ marketAuthority: getNextAccount(),
3046
+ entry: getNextAccount(),
3047
+ entryByMint: getNextAccount()
3048
+ },
3049
+ data: getMigrateEntryInstructionDataDecoder().decode(instruction.data)
3050
+ };
3051
+ }
3052
+ var PREVIEW_PAYOUT_IF_WINNER_DISCRIMINATOR = new Uint8Array([
3053
+ 228,
3054
+ 144,
3055
+ 72,
3056
+ 185,
3057
+ 234,
3058
+ 186,
3059
+ 183,
3060
+ 143
3061
+ ]);
3062
+ function getPreviewPayoutIfWinnerDiscriminatorBytes() {
3063
+ return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
3064
+ PREVIEW_PAYOUT_IF_WINNER_DISCRIMINATOR
3065
+ );
3066
+ }
3067
+ function getPreviewPayoutIfWinnerInstructionDataEncoder() {
3068
+ return kit.transformEncoder(
3069
+ kit.getStructEncoder([
3070
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
3071
+ ["candidateWinnerMint", kit.getAddressEncoder()],
3072
+ ["tokenAmount", kit.getU64Encoder()]
3073
+ ]),
3074
+ (value) => ({
3075
+ ...value,
3076
+ discriminator: PREVIEW_PAYOUT_IF_WINNER_DISCRIMINATOR
3077
+ })
3078
+ );
3079
+ }
3080
+ function getPreviewPayoutIfWinnerInstructionDataDecoder() {
3081
+ return kit.getStructDecoder([
3082
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
3083
+ ["candidateWinnerMint", kit.getAddressDecoder()],
3084
+ ["tokenAmount", kit.getU64Decoder()]
3085
+ ]);
3086
+ }
3087
+ function getPreviewPayoutIfWinnerInstructionDataCodec() {
3088
+ return kit.combineCodec(
3089
+ getPreviewPayoutIfWinnerInstructionDataEncoder(),
3090
+ getPreviewPayoutIfWinnerInstructionDataDecoder()
3091
+ );
3092
+ }
3093
+ function getPreviewPayoutIfWinnerInstruction(input, config) {
3094
+ const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
3095
+ const originalAccounts = {
3096
+ market: { value: input.market ?? null, isWritable: false },
3097
+ candidateMint: { value: input.candidateMint ?? null, isWritable: false }
3098
+ };
3099
+ const accounts = originalAccounts;
3100
+ const args = { ...input };
3101
+ const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
3102
+ return Object.freeze({
3103
+ accounts: [
3104
+ getAccountMeta("market", accounts.market),
3105
+ getAccountMeta("candidateMint", accounts.candidateMint)
3106
+ ],
3107
+ data: getPreviewPayoutIfWinnerInstructionDataEncoder().encode(
3108
+ args
3109
+ ),
3110
+ programAddress
3111
+ });
3112
+ }
3113
+ function parsePreviewPayoutIfWinnerInstruction(instruction) {
3114
+ if (instruction.accounts.length < 2) {
3115
+ throw new kit.SolanaError(
3116
+ kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3117
+ {
3118
+ actualAccountMetas: instruction.accounts.length,
3119
+ expectedAccountMetas: 2
3120
+ }
3121
+ );
3122
+ }
3123
+ let accountIndex = 0;
3124
+ const getNextAccount = () => {
3125
+ const accountMeta = instruction.accounts[accountIndex];
3126
+ accountIndex += 1;
3127
+ return accountMeta;
3128
+ };
3129
+ return {
3130
+ programAddress: instruction.programAddress,
3131
+ accounts: { market: getNextAccount(), candidateMint: getNextAccount() },
3132
+ data: getPreviewPayoutIfWinnerInstructionDataDecoder().decode(
3133
+ instruction.data
3134
+ )
3135
+ };
3136
+ }
3137
+ var REGISTER_ENTRY_DISCRIMINATOR = new Uint8Array([
3138
+ 198,
3139
+ 25,
3140
+ 1,
3141
+ 183,
3142
+ 73,
3143
+ 219,
3144
+ 215,
3145
+ 14
3146
+ ]);
3147
+ function getRegisterEntryDiscriminatorBytes() {
3148
+ return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
3149
+ REGISTER_ENTRY_DISCRIMINATOR
3150
+ );
3151
+ }
3152
+ function getRegisterEntryInstructionDataEncoder() {
3153
+ return kit.transformEncoder(
3154
+ kit.getStructEncoder([
3155
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
3156
+ ["entryId", kit.fixEncoderSize(kit.getBytesEncoder(), 32)]
3157
+ ]),
3158
+ (value) => ({ ...value, discriminator: REGISTER_ENTRY_DISCRIMINATOR })
3159
+ );
3160
+ }
3161
+ function getRegisterEntryInstructionDataDecoder() {
3162
+ return kit.getStructDecoder([
3163
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
3164
+ ["entryId", kit.fixDecoderSize(kit.getBytesDecoder(), 32)]
3165
+ ]);
3166
+ }
3167
+ function getRegisterEntryInstructionDataCodec() {
3168
+ return kit.combineCodec(
3169
+ getRegisterEntryInstructionDataEncoder(),
3170
+ getRegisterEntryInstructionDataDecoder()
3171
+ );
3172
+ }
3173
+ async function getRegisterEntryInstructionAsync(input, config) {
3174
+ const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
3175
+ const originalAccounts = {
3176
+ initializerConfig: {
3177
+ value: input.initializerConfig ?? null,
3178
+ isWritable: false
3179
+ },
3180
+ launch: { value: input.launch ?? null, isWritable: false },
3181
+ launchAuthority: {
3182
+ value: input.launchAuthority ?? null,
3183
+ isWritable: false
3184
+ },
3185
+ baseMint: { value: input.baseMint ?? null, isWritable: false },
3186
+ quoteMint: { value: input.quoteMint ?? null, isWritable: false },
3187
+ baseVault: { value: input.baseVault ?? null, isWritable: false },
3188
+ quoteVault: { value: input.quoteVault ?? null, isWritable: false },
3189
+ payer: { value: input.payer ?? null, isWritable: true },
3190
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
3191
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
3192
+ rent: { value: input.rent ?? null, isWritable: false },
3193
+ oracle: { value: input.oracle ?? null, isWritable: false },
3194
+ market: { value: input.market ?? null, isWritable: true },
3195
+ potVault: { value: input.potVault ?? null, isWritable: true },
3196
+ marketAuthority: {
3197
+ value: input.marketAuthority ?? null,
3198
+ isWritable: false
3199
+ },
3200
+ entry: { value: input.entry ?? null, isWritable: true },
3201
+ entryByMint: { value: input.entryByMint ?? null, isWritable: true }
3202
+ };
3203
+ const accounts = originalAccounts;
3204
+ const args = { ...input };
3205
+ if (!accounts.tokenProgram.value) {
3206
+ accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
3207
+ }
3208
+ if (!accounts.systemProgram.value) {
3209
+ accounts.systemProgram.value = "11111111111111111111111111111111";
3210
+ }
3211
+ if (!accounts.rent.value) {
3212
+ accounts.rent.value = "SysvarRent111111111111111111111111111111111";
3213
+ }
3214
+ if (!accounts.market.value) {
3215
+ accounts.market.value = await kit.getProgramDerivedAddress({
3216
+ programAddress,
3217
+ seeds: [
3218
+ kit.getBytesEncoder().encode(new Uint8Array([109, 97, 114, 107, 101, 116])),
3219
+ kit.getAddressEncoder().encode(
3220
+ programClientCore.getAddressFromResolvedInstructionAccount(
3221
+ "oracle",
3222
+ accounts.oracle.value
3223
+ )
3224
+ )
3225
+ ]
3226
+ });
3227
+ }
3228
+ if (!accounts.potVault.value) {
3229
+ accounts.potVault.value = await kit.getProgramDerivedAddress({
3230
+ programAddress,
3231
+ seeds: [
3232
+ kit.getBytesEncoder().encode(
3233
+ new Uint8Array([112, 111, 116, 95, 118, 97, 117, 108, 116])
3234
+ ),
3235
+ kit.getAddressEncoder().encode(
3236
+ programClientCore.getAddressFromResolvedInstructionAccount(
3237
+ "market",
3238
+ accounts.market.value
3239
+ )
3240
+ )
3241
+ ]
3242
+ });
3243
+ }
3244
+ if (!accounts.marketAuthority.value) {
3245
+ accounts.marketAuthority.value = await kit.getProgramDerivedAddress({
3246
+ programAddress,
3247
+ seeds: [
3248
+ kit.getBytesEncoder().encode(
3249
+ new Uint8Array([
3250
+ 109,
3251
+ 97,
3252
+ 114,
3253
+ 107,
3254
+ 101,
3255
+ 116,
3256
+ 95,
3257
+ 97,
3258
+ 117,
3259
+ 116,
3260
+ 104,
3261
+ 111,
3262
+ 114,
3263
+ 105,
3264
+ 116,
3265
+ 121
3266
+ ])
3267
+ ),
3268
+ kit.getAddressEncoder().encode(
3269
+ programClientCore.getAddressFromResolvedInstructionAccount(
3270
+ "market",
3271
+ accounts.market.value
3272
+ )
3273
+ )
3274
+ ]
3275
+ });
3276
+ }
3277
+ if (!accounts.entryByMint.value) {
3278
+ accounts.entryByMint.value = await kit.getProgramDerivedAddress({
3279
+ programAddress,
3280
+ seeds: [
3281
+ kit.getBytesEncoder().encode(
3282
+ new Uint8Array([
3283
+ 101,
3284
+ 110,
3285
+ 116,
3286
+ 114,
3287
+ 121,
3288
+ 95,
3289
+ 98,
3290
+ 121,
3291
+ 95,
3292
+ 109,
3293
+ 105,
3294
+ 110,
3295
+ 116
3296
+ ])
3297
+ ),
3298
+ kit.getAddressEncoder().encode(
3299
+ programClientCore.getAddressFromResolvedInstructionAccount(
3300
+ "oracle",
3301
+ accounts.oracle.value
3302
+ )
3303
+ ),
3304
+ kit.getAddressEncoder().encode(
3305
+ programClientCore.getAddressFromResolvedInstructionAccount(
3306
+ "baseMint",
3307
+ accounts.baseMint.value
3308
+ )
3309
+ )
3310
+ ]
3311
+ });
3312
+ }
3313
+ const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
3314
+ return Object.freeze({
3315
+ accounts: [
3316
+ getAccountMeta("initializerConfig", accounts.initializerConfig),
3317
+ getAccountMeta("launch", accounts.launch),
3318
+ getAccountMeta("launchAuthority", accounts.launchAuthority),
3319
+ getAccountMeta("baseMint", accounts.baseMint),
3320
+ getAccountMeta("quoteMint", accounts.quoteMint),
3321
+ getAccountMeta("baseVault", accounts.baseVault),
3322
+ getAccountMeta("quoteVault", accounts.quoteVault),
3323
+ getAccountMeta("payer", accounts.payer),
3324
+ getAccountMeta("tokenProgram", accounts.tokenProgram),
3325
+ getAccountMeta("systemProgram", accounts.systemProgram),
3326
+ getAccountMeta("rent", accounts.rent),
3327
+ getAccountMeta("oracle", accounts.oracle),
3328
+ getAccountMeta("market", accounts.market),
3329
+ getAccountMeta("potVault", accounts.potVault),
3330
+ getAccountMeta("marketAuthority", accounts.marketAuthority),
3331
+ getAccountMeta("entry", accounts.entry),
3332
+ getAccountMeta("entryByMint", accounts.entryByMint)
3333
+ ],
3334
+ data: getRegisterEntryInstructionDataEncoder().encode(
3335
+ args
3336
+ ),
3337
+ programAddress
3338
+ });
3339
+ }
3340
+ function getRegisterEntryInstruction(input, config) {
3341
+ const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
3342
+ const originalAccounts = {
3343
+ initializerConfig: {
3344
+ value: input.initializerConfig ?? null,
3345
+ isWritable: false
3346
+ },
3347
+ launch: { value: input.launch ?? null, isWritable: false },
3348
+ launchAuthority: {
3349
+ value: input.launchAuthority ?? null,
3350
+ isWritable: false
3351
+ },
3352
+ baseMint: { value: input.baseMint ?? null, isWritable: false },
3353
+ quoteMint: { value: input.quoteMint ?? null, isWritable: false },
3354
+ baseVault: { value: input.baseVault ?? null, isWritable: false },
3355
+ quoteVault: { value: input.quoteVault ?? null, isWritable: false },
3356
+ payer: { value: input.payer ?? null, isWritable: true },
3357
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
3358
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
3359
+ rent: { value: input.rent ?? null, isWritable: false },
3360
+ oracle: { value: input.oracle ?? null, isWritable: false },
3361
+ market: { value: input.market ?? null, isWritable: true },
3362
+ potVault: { value: input.potVault ?? null, isWritable: true },
3363
+ marketAuthority: {
3364
+ value: input.marketAuthority ?? null,
3365
+ isWritable: false
3366
+ },
3367
+ entry: { value: input.entry ?? null, isWritable: true },
3368
+ entryByMint: { value: input.entryByMint ?? null, isWritable: true }
3369
+ };
3370
+ const accounts = originalAccounts;
3371
+ const args = { ...input };
3372
+ if (!accounts.tokenProgram.value) {
3373
+ accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
3374
+ }
3375
+ if (!accounts.systemProgram.value) {
3376
+ accounts.systemProgram.value = "11111111111111111111111111111111";
3377
+ }
3378
+ if (!accounts.rent.value) {
3379
+ accounts.rent.value = "SysvarRent111111111111111111111111111111111";
3380
+ }
3381
+ const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
3382
+ return Object.freeze({
3383
+ accounts: [
3384
+ getAccountMeta("initializerConfig", accounts.initializerConfig),
3385
+ getAccountMeta("launch", accounts.launch),
3386
+ getAccountMeta("launchAuthority", accounts.launchAuthority),
3387
+ getAccountMeta("baseMint", accounts.baseMint),
3388
+ getAccountMeta("quoteMint", accounts.quoteMint),
3389
+ getAccountMeta("baseVault", accounts.baseVault),
3390
+ getAccountMeta("quoteVault", accounts.quoteVault),
3391
+ getAccountMeta("payer", accounts.payer),
3392
+ getAccountMeta("tokenProgram", accounts.tokenProgram),
3393
+ getAccountMeta("systemProgram", accounts.systemProgram),
3394
+ getAccountMeta("rent", accounts.rent),
3395
+ getAccountMeta("oracle", accounts.oracle),
3396
+ getAccountMeta("market", accounts.market),
3397
+ getAccountMeta("potVault", accounts.potVault),
3398
+ getAccountMeta("marketAuthority", accounts.marketAuthority),
3399
+ getAccountMeta("entry", accounts.entry),
3400
+ getAccountMeta("entryByMint", accounts.entryByMint)
3401
+ ],
3402
+ data: getRegisterEntryInstructionDataEncoder().encode(
3403
+ args
3404
+ ),
3405
+ programAddress
3406
+ });
3407
+ }
3408
+ function parseRegisterEntryInstruction(instruction) {
3409
+ if (instruction.accounts.length < 17) {
3410
+ throw new kit.SolanaError(
3411
+ kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3412
+ {
3413
+ actualAccountMetas: instruction.accounts.length,
3414
+ expectedAccountMetas: 17
3415
+ }
3416
+ );
3417
+ }
3418
+ let accountIndex = 0;
3419
+ const getNextAccount = () => {
3420
+ const accountMeta = instruction.accounts[accountIndex];
3421
+ accountIndex += 1;
3422
+ return accountMeta;
3423
+ };
3424
+ return {
3425
+ programAddress: instruction.programAddress,
3426
+ accounts: {
3427
+ initializerConfig: getNextAccount(),
3428
+ launch: getNextAccount(),
3429
+ launchAuthority: getNextAccount(),
3430
+ baseMint: getNextAccount(),
3431
+ quoteMint: getNextAccount(),
3432
+ baseVault: getNextAccount(),
3433
+ quoteVault: getNextAccount(),
3434
+ payer: getNextAccount(),
3435
+ tokenProgram: getNextAccount(),
3436
+ systemProgram: getNextAccount(),
3437
+ rent: getNextAccount(),
3438
+ oracle: getNextAccount(),
3439
+ market: getNextAccount(),
3440
+ potVault: getNextAccount(),
3441
+ marketAuthority: getNextAccount(),
3442
+ entry: getNextAccount(),
3443
+ entryByMint: getNextAccount()
3444
+ },
3445
+ data: getRegisterEntryInstructionDataDecoder().decode(instruction.data)
3446
+ };
3447
+ }
3448
+
3449
+ // src/solana/generated/predictionMigrator/programs/predictionMigrator.ts
3450
+ var PREDICTION_MIGRATOR_PROGRAM_ADDRESS = "HYHdyy7QZg8Ucky9Z97xNtSCvrZxVNkeoney8xEPXjiZ";
3451
+ var PredictionMigratorAccount = /* @__PURE__ */ ((PredictionMigratorAccount2) => {
3452
+ PredictionMigratorAccount2[PredictionMigratorAccount2["ClaimReceipt"] = 0] = "ClaimReceipt";
3453
+ PredictionMigratorAccount2[PredictionMigratorAccount2["Entry"] = 1] = "Entry";
3454
+ PredictionMigratorAccount2[PredictionMigratorAccount2["EntryByMint"] = 2] = "EntryByMint";
3455
+ PredictionMigratorAccount2[PredictionMigratorAccount2["Launch"] = 3] = "Launch";
3456
+ PredictionMigratorAccount2[PredictionMigratorAccount2["Market"] = 4] = "Market";
3457
+ PredictionMigratorAccount2[PredictionMigratorAccount2["OracleState"] = 5] = "OracleState";
3458
+ return PredictionMigratorAccount2;
3459
+ })(PredictionMigratorAccount || {});
3460
+ function identifyPredictionMigratorAccount(account) {
3461
+ const data = "data" in account ? account.data : account;
3462
+ if (kit.containsBytes(
3463
+ data,
3464
+ kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
3465
+ new Uint8Array([223, 233, 11, 229, 124, 165, 207, 28])
3466
+ ),
3467
+ 0
3468
+ )) {
3469
+ return 0 /* ClaimReceipt */;
3470
+ }
3471
+ if (kit.containsBytes(
3472
+ data,
3473
+ kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
3474
+ new Uint8Array([63, 18, 152, 113, 215, 246, 221, 250])
3475
+ ),
3476
+ 0
3477
+ )) {
3478
+ return 1 /* Entry */;
3479
+ }
3480
+ if (kit.containsBytes(
3481
+ data,
3482
+ kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
3483
+ new Uint8Array([188, 191, 157, 194, 68, 82, 181, 126])
3484
+ ),
3485
+ 0
3486
+ )) {
3487
+ return 2 /* EntryByMint */;
3488
+ }
3489
+ if (kit.containsBytes(
3490
+ data,
3491
+ kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
3492
+ new Uint8Array([144, 51, 51, 163, 206, 85, 213, 38])
3493
+ ),
3494
+ 0
3495
+ )) {
3496
+ return 3 /* Launch */;
3497
+ }
3498
+ if (kit.containsBytes(
3499
+ data,
3500
+ kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
3501
+ new Uint8Array([219, 190, 213, 55, 0, 227, 198, 154])
3502
+ ),
3503
+ 0
3504
+ )) {
3505
+ return 4 /* Market */;
3506
+ }
3507
+ if (kit.containsBytes(
3508
+ data,
3509
+ kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
3510
+ new Uint8Array([97, 156, 157, 189, 194, 73, 8, 15])
3511
+ ),
3512
+ 0
3513
+ )) {
3514
+ return 5 /* OracleState */;
3515
+ }
3516
+ throw new kit.SolanaError(
3517
+ kit.SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT,
3518
+ { accountData: data, programName: "predictionMigrator" }
3519
+ );
3520
+ }
3521
+ var PredictionMigratorInstruction = /* @__PURE__ */ ((PredictionMigratorInstruction2) => {
3522
+ PredictionMigratorInstruction2[PredictionMigratorInstruction2["Claim"] = 0] = "Claim";
3523
+ PredictionMigratorInstruction2[PredictionMigratorInstruction2["MigrateEntry"] = 1] = "MigrateEntry";
3524
+ PredictionMigratorInstruction2[PredictionMigratorInstruction2["PreviewPayoutIfWinner"] = 2] = "PreviewPayoutIfWinner";
3525
+ PredictionMigratorInstruction2[PredictionMigratorInstruction2["RegisterEntry"] = 3] = "RegisterEntry";
3526
+ return PredictionMigratorInstruction2;
3527
+ })(PredictionMigratorInstruction || {});
3528
+ function identifyPredictionMigratorInstruction(instruction) {
3529
+ const data = "data" in instruction ? instruction.data : instruction;
3530
+ if (kit.containsBytes(
3531
+ data,
3532
+ kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
3533
+ new Uint8Array([62, 198, 214, 193, 213, 159, 108, 210])
3534
+ ),
3535
+ 0
3536
+ )) {
3537
+ return 0 /* Claim */;
3538
+ }
3539
+ if (kit.containsBytes(
3540
+ data,
3541
+ kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
3542
+ new Uint8Array([239, 154, 55, 173, 110, 36, 188, 214])
3543
+ ),
3544
+ 0
3545
+ )) {
3546
+ return 1 /* MigrateEntry */;
3547
+ }
3548
+ if (kit.containsBytes(
3549
+ data,
3550
+ kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
3551
+ new Uint8Array([228, 144, 72, 185, 234, 186, 183, 143])
3552
+ ),
3553
+ 0
3554
+ )) {
3555
+ return 2 /* PreviewPayoutIfWinner */;
3556
+ }
3557
+ if (kit.containsBytes(
3558
+ data,
3559
+ kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
3560
+ new Uint8Array([198, 25, 1, 183, 73, 219, 215, 14])
3561
+ ),
3562
+ 0
3563
+ )) {
3564
+ return 3 /* RegisterEntry */;
3565
+ }
3566
+ throw new kit.SolanaError(
3567
+ kit.SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
3568
+ { instructionData: data, programName: "predictionMigrator" }
3569
+ );
3570
+ }
3571
+ function parsePredictionMigratorInstruction(instruction) {
3572
+ const instructionType = identifyPredictionMigratorInstruction(instruction);
3573
+ switch (instructionType) {
3574
+ case 0 /* Claim */: {
3575
+ kit.assertIsInstructionWithAccounts(instruction);
3576
+ return {
3577
+ instructionType: 0 /* Claim */,
3578
+ ...parseClaimInstruction(instruction)
3579
+ };
3580
+ }
3581
+ case 1 /* MigrateEntry */: {
3582
+ kit.assertIsInstructionWithAccounts(instruction);
3583
+ return {
3584
+ instructionType: 1 /* MigrateEntry */,
3585
+ ...parseMigrateEntryInstruction(instruction)
3586
+ };
3587
+ }
3588
+ case 2 /* PreviewPayoutIfWinner */: {
3589
+ kit.assertIsInstructionWithAccounts(instruction);
3590
+ return {
3591
+ instructionType: 2 /* PreviewPayoutIfWinner */,
3592
+ ...parsePreviewPayoutIfWinnerInstruction(instruction)
3593
+ };
3594
+ }
3595
+ case 3 /* RegisterEntry */: {
3596
+ kit.assertIsInstructionWithAccounts(instruction);
3597
+ return {
3598
+ instructionType: 3 /* RegisterEntry */,
3599
+ ...parseRegisterEntryInstruction(instruction)
3600
+ };
3601
+ }
3602
+ default:
3603
+ throw new kit.SolanaError(
3604
+ kit.SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
3605
+ {
3606
+ instructionType,
3607
+ programName: "predictionMigrator"
3608
+ }
3609
+ );
3610
+ }
3611
+ }
3612
+ function predictionMigratorProgram() {
3613
+ return (client) => {
3614
+ return {
3615
+ ...client,
3616
+ predictionMigrator: {
3617
+ accounts: {
3618
+ claimReceipt: programClientCore.addSelfFetchFunctions(client, getClaimReceiptCodec()),
3619
+ entry: programClientCore.addSelfFetchFunctions(client, getEntryCodec()),
3620
+ entryByMint: programClientCore.addSelfFetchFunctions(client, getEntryByMintCodec()),
3621
+ launch: programClientCore.addSelfFetchFunctions(client, getLaunchCodec2()),
3622
+ market: programClientCore.addSelfFetchFunctions(client, getMarketCodec()),
3623
+ oracleState: programClientCore.addSelfFetchFunctions(client, getOracleStateCodec())
3624
+ },
3625
+ instructions: {
3626
+ claim: (input) => programClientCore.addSelfPlanAndSendFunctions(
3627
+ client,
3628
+ getClaimInstructionAsync({
3629
+ ...input,
3630
+ payer: input.payer ?? client.payer
3631
+ })
3632
+ ),
3633
+ migrateEntry: (input) => programClientCore.addSelfPlanAndSendFunctions(
3634
+ client,
3635
+ getMigrateEntryInstructionAsync({
3636
+ ...input,
3637
+ payer: input.payer ?? client.payer
3638
+ })
3639
+ ),
3640
+ previewPayoutIfWinner: (input) => programClientCore.addSelfPlanAndSendFunctions(
3641
+ client,
3642
+ getPreviewPayoutIfWinnerInstruction(input)
3643
+ ),
3644
+ registerEntry: (input) => programClientCore.addSelfPlanAndSendFunctions(
3645
+ client,
3646
+ getRegisterEntryInstructionAsync({
3647
+ ...input,
3648
+ payer: input.payer ?? client.payer
3649
+ })
3650
+ )
3651
+ }
3652
+ }
3653
+ };
3654
+ };
3655
+ }
3656
+ var addressCodec4 = kit.getAddressCodec();
3657
+ var textEncoder4 = new TextEncoder();
3658
+ async function getPredictionMarketAddress(oracleState, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
3659
+ return kit.getProgramDerivedAddress({
3660
+ programAddress: programId,
3661
+ seeds: [textEncoder4.encode("market"), addressCodec4.encode(oracleState)]
3662
+ });
3663
+ }
3664
+ async function getPredictionMarketAuthorityAddress(market, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
3665
+ return kit.getProgramDerivedAddress({
3666
+ programAddress: programId,
3667
+ seeds: [
3668
+ textEncoder4.encode("market_authority"),
3669
+ addressCodec4.encode(market)
3670
+ ]
3671
+ });
3672
+ }
3673
+ async function getPredictionPotVaultAddress(market, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
3674
+ return kit.getProgramDerivedAddress({
3675
+ programAddress: programId,
3676
+ seeds: [textEncoder4.encode("pot_vault"), addressCodec4.encode(market)]
3677
+ });
3678
+ }
3679
+ async function getPredictionEntryAddress(oracleState, entryId, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
3680
+ return kit.getProgramDerivedAddress({
3681
+ programAddress: programId,
3682
+ seeds: [
3683
+ textEncoder4.encode("entry"),
3684
+ addressCodec4.encode(oracleState),
3685
+ entryId
3686
+ ]
3687
+ });
3688
+ }
3689
+ async function getPredictionEntryByMintAddress(oracleState, mint, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
3690
+ return kit.getProgramDerivedAddress({
3691
+ programAddress: programId,
3692
+ seeds: [
3693
+ textEncoder4.encode("entry_by_mint"),
3694
+ addressCodec4.encode(oracleState),
3695
+ addressCodec4.encode(mint)
3696
+ ]
3697
+ });
3698
+ }
3699
+
3700
+ // src/solana/initializer/instructions/initializeLaunch.ts
3701
+ function isTransactionSigner5(value) {
3702
+ return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
3703
+ }
3704
+ function createAccountMeta(value, role) {
3705
+ if (isTransactionSigner5(value)) {
3706
+ return { address: value.address, role, signer: value };
3707
+ }
3708
+ return { address: value, role };
3709
+ }
3710
+ async function getTokenMetadataAddress(mint) {
3711
+ const encoder = kit.getAddressEncoder();
3712
+ const [metadataAddress] = await kit.getProgramDerivedAddress({
3713
+ programAddress: chunkDPKVNI6Q_cjs.TOKEN_METADATA_PROGRAM_ID,
3714
+ seeds: [
3715
+ new TextEncoder().encode("metadata"),
3716
+ encoder.encode(chunkDPKVNI6Q_cjs.TOKEN_METADATA_PROGRAM_ID),
3717
+ encoder.encode(mint)
3718
+ ]
3719
+ });
3720
+ return metadataAddress;
3721
+ }
3722
+ var ALT_INDEX = {
3723
+ [chunkDPKVNI6Q_cjs.TOKEN_PROGRAM_ADDRESS]: 0,
3724
+ [chunkDPKVNI6Q_cjs.SYSTEM_PROGRAM_ADDRESS]: 1,
3725
+ SysvarRent111111111111111111111111111111111: 2,
3726
+ [INITIALIZER_PROGRAM_ID]: 3,
3727
+ [chunkDPKVNI6Q_cjs.TOKEN_METADATA_PROGRAM_ID]: 4,
3728
+ [CPMM_MIGRATOR_PROGRAM_ID]: 5,
3729
+ So11111111111111111111111111111111111111112: 6,
3730
+ // index 7 = config PDA — resolved at call time from accounts.config
3731
+ [PREDICTION_MIGRATOR_PROGRAM_ADDRESS]: 8
3732
+ };
3733
+ function validateInitializeLaunchCurveParams(args) {
3734
+ if (args.curveKind !== CURVE_KIND_XYK) {
3735
+ throw new Error(
3736
+ `unsupported curve kind: ${args.curveKind}; only CURVE_KIND_XYK is currently enabled`
3737
+ );
3738
+ }
3739
+ if (args.curveParams.length !== 1 || args.curveParams[0] !== CURVE_PARAMS_FORMAT_XYK_V0) {
3740
+ throw new Error("xyk curve params must be [CURVE_PARAMS_FORMAT_XYK_V0]");
3741
+ }
3742
+ }
3743
+ async function createInitializeLaunchInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
3744
+ validateInitializeLaunchCurveParams(args);
3745
+ const {
3746
+ config,
3747
+ launch,
3748
+ launchAuthority,
3749
+ baseMint,
3750
+ quoteMint,
3751
+ baseVault,
3752
+ quoteVault,
3753
+ payer,
3754
+ authority,
3755
+ migratorProgram,
3756
+ tokenProgram = chunkDPKVNI6Q_cjs.TOKEN_PROGRAM_ADDRESS,
3757
+ systemProgram = chunkDPKVNI6Q_cjs.SYSTEM_PROGRAM_ADDRESS,
3758
+ rent,
3759
+ metadataAccount,
3760
+ addressLookupTable: alt
3761
+ } = accounts;
3762
+ const withMetadata = Boolean(
3763
+ args.metadataName && args.metadataName.length > 0
3764
+ );
3765
+ if (withMetadata && !metadataAccount) {
3766
+ throw new Error(
3767
+ "metadataName is set but metadataAccount was not provided. Derive it with await initializer.getTokenMetadataAddress(baseMintAddress)."
3768
+ );
3769
+ }
3770
+ const altIndexMap = alt ? { ...ALT_INDEX, [config]: 7 } : {};
3771
+ function staticOrLookup(addr, role) {
3772
+ if (alt && altIndexMap[addr] !== void 0) {
3773
+ return {
3774
+ address: addr,
3775
+ role,
3776
+ lookupTableAddress: alt,
3777
+ addressIndex: altIndexMap[addr]
3778
+ };
3779
+ }
3780
+ return { address: addr, role };
3781
+ }
3782
+ const keys = [
3783
+ staticOrLookup(config, kit.AccountRole.READONLY),
3784
+ { address: launch, role: kit.AccountRole.WRITABLE },
3785
+ { address: launchAuthority, role: kit.AccountRole.READONLY },
3786
+ createAccountMeta(baseMint, kit.AccountRole.WRITABLE_SIGNER),
3787
+ staticOrLookup(quoteMint, kit.AccountRole.READONLY),
3788
+ createAccountMeta(baseVault, kit.AccountRole.WRITABLE_SIGNER),
3789
+ createAccountMeta(quoteVault, kit.AccountRole.WRITABLE_SIGNER),
3790
+ createAccountMeta(payer, kit.AccountRole.WRITABLE_SIGNER)
3791
+ ];
3792
+ if (authority) {
3793
+ keys.push(createAccountMeta(authority, kit.AccountRole.READONLY_SIGNER));
3794
+ }
3795
+ if (migratorProgram) {
3796
+ keys.push(staticOrLookup(migratorProgram, kit.AccountRole.READONLY));
3797
+ }
3798
+ keys.push(staticOrLookup(tokenProgram, kit.AccountRole.READONLY));
3799
+ keys.push(staticOrLookup(systemProgram, kit.AccountRole.READONLY));
3800
+ keys.push(staticOrLookup(rent, kit.AccountRole.READONLY));
3801
+ if (withMetadata) {
3802
+ keys.push({ address: metadataAccount, role: kit.AccountRole.WRITABLE });
3803
+ keys.push(staticOrLookup(chunkDPKVNI6Q_cjs.TOKEN_METADATA_PROGRAM_ID, kit.AccountRole.READONLY));
3804
+ }
3805
+ const encoderArgs = {
3806
+ ...args,
3807
+ allowBuy: args.allowBuy ? 1 : 0,
3808
+ allowSell: args.allowSell ? 1 : 0,
3809
+ migratorProgram: migratorProgram ?? chunkDPKVNI6Q_cjs.SYSTEM_PROGRAM_ADDRESS
3810
+ };
3811
+ const data = new Uint8Array(
3812
+ getInitializeLaunchInstructionDataEncoder().encode(encoderArgs)
3813
+ );
3814
+ if (migratorProgram === CPMM_MIGRATOR_PROGRAM_ID) {
3815
+ const [cpmmMigratorState] = await getCpmmMigratorStateAddress(launch);
3816
+ keys.push({ address: cpmmMigratorState, role: kit.AccountRole.WRITABLE });
3817
+ }
3818
+ if (migratorProgram === PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
3819
+ const oracleState = args.namespace;
3820
+ const entryId = args.launchId;
3821
+ const baseMintAddress = isTransactionSigner5(baseMint) ? baseMint.address : baseMint;
3822
+ const [market] = await getPredictionMarketAddress(oracleState);
3823
+ const [potVault] = await getPredictionPotVaultAddress(market);
3824
+ const [marketAuthority] = await getPredictionMarketAuthorityAddress(market);
3825
+ const [entry] = await getPredictionEntryAddress(oracleState, entryId);
3826
+ const [entryByMint] = await getPredictionEntryByMintAddress(
3827
+ oracleState,
3828
+ baseMintAddress
3829
+ );
3830
+ keys.push({ address: oracleState, role: kit.AccountRole.READONLY });
3831
+ keys.push({ address: market, role: kit.AccountRole.WRITABLE });
3832
+ keys.push({ address: potVault, role: kit.AccountRole.WRITABLE });
3833
+ keys.push({ address: marketAuthority, role: kit.AccountRole.READONLY });
3834
+ keys.push({ address: entry, role: kit.AccountRole.WRITABLE });
3835
+ keys.push({ address: entryByMint, role: kit.AccountRole.WRITABLE });
3836
+ }
3837
+ return { programAddress: programId, accounts: keys, data };
3838
+ }
3839
+ function isTransactionSigner6(value) {
3840
+ return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
3841
+ }
3842
+ function createAccountMeta2(value, role) {
3843
+ if (isTransactionSigner6(value)) {
3844
+ return { address: value.address, role, signer: value };
3845
+ }
3846
+ return { address: value, role };
3847
+ }
3848
+ function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
3849
+ const {
3850
+ config,
3851
+ launch,
3852
+ launchAuthority,
3853
+ baseVault,
3854
+ quoteVault,
3855
+ userBaseAccount,
3856
+ userQuoteAccount,
3857
+ baseMint,
3858
+ quoteMint,
3859
+ user,
3860
+ sentinelProgram = chunkDPKVNI6Q_cjs.SYSTEM_PROGRAM_ADDRESS,
3861
+ tokenProgram = chunkDPKVNI6Q_cjs.TOKEN_PROGRAM_ADDRESS
3862
+ } = accounts;
3863
+ const keys = [
3864
+ { address: config, role: kit.AccountRole.READONLY },
3865
+ { address: launch, role: kit.AccountRole.WRITABLE },
3866
+ { address: launchAuthority, role: kit.AccountRole.READONLY },
3867
+ { address: baseVault, role: kit.AccountRole.WRITABLE },
3868
+ { address: quoteVault, role: kit.AccountRole.WRITABLE },
3869
+ { address: userBaseAccount, role: kit.AccountRole.WRITABLE },
3870
+ { address: userQuoteAccount, role: kit.AccountRole.WRITABLE },
3871
+ { address: baseMint, role: kit.AccountRole.READONLY },
3872
+ { address: quoteMint, role: kit.AccountRole.READONLY },
3873
+ createAccountMeta2(user, kit.AccountRole.READONLY_SIGNER),
3874
+ // sentinel_program is Optional in the on-chain struct but still occupies a fixed
3875
+ // slot (token_program follows it). Always emit it — use SYSTEM_PROGRAM_ADDRESS as the
3876
+ // no-op placeholder when no real sentinel is configured.
3877
+ { address: sentinelProgram, role: kit.AccountRole.READONLY },
3878
+ { address: tokenProgram, role: kit.AccountRole.READONLY }
3879
+ ];
3880
+ const data = new Uint8Array(
3881
+ getCurveSwapExactInInstructionDataEncoder().encode(args)
3882
+ );
3883
+ return { programAddress: programId, accounts: keys, data };
3884
+ }
3885
+ function isTransactionSigner7(value) {
3886
+ return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
3887
+ }
3888
+ function createSignerAccountMeta5(value, role) {
3889
+ if (isTransactionSigner7(value)) {
3890
+ return { address: value.address, role, signer: value };
3891
+ }
3892
+ return { address: value, role };
3893
+ }
3894
+ function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRAM_ID) {
3895
+ const {
3896
+ config,
3897
+ launch,
3898
+ launchAuthority,
3899
+ baseMint,
3900
+ quoteMint,
3901
+ baseVault,
3902
+ quoteVault,
3903
+ migratorProgram,
3904
+ payer,
3905
+ tokenProgram = chunkDPKVNI6Q_cjs.TOKEN_PROGRAM_ADDRESS,
3906
+ systemProgram = chunkDPKVNI6Q_cjs.SYSTEM_PROGRAM_ADDRESS,
3907
+ rent
3908
+ } = accounts;
3909
+ const keys = [
3910
+ { address: config, role: kit.AccountRole.READONLY },
3911
+ { address: launch, role: kit.AccountRole.WRITABLE },
3912
+ { address: launchAuthority, role: kit.AccountRole.READONLY },
3913
+ { address: baseMint, role: kit.AccountRole.READONLY },
3914
+ { address: quoteMint, role: kit.AccountRole.READONLY },
3915
+ { address: baseVault, role: kit.AccountRole.WRITABLE },
3916
+ { address: quoteVault, role: kit.AccountRole.WRITABLE },
3917
+ { address: migratorProgram, role: kit.AccountRole.READONLY },
3918
+ createSignerAccountMeta5(payer, kit.AccountRole.WRITABLE_SIGNER),
3919
+ { address: tokenProgram, role: kit.AccountRole.READONLY },
3920
+ { address: systemProgram, role: kit.AccountRole.READONLY },
3921
+ { address: rent, role: kit.AccountRole.READONLY }
3922
+ ];
3923
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
3924
+ INITIALIZER_INSTRUCTION_DISCRIMINATORS.migrateLaunch
3925
+ );
3926
+ return { programAddress: programId, accounts: keys, data };
3927
+ }
3928
+ function isTransactionSigner8(value) {
3929
+ return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
3930
+ }
3931
+ function createAccountMeta3(value, role) {
3932
+ if (isTransactionSigner8(value)) {
3933
+ return { address: value.address, role, signer: value };
3934
+ }
3935
+ return { address: value, role };
3936
+ }
3937
+ function createAbortLaunchInstruction(accounts, programId = INITIALIZER_PROGRAM_ID) {
3938
+ const {
3939
+ config,
3940
+ launch,
3941
+ launchAuthority,
3942
+ baseVault,
3943
+ quoteVault,
3944
+ authority,
3945
+ authorityBaseAccount,
3946
+ baseMint,
3947
+ tokenProgram = chunkDPKVNI6Q_cjs.TOKEN_PROGRAM_ADDRESS
3948
+ } = accounts;
3949
+ const keys = [
3950
+ { address: config, role: kit.AccountRole.READONLY },
3951
+ { address: launch, role: kit.AccountRole.WRITABLE },
3952
+ { address: launchAuthority, role: kit.AccountRole.READONLY },
3953
+ { address: baseVault, role: kit.AccountRole.WRITABLE },
3954
+ { address: quoteVault, role: kit.AccountRole.READONLY },
3955
+ createAccountMeta3(authority, kit.AccountRole.READONLY_SIGNER),
3956
+ { address: authorityBaseAccount, role: kit.AccountRole.WRITABLE },
3957
+ { address: baseMint, role: kit.AccountRole.READONLY },
3958
+ { address: tokenProgram, role: kit.AccountRole.READONLY }
3959
+ ];
3960
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
3961
+ INITIALIZER_INSTRUCTION_DISCRIMINATORS.abortLaunch
3962
+ );
3963
+ return { programAddress: programId, accounts: keys, data };
3964
+ }
3965
+ var previewSwapExactInResultCodec = kit.getStructCodec([
3966
+ ["amountOut", kit.getU64Codec()],
3967
+ ["feePaid", kit.getU64Codec()]
3968
+ ]);
3969
+ function createPreviewSwapExactInInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
3970
+ const { launch, baseVault, quoteVault, sentinelProgram } = accounts;
3971
+ const keys = [
3972
+ { address: launch, role: kit.AccountRole.READONLY },
3973
+ { address: baseVault, role: kit.AccountRole.READONLY },
3974
+ { address: quoteVault, role: kit.AccountRole.READONLY }
3975
+ ];
3976
+ const accountsList = sentinelProgram ? [...keys, { address: sentinelProgram, role: kit.AccountRole.READONLY }] : keys;
3977
+ const data = new Uint8Array(
3978
+ getPreviewSwapExactInInstructionDataEncoder().encode(args)
3979
+ );
3980
+ return { programAddress: programId, accounts: accountsList, data };
3981
+ }
3982
+ function decodePreviewSwapExactInResult(data) {
3983
+ return previewSwapExactInResultCodec.decode(data);
3984
+ }
3985
+ var previewMigrationResultCodec = kit.getStructCodec([
3986
+ ["baseVaultAmount", kit.getU64Codec()],
3987
+ ["quoteVaultAmount", kit.getU64Codec()],
3988
+ ["baseMintSupply", kit.getU64Codec()]
3989
+ ]);
3990
+ function createPreviewMigrationInstruction(accounts, programId = INITIALIZER_PROGRAM_ID) {
3991
+ const { launch, baseMint, baseVault, quoteVault } = accounts;
3992
+ const keys = [
3993
+ { address: launch, role: kit.AccountRole.READONLY },
3994
+ { address: baseMint, role: kit.AccountRole.READONLY },
3995
+ { address: baseVault, role: kit.AccountRole.READONLY },
3996
+ { address: quoteVault, role: kit.AccountRole.READONLY }
3997
+ ];
3998
+ const data = chunkBXATWUGJ_cjs.encodeInstructionData(
3999
+ INITIALIZER_INSTRUCTION_DISCRIMINATORS.previewMigration
4000
+ );
4001
+ return { programAddress: programId, accounts: keys, data };
4002
+ }
4003
+ function decodePreviewMigrationResult(data) {
4004
+ return previewMigrationResultCodec.decode(data);
4005
+ }
4006
+ function computeRemainingAccountsHash(addresses) {
4007
+ const addressEncoder = kit.getAddressEncoder();
4008
+ const buf = new Uint8Array(4 + addresses.length * 32);
4009
+ new DataView(buf.buffer).setUint32(0, addresses.length, true);
4010
+ for (let i = 0; i < addresses.length; i++) {
4011
+ buf.set(addressEncoder.encode(addresses[i]), 4 + i * 32);
4012
+ }
4013
+ return sha3_js.keccak_256(buf);
4014
+ }
4015
+ function phaseLabel(phase) {
4016
+ switch (phase) {
4017
+ case PHASE_TRADING:
4018
+ return "TRADING";
4019
+ case PHASE_MIGRATED:
4020
+ return "MIGRATED";
4021
+ case PHASE_ABORTED:
4022
+ return "ABORTED";
4023
+ default:
4024
+ return String(phase);
4025
+ }
4026
+ }
4027
+ var addressCodec5 = kit.getAddressCodec();
4028
+ function bytesToBase64(bytes) {
4029
+ let binary = "";
4030
+ for (let i = 0; i < bytes.length; i++) {
4031
+ binary += String.fromCharCode(bytes[i]);
4032
+ }
4033
+ return btoa(binary);
4034
+ }
4035
+ function base64ToBytes2(base64) {
4036
+ const binary = atob(base64);
4037
+ const bytes = new Uint8Array(binary.length);
4038
+ for (let i = 0; i < binary.length; i++) {
4039
+ bytes[i] = binary.charCodeAt(i);
4040
+ }
4041
+ return bytes;
4042
+ }
4043
+ async function fetchLaunch2(rpc, address3, config) {
4044
+ const response = await rpc.getAccountInfo(address3, {
4045
+ encoding: "base64",
4046
+ commitment: config?.commitment
4047
+ }).send();
4048
+ if (!response.value) {
4049
+ return null;
4050
+ }
4051
+ return getLaunchDecoder().decode(base64ToBytes2(response.value.data[0]));
4052
+ }
4053
+ async function fetchAllLaunches(rpc, config) {
4054
+ const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
4055
+ const discriminatorFilter = {
4056
+ memcmp: {
4057
+ offset: 0n,
4058
+ bytes: bytesToBase64(
4059
+ INITIALIZER_ACCOUNT_DISCRIMINATORS.Launch
4060
+ ),
4061
+ encoding: "base64"
4062
+ }
4063
+ };
4064
+ const response = await rpc.getProgramAccounts(programId, {
4065
+ encoding: "base64",
4066
+ commitment: config?.commitment,
4067
+ filters: [discriminatorFilter]
4068
+ }).send();
4069
+ const accounts = Array.isArray(response) ? response : response.value;
4070
+ const launches = [];
4071
+ const decoder = getLaunchDecoder();
4072
+ for (const account of accounts) {
4073
+ try {
4074
+ const launch = decoder.decode(base64ToBytes2(account.account.data[0]));
4075
+ launches.push({ address: account.pubkey, account: launch });
4076
+ } catch {
4077
+ console.warn(`Failed to decode launch account: ${account.pubkey}`);
4078
+ }
4079
+ }
4080
+ return launches;
4081
+ }
4082
+ async function fetchLaunchesByAuthority(rpc, authority, config) {
4083
+ const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
4084
+ const discriminatorFilter = {
4085
+ memcmp: {
4086
+ offset: 0n,
4087
+ bytes: bytesToBase64(
4088
+ INITIALIZER_ACCOUNT_DISCRIMINATORS.Launch
4089
+ ),
4090
+ encoding: "base64"
4091
+ }
4092
+ };
4093
+ const authorityFilter = {
4094
+ memcmp: {
4095
+ offset: 8n,
4096
+ bytes: bytesToBase64(
4097
+ addressCodec5.encode(authority)
4098
+ ),
4099
+ encoding: "base64"
4100
+ }
4101
+ };
4102
+ const response = await rpc.getProgramAccounts(programId, {
4103
+ encoding: "base64",
4104
+ commitment: config?.commitment,
4105
+ filters: [discriminatorFilter, authorityFilter]
4106
+ }).send();
4107
+ const accounts = Array.isArray(response) ? response : response.value;
4108
+ const launches = [];
4109
+ const decoder = getLaunchDecoder();
4110
+ for (const account of accounts) {
4111
+ try {
4112
+ const launch = decoder.decode(base64ToBytes2(account.account.data[0]));
4113
+ launches.push({ address: account.pubkey, account: launch });
4114
+ } catch {
4115
+ console.warn(`Failed to decode launch account: ${account.pubkey}`);
4116
+ }
4117
+ }
4118
+ return launches;
4119
+ }
4120
+ async function launchExists(rpc, namespace, launchId, config) {
4121
+ const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
4122
+ const [launchAddress] = await getLaunchAddress(
4123
+ namespace,
4124
+ launchId,
4125
+ programId
4126
+ );
4127
+ const launch = await fetchLaunch2(rpc, launchAddress, config);
4128
+ return launch !== null;
4129
+ }
4130
+
4131
+ // src/solana/migrators/cpmmMigrator/index.ts
4132
+ var cpmmMigrator_exports = {};
4133
+ chunkQ7SFCCGT_cjs.__export(cpmmMigrator_exports, {
4134
+ CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS: () => CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS,
4135
+ CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS: () => CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS,
4136
+ CPMM_MIGRATOR_PROGRAM_ID: () => CPMM_MIGRATOR_PROGRAM_ID,
4137
+ MAX_RECIPIENTS: () => MAX_RECIPIENTS,
4138
+ SEED_STATE: () => SEED_STATE,
4139
+ encodeMigrateCalldata: () => encodeMigrateCalldata,
4140
+ encodeRegisterLaunchCalldata: () => encodeRegisterLaunchCalldata,
4141
+ fetchCpmmMigratorState: () => fetchCpmmMigratorState,
4142
+ getCpmmMigratorStateAddress: () => getCpmmMigratorStateAddress,
4143
+ getCpmmMigratorStateCodec: () => getCpmmMigratorStateCodec,
4144
+ getCpmmMigratorStateDecoder: () => getCpmmMigratorStateDecoder,
4145
+ getCpmmMigratorStateEncoder: () => getCpmmMigratorStateEncoder,
4146
+ getMigrateArgsCodec: () => getMigrateArgsCodec,
4147
+ getMigrateArgsDecoder: () => getMigrateArgsDecoder,
4148
+ getMigrateArgsEncoder: () => getMigrateArgsEncoder,
4149
+ getRecipientCodec: () => getRecipientCodec,
4150
+ getRecipientDecoder: () => getRecipientDecoder,
4151
+ getRecipientEncoder: () => getRecipientEncoder,
4152
+ getRegisterLaunchArgsCodec: () => getRegisterLaunchArgsCodec,
4153
+ getRegisterLaunchArgsDecoder: () => getRegisterLaunchArgsDecoder,
4154
+ getRegisterLaunchArgsEncoder: () => getRegisterLaunchArgsEncoder
4155
+ });
4156
+ function getMigrateArgsEncoder() {
4157
+ return kit.getStructEncoder([
4158
+ ["baseForDistribution", kit.getU64Encoder()],
4159
+ ["baseForLiquidity", kit.getU64Encoder()]
4160
+ ]);
4161
+ }
4162
+ function getMigrateArgsDecoder() {
4163
+ return kit.getStructDecoder([
4164
+ ["baseForDistribution", kit.getU64Decoder()],
4165
+ ["baseForLiquidity", kit.getU64Decoder()]
4166
+ ]);
4167
+ }
4168
+ function getMigrateArgsCodec() {
4169
+ return kit.combineCodec(getMigrateArgsEncoder(), getMigrateArgsDecoder());
4170
+ }
4171
+ function getRecipientEncoder() {
4172
+ return kit.getStructEncoder([
4173
+ ["wallet", kit.getAddressEncoder()],
4174
+ ["amount", kit.getU64Encoder()]
4175
+ ]);
4176
+ }
4177
+ function getRecipientDecoder() {
4178
+ return kit.getStructDecoder([
4179
+ ["wallet", kit.getAddressDecoder()],
4180
+ ["amount", kit.getU64Decoder()]
4181
+ ]);
4182
+ }
4183
+ function getRecipientCodec() {
4184
+ return kit.combineCodec(getRecipientEncoder(), getRecipientDecoder());
4185
+ }
4186
+ function getRegisterLaunchArgsEncoder() {
4187
+ return kit.getStructEncoder([
4188
+ ["cpmmConfig", kit.getAddressEncoder()],
4189
+ ["initialSwapFeeBps", kit.getU16Encoder()],
4190
+ ["initialFeeSplitBps", kit.getU16Encoder()],
4191
+ ["recipients", kit.getArrayEncoder(getRecipientEncoder())],
4192
+ ["minRaiseQuote", kit.getU64Encoder()],
4193
+ ["minMigrationPriceQ64Opt", kit.getOptionEncoder(kit.getU128Encoder())]
4194
+ ]);
4195
+ }
4196
+ function getRegisterLaunchArgsDecoder() {
4197
+ return kit.getStructDecoder([
4198
+ ["cpmmConfig", kit.getAddressDecoder()],
4199
+ ["initialSwapFeeBps", kit.getU16Decoder()],
4200
+ ["initialFeeSplitBps", kit.getU16Decoder()],
4201
+ ["recipients", kit.getArrayDecoder(getRecipientDecoder())],
4202
+ ["minRaiseQuote", kit.getU64Decoder()],
4203
+ ["minMigrationPriceQ64Opt", kit.getOptionDecoder(kit.getU128Decoder())]
4204
+ ]);
4205
+ }
4206
+ function getRegisterLaunchArgsCodec() {
4207
+ return kit.combineCodec(
4208
+ getRegisterLaunchArgsEncoder(),
4209
+ getRegisterLaunchArgsDecoder()
4210
+ );
4211
+ }
4212
+
4213
+ // src/solana/generated/cpmmMigrator/accounts/cpmmMigratorState.ts
4214
+ var CPMM_MIGRATOR_STATE_DISCRIMINATOR = new Uint8Array([
4215
+ 169,
4216
+ 86,
4217
+ 255,
4218
+ 187,
4219
+ 37,
4220
+ 248,
4221
+ 11,
4222
+ 176
4223
+ ]);
4224
+ function getCpmmMigratorStateEncoder() {
4225
+ return kit.transformEncoder(
4226
+ kit.getStructEncoder([
4227
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
4228
+ ["launch", kit.getAddressEncoder()],
4229
+ ["admin", kit.getAddressEncoder()],
4230
+ ["cpmmConfig", kit.getAddressEncoder()],
4231
+ ["initialSwapFeeBps", kit.getU16Encoder()],
4232
+ ["initialFeeSplitBps", kit.getU16Encoder()],
4233
+ ["pad0", kit.fixEncoderSize(kit.getBytesEncoder(), 4)],
4234
+ ["recipients", kit.getArrayEncoder(getRecipientEncoder(), { size: 2 })],
4235
+ ["minRaiseQuote", kit.getU64Encoder()],
4236
+ ["minMigrationPriceQ64Opt", kit.getOptionEncoder(kit.getU128Encoder())],
4237
+ ["isMigrated", kit.getBooleanEncoder()],
4238
+ ["bump", kit.getU8Encoder()],
4239
+ ["reserved", kit.fixEncoderSize(kit.getBytesEncoder(), 14)]
4240
+ ]),
4241
+ (value) => ({ ...value, discriminator: CPMM_MIGRATOR_STATE_DISCRIMINATOR })
4242
+ );
4243
+ }
4244
+ function getCpmmMigratorStateDecoder() {
4245
+ return kit.getStructDecoder([
4246
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
4247
+ ["launch", kit.getAddressDecoder()],
4248
+ ["admin", kit.getAddressDecoder()],
4249
+ ["cpmmConfig", kit.getAddressDecoder()],
4250
+ ["initialSwapFeeBps", kit.getU16Decoder()],
4251
+ ["initialFeeSplitBps", kit.getU16Decoder()],
4252
+ ["pad0", kit.fixDecoderSize(kit.getBytesDecoder(), 4)],
4253
+ ["recipients", kit.getArrayDecoder(getRecipientDecoder(), { size: 2 })],
4254
+ ["minRaiseQuote", kit.getU64Decoder()],
4255
+ ["minMigrationPriceQ64Opt", kit.getOptionDecoder(kit.getU128Decoder())],
4256
+ ["isMigrated", kit.getBooleanDecoder()],
4257
+ ["bump", kit.getU8Decoder()],
4258
+ ["reserved", kit.fixDecoderSize(kit.getBytesDecoder(), 14)]
4259
+ ]);
4260
+ }
4261
+ function getCpmmMigratorStateCodec() {
4262
+ return kit.combineCodec(
4263
+ getCpmmMigratorStateEncoder(),
4264
+ getCpmmMigratorStateDecoder()
4265
+ );
4266
+ }
4267
+ if (process.env.NODE_ENV !== "production") ;
4268
+
4269
+ // src/solana/migrators/cpmmMigrator/client.ts
4270
+ function base64ToBytes3(base64) {
4271
+ const binary = atob(base64);
4272
+ const bytes = new Uint8Array(binary.length);
4273
+ for (let i = 0; i < binary.length; i++) {
4274
+ bytes[i] = binary.charCodeAt(i);
4275
+ }
4276
+ return bytes;
4277
+ }
4278
+ async function fetchCpmmMigratorState(rpc, address3) {
4279
+ const response = await rpc.getAccountInfo(address3, { encoding: "base64" }).send();
4280
+ if (!response.value) return null;
4281
+ return getCpmmMigratorStateDecoder().decode(
4282
+ base64ToBytes3(response.value.data[0])
4283
+ );
4284
+ }
4285
+
4286
+ // src/solana/migrators/cpmmMigrator/index.ts
4287
+ function encodeRegisterLaunchCalldata(args) {
4288
+ const encoded = new Uint8Array(getRegisterLaunchArgsEncoder().encode(args));
4289
+ return kit.mergeBytes([
4290
+ CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS.registerLaunch,
4291
+ encoded
4292
+ ]);
4293
+ }
4294
+ function encodeMigrateCalldata(args) {
4295
+ const encoded = new Uint8Array(getMigrateArgsEncoder().encode(args));
4296
+ return kit.mergeBytes([
4297
+ CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS.migrate,
4298
+ encoded
4299
+ ]);
4300
+ }
4301
+
4302
+ // src/solana/migrators/predictionMigrator/index.ts
4303
+ var predictionMigrator_exports = {};
4304
+ chunkQ7SFCCGT_cjs.__export(predictionMigrator_exports, {
4305
+ CLAIM_DISCRIMINATOR: () => CLAIM_DISCRIMINATOR,
4306
+ CLAIM_RECEIPT_DISCRIMINATOR: () => CLAIM_RECEIPT_DISCRIMINATOR,
4307
+ ENTRY_BY_MINT_DISCRIMINATOR: () => ENTRY_BY_MINT_DISCRIMINATOR,
4308
+ ENTRY_DISCRIMINATOR: () => ENTRY_DISCRIMINATOR,
4309
+ LAUNCH_DISCRIMINATOR: () => LAUNCH_DISCRIMINATOR2,
4310
+ MARKET_DISCRIMINATOR: () => MARKET_DISCRIMINATOR,
4311
+ MIGRATE_ENTRY_DISCRIMINATOR: () => MIGRATE_ENTRY_DISCRIMINATOR,
4312
+ ORACLE_STATE_DISCRIMINATOR: () => ORACLE_STATE_DISCRIMINATOR,
4313
+ PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_MIGRATED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_MIGRATED,
4314
+ PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_REGISTERED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_REGISTERED,
4315
+ PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_MIGRATED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_MIGRATED,
4316
+ PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_REGISTERED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_REGISTERED,
4317
+ PREDICTION_MIGRATOR_ERROR__INSUFFICIENT_BALANCE: () => PREDICTION_MIGRATOR_ERROR__INSUFFICIENT_BALANCE,
4318
+ PREDICTION_MIGRATOR_ERROR__INVALID_ENTRY_ID: () => PREDICTION_MIGRATOR_ERROR__INVALID_ENTRY_ID,
4319
+ PREDICTION_MIGRATOR_ERROR__INVALID_INPUT: () => PREDICTION_MIGRATOR_ERROR__INVALID_INPUT,
4320
+ PREDICTION_MIGRATOR_ERROR__INVALID_MARKET: () => PREDICTION_MIGRATOR_ERROR__INVALID_MARKET,
4321
+ PREDICTION_MIGRATOR_ERROR__INVALID_MINT: () => PREDICTION_MIGRATOR_ERROR__INVALID_MINT,
4322
+ PREDICTION_MIGRATOR_ERROR__INVALID_ORACLE: () => PREDICTION_MIGRATOR_ERROR__INVALID_ORACLE,
4323
+ PREDICTION_MIGRATOR_ERROR__INVALID_VAULT: () => PREDICTION_MIGRATOR_ERROR__INVALID_VAULT,
4324
+ PREDICTION_MIGRATOR_ERROR__INVALID_WINNER_MINT: () => PREDICTION_MIGRATOR_ERROR__INVALID_WINNER_MINT,
4325
+ PREDICTION_MIGRATOR_ERROR__MARKET_NOT_RESOLVED: () => PREDICTION_MIGRATOR_ERROR__MARKET_NOT_RESOLVED,
4326
+ PREDICTION_MIGRATOR_ERROR__MATH_OVERFLOW: () => PREDICTION_MIGRATOR_ERROR__MATH_OVERFLOW,
4327
+ PREDICTION_MIGRATOR_ERROR__NO_PENDING_REWARDS: () => PREDICTION_MIGRATOR_ERROR__NO_PENDING_REWARDS,
4328
+ PREDICTION_MIGRATOR_ERROR__ORACLE_NOT_FINALIZED: () => PREDICTION_MIGRATOR_ERROR__ORACLE_NOT_FINALIZED,
4329
+ PREDICTION_MIGRATOR_ERROR__QUOTE_MINT_MISMATCH: () => PREDICTION_MIGRATOR_ERROR__QUOTE_MINT_MISMATCH,
4330
+ PREDICTION_MIGRATOR_ERROR__UNAUTHORIZED: () => PREDICTION_MIGRATOR_ERROR__UNAUTHORIZED,
4331
+ PREDICTION_MIGRATOR_ERROR__WINNING_ENTRY_NOT_MIGRATED: () => PREDICTION_MIGRATOR_ERROR__WINNING_ENTRY_NOT_MIGRATED,
4332
+ PREDICTION_MIGRATOR_ERROR__ZERO_CLAIMABLE_SUPPLY: () => PREDICTION_MIGRATOR_ERROR__ZERO_CLAIMABLE_SUPPLY,
4333
+ PREDICTION_MIGRATOR_PROGRAM_ADDRESS: () => PREDICTION_MIGRATOR_PROGRAM_ADDRESS,
4334
+ PREVIEW_PAYOUT_IF_WINNER_DISCRIMINATOR: () => PREVIEW_PAYOUT_IF_WINNER_DISCRIMINATOR,
4335
+ PredictionMigratorAccount: () => PredictionMigratorAccount,
4336
+ PredictionMigratorInstruction: () => PredictionMigratorInstruction,
4337
+ REGISTER_ENTRY_DISCRIMINATOR: () => REGISTER_ENTRY_DISCRIMINATOR,
4338
+ decodeClaimReceipt: () => decodeClaimReceipt,
4339
+ decodeEntry: () => decodeEntry,
4340
+ decodeEntryByMint: () => decodeEntryByMint,
4341
+ decodeLaunch: () => decodeLaunch,
4342
+ decodeMarket: () => decodeMarket,
4343
+ decodeOracleState: () => decodeOracleState2,
4344
+ fetchAllClaimReceipt: () => fetchAllClaimReceipt,
4345
+ fetchAllEntry: () => fetchAllEntry,
4346
+ fetchAllEntryByMint: () => fetchAllEntryByMint,
4347
+ fetchAllLaunch: () => fetchAllLaunch,
4348
+ fetchAllMarket: () => fetchAllMarket,
4349
+ fetchAllMaybeClaimReceipt: () => fetchAllMaybeClaimReceipt,
4350
+ fetchAllMaybeEntry: () => fetchAllMaybeEntry,
4351
+ fetchAllMaybeEntryByMint: () => fetchAllMaybeEntryByMint,
4352
+ fetchAllMaybeLaunch: () => fetchAllMaybeLaunch,
4353
+ fetchAllMaybeMarket: () => fetchAllMaybeMarket,
4354
+ fetchAllMaybeOracleState: () => fetchAllMaybeOracleState,
4355
+ fetchAllOracleState: () => fetchAllOracleState,
4356
+ fetchClaimReceipt: () => fetchClaimReceipt,
4357
+ fetchEntry: () => fetchEntry,
4358
+ fetchEntryByMint: () => fetchEntryByMint,
4359
+ fetchLaunch: () => fetchLaunch,
4360
+ fetchMarket: () => fetchMarket,
4361
+ fetchMaybeClaimReceipt: () => fetchMaybeClaimReceipt,
4362
+ fetchMaybeEntry: () => fetchMaybeEntry,
4363
+ fetchMaybeEntryByMint: () => fetchMaybeEntryByMint,
4364
+ fetchMaybeLaunch: () => fetchMaybeLaunch,
4365
+ fetchMaybeMarket: () => fetchMaybeMarket,
4366
+ fetchMaybeOracleState: () => fetchMaybeOracleState,
4367
+ fetchOracleState: () => fetchOracleState,
4368
+ getAccumulatorUpdatedCodec: () => getAccumulatorUpdatedCodec,
4369
+ getAccumulatorUpdatedDecoder: () => getAccumulatorUpdatedDecoder,
4370
+ getAccumulatorUpdatedEncoder: () => getAccumulatorUpdatedEncoder,
4371
+ getCalldataBufCodec: () => getCalldataBufCodec,
4372
+ getCalldataBufDecoder: () => getCalldataBufDecoder2,
4373
+ getCalldataBufEncoder: () => getCalldataBufEncoder2,
4374
+ getClaimDiscriminatorBytes: () => getClaimDiscriminatorBytes,
4375
+ getClaimInstruction: () => getClaimInstruction,
4376
+ getClaimInstructionAsync: () => getClaimInstructionAsync,
4377
+ getClaimInstructionDataCodec: () => getClaimInstructionDataCodec,
4378
+ getClaimInstructionDataDecoder: () => getClaimInstructionDataDecoder,
4379
+ getClaimInstructionDataEncoder: () => getClaimInstructionDataEncoder,
4380
+ getClaimReceiptCodec: () => getClaimReceiptCodec,
4381
+ getClaimReceiptDecoder: () => getClaimReceiptDecoder,
4382
+ getClaimReceiptDiscriminatorBytes: () => getClaimReceiptDiscriminatorBytes,
4383
+ getClaimReceiptEncoder: () => getClaimReceiptEncoder,
4384
+ getClaimReceiptSize: () => getClaimReceiptSize,
4385
+ getEntryByMintCodec: () => getEntryByMintCodec,
4386
+ getEntryByMintDecoder: () => getEntryByMintDecoder,
4387
+ getEntryByMintDiscriminatorBytes: () => getEntryByMintDiscriminatorBytes,
4388
+ getEntryByMintEncoder: () => getEntryByMintEncoder,
4389
+ getEntryByMintSize: () => getEntryByMintSize,
4390
+ getEntryCodec: () => getEntryCodec,
4391
+ getEntryDecoder: () => getEntryDecoder,
4392
+ getEntryDiscriminatorBytes: () => getEntryDiscriminatorBytes,
4393
+ getEntryEncoder: () => getEntryEncoder,
4394
+ getEntryMigratedCodec: () => getEntryMigratedCodec,
4395
+ getEntryMigratedDecoder: () => getEntryMigratedDecoder,
4396
+ getEntryMigratedEncoder: () => getEntryMigratedEncoder,
4397
+ getEntryRegisteredCodec: () => getEntryRegisteredCodec,
4398
+ getEntryRegisteredDecoder: () => getEntryRegisteredDecoder,
4399
+ getEntryRegisteredEncoder: () => getEntryRegisteredEncoder,
4400
+ getEntrySize: () => getEntrySize,
4401
+ getLaunchCodec: () => getLaunchCodec2,
4402
+ getLaunchDecoder: () => getLaunchDecoder2,
4403
+ getLaunchDiscriminatorBytes: () => getLaunchDiscriminatorBytes,
4404
+ getLaunchEncoder: () => getLaunchEncoder2,
4405
+ getLaunchSize: () => getLaunchSize,
4406
+ getMarketCodec: () => getMarketCodec,
4407
+ getMarketCreatedCodec: () => getMarketCreatedCodec,
4408
+ getMarketCreatedDecoder: () => getMarketCreatedDecoder,
4409
+ getMarketCreatedEncoder: () => getMarketCreatedEncoder,
4410
+ getMarketDecoder: () => getMarketDecoder,
4411
+ getMarketDiscriminatorBytes: () => getMarketDiscriminatorBytes,
4412
+ getMarketEncoder: () => getMarketEncoder,
4413
+ getMarketResolvedCodec: () => getMarketResolvedCodec,
4414
+ getMarketResolvedDecoder: () => getMarketResolvedDecoder,
4415
+ getMarketResolvedEncoder: () => getMarketResolvedEncoder,
4416
+ getMarketSize: () => getMarketSize,
4417
+ getMigrateEntryArgsCodec: () => getMigrateEntryArgsCodec,
4418
+ getMigrateEntryArgsDecoder: () => getMigrateEntryArgsDecoder,
4419
+ getMigrateEntryArgsEncoder: () => getMigrateEntryArgsEncoder,
4420
+ getMigrateEntryDiscriminatorBytes: () => getMigrateEntryDiscriminatorBytes,
4421
+ getMigrateEntryInstruction: () => getMigrateEntryInstruction,
4422
+ getMigrateEntryInstructionAsync: () => getMigrateEntryInstructionAsync,
4423
+ getMigrateEntryInstructionDataCodec: () => getMigrateEntryInstructionDataCodec,
4424
+ getMigrateEntryInstructionDataDecoder: () => getMigrateEntryInstructionDataDecoder,
4425
+ getMigrateEntryInstructionDataEncoder: () => getMigrateEntryInstructionDataEncoder,
4426
+ getOracleStateCodec: () => getOracleStateCodec,
4427
+ getOracleStateDecoder: () => getOracleStateDecoder,
4428
+ getOracleStateDiscriminatorBytes: () => getOracleStateDiscriminatorBytes,
4429
+ getOracleStateEncoder: () => getOracleStateEncoder,
4430
+ getOracleStateSize: () => getOracleStateSize,
4431
+ getPredictionEntryAddress: () => getPredictionEntryAddress,
4432
+ getPredictionEntryByMintAddress: () => getPredictionEntryByMintAddress,
4433
+ getPredictionMarketAddress: () => getPredictionMarketAddress,
4434
+ getPredictionMarketAuthorityAddress: () => getPredictionMarketAuthorityAddress,
4435
+ getPredictionMigratorErrorMessage: () => getPredictionMigratorErrorMessage,
4436
+ getPredictionPotVaultAddress: () => getPredictionPotVaultAddress,
4437
+ getPreviewPayoutIfWinnerArgsCodec: () => getPreviewPayoutIfWinnerArgsCodec,
4438
+ getPreviewPayoutIfWinnerArgsDecoder: () => getPreviewPayoutIfWinnerArgsDecoder,
4439
+ getPreviewPayoutIfWinnerArgsEncoder: () => getPreviewPayoutIfWinnerArgsEncoder,
4440
+ getPreviewPayoutIfWinnerDiscriminatorBytes: () => getPreviewPayoutIfWinnerDiscriminatorBytes,
4441
+ getPreviewPayoutIfWinnerInstruction: () => getPreviewPayoutIfWinnerInstruction,
4442
+ getPreviewPayoutIfWinnerInstructionDataCodec: () => getPreviewPayoutIfWinnerInstructionDataCodec,
4443
+ getPreviewPayoutIfWinnerInstructionDataDecoder: () => getPreviewPayoutIfWinnerInstructionDataDecoder,
4444
+ getPreviewPayoutIfWinnerInstructionDataEncoder: () => getPreviewPayoutIfWinnerInstructionDataEncoder,
4445
+ getRegisterEntryArgsCodec: () => getRegisterEntryArgsCodec,
4446
+ getRegisterEntryArgsDecoder: () => getRegisterEntryArgsDecoder,
4447
+ getRegisterEntryArgsEncoder: () => getRegisterEntryArgsEncoder,
4448
+ getRegisterEntryDiscriminatorBytes: () => getRegisterEntryDiscriminatorBytes,
4449
+ getRegisterEntryInstruction: () => getRegisterEntryInstruction,
4450
+ getRegisterEntryInstructionAsync: () => getRegisterEntryInstructionAsync,
4451
+ getRegisterEntryInstructionDataCodec: () => getRegisterEntryInstructionDataCodec,
4452
+ getRegisterEntryInstructionDataDecoder: () => getRegisterEntryInstructionDataDecoder,
4453
+ getRegisterEntryInstructionDataEncoder: () => getRegisterEntryInstructionDataEncoder,
4454
+ getRewardsClaimedCodec: () => getRewardsClaimedCodec,
4455
+ getRewardsClaimedDecoder: () => getRewardsClaimedDecoder,
4456
+ getRewardsClaimedEncoder: () => getRewardsClaimedEncoder,
4457
+ identifyPredictionMigratorAccount: () => identifyPredictionMigratorAccount,
4458
+ identifyPredictionMigratorInstruction: () => identifyPredictionMigratorInstruction,
4459
+ isPredictionMigratorError: () => isPredictionMigratorError,
4460
+ parseClaimInstruction: () => parseClaimInstruction,
4461
+ parseMigrateEntryInstruction: () => parseMigrateEntryInstruction,
4462
+ parsePredictionMigratorInstruction: () => parsePredictionMigratorInstruction,
4463
+ parsePreviewPayoutIfWinnerInstruction: () => parsePreviewPayoutIfWinnerInstruction,
4464
+ parseRegisterEntryInstruction: () => parseRegisterEntryInstruction,
4465
+ predictionMigratorProgram: () => predictionMigratorProgram
4466
+ });
4467
+ var PREDICTION_MIGRATOR_ERROR__UNAUTHORIZED = 6e3;
4468
+ var PREDICTION_MIGRATOR_ERROR__QUOTE_MINT_MISMATCH = 6001;
4469
+ var PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_REGISTERED = 6002;
4470
+ var PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_REGISTERED = 6003;
4471
+ var PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_MIGRATED = 6004;
4472
+ var PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_MIGRATED = 6005;
4473
+ var PREDICTION_MIGRATOR_ERROR__ORACLE_NOT_FINALIZED = 6006;
4474
+ var PREDICTION_MIGRATOR_ERROR__MARKET_NOT_RESOLVED = 6007;
4475
+ var PREDICTION_MIGRATOR_ERROR__INVALID_WINNER_MINT = 6008;
4476
+ var PREDICTION_MIGRATOR_ERROR__INSUFFICIENT_BALANCE = 6009;
4477
+ var PREDICTION_MIGRATOR_ERROR__MATH_OVERFLOW = 6010;
4478
+ var PREDICTION_MIGRATOR_ERROR__INVALID_ENTRY_ID = 6011;
4479
+ var PREDICTION_MIGRATOR_ERROR__INVALID_MARKET = 6012;
4480
+ var PREDICTION_MIGRATOR_ERROR__INVALID_VAULT = 6013;
4481
+ var PREDICTION_MIGRATOR_ERROR__INVALID_MINT = 6014;
4482
+ var PREDICTION_MIGRATOR_ERROR__WINNING_ENTRY_NOT_MIGRATED = 6015;
4483
+ var PREDICTION_MIGRATOR_ERROR__NO_PENDING_REWARDS = 6016;
4484
+ var PREDICTION_MIGRATOR_ERROR__INVALID_ORACLE = 6017;
4485
+ var PREDICTION_MIGRATOR_ERROR__ZERO_CLAIMABLE_SUPPLY = 6018;
4486
+ var PREDICTION_MIGRATOR_ERROR__INVALID_INPUT = 6019;
4487
+ var predictionMigratorErrorMessages;
4488
+ if (process.env.NODE_ENV !== "production") {
4489
+ predictionMigratorErrorMessages = {
4490
+ [PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_MIGRATED]: `Entry already migrated`,
4491
+ [PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_REGISTERED]: `Entry already registered`,
4492
+ [PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_MIGRATED]: `Entry not migrated`,
4493
+ [PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_REGISTERED]: `Entry not registered`,
4494
+ [PREDICTION_MIGRATOR_ERROR__INSUFFICIENT_BALANCE]: `Insufficient balance`,
4495
+ [PREDICTION_MIGRATOR_ERROR__INVALID_ENTRY_ID]: `Invalid entry ID`,
4496
+ [PREDICTION_MIGRATOR_ERROR__INVALID_INPUT]: `Invalid input`,
4497
+ [PREDICTION_MIGRATOR_ERROR__INVALID_MARKET]: `Invalid market`,
4498
+ [PREDICTION_MIGRATOR_ERROR__INVALID_MINT]: `Invalid mint`,
4499
+ [PREDICTION_MIGRATOR_ERROR__INVALID_ORACLE]: `Invalid oracle`,
4500
+ [PREDICTION_MIGRATOR_ERROR__INVALID_VAULT]: `Invalid vault`,
4501
+ [PREDICTION_MIGRATOR_ERROR__INVALID_WINNER_MINT]: `Invalid winner mint`,
4502
+ [PREDICTION_MIGRATOR_ERROR__MARKET_NOT_RESOLVED]: `Market not resolved`,
4503
+ [PREDICTION_MIGRATOR_ERROR__MATH_OVERFLOW]: `Math overflow`,
4504
+ [PREDICTION_MIGRATOR_ERROR__NO_PENDING_REWARDS]: `No pending rewards`,
4505
+ [PREDICTION_MIGRATOR_ERROR__ORACLE_NOT_FINALIZED]: `Oracle not finalized`,
4506
+ [PREDICTION_MIGRATOR_ERROR__QUOTE_MINT_MISMATCH]: `Quote mint mismatch`,
4507
+ [PREDICTION_MIGRATOR_ERROR__UNAUTHORIZED]: `Unauthorized`,
4508
+ [PREDICTION_MIGRATOR_ERROR__WINNING_ENTRY_NOT_MIGRATED]: `Winning entry not migrated`,
4509
+ [PREDICTION_MIGRATOR_ERROR__ZERO_CLAIMABLE_SUPPLY]: `Zero claimable supply`
4510
+ };
4511
+ }
4512
+ function getPredictionMigratorErrorMessage(code) {
4513
+ if (process.env.NODE_ENV !== "production") {
4514
+ return predictionMigratorErrorMessages[code];
4515
+ }
4516
+ return "Error message not available in production bundles.";
4517
+ }
4518
+ function isPredictionMigratorError(error, transactionMessage, code) {
4519
+ return kit.isProgramError(
4520
+ error,
4521
+ transactionMessage,
4522
+ PREDICTION_MIGRATOR_PROGRAM_ADDRESS,
4523
+ code
4524
+ );
4525
+ }
4526
+
4527
+ // src/solana/trustedOracle/index.ts
4528
+ var trustedOracle_exports = {};
4529
+ chunkQ7SFCCGT_cjs.__export(trustedOracle_exports, {
4530
+ FINALIZE_DISCRIMINATOR: () => FINALIZE_DISCRIMINATOR,
4531
+ INITIALIZE_ORACLE_DISCRIMINATOR: () => INITIALIZE_ORACLE_DISCRIMINATOR,
4532
+ ORACLE_STATE_DISCRIMINATOR: () => ORACLE_STATE_DISCRIMINATOR2,
4533
+ TRUSTED_ORACLE_ERROR__ALREADY_FINALIZED: () => TRUSTED_ORACLE_ERROR__ALREADY_FINALIZED,
4534
+ TRUSTED_ORACLE_ERROR__INVALID_WINNING_MINT: () => TRUSTED_ORACLE_ERROR__INVALID_WINNING_MINT,
4535
+ TRUSTED_ORACLE_ERROR__NOT_FINALIZED: () => TRUSTED_ORACLE_ERROR__NOT_FINALIZED,
4536
+ TRUSTED_ORACLE_ERROR__UNAUTHORIZED: () => TRUSTED_ORACLE_ERROR__UNAUTHORIZED,
4537
+ TRUSTED_ORACLE_PROGRAM_ADDRESS: () => TRUSTED_ORACLE_PROGRAM_ADDRESS,
4538
+ TrustedOracleAccount: () => TrustedOracleAccount,
4539
+ TrustedOracleInstruction: () => TrustedOracleInstruction,
4540
+ decodeOracleState: () => decodeOracleState3,
4541
+ fetchAllMaybeOracleState: () => fetchAllMaybeOracleState2,
4542
+ fetchAllOracleState: () => fetchAllOracleState2,
4543
+ fetchMaybeOracleState: () => fetchMaybeOracleState2,
4544
+ fetchOracleState: () => fetchOracleState2,
4545
+ getFinalizeDiscriminatorBytes: () => getFinalizeDiscriminatorBytes,
4546
+ getFinalizeInstruction: () => getFinalizeInstruction,
4547
+ getFinalizeInstructionDataCodec: () => getFinalizeInstructionDataCodec,
4548
+ getFinalizeInstructionDataDecoder: () => getFinalizeInstructionDataDecoder,
4549
+ getFinalizeInstructionDataEncoder: () => getFinalizeInstructionDataEncoder,
4550
+ getInitializeOracleArgsCodec: () => getInitializeOracleArgsCodec,
4551
+ getInitializeOracleArgsDecoder: () => getInitializeOracleArgsDecoder,
4552
+ getInitializeOracleArgsEncoder: () => getInitializeOracleArgsEncoder,
4553
+ getInitializeOracleDiscriminatorBytes: () => getInitializeOracleDiscriminatorBytes,
4554
+ getInitializeOracleInstruction: () => getInitializeOracleInstruction,
4555
+ getInitializeOracleInstructionDataCodec: () => getInitializeOracleInstructionDataCodec,
4556
+ getInitializeOracleInstructionDataDecoder: () => getInitializeOracleInstructionDataDecoder,
4557
+ getInitializeOracleInstructionDataEncoder: () => getInitializeOracleInstructionDataEncoder,
4558
+ getOracleStateAddress: () => getOracleStateAddress,
4559
+ getOracleStateCodec: () => getOracleStateCodec2,
4560
+ getOracleStateDecoder: () => getOracleStateDecoder2,
4561
+ getOracleStateDiscriminatorBytes: () => getOracleStateDiscriminatorBytes2,
4562
+ getOracleStateEncoder: () => getOracleStateEncoder2,
4563
+ getOracleStateSize: () => getOracleStateSize2,
4564
+ getTrustedOracleErrorMessage: () => getTrustedOracleErrorMessage,
4565
+ identifyTrustedOracleAccount: () => identifyTrustedOracleAccount,
4566
+ identifyTrustedOracleInstruction: () => identifyTrustedOracleInstruction,
4567
+ isTrustedOracleError: () => isTrustedOracleError,
4568
+ parseFinalizeInstruction: () => parseFinalizeInstruction,
4569
+ parseInitializeOracleInstruction: () => parseInitializeOracleInstruction,
4570
+ parseTrustedOracleInstruction: () => parseTrustedOracleInstruction,
4571
+ trustedOracleProgram: () => trustedOracleProgram
4572
+ });
4573
+ var ORACLE_STATE_DISCRIMINATOR2 = new Uint8Array([
4574
+ 97,
4575
+ 156,
4576
+ 157,
4577
+ 189,
4578
+ 194,
4579
+ 73,
4580
+ 8,
4581
+ 15
4582
+ ]);
4583
+ function getOracleStateDiscriminatorBytes2() {
4584
+ return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
4585
+ ORACLE_STATE_DISCRIMINATOR2
4586
+ );
4587
+ }
4588
+ function getOracleStateEncoder2() {
4589
+ return kit.transformEncoder(
4590
+ kit.getStructEncoder([
4591
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
4592
+ ["oracleAuthority", kit.getAddressEncoder()],
4593
+ ["quoteMint", kit.getAddressEncoder()],
4594
+ ["isFinalized", kit.getBooleanEncoder()],
4595
+ ["winningMint", kit.getAddressEncoder()],
4596
+ ["nonce", kit.getU64Encoder()],
4597
+ ["bump", kit.getU8Encoder()],
4598
+ ["reserved", kit.fixEncoderSize(kit.getBytesEncoder(), 31)]
4599
+ ]),
4600
+ (value) => ({ ...value, discriminator: ORACLE_STATE_DISCRIMINATOR2 })
4601
+ );
4602
+ }
4603
+ function getOracleStateDecoder2() {
4604
+ return kit.getStructDecoder([
4605
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
4606
+ ["oracleAuthority", kit.getAddressDecoder()],
4607
+ ["quoteMint", kit.getAddressDecoder()],
4608
+ ["isFinalized", kit.getBooleanDecoder()],
4609
+ ["winningMint", kit.getAddressDecoder()],
4610
+ ["nonce", kit.getU64Decoder()],
4611
+ ["bump", kit.getU8Decoder()],
4612
+ ["reserved", kit.fixDecoderSize(kit.getBytesDecoder(), 31)]
4613
+ ]);
4614
+ }
4615
+ function getOracleStateCodec2() {
4616
+ return kit.combineCodec(getOracleStateEncoder2(), getOracleStateDecoder2());
4617
+ }
4618
+ function decodeOracleState3(encodedAccount) {
4619
+ return kit.decodeAccount(
4620
+ encodedAccount,
4621
+ getOracleStateDecoder2()
4622
+ );
4623
+ }
4624
+ async function fetchOracleState2(rpc, address3, config) {
4625
+ const maybeAccount = await fetchMaybeOracleState2(rpc, address3, config);
4626
+ kit.assertAccountExists(maybeAccount);
4627
+ return maybeAccount;
4628
+ }
4629
+ async function fetchMaybeOracleState2(rpc, address3, config) {
4630
+ const maybeAccount = await kit.fetchEncodedAccount(rpc, address3, config);
4631
+ return decodeOracleState3(maybeAccount);
4632
+ }
4633
+ async function fetchAllOracleState2(rpc, addresses, config) {
4634
+ const maybeAccounts = await fetchAllMaybeOracleState2(rpc, addresses, config);
4635
+ kit.assertAccountsExist(maybeAccounts);
4636
+ return maybeAccounts;
4637
+ }
4638
+ async function fetchAllMaybeOracleState2(rpc, addresses, config) {
4639
+ const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
4640
+ return maybeAccounts.map((maybeAccount) => decodeOracleState3(maybeAccount));
4641
+ }
4642
+ function getOracleStateSize2() {
4643
+ return 145;
4644
+ }
4645
+ var FINALIZE_DISCRIMINATOR = new Uint8Array([
4646
+ 171,
4647
+ 61,
4648
+ 218,
4649
+ 56,
4650
+ 127,
4651
+ 115,
4652
+ 12,
4653
+ 217
4654
+ ]);
4655
+ function getFinalizeDiscriminatorBytes() {
4656
+ return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(FINALIZE_DISCRIMINATOR);
4657
+ }
4658
+ function getFinalizeInstructionDataEncoder() {
4659
+ return kit.transformEncoder(
4660
+ kit.getStructEncoder([
4661
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
4662
+ ["winningMint", kit.getAddressEncoder()]
4663
+ ]),
4664
+ (value) => ({ ...value, discriminator: FINALIZE_DISCRIMINATOR })
4665
+ );
4666
+ }
4667
+ function getFinalizeInstructionDataDecoder() {
4668
+ return kit.getStructDecoder([
4669
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
4670
+ ["winningMint", kit.getAddressDecoder()]
4671
+ ]);
4672
+ }
4673
+ function getFinalizeInstructionDataCodec() {
4674
+ return kit.combineCodec(
4675
+ getFinalizeInstructionDataEncoder(),
4676
+ getFinalizeInstructionDataDecoder()
4677
+ );
4678
+ }
4679
+ function getFinalizeInstruction(input, config) {
4680
+ const programAddress = config?.programAddress ?? TRUSTED_ORACLE_PROGRAM_ADDRESS;
4681
+ const originalAccounts = {
4682
+ oracleAuthority: {
4683
+ value: input.oracleAuthority ?? null,
4684
+ isWritable: false
4685
+ },
4686
+ oracleState: { value: input.oracleState ?? null, isWritable: true }
4687
+ };
4688
+ const accounts = originalAccounts;
4689
+ const args = { ...input };
4690
+ const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
4691
+ return Object.freeze({
4692
+ accounts: [
4693
+ getAccountMeta("oracleAuthority", accounts.oracleAuthority),
4694
+ getAccountMeta("oracleState", accounts.oracleState)
4695
+ ],
4696
+ data: getFinalizeInstructionDataEncoder().encode(
4697
+ args
4698
+ ),
4699
+ programAddress
4700
+ });
4701
+ }
4702
+ function parseFinalizeInstruction(instruction) {
4703
+ if (instruction.accounts.length < 2) {
4704
+ throw new kit.SolanaError(
4705
+ kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
4706
+ {
4707
+ actualAccountMetas: instruction.accounts.length,
4708
+ expectedAccountMetas: 2
4709
+ }
4710
+ );
4711
+ }
4712
+ let accountIndex = 0;
4713
+ const getNextAccount = () => {
4714
+ const accountMeta = instruction.accounts[accountIndex];
4715
+ accountIndex += 1;
4716
+ return accountMeta;
4717
+ };
4718
+ return {
4719
+ programAddress: instruction.programAddress,
4720
+ accounts: {
4721
+ oracleAuthority: getNextAccount(),
4722
+ oracleState: getNextAccount()
4723
+ },
4724
+ data: getFinalizeInstructionDataDecoder().decode(instruction.data)
4725
+ };
4726
+ }
4727
+ var INITIALIZE_ORACLE_DISCRIMINATOR = new Uint8Array([
4728
+ 144,
4729
+ 223,
4730
+ 131,
4731
+ 120,
4732
+ 196,
4733
+ 253,
4734
+ 181,
4735
+ 99
4736
+ ]);
4737
+ function getInitializeOracleDiscriminatorBytes() {
4738
+ return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
4739
+ INITIALIZE_ORACLE_DISCRIMINATOR
4740
+ );
4741
+ }
4742
+ function getInitializeOracleInstructionDataEncoder() {
4743
+ return kit.transformEncoder(
4744
+ kit.getStructEncoder([
4745
+ ["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
4746
+ ["nonce", kit.getU64Encoder()],
4747
+ ["quoteMint", kit.getAddressEncoder()]
4748
+ ]),
4749
+ (value) => ({ ...value, discriminator: INITIALIZE_ORACLE_DISCRIMINATOR })
4750
+ );
4751
+ }
4752
+ function getInitializeOracleInstructionDataDecoder() {
4753
+ return kit.getStructDecoder([
4754
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
4755
+ ["nonce", kit.getU64Decoder()],
4756
+ ["quoteMint", kit.getAddressDecoder()]
4757
+ ]);
4758
+ }
4759
+ function getInitializeOracleInstructionDataCodec() {
4760
+ return kit.combineCodec(
4761
+ getInitializeOracleInstructionDataEncoder(),
4762
+ getInitializeOracleInstructionDataDecoder()
4763
+ );
4764
+ }
4765
+ function getInitializeOracleInstruction(input, config) {
4766
+ const programAddress = config?.programAddress ?? TRUSTED_ORACLE_PROGRAM_ADDRESS;
4767
+ const originalAccounts = {
4768
+ oracleAuthority: { value: input.oracleAuthority ?? null, isWritable: true },
4769
+ oracleState: { value: input.oracleState ?? null, isWritable: true },
4770
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
4771
+ };
4772
+ const accounts = originalAccounts;
4773
+ const args = { ...input };
4774
+ if (!accounts.systemProgram.value) {
4775
+ accounts.systemProgram.value = "11111111111111111111111111111111";
4776
+ }
4777
+ const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
4778
+ return Object.freeze({
4779
+ accounts: [
4780
+ getAccountMeta("oracleAuthority", accounts.oracleAuthority),
4781
+ getAccountMeta("oracleState", accounts.oracleState),
4782
+ getAccountMeta("systemProgram", accounts.systemProgram)
4783
+ ],
4784
+ data: getInitializeOracleInstructionDataEncoder().encode(
4785
+ args
4786
+ ),
4787
+ programAddress
4788
+ });
4789
+ }
4790
+ function parseInitializeOracleInstruction(instruction) {
4791
+ if (instruction.accounts.length < 3) {
4792
+ throw new kit.SolanaError(
4793
+ kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
4794
+ {
4795
+ actualAccountMetas: instruction.accounts.length,
4796
+ expectedAccountMetas: 3
4797
+ }
4798
+ );
4799
+ }
4800
+ let accountIndex = 0;
4801
+ const getNextAccount = () => {
4802
+ const accountMeta = instruction.accounts[accountIndex];
4803
+ accountIndex += 1;
4804
+ return accountMeta;
4805
+ };
4806
+ return {
4807
+ programAddress: instruction.programAddress,
4808
+ accounts: {
4809
+ oracleAuthority: getNextAccount(),
4810
+ oracleState: getNextAccount(),
4811
+ systemProgram: getNextAccount()
4812
+ },
4813
+ data: getInitializeOracleInstructionDataDecoder().decode(instruction.data)
4814
+ };
4815
+ }
4816
+
4817
+ // src/solana/generated/trustedOracle/programs/trustedOracle.ts
4818
+ var TRUSTED_ORACLE_PROGRAM_ADDRESS = "HhUzN7VvonNUevATyugZUepzxpeEZMXQbV92X2xvsp5m";
4819
+ var TrustedOracleAccount = /* @__PURE__ */ ((TrustedOracleAccount2) => {
4820
+ TrustedOracleAccount2[TrustedOracleAccount2["OracleState"] = 0] = "OracleState";
4821
+ return TrustedOracleAccount2;
4822
+ })(TrustedOracleAccount || {});
4823
+ function identifyTrustedOracleAccount(account) {
4824
+ const data = "data" in account ? account.data : account;
4825
+ if (kit.containsBytes(
4826
+ data,
4827
+ kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
4828
+ new Uint8Array([97, 156, 157, 189, 194, 73, 8, 15])
4829
+ ),
4830
+ 0
4831
+ )) {
4832
+ return 0 /* OracleState */;
4833
+ }
4834
+ throw new kit.SolanaError(
4835
+ kit.SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT,
4836
+ { accountData: data, programName: "trustedOracle" }
4837
+ );
4838
+ }
4839
+ var TrustedOracleInstruction = /* @__PURE__ */ ((TrustedOracleInstruction2) => {
4840
+ TrustedOracleInstruction2[TrustedOracleInstruction2["Finalize"] = 0] = "Finalize";
4841
+ TrustedOracleInstruction2[TrustedOracleInstruction2["InitializeOracle"] = 1] = "InitializeOracle";
4842
+ return TrustedOracleInstruction2;
4843
+ })(TrustedOracleInstruction || {});
4844
+ function identifyTrustedOracleInstruction(instruction) {
4845
+ const data = "data" in instruction ? instruction.data : instruction;
4846
+ if (kit.containsBytes(
4847
+ data,
4848
+ kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
4849
+ new Uint8Array([171, 61, 218, 56, 127, 115, 12, 217])
4850
+ ),
4851
+ 0
4852
+ )) {
4853
+ return 0 /* Finalize */;
4854
+ }
4855
+ if (kit.containsBytes(
4856
+ data,
4857
+ kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
4858
+ new Uint8Array([144, 223, 131, 120, 196, 253, 181, 99])
4859
+ ),
4860
+ 0
4861
+ )) {
4862
+ return 1 /* InitializeOracle */;
4863
+ }
4864
+ throw new kit.SolanaError(
4865
+ kit.SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
4866
+ { instructionData: data, programName: "trustedOracle" }
4867
+ );
4868
+ }
4869
+ function parseTrustedOracleInstruction(instruction) {
4870
+ const instructionType = identifyTrustedOracleInstruction(instruction);
4871
+ switch (instructionType) {
4872
+ case 0 /* Finalize */: {
4873
+ kit.assertIsInstructionWithAccounts(instruction);
4874
+ return {
4875
+ instructionType: 0 /* Finalize */,
4876
+ ...parseFinalizeInstruction(instruction)
4877
+ };
4878
+ }
4879
+ case 1 /* InitializeOracle */: {
4880
+ kit.assertIsInstructionWithAccounts(instruction);
4881
+ return {
4882
+ instructionType: 1 /* InitializeOracle */,
4883
+ ...parseInitializeOracleInstruction(instruction)
4884
+ };
4885
+ }
4886
+ default:
4887
+ throw new kit.SolanaError(
4888
+ kit.SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
4889
+ {
4890
+ instructionType,
4891
+ programName: "trustedOracle"
4892
+ }
4893
+ );
4894
+ }
4895
+ }
4896
+ function trustedOracleProgram() {
4897
+ return (client) => {
4898
+ return {
4899
+ ...client,
4900
+ trustedOracle: {
4901
+ accounts: {
4902
+ oracleState: programClientCore.addSelfFetchFunctions(client, getOracleStateCodec2())
4903
+ },
4904
+ instructions: {
4905
+ finalize: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getFinalizeInstruction(input)),
4906
+ initializeOracle: (input) => programClientCore.addSelfPlanAndSendFunctions(
4907
+ client,
4908
+ getInitializeOracleInstruction(input)
4909
+ )
4910
+ }
4911
+ }
4912
+ };
4913
+ };
4914
+ }
4915
+
4916
+ // src/solana/generated/trustedOracle/errors/trustedOracle.ts
4917
+ var TRUSTED_ORACLE_ERROR__UNAUTHORIZED = 6e3;
4918
+ var TRUSTED_ORACLE_ERROR__ALREADY_FINALIZED = 6001;
4919
+ var TRUSTED_ORACLE_ERROR__NOT_FINALIZED = 6002;
4920
+ var TRUSTED_ORACLE_ERROR__INVALID_WINNING_MINT = 6003;
4921
+ var trustedOracleErrorMessages;
4922
+ if (process.env.NODE_ENV !== "production") {
4923
+ trustedOracleErrorMessages = {
4924
+ [TRUSTED_ORACLE_ERROR__ALREADY_FINALIZED]: `Oracle already finalized`,
4925
+ [TRUSTED_ORACLE_ERROR__INVALID_WINNING_MINT]: `Invalid winning mint`,
4926
+ [TRUSTED_ORACLE_ERROR__NOT_FINALIZED]: `Oracle not finalized`,
4927
+ [TRUSTED_ORACLE_ERROR__UNAUTHORIZED]: `Unauthorized: only oracle authority can perform this action`
4928
+ };
4929
+ }
4930
+ function getTrustedOracleErrorMessage(code) {
4931
+ if (process.env.NODE_ENV !== "production") {
4932
+ return trustedOracleErrorMessages[code];
4933
+ }
4934
+ return "Error message not available in production bundles.";
4935
+ }
4936
+ function isTrustedOracleError(error, transactionMessage, code) {
4937
+ return kit.isProgramError(
4938
+ error,
4939
+ transactionMessage,
4940
+ TRUSTED_ORACLE_PROGRAM_ADDRESS,
4941
+ code
4942
+ );
4943
+ }
4944
+ function getInitializeOracleArgsEncoder() {
4945
+ return kit.getStructEncoder([
4946
+ ["nonce", kit.getU64Encoder()],
4947
+ ["quoteMint", kit.getAddressEncoder()]
4948
+ ]);
4949
+ }
4950
+ function getInitializeOracleArgsDecoder() {
4951
+ return kit.getStructDecoder([
4952
+ ["nonce", kit.getU64Decoder()],
4953
+ ["quoteMint", kit.getAddressDecoder()]
4954
+ ]);
4955
+ }
4956
+ function getInitializeOracleArgsCodec() {
4957
+ return kit.combineCodec(
4958
+ getInitializeOracleArgsEncoder(),
4959
+ getInitializeOracleArgsDecoder()
4960
+ );
4961
+ }
4962
+ async function getOracleStateAddress(oracleAuthority, nonce) {
4963
+ const nonceBytes = new Uint8Array(8);
4964
+ new DataView(nonceBytes.buffer).setBigUint64(0, nonce, true);
4965
+ return kit.getProgramDerivedAddress({
4966
+ programAddress: TRUSTED_ORACLE_PROGRAM_ADDRESS,
4967
+ seeds: [
4968
+ new TextEncoder().encode("oracle"),
4969
+ kit.getAddressEncoder().encode(oracleAuthority),
4970
+ nonceBytes
4971
+ ]
4972
+ });
4973
+ }
4974
+
4975
+ exports.cpmm = cpmm_exports;
4976
+ exports.cpmmMigrator = cpmmMigrator_exports;
4977
+ exports.initializer = initializer_exports;
4978
+ exports.predictionMigrator = predictionMigrator_exports;
4979
+ exports.trustedOracle = trustedOracle_exports;
4980
+ //# sourceMappingURL=index.cjs.map
4981
+ //# sourceMappingURL=index.cjs.map