@whetstone-research/doppler-sdk 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-LIXSTCMM.js → chunk-BSHIMMA4.js} +74 -31
- package/dist/chunk-BSHIMMA4.js.map +1 -0
- package/dist/{chunk-T46KDO65.js → chunk-J57ROY36.js} +16 -29
- package/dist/chunk-J57ROY36.js.map +1 -0
- package/dist/evm/index.js +2 -2
- package/dist/evm/index.js.map +1 -1
- package/dist/{oracle-B2LV97ff.d.ts → oracle-CU-nZnja.d.ts} +1 -1
- package/dist/{pda-LKHUH6JK.js → pda-TXZDXZZ4.js} +3 -3
- package/dist/pda-TXZDXZZ4.js.map +1 -0
- package/dist/solana/index.d.ts +2212 -162
- package/dist/solana/index.js +3163 -486
- package/dist/solana/index.js.map +1 -1
- package/dist/solana/react/index.d.ts +1 -1
- package/dist/solana/react/index.js +5 -5
- package/dist/solana/react/index.js.map +1 -1
- package/package.json +11 -6
- package/dist/chunk-LIXSTCMM.js.map +0 -1
- package/dist/chunk-T46KDO65.js.map +0 -1
- package/dist/pda-LKHUH6JK.js.map +0 -1
package/dist/solana/index.js
CHANGED
|
@@ -1,11 +1,176 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { SYSTEM_PROGRAM_ID, ACCOUNT_ROLE_WRITABLE, ACCOUNT_ROLE_READONLY, TOKEN_METADATA_PROGRAM_ID, TOKEN_PROGRAM_ID, ACCOUNT_ROLE_WRITABLE_SIGNER, ACCOUNT_ROLE_SIGNER, PROGRAM_ID, INSTRUCTION_DISCRIMINATORS, getConfigAddress } from '../chunk-T46KDO65.js';
|
|
4
|
-
export { ACCOUNT_DISCRIMINATORS, ACCOUNT_ROLE_READONLY, ACCOUNT_ROLE_SIGNER, ACCOUNT_ROLE_WRITABLE, ACCOUNT_ROLE_WRITABLE_SIGNER, ACCOUNT_VERSION, ASSOCIATED_TOKEN_PROGRAM_ID, BPS_DENOM, INSTRUCTION_DISCRIMINATORS, MAX_ORACLE_OBSERVATIONS, MAX_SENTINEL_ALLOWLIST, PROGRAM_ID, Q64_ONE, SEED_AUTHORITY, SEED_CONFIG, SEED_ORACLE, SEED_POOL, SEED_POSITION, SEED_PROTOCOL_POSITION, SENTINEL_NO_CHANGE, SENTINEL_PROGRAM_ID, SF_AFTER_ADD_LIQ, SF_AFTER_REMOVE_LIQ, SF_AFTER_SWAP, SF_BEFORE_ADD_LIQ, SF_BEFORE_REMOVE_LIQ, SF_BEFORE_SWAP, SYSTEM_PROGRAM_ID, TOKEN_METADATA_PROGRAM_ID, TOKEN_PROGRAM_ID, areMintsOrdered, getConfigAddress, getLiquidityAddresses, getOracleAddress, getPoolAddress, getPoolAuthorityAddress, getPoolInitAddresses, getPositionAddress, getProtocolPositionAddress, getSwapAddresses, sortMints } from '../chunk-T46KDO65.js';
|
|
1
|
+
import { transferAdminArgsCodec, swapExactInArgsCodec, sortPositionsByShares, sortPoolsByReserves, setSentinelArgsCodec, setRouteArgsCodec, setFeesArgsCodec, removeLiquidityArgsCodec, ratioToNumber, quoteToNumeraireArgsCodec, q64ToNumber, q64Mul, q64Div, positionDataCodec, poolExists, poolDataCodec, oracleStateDataCodec, oracleConsultArgsCodec, observationCodec, numberToQ64, minBigInt, maxBigInt, isqrt, isOracleStale, initializePoolArgsCodec, initializeOracleArgsCodec, initializeConfigArgsCodec, getTvl, getSwapQuoteExactOut, getSwapQuote, getSpotPrice1, getSpotPrice0, getRemoveLiquidityQuote, getPositionValue, getPositionAddressFromParams, getPoolByMints, getPoolAddressFromMints, getPendingFees, getOracleSpotPrices, getOracleForPool, getOracleDeviation, getOracleBufferStats, getOracleAge, getOracleAddressFromPool, getK, getAddLiquidityQuote, filterPoolsByMint, filterActivePositions, fetchUserPositions, fetchPositionsBatch, fetchPositionByParams, fetchPosition, fetchPoolsBatch, fetchPoolPositions, fetchPool, fetchOraclesBatch, fetchOracle, fetchAllPools, encodeTransferAdminArgs, encodeSwapExactInArgs, encodeSetSentinelArgs, encodeSetRouteArgs, encodeSetFeesArgs, encodeRemoveLiquidityArgs, encodeQuoteToNumeraireArgs, encodeOracleConsultArgs, encodeInstructionData, encodeInitializePoolArgs, encodeInitializeOracleArgs, encodeInitializeConfigArgs, encodeCreatePositionArgs, encodeCollectProtocolFeesArgs, encodeCollectFeesArgs, encodeAddLiquidityArgs, decodePosition, decodePool, decodeOracleState, decodeAmmConfig, createPositionArgsCodec, createCollectFeesInstruction, consultTwap, computePrice1Q64, computePrice0Q64, comparePoolAndOraclePrices, collectProtocolFeesArgsCodec, collectFeesArgsCodec, ceilDiv, calculateTwapNumber, calculateTwap, calculateAccruedFees, ammConfigDataCodec, addLiquidityArgsCodec, MAX_FEE_AMOUNT } from '../chunk-BSHIMMA4.js';
|
|
2
|
+
import { sortMints, getSwapAddresses, getProtocolPositionAddress, getPositionAddress, getPoolInitAddresses, getPoolAuthorityAddress, getPoolAddress, getOracleAddress, getLiquidityAddresses, getConfigAddress, CPMM_PROGRAM_ID, areMintsOrdered, TOKEN_METADATA_PROGRAM_ID, SF_BEFORE_SWAP, SF_BEFORE_REMOVE_LIQ, SF_BEFORE_ADD_LIQ, SF_AFTER_SWAP, SF_AFTER_REMOVE_LIQ, SF_AFTER_ADD_LIQ, SENTINEL_NO_CHANGE, SEED_PROTOCOL_POSITION, SEED_POSITION, SEED_POOL, SEED_ORACLE, SEED_CONFIG, SEED_AUTHORITY, Q64_ONE, MAX_SENTINEL_ALLOWLIST, MAX_ORACLE_OBSERVATIONS, INSTRUCTION_DISCRIMINATORS, BPS_DENOM, ACCOUNT_VERSION, ACCOUNT_DISCRIMINATORS, SYSTEM_PROGRAM_ADDRESS, TOKEN_PROGRAM_ADDRESS } from '../chunk-J57ROY36.js';
|
|
5
3
|
import { __export } from '../chunk-PZ5AY32C.js';
|
|
6
|
-
import { getAddressCodec, getStructCodec, getU64Codec, getU128Codec, getBooleanCodec, getU8Codec, address, transformEncoder, getStructEncoder, fixEncoderSize, getAddressEncoder, getU8Encoder, getArrayEncoder, getBytesEncoder, getStructDecoder, fixDecoderSize, getAddressDecoder, getU8Decoder, getArrayDecoder, getBytesDecoder, combineCodec, getU64Encoder, getU16Encoder, addEncoderSizePrefix, getU32Encoder, getUtf8Encoder, getU64Decoder, getU16Decoder, addDecoderSizePrefix, getU32Decoder, getUtf8Decoder,
|
|
7
|
-
import '@solana/program-client-core';
|
|
4
|
+
import { getAddressCodec, getProgramDerivedAddress, AccountRole, getStructCodec, getU64Codec, getU128Codec, getBooleanCodec, getU8Codec, address, transformEncoder, getStructEncoder, fixEncoderSize, getAddressEncoder, getU8Encoder, getArrayEncoder, getBytesEncoder, getStructDecoder, fixDecoderSize, getAddressDecoder, getU8Decoder, getArrayDecoder, getBytesDecoder, combineCodec, getU64Encoder, getU16Encoder, addEncoderSizePrefix, getU32Encoder, getUtf8Encoder, getU64Decoder, getU16Decoder, addDecoderSizePrefix, getU32Decoder, getUtf8Decoder, getOptionEncoder, getU128Encoder, getOptionDecoder, getU128Decoder, getBooleanEncoder, getBooleanDecoder, mergeBytes, isProgramError, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, SolanaError, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, containsBytes, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, assertIsInstructionWithAccounts } from '@solana/kit';
|
|
5
|
+
import { getAccountMetaFactory, addSelfPlanAndSendFunctions, addSelfFetchFunctions, getAddressFromResolvedInstructionAccount } from '@solana/program-client-core';
|
|
6
|
+
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
8
7
|
|
|
8
|
+
// src/solana/cpmm/index.ts
|
|
9
|
+
var cpmm_exports = {};
|
|
10
|
+
__export(cpmm_exports, {
|
|
11
|
+
ACCOUNT_DISCRIMINATORS: () => ACCOUNT_DISCRIMINATORS,
|
|
12
|
+
ACCOUNT_VERSION: () => ACCOUNT_VERSION,
|
|
13
|
+
BPS_DENOM: () => BPS_DENOM,
|
|
14
|
+
CPMM_ERROR_MESSAGES: () => CPMM_ERROR_MESSAGES,
|
|
15
|
+
CPMM_PROGRAM_ID: () => CPMM_PROGRAM_ID,
|
|
16
|
+
CpmmError: () => CpmmError,
|
|
17
|
+
CpmmErrorCode: () => CpmmErrorCode,
|
|
18
|
+
INSTRUCTION_DISCRIMINATORS: () => INSTRUCTION_DISCRIMINATORS,
|
|
19
|
+
MAX_FEE_AMOUNT: () => MAX_FEE_AMOUNT,
|
|
20
|
+
MAX_ORACLE_OBSERVATIONS: () => MAX_ORACLE_OBSERVATIONS,
|
|
21
|
+
MAX_SENTINEL_ALLOWLIST: () => MAX_SENTINEL_ALLOWLIST,
|
|
22
|
+
Q64_ONE: () => Q64_ONE,
|
|
23
|
+
SEED_AUTHORITY: () => SEED_AUTHORITY,
|
|
24
|
+
SEED_CONFIG: () => SEED_CONFIG,
|
|
25
|
+
SEED_ORACLE: () => SEED_ORACLE,
|
|
26
|
+
SEED_POOL: () => SEED_POOL,
|
|
27
|
+
SEED_POSITION: () => SEED_POSITION,
|
|
28
|
+
SEED_PROTOCOL_POSITION: () => SEED_PROTOCOL_POSITION,
|
|
29
|
+
SENTINEL_NO_CHANGE: () => SENTINEL_NO_CHANGE,
|
|
30
|
+
SF_AFTER_ADD_LIQ: () => SF_AFTER_ADD_LIQ,
|
|
31
|
+
SF_AFTER_REMOVE_LIQ: () => SF_AFTER_REMOVE_LIQ,
|
|
32
|
+
SF_AFTER_SWAP: () => SF_AFTER_SWAP,
|
|
33
|
+
SF_BEFORE_ADD_LIQ: () => SF_BEFORE_ADD_LIQ,
|
|
34
|
+
SF_BEFORE_REMOVE_LIQ: () => SF_BEFORE_REMOVE_LIQ,
|
|
35
|
+
SF_BEFORE_SWAP: () => SF_BEFORE_SWAP,
|
|
36
|
+
TOKEN_METADATA_PROGRAM_ID: () => TOKEN_METADATA_PROGRAM_ID,
|
|
37
|
+
addLiquidityArgsCodec: () => addLiquidityArgsCodec,
|
|
38
|
+
ammConfigDataCodec: () => ammConfigDataCodec,
|
|
39
|
+
areMintsOrdered: () => areMintsOrdered,
|
|
40
|
+
calculateAccruedFees: () => calculateAccruedFees,
|
|
41
|
+
calculateTwap: () => calculateTwap,
|
|
42
|
+
calculateTwapNumber: () => calculateTwapNumber,
|
|
43
|
+
ceilDiv: () => ceilDiv,
|
|
44
|
+
collectFeesArgsCodec: () => collectFeesArgsCodec,
|
|
45
|
+
collectProtocolFeesArgsCodec: () => collectProtocolFeesArgsCodec,
|
|
46
|
+
comparePoolAndOraclePrices: () => comparePoolAndOraclePrices,
|
|
47
|
+
computePrice0Q64: () => computePrice0Q64,
|
|
48
|
+
computePrice1Q64: () => computePrice1Q64,
|
|
49
|
+
consultTwap: () => consultTwap,
|
|
50
|
+
createAddLiquidityInstruction: () => createAddLiquidityInstruction,
|
|
51
|
+
createClosePositionInstruction: () => createClosePositionInstruction,
|
|
52
|
+
createCollectFeesInstruction: () => createCollectFeesInstruction,
|
|
53
|
+
createCollectProtocolFeesInstruction: () => createCollectProtocolFeesInstruction,
|
|
54
|
+
createCreatePositionInstruction: () => createCreatePositionInstruction,
|
|
55
|
+
createInitializeConfigInstruction: () => createInitializeConfigInstruction,
|
|
56
|
+
createInitializeOracleInstruction: () => createInitializeOracleInstruction,
|
|
57
|
+
createInitializePoolInstruction: () => createInitializePoolInstruction,
|
|
58
|
+
createOracleConsultInstruction: () => createOracleConsultInstruction,
|
|
59
|
+
createOracleUpdateInstruction: () => createOracleUpdateInstruction,
|
|
60
|
+
createPauseInstruction: () => createPauseInstruction,
|
|
61
|
+
createPositionArgsCodec: () => createPositionArgsCodec,
|
|
62
|
+
createQuoteToNumeraireInstruction: () => createQuoteToNumeraireInstruction,
|
|
63
|
+
createRemoveLiquidityInstruction: () => createRemoveLiquidityInstruction,
|
|
64
|
+
createSetFeesInstruction: () => createSetFeesInstruction,
|
|
65
|
+
createSetRouteInstruction: () => createSetRouteInstruction,
|
|
66
|
+
createSetSentinelInstruction: () => createSetSentinelInstruction,
|
|
67
|
+
createSkimInstruction: () => createSkimInstruction,
|
|
68
|
+
createSwapExactInInstruction: () => createSwapExactInInstruction,
|
|
69
|
+
createSwapInstruction: () => createSwapInstruction,
|
|
70
|
+
createTransferAdminInstruction: () => createTransferAdminInstruction,
|
|
71
|
+
createUnpauseInstruction: () => createUnpauseInstruction,
|
|
72
|
+
curveParamsToMarketCap: () => curveParamsToMarketCap,
|
|
73
|
+
decodeAmmConfig: () => decodeAmmConfig,
|
|
74
|
+
decodeOracleConsultResult: () => decodeOracleConsultResult,
|
|
75
|
+
decodeOracleState: () => decodeOracleState,
|
|
76
|
+
decodePool: () => decodePool,
|
|
77
|
+
decodePosition: () => decodePosition,
|
|
78
|
+
decodeQuoteToNumeraireResult: () => decodeQuoteToNumeraireResult,
|
|
79
|
+
encodeAddLiquidityArgs: () => encodeAddLiquidityArgs,
|
|
80
|
+
encodeCollectFeesArgs: () => encodeCollectFeesArgs,
|
|
81
|
+
encodeCollectProtocolFeesArgs: () => encodeCollectProtocolFeesArgs,
|
|
82
|
+
encodeCreatePositionArgs: () => encodeCreatePositionArgs,
|
|
83
|
+
encodeInitializeConfigArgs: () => encodeInitializeConfigArgs,
|
|
84
|
+
encodeInitializeOracleArgs: () => encodeInitializeOracleArgs,
|
|
85
|
+
encodeInitializePoolArgs: () => encodeInitializePoolArgs,
|
|
86
|
+
encodeInstructionData: () => encodeInstructionData,
|
|
87
|
+
encodeOracleConsultArgs: () => encodeOracleConsultArgs,
|
|
88
|
+
encodeQuoteToNumeraireArgs: () => encodeQuoteToNumeraireArgs,
|
|
89
|
+
encodeRemoveLiquidityArgs: () => encodeRemoveLiquidityArgs,
|
|
90
|
+
encodeSetFeesArgs: () => encodeSetFeesArgs,
|
|
91
|
+
encodeSetRouteArgs: () => encodeSetRouteArgs,
|
|
92
|
+
encodeSetSentinelArgs: () => encodeSetSentinelArgs,
|
|
93
|
+
encodeSwapExactInArgs: () => encodeSwapExactInArgs,
|
|
94
|
+
encodeTransferAdminArgs: () => encodeTransferAdminArgs,
|
|
95
|
+
fetchAllPools: () => fetchAllPools,
|
|
96
|
+
fetchConfig: () => fetchConfig,
|
|
97
|
+
fetchConfigWithAddress: () => fetchConfigWithAddress,
|
|
98
|
+
fetchOracle: () => fetchOracle,
|
|
99
|
+
fetchOraclesBatch: () => fetchOraclesBatch,
|
|
100
|
+
fetchPool: () => fetchPool,
|
|
101
|
+
fetchPoolPositions: () => fetchPoolPositions,
|
|
102
|
+
fetchPoolsBatch: () => fetchPoolsBatch,
|
|
103
|
+
fetchPosition: () => fetchPosition,
|
|
104
|
+
fetchPositionByParams: () => fetchPositionByParams,
|
|
105
|
+
fetchPositionsBatch: () => fetchPositionsBatch,
|
|
106
|
+
fetchUserPositions: () => fetchUserPositions,
|
|
107
|
+
filterActivePositions: () => filterActivePositions,
|
|
108
|
+
filterPoolsByMint: () => filterPoolsByMint,
|
|
109
|
+
getAddLiquidityQuote: () => getAddLiquidityQuote,
|
|
110
|
+
getConfigAddress: () => getConfigAddress,
|
|
111
|
+
getErrorMessage: () => getErrorMessage,
|
|
112
|
+
getK: () => getK,
|
|
113
|
+
getLiquidityAddresses: () => getLiquidityAddresses,
|
|
114
|
+
getMetadataAddress: () => getMetadataAddress,
|
|
115
|
+
getOracleAddress: () => getOracleAddress,
|
|
116
|
+
getOracleAddressFromPool: () => getOracleAddressFromPool,
|
|
117
|
+
getOracleAge: () => getOracleAge,
|
|
118
|
+
getOracleBufferStats: () => getOracleBufferStats,
|
|
119
|
+
getOracleDeviation: () => getOracleDeviation,
|
|
120
|
+
getOracleForPool: () => getOracleForPool,
|
|
121
|
+
getOracleSpotPrices: () => getOracleSpotPrices,
|
|
122
|
+
getPendingFees: () => getPendingFees,
|
|
123
|
+
getPoolAddress: () => getPoolAddress,
|
|
124
|
+
getPoolAddressFromMints: () => getPoolAddressFromMints,
|
|
125
|
+
getPoolAuthorityAddress: () => getPoolAuthorityAddress,
|
|
126
|
+
getPoolByMints: () => getPoolByMints,
|
|
127
|
+
getPoolInitAddresses: () => getPoolInitAddresses,
|
|
128
|
+
getPositionAddress: () => getPositionAddress,
|
|
129
|
+
getPositionAddressFromParams: () => getPositionAddressFromParams,
|
|
130
|
+
getPositionValue: () => getPositionValue,
|
|
131
|
+
getProtocolPositionAddress: () => getProtocolPositionAddress,
|
|
132
|
+
getRemoveLiquidityQuote: () => getRemoveLiquidityQuote,
|
|
133
|
+
getSpotPrice0: () => getSpotPrice0,
|
|
134
|
+
getSpotPrice1: () => getSpotPrice1,
|
|
135
|
+
getSwapAddresses: () => getSwapAddresses,
|
|
136
|
+
getSwapQuote: () => getSwapQuote,
|
|
137
|
+
getSwapQuoteExactOut: () => getSwapQuoteExactOut,
|
|
138
|
+
getTvl: () => getTvl,
|
|
139
|
+
initializeConfigArgsCodec: () => initializeConfigArgsCodec,
|
|
140
|
+
initializeOracleArgsCodec: () => initializeOracleArgsCodec,
|
|
141
|
+
initializePoolArgsCodec: () => initializePoolArgsCodec,
|
|
142
|
+
isCpmmError: () => isCpmmError,
|
|
143
|
+
isOracleStale: () => isOracleStale,
|
|
144
|
+
isqrt: () => isqrt,
|
|
145
|
+
marketCapToCurveParams: () => marketCapToCurveParams,
|
|
146
|
+
marketCapToSingleCurveParams: () => marketCapToSingleCurveParams,
|
|
147
|
+
marketCapToTokenPrice: () => marketCapToTokenPrice,
|
|
148
|
+
maxBigInt: () => maxBigInt,
|
|
149
|
+
minBigInt: () => minBigInt,
|
|
150
|
+
numberToQ64: () => numberToQ64,
|
|
151
|
+
observationCodec: () => observationCodec,
|
|
152
|
+
oracleConsultArgsCodec: () => oracleConsultArgsCodec,
|
|
153
|
+
oracleStateDataCodec: () => oracleStateDataCodec,
|
|
154
|
+
parseErrorFromLogs: () => parseErrorFromLogs,
|
|
155
|
+
poolDataCodec: () => poolDataCodec,
|
|
156
|
+
poolExists: () => poolExists,
|
|
157
|
+
positionDataCodec: () => positionDataCodec,
|
|
158
|
+
q64Div: () => q64Div,
|
|
159
|
+
q64Mul: () => q64Mul,
|
|
160
|
+
q64ToNumber: () => q64ToNumber,
|
|
161
|
+
quoteToNumeraireArgsCodec: () => quoteToNumeraireArgsCodec,
|
|
162
|
+
ratioToNumber: () => ratioToNumber,
|
|
163
|
+
removeLiquidityArgsCodec: () => removeLiquidityArgsCodec,
|
|
164
|
+
setFeesArgsCodec: () => setFeesArgsCodec,
|
|
165
|
+
setRouteArgsCodec: () => setRouteArgsCodec,
|
|
166
|
+
setSentinelArgsCodec: () => setSentinelArgsCodec,
|
|
167
|
+
sortMints: () => sortMints,
|
|
168
|
+
sortPoolsByReserves: () => sortPoolsByReserves,
|
|
169
|
+
sortPositionsByShares: () => sortPositionsByShares,
|
|
170
|
+
swapExactInArgsCodec: () => swapExactInArgsCodec,
|
|
171
|
+
transferAdminArgsCodec: () => transferAdminArgsCodec,
|
|
172
|
+
validateMarketCapParameters: () => validateMarketCapParameters
|
|
173
|
+
});
|
|
9
174
|
var addressCodec = getAddressCodec();
|
|
10
175
|
var textEncoder = new TextEncoder();
|
|
11
176
|
async function getMetadataAddress(mint) {
|
|
@@ -301,14 +466,12 @@ function getErrorMessage(code) {
|
|
|
301
466
|
}
|
|
302
467
|
return `Unknown error code: ${code}`;
|
|
303
468
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
function createInitializeConfigInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
307
|
-
const { config, payer, systemProgram = SYSTEM_PROGRAM_ID } = accounts;
|
|
469
|
+
function createInitializeConfigInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
470
|
+
const { config, payer, systemProgram = SYSTEM_PROGRAM_ADDRESS } = accounts;
|
|
308
471
|
const keys = [
|
|
309
|
-
{ address: config, role:
|
|
310
|
-
{ address: payer, role:
|
|
311
|
-
{ address: systemProgram, role:
|
|
472
|
+
{ address: config, role: AccountRole.WRITABLE },
|
|
473
|
+
{ address: payer, role: AccountRole.WRITABLE_SIGNER },
|
|
474
|
+
{ address: systemProgram, role: AccountRole.READONLY }
|
|
312
475
|
];
|
|
313
476
|
const data = encodeInstructionData(
|
|
314
477
|
INSTRUCTION_DISCRIMINATORS.initializeConfig,
|
|
@@ -321,8 +484,6 @@ function createInitializeConfigInstruction(accounts, args, programId = PROGRAM_I
|
|
|
321
484
|
data
|
|
322
485
|
};
|
|
323
486
|
}
|
|
324
|
-
|
|
325
|
-
// src/solana/instructions/initializePool.ts
|
|
326
487
|
function isTransactionSigner(value) {
|
|
327
488
|
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
328
489
|
}
|
|
@@ -336,7 +497,7 @@ function createSignerAccountMeta(value, role) {
|
|
|
336
497
|
}
|
|
337
498
|
return { address: value, role };
|
|
338
499
|
}
|
|
339
|
-
function createInitializePoolInstruction(accounts, args, programId =
|
|
500
|
+
function createInitializePoolInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
340
501
|
const {
|
|
341
502
|
config,
|
|
342
503
|
pool,
|
|
@@ -347,23 +508,23 @@ function createInitializePoolInstruction(accounts, args, programId = PROGRAM_ID)
|
|
|
347
508
|
token0Mint,
|
|
348
509
|
token1Mint,
|
|
349
510
|
payer,
|
|
350
|
-
tokenProgram =
|
|
351
|
-
systemProgram =
|
|
511
|
+
tokenProgram = TOKEN_PROGRAM_ADDRESS,
|
|
512
|
+
systemProgram = SYSTEM_PROGRAM_ADDRESS,
|
|
352
513
|
rent
|
|
353
514
|
} = accounts;
|
|
354
515
|
const keys = [
|
|
355
|
-
{ address: config, role:
|
|
356
|
-
{ address: pool, role:
|
|
357
|
-
{ address: protocolPosition, role:
|
|
358
|
-
{ address: authority, role:
|
|
359
|
-
createSignerAccountMeta(vault0,
|
|
360
|
-
createSignerAccountMeta(vault1,
|
|
361
|
-
{ address: token0Mint, role:
|
|
362
|
-
{ address: token1Mint, role:
|
|
363
|
-
createSignerAccountMeta(payer,
|
|
364
|
-
{ address: tokenProgram, role:
|
|
365
|
-
{ address: systemProgram, role:
|
|
366
|
-
{ address: rent, role:
|
|
516
|
+
{ address: config, role: AccountRole.READONLY },
|
|
517
|
+
{ address: pool, role: AccountRole.WRITABLE },
|
|
518
|
+
{ address: protocolPosition, role: AccountRole.WRITABLE },
|
|
519
|
+
{ address: authority, role: AccountRole.READONLY },
|
|
520
|
+
createSignerAccountMeta(vault0, AccountRole.WRITABLE_SIGNER),
|
|
521
|
+
createSignerAccountMeta(vault1, AccountRole.WRITABLE_SIGNER),
|
|
522
|
+
{ address: token0Mint, role: AccountRole.READONLY },
|
|
523
|
+
{ address: token1Mint, role: AccountRole.READONLY },
|
|
524
|
+
createSignerAccountMeta(payer, AccountRole.WRITABLE_SIGNER),
|
|
525
|
+
{ address: tokenProgram, role: AccountRole.READONLY },
|
|
526
|
+
{ address: systemProgram, role: AccountRole.READONLY },
|
|
527
|
+
{ address: rent, role: AccountRole.READONLY }
|
|
367
528
|
];
|
|
368
529
|
const data = encodeInstructionData(
|
|
369
530
|
INSTRUCTION_DISCRIMINATORS.initializePool,
|
|
@@ -376,24 +537,22 @@ function createInitializePoolInstruction(accounts, args, programId = PROGRAM_ID)
|
|
|
376
537
|
data
|
|
377
538
|
};
|
|
378
539
|
}
|
|
379
|
-
|
|
380
|
-
// src/solana/instructions/initializeOracle.ts
|
|
381
|
-
function createInitializeOracleInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
540
|
+
function createInitializeOracleInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
382
541
|
const {
|
|
383
542
|
config,
|
|
384
543
|
pool,
|
|
385
544
|
oracle,
|
|
386
545
|
admin,
|
|
387
546
|
payer,
|
|
388
|
-
systemProgram =
|
|
547
|
+
systemProgram = SYSTEM_PROGRAM_ADDRESS
|
|
389
548
|
} = accounts;
|
|
390
549
|
const keys = [
|
|
391
|
-
{ address: config, role:
|
|
392
|
-
{ address: pool, role:
|
|
393
|
-
{ address: oracle, role:
|
|
394
|
-
{ address: admin, role:
|
|
395
|
-
{ address: payer, role:
|
|
396
|
-
{ address: systemProgram, role:
|
|
550
|
+
{ address: config, role: AccountRole.READONLY },
|
|
551
|
+
{ address: pool, role: AccountRole.READONLY },
|
|
552
|
+
{ address: oracle, role: AccountRole.WRITABLE },
|
|
553
|
+
{ address: admin, role: AccountRole.READONLY_SIGNER },
|
|
554
|
+
{ address: payer, role: AccountRole.WRITABLE_SIGNER },
|
|
555
|
+
{ address: systemProgram, role: AccountRole.READONLY }
|
|
397
556
|
];
|
|
398
557
|
const data = encodeInstructionData(
|
|
399
558
|
INSTRUCTION_DISCRIMINATORS.initializeOracle,
|
|
@@ -406,14 +565,12 @@ function createInitializeOracleInstruction(accounts, args, programId = PROGRAM_I
|
|
|
406
565
|
data
|
|
407
566
|
};
|
|
408
567
|
}
|
|
409
|
-
|
|
410
|
-
// src/solana/instructions/setFees.ts
|
|
411
|
-
function createSetFeesInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
568
|
+
function createSetFeesInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
412
569
|
const { config, pool, admin } = accounts;
|
|
413
570
|
const keys = [
|
|
414
|
-
{ address: config, role:
|
|
415
|
-
{ address: pool, role:
|
|
416
|
-
{ address: admin, role:
|
|
571
|
+
{ address: config, role: AccountRole.READONLY },
|
|
572
|
+
{ address: pool, role: AccountRole.WRITABLE },
|
|
573
|
+
{ address: admin, role: AccountRole.READONLY_SIGNER }
|
|
417
574
|
];
|
|
418
575
|
const data = encodeInstructionData(
|
|
419
576
|
INSTRUCTION_DISCRIMINATORS.setFees,
|
|
@@ -426,14 +583,12 @@ function createSetFeesInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
|
426
583
|
data
|
|
427
584
|
};
|
|
428
585
|
}
|
|
429
|
-
|
|
430
|
-
// src/solana/instructions/setSentinel.ts
|
|
431
|
-
function createSetSentinelInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
586
|
+
function createSetSentinelInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
432
587
|
const { config, pool, admin } = accounts;
|
|
433
588
|
const keys = [
|
|
434
|
-
{ address: config, role:
|
|
435
|
-
{ address: pool, role:
|
|
436
|
-
{ address: admin, role:
|
|
589
|
+
{ address: config, role: AccountRole.READONLY },
|
|
590
|
+
{ address: pool, role: AccountRole.WRITABLE },
|
|
591
|
+
{ address: admin, role: AccountRole.READONLY_SIGNER }
|
|
437
592
|
];
|
|
438
593
|
const data = encodeInstructionData(
|
|
439
594
|
INSTRUCTION_DISCRIMINATORS.setSentinel,
|
|
@@ -446,18 +601,16 @@ function createSetSentinelInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
|
446
601
|
data
|
|
447
602
|
};
|
|
448
603
|
}
|
|
449
|
-
|
|
450
|
-
// src/solana/instructions/setRoute.ts
|
|
451
|
-
function createSetRouteInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
604
|
+
function createSetRouteInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
452
605
|
const { config, pool, nextPool, admin } = accounts;
|
|
453
606
|
const keys = [
|
|
454
|
-
{ address: config, role:
|
|
455
|
-
{ address: pool, role:
|
|
607
|
+
{ address: config, role: AccountRole.READONLY },
|
|
608
|
+
{ address: pool, role: AccountRole.WRITABLE }
|
|
456
609
|
];
|
|
457
610
|
if (nextPool) {
|
|
458
|
-
keys.push({ address: nextPool, role:
|
|
611
|
+
keys.push({ address: nextPool, role: AccountRole.READONLY });
|
|
459
612
|
}
|
|
460
|
-
keys.push({ address: admin, role:
|
|
613
|
+
keys.push({ address: admin, role: AccountRole.READONLY_SIGNER });
|
|
461
614
|
const data = encodeInstructionData(
|
|
462
615
|
INSTRUCTION_DISCRIMINATORS.setRoute,
|
|
463
616
|
setRouteArgsCodec,
|
|
@@ -469,13 +622,11 @@ function createSetRouteInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
|
469
622
|
data
|
|
470
623
|
};
|
|
471
624
|
}
|
|
472
|
-
|
|
473
|
-
// src/solana/instructions/pause.ts
|
|
474
|
-
function createPauseInstruction(accounts, programId = PROGRAM_ID) {
|
|
625
|
+
function createPauseInstruction(accounts, programId = CPMM_PROGRAM_ID) {
|
|
475
626
|
const { config, admin } = accounts;
|
|
476
627
|
const keys = [
|
|
477
|
-
{ address: config, role:
|
|
478
|
-
{ address: admin, role:
|
|
628
|
+
{ address: config, role: AccountRole.WRITABLE },
|
|
629
|
+
{ address: admin, role: AccountRole.READONLY_SIGNER }
|
|
479
630
|
];
|
|
480
631
|
const data = INSTRUCTION_DISCRIMINATORS.pause;
|
|
481
632
|
return {
|
|
@@ -484,13 +635,11 @@ function createPauseInstruction(accounts, programId = PROGRAM_ID) {
|
|
|
484
635
|
data
|
|
485
636
|
};
|
|
486
637
|
}
|
|
487
|
-
|
|
488
|
-
// src/solana/instructions/unpause.ts
|
|
489
|
-
function createUnpauseInstruction(accounts, programId = PROGRAM_ID) {
|
|
638
|
+
function createUnpauseInstruction(accounts, programId = CPMM_PROGRAM_ID) {
|
|
490
639
|
const { config, admin } = accounts;
|
|
491
640
|
const keys = [
|
|
492
|
-
{ address: config, role:
|
|
493
|
-
{ address: admin, role:
|
|
641
|
+
{ address: config, role: AccountRole.WRITABLE },
|
|
642
|
+
{ address: admin, role: AccountRole.READONLY_SIGNER }
|
|
494
643
|
];
|
|
495
644
|
const data = INSTRUCTION_DISCRIMINATORS.unpause;
|
|
496
645
|
return {
|
|
@@ -499,13 +648,11 @@ function createUnpauseInstruction(accounts, programId = PROGRAM_ID) {
|
|
|
499
648
|
data
|
|
500
649
|
};
|
|
501
650
|
}
|
|
502
|
-
|
|
503
|
-
// src/solana/instructions/transferAdmin.ts
|
|
504
|
-
function createTransferAdminInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
651
|
+
function createTransferAdminInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
505
652
|
const { config, admin } = accounts;
|
|
506
653
|
const keys = [
|
|
507
|
-
{ address: config, role:
|
|
508
|
-
{ address: admin, role:
|
|
654
|
+
{ address: config, role: AccountRole.WRITABLE },
|
|
655
|
+
{ address: admin, role: AccountRole.READONLY_SIGNER }
|
|
509
656
|
];
|
|
510
657
|
const data = encodeInstructionData(
|
|
511
658
|
INSTRUCTION_DISCRIMINATORS.transferAdmin,
|
|
@@ -518,9 +665,7 @@ function createTransferAdminInstruction(accounts, args, programId = PROGRAM_ID)
|
|
|
518
665
|
data
|
|
519
666
|
};
|
|
520
667
|
}
|
|
521
|
-
|
|
522
|
-
// src/solana/instructions/skim.ts
|
|
523
|
-
function createSkimInstruction(accounts, programId = PROGRAM_ID) {
|
|
668
|
+
function createSkimInstruction(accounts, programId = CPMM_PROGRAM_ID) {
|
|
524
669
|
const {
|
|
525
670
|
config,
|
|
526
671
|
pool,
|
|
@@ -532,20 +677,20 @@ function createSkimInstruction(accounts, programId = PROGRAM_ID) {
|
|
|
532
677
|
token1Mint,
|
|
533
678
|
adminAta0,
|
|
534
679
|
adminAta1,
|
|
535
|
-
tokenProgram =
|
|
680
|
+
tokenProgram = TOKEN_PROGRAM_ADDRESS
|
|
536
681
|
} = accounts;
|
|
537
682
|
const keys = [
|
|
538
|
-
{ address: config, role:
|
|
539
|
-
{ address: pool, role:
|
|
540
|
-
{ address: admin, role:
|
|
541
|
-
{ address: authority, role:
|
|
542
|
-
{ address: vault0, role:
|
|
543
|
-
{ address: vault1, role:
|
|
544
|
-
{ address: token0Mint, role:
|
|
545
|
-
{ address: token1Mint, role:
|
|
546
|
-
{ address: adminAta0, role:
|
|
547
|
-
{ address: adminAta1, role:
|
|
548
|
-
{ address: tokenProgram, role:
|
|
683
|
+
{ address: config, role: AccountRole.READONLY },
|
|
684
|
+
{ address: pool, role: AccountRole.READONLY },
|
|
685
|
+
{ address: admin, role: AccountRole.READONLY_SIGNER },
|
|
686
|
+
{ address: authority, role: AccountRole.READONLY },
|
|
687
|
+
{ address: vault0, role: AccountRole.WRITABLE },
|
|
688
|
+
{ address: vault1, role: AccountRole.WRITABLE },
|
|
689
|
+
{ address: token0Mint, role: AccountRole.READONLY },
|
|
690
|
+
{ address: token1Mint, role: AccountRole.READONLY },
|
|
691
|
+
{ address: adminAta0, role: AccountRole.WRITABLE },
|
|
692
|
+
{ address: adminAta1, role: AccountRole.WRITABLE },
|
|
693
|
+
{ address: tokenProgram, role: AccountRole.READONLY }
|
|
549
694
|
];
|
|
550
695
|
const data = INSTRUCTION_DISCRIMINATORS.skim;
|
|
551
696
|
return {
|
|
@@ -554,9 +699,7 @@ function createSkimInstruction(accounts, programId = PROGRAM_ID) {
|
|
|
554
699
|
data
|
|
555
700
|
};
|
|
556
701
|
}
|
|
557
|
-
|
|
558
|
-
// src/solana/instructions/swapExactIn.ts
|
|
559
|
-
function createSwapExactInInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
702
|
+
function createSwapExactInInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
560
703
|
const {
|
|
561
704
|
config,
|
|
562
705
|
pool,
|
|
@@ -568,28 +711,28 @@ function createSwapExactInInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
|
568
711
|
userIn,
|
|
569
712
|
userOut,
|
|
570
713
|
user,
|
|
571
|
-
tokenProgram =
|
|
714
|
+
tokenProgram = TOKEN_PROGRAM_ADDRESS,
|
|
572
715
|
oracle,
|
|
573
716
|
remainingAccounts = []
|
|
574
717
|
} = accounts;
|
|
575
718
|
const keys = [
|
|
576
|
-
{ address: config, role:
|
|
577
|
-
{ address: pool, role:
|
|
578
|
-
{ address: authority, role:
|
|
579
|
-
{ address: vaultIn, role:
|
|
580
|
-
{ address: vaultOut, role:
|
|
581
|
-
{ address: token0Mint, role:
|
|
582
|
-
{ address: token1Mint, role:
|
|
583
|
-
{ address: userIn, role:
|
|
584
|
-
{ address: userOut, role:
|
|
585
|
-
{ address: user, role:
|
|
586
|
-
{ address: tokenProgram, role:
|
|
719
|
+
{ address: config, role: AccountRole.READONLY },
|
|
720
|
+
{ address: pool, role: AccountRole.WRITABLE },
|
|
721
|
+
{ address: authority, role: AccountRole.READONLY },
|
|
722
|
+
{ address: vaultIn, role: AccountRole.WRITABLE },
|
|
723
|
+
{ address: vaultOut, role: AccountRole.WRITABLE },
|
|
724
|
+
{ address: token0Mint, role: AccountRole.READONLY },
|
|
725
|
+
{ address: token1Mint, role: AccountRole.READONLY },
|
|
726
|
+
{ address: userIn, role: AccountRole.WRITABLE },
|
|
727
|
+
{ address: userOut, role: AccountRole.WRITABLE },
|
|
728
|
+
{ address: user, role: AccountRole.READONLY_SIGNER },
|
|
729
|
+
{ address: tokenProgram, role: AccountRole.READONLY }
|
|
587
730
|
];
|
|
588
731
|
if (oracle) {
|
|
589
|
-
keys.push({ address: oracle, role:
|
|
732
|
+
keys.push({ address: oracle, role: AccountRole.WRITABLE });
|
|
590
733
|
}
|
|
591
734
|
for (const account of remainingAccounts) {
|
|
592
|
-
keys.push({ address: account, role:
|
|
735
|
+
keys.push({ address: account, role: AccountRole.READONLY });
|
|
593
736
|
}
|
|
594
737
|
const data = encodeInstructionData(
|
|
595
738
|
INSTRUCTION_DISCRIMINATORS.swapExactIn,
|
|
@@ -620,7 +763,7 @@ function createSwapInstruction(params) {
|
|
|
620
763
|
oracle,
|
|
621
764
|
remainingAccounts,
|
|
622
765
|
updateOracle = false,
|
|
623
|
-
programId =
|
|
766
|
+
programId = CPMM_PROGRAM_ID
|
|
624
767
|
} = params;
|
|
625
768
|
const [vaultIn, vaultOut] = direction === 0 ? [vault0, vault1] : [vault1, vault0];
|
|
626
769
|
const [userIn, userOut] = direction === 0 ? [userToken0, userToken1] : [userToken1, userToken0];
|
|
@@ -648,22 +791,20 @@ function createSwapInstruction(params) {
|
|
|
648
791
|
programId
|
|
649
792
|
);
|
|
650
793
|
}
|
|
651
|
-
|
|
652
|
-
// src/solana/instructions/createPosition.ts
|
|
653
|
-
function createCreatePositionInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
794
|
+
function createCreatePositionInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
654
795
|
const {
|
|
655
796
|
pool,
|
|
656
797
|
position,
|
|
657
798
|
owner,
|
|
658
799
|
payer,
|
|
659
|
-
systemProgram =
|
|
800
|
+
systemProgram = SYSTEM_PROGRAM_ADDRESS
|
|
660
801
|
} = accounts;
|
|
661
802
|
const keys = [
|
|
662
|
-
{ address: pool, role:
|
|
663
|
-
{ address: position, role:
|
|
664
|
-
{ address: owner, role:
|
|
665
|
-
{ address: payer, role:
|
|
666
|
-
{ address: systemProgram, role:
|
|
803
|
+
{ address: pool, role: AccountRole.READONLY },
|
|
804
|
+
{ address: position, role: AccountRole.WRITABLE },
|
|
805
|
+
{ address: owner, role: AccountRole.READONLY_SIGNER },
|
|
806
|
+
{ address: payer, role: AccountRole.WRITABLE_SIGNER },
|
|
807
|
+
{ address: systemProgram, role: AccountRole.READONLY }
|
|
667
808
|
];
|
|
668
809
|
const data = encodeInstructionData(
|
|
669
810
|
INSTRUCTION_DISCRIMINATORS.createPosition,
|
|
@@ -676,15 +817,13 @@ function createCreatePositionInstruction(accounts, args, programId = PROGRAM_ID)
|
|
|
676
817
|
data
|
|
677
818
|
};
|
|
678
819
|
}
|
|
679
|
-
|
|
680
|
-
// src/solana/instructions/closePosition.ts
|
|
681
|
-
function createClosePositionInstruction(accounts, programId = PROGRAM_ID) {
|
|
820
|
+
function createClosePositionInstruction(accounts, programId = CPMM_PROGRAM_ID) {
|
|
682
821
|
const { pool, position, owner, rentRecipient } = accounts;
|
|
683
822
|
const keys = [
|
|
684
|
-
{ address: pool, role:
|
|
685
|
-
{ address: position, role:
|
|
686
|
-
{ address: owner, role:
|
|
687
|
-
{ address: rentRecipient, role:
|
|
823
|
+
{ address: pool, role: AccountRole.READONLY },
|
|
824
|
+
{ address: position, role: AccountRole.WRITABLE },
|
|
825
|
+
{ address: owner, role: AccountRole.READONLY_SIGNER },
|
|
826
|
+
{ address: rentRecipient, role: AccountRole.WRITABLE }
|
|
688
827
|
];
|
|
689
828
|
const data = INSTRUCTION_DISCRIMINATORS.closePosition;
|
|
690
829
|
return {
|
|
@@ -699,7 +838,7 @@ var addLiquidityArgsWithOracleCodec = getStructCodec([
|
|
|
699
838
|
["minSharesOut", getU128Codec()],
|
|
700
839
|
["updateOracle", getBooleanCodec()]
|
|
701
840
|
]);
|
|
702
|
-
function createAddLiquidityInstruction(accounts, args, programId =
|
|
841
|
+
function createAddLiquidityInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
703
842
|
const {
|
|
704
843
|
config,
|
|
705
844
|
pool,
|
|
@@ -713,30 +852,30 @@ function createAddLiquidityInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
|
713
852
|
token1Mint,
|
|
714
853
|
user0,
|
|
715
854
|
user1,
|
|
716
|
-
tokenProgram =
|
|
855
|
+
tokenProgram = TOKEN_PROGRAM_ADDRESS,
|
|
717
856
|
oracle,
|
|
718
857
|
remainingAccounts = []
|
|
719
858
|
} = accounts;
|
|
720
859
|
const keys = [
|
|
721
|
-
{ address: config, role:
|
|
722
|
-
{ address: pool, role:
|
|
723
|
-
{ address: position, role:
|
|
724
|
-
{ address: protocolPosition, role:
|
|
725
|
-
{ address: owner, role:
|
|
726
|
-
{ address: authority, role:
|
|
727
|
-
{ address: vault0, role:
|
|
728
|
-
{ address: vault1, role:
|
|
729
|
-
{ address: token0Mint, role:
|
|
730
|
-
{ address: token1Mint, role:
|
|
731
|
-
{ address: user0, role:
|
|
732
|
-
{ address: user1, role:
|
|
733
|
-
{ address: tokenProgram, role:
|
|
860
|
+
{ address: config, role: AccountRole.READONLY },
|
|
861
|
+
{ address: pool, role: AccountRole.WRITABLE },
|
|
862
|
+
{ address: position, role: AccountRole.WRITABLE },
|
|
863
|
+
{ address: protocolPosition, role: AccountRole.WRITABLE },
|
|
864
|
+
{ address: owner, role: AccountRole.READONLY_SIGNER },
|
|
865
|
+
{ address: authority, role: AccountRole.READONLY },
|
|
866
|
+
{ address: vault0, role: AccountRole.WRITABLE },
|
|
867
|
+
{ address: vault1, role: AccountRole.WRITABLE },
|
|
868
|
+
{ address: token0Mint, role: AccountRole.READONLY },
|
|
869
|
+
{ address: token1Mint, role: AccountRole.READONLY },
|
|
870
|
+
{ address: user0, role: AccountRole.WRITABLE },
|
|
871
|
+
{ address: user1, role: AccountRole.WRITABLE },
|
|
872
|
+
{ address: tokenProgram, role: AccountRole.READONLY }
|
|
734
873
|
];
|
|
735
874
|
if (oracle) {
|
|
736
|
-
keys.push({ address: oracle, role:
|
|
875
|
+
keys.push({ address: oracle, role: AccountRole.WRITABLE });
|
|
737
876
|
}
|
|
738
877
|
for (const account of remainingAccounts) {
|
|
739
|
-
keys.push({ address: account, role:
|
|
878
|
+
keys.push({ address: account, role: AccountRole.READONLY });
|
|
740
879
|
}
|
|
741
880
|
const data = encodeInstructionData(
|
|
742
881
|
INSTRUCTION_DISCRIMINATORS.addLiquidity,
|
|
@@ -749,9 +888,7 @@ function createAddLiquidityInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
|
749
888
|
data
|
|
750
889
|
};
|
|
751
890
|
}
|
|
752
|
-
|
|
753
|
-
// src/solana/instructions/removeLiquidity.ts
|
|
754
|
-
function createRemoveLiquidityInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
891
|
+
function createRemoveLiquidityInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
755
892
|
const {
|
|
756
893
|
config,
|
|
757
894
|
pool,
|
|
@@ -765,30 +902,30 @@ function createRemoveLiquidityInstruction(accounts, args, programId = PROGRAM_ID
|
|
|
765
902
|
token1Mint,
|
|
766
903
|
user0,
|
|
767
904
|
user1,
|
|
768
|
-
tokenProgram =
|
|
905
|
+
tokenProgram = TOKEN_PROGRAM_ADDRESS,
|
|
769
906
|
oracle,
|
|
770
907
|
remainingAccounts = []
|
|
771
908
|
} = accounts;
|
|
772
909
|
const keys = [
|
|
773
|
-
{ address: config, role:
|
|
774
|
-
{ address: pool, role:
|
|
775
|
-
{ address: position, role:
|
|
776
|
-
{ address: protocolPosition, role:
|
|
777
|
-
{ address: owner, role:
|
|
778
|
-
{ address: authority, role:
|
|
779
|
-
{ address: vault0, role:
|
|
780
|
-
{ address: vault1, role:
|
|
781
|
-
{ address: token0Mint, role:
|
|
782
|
-
{ address: token1Mint, role:
|
|
783
|
-
{ address: user0, role:
|
|
784
|
-
{ address: user1, role:
|
|
785
|
-
{ address: tokenProgram, role:
|
|
910
|
+
{ address: config, role: AccountRole.READONLY },
|
|
911
|
+
{ address: pool, role: AccountRole.WRITABLE },
|
|
912
|
+
{ address: position, role: AccountRole.WRITABLE },
|
|
913
|
+
{ address: protocolPosition, role: AccountRole.WRITABLE },
|
|
914
|
+
{ address: owner, role: AccountRole.READONLY_SIGNER },
|
|
915
|
+
{ address: authority, role: AccountRole.READONLY },
|
|
916
|
+
{ address: vault0, role: AccountRole.WRITABLE },
|
|
917
|
+
{ address: vault1, role: AccountRole.WRITABLE },
|
|
918
|
+
{ address: token0Mint, role: AccountRole.READONLY },
|
|
919
|
+
{ address: token1Mint, role: AccountRole.READONLY },
|
|
920
|
+
{ address: user0, role: AccountRole.WRITABLE },
|
|
921
|
+
{ address: user1, role: AccountRole.WRITABLE },
|
|
922
|
+
{ address: tokenProgram, role: AccountRole.READONLY }
|
|
786
923
|
];
|
|
787
924
|
if (oracle) {
|
|
788
|
-
keys.push({ address: oracle, role:
|
|
925
|
+
keys.push({ address: oracle, role: AccountRole.WRITABLE });
|
|
789
926
|
}
|
|
790
927
|
for (const account of remainingAccounts) {
|
|
791
|
-
keys.push({ address: account, role:
|
|
928
|
+
keys.push({ address: account, role: AccountRole.READONLY });
|
|
792
929
|
}
|
|
793
930
|
const data = encodeInstructionData(
|
|
794
931
|
INSTRUCTION_DISCRIMINATORS.removeLiquidity,
|
|
@@ -801,9 +938,7 @@ function createRemoveLiquidityInstruction(accounts, args, programId = PROGRAM_ID
|
|
|
801
938
|
data
|
|
802
939
|
};
|
|
803
940
|
}
|
|
804
|
-
|
|
805
|
-
// src/solana/instructions/collectProtocolFees.ts
|
|
806
|
-
function createCollectProtocolFeesInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
941
|
+
function createCollectProtocolFeesInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
807
942
|
const {
|
|
808
943
|
config,
|
|
809
944
|
pool,
|
|
@@ -816,21 +951,21 @@ function createCollectProtocolFeesInstruction(accounts, args, programId = PROGRA
|
|
|
816
951
|
token1Mint,
|
|
817
952
|
recipient0,
|
|
818
953
|
recipient1,
|
|
819
|
-
tokenProgram =
|
|
954
|
+
tokenProgram = TOKEN_PROGRAM_ADDRESS
|
|
820
955
|
} = accounts;
|
|
821
956
|
const keys = [
|
|
822
|
-
{ address: config, role:
|
|
823
|
-
{ address: pool, role:
|
|
824
|
-
{ address: protocolPosition, role:
|
|
825
|
-
{ address: admin, role:
|
|
826
|
-
{ address: authority, role:
|
|
827
|
-
{ address: vault0, role:
|
|
828
|
-
{ address: vault1, role:
|
|
829
|
-
{ address: token0Mint, role:
|
|
830
|
-
{ address: token1Mint, role:
|
|
831
|
-
{ address: recipient0, role:
|
|
832
|
-
{ address: recipient1, role:
|
|
833
|
-
{ address: tokenProgram, role:
|
|
957
|
+
{ address: config, role: AccountRole.READONLY },
|
|
958
|
+
{ address: pool, role: AccountRole.WRITABLE },
|
|
959
|
+
{ address: protocolPosition, role: AccountRole.WRITABLE },
|
|
960
|
+
{ address: admin, role: AccountRole.READONLY_SIGNER },
|
|
961
|
+
{ address: authority, role: AccountRole.READONLY },
|
|
962
|
+
{ address: vault0, role: AccountRole.WRITABLE },
|
|
963
|
+
{ address: vault1, role: AccountRole.WRITABLE },
|
|
964
|
+
{ address: token0Mint, role: AccountRole.READONLY },
|
|
965
|
+
{ address: token1Mint, role: AccountRole.READONLY },
|
|
966
|
+
{ address: recipient0, role: AccountRole.WRITABLE },
|
|
967
|
+
{ address: recipient1, role: AccountRole.WRITABLE },
|
|
968
|
+
{ address: tokenProgram, role: AccountRole.READONLY }
|
|
834
969
|
];
|
|
835
970
|
const data = encodeInstructionData(
|
|
836
971
|
INSTRUCTION_DISCRIMINATORS.collectProtocolFees,
|
|
@@ -843,13 +978,11 @@ function createCollectProtocolFeesInstruction(accounts, args, programId = PROGRA
|
|
|
843
978
|
data
|
|
844
979
|
};
|
|
845
980
|
}
|
|
846
|
-
|
|
847
|
-
// src/solana/instructions/oracleUpdate.ts
|
|
848
|
-
function createOracleUpdateInstruction(accounts, programId = PROGRAM_ID) {
|
|
981
|
+
function createOracleUpdateInstruction(accounts, programId = CPMM_PROGRAM_ID) {
|
|
849
982
|
const { pool, oracle } = accounts;
|
|
850
983
|
const keys = [
|
|
851
|
-
{ address: pool, role:
|
|
852
|
-
{ address: oracle, role:
|
|
984
|
+
{ address: pool, role: AccountRole.READONLY },
|
|
985
|
+
{ address: oracle, role: AccountRole.WRITABLE }
|
|
853
986
|
];
|
|
854
987
|
const data = INSTRUCTION_DISCRIMINATORS.oracleUpdate;
|
|
855
988
|
return {
|
|
@@ -865,11 +998,11 @@ var oracleConsultResultCodec = getStructCodec([
|
|
|
865
998
|
function decodeOracleConsultResult(data) {
|
|
866
999
|
return oracleConsultResultCodec.decode(data);
|
|
867
1000
|
}
|
|
868
|
-
function createOracleConsultInstruction(accounts, args, programId =
|
|
1001
|
+
function createOracleConsultInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
869
1002
|
const { pool, oracle } = accounts;
|
|
870
1003
|
const keys = [
|
|
871
|
-
{ address: pool, role:
|
|
872
|
-
{ address: oracle, role:
|
|
1004
|
+
{ address: pool, role: AccountRole.READONLY },
|
|
1005
|
+
{ address: oracle, role: AccountRole.READONLY }
|
|
873
1006
|
];
|
|
874
1007
|
const data = encodeInstructionData(
|
|
875
1008
|
INSTRUCTION_DISCRIMINATORS.oracleConsult,
|
|
@@ -890,14 +1023,14 @@ var quoteToNumeraireResultCodec = getStructCodec([
|
|
|
890
1023
|
function decodeQuoteToNumeraireResult(data) {
|
|
891
1024
|
return quoteToNumeraireResultCodec.decode(data);
|
|
892
1025
|
}
|
|
893
|
-
function createQuoteToNumeraireInstruction(accounts, args, programId =
|
|
1026
|
+
function createQuoteToNumeraireInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
|
|
894
1027
|
const { config, startPool, remainingAccounts = [] } = accounts;
|
|
895
1028
|
const keys = [
|
|
896
|
-
{ address: config, role:
|
|
897
|
-
{ address: startPool, role:
|
|
1029
|
+
{ address: config, role: AccountRole.READONLY },
|
|
1030
|
+
{ address: startPool, role: AccountRole.READONLY }
|
|
898
1031
|
];
|
|
899
1032
|
for (const account of remainingAccounts) {
|
|
900
|
-
keys.push({ address: account, role:
|
|
1033
|
+
keys.push({ address: account, role: AccountRole.READONLY });
|
|
901
1034
|
}
|
|
902
1035
|
const data = encodeInstructionData(
|
|
903
1036
|
INSTRUCTION_DISCRIMINATORS.quoteToNumeraire,
|
|
@@ -920,7 +1053,7 @@ function base64ToBytes(base64) {
|
|
|
920
1053
|
}
|
|
921
1054
|
return bytes;
|
|
922
1055
|
}
|
|
923
|
-
async function fetchConfig(rpc, programId =
|
|
1056
|
+
async function fetchConfig(rpc, programId = CPMM_PROGRAM_ID, commitment) {
|
|
924
1057
|
const [configAddress] = await getConfigAddress(programId);
|
|
925
1058
|
const response = await rpc.getAccountInfo(configAddress, {
|
|
926
1059
|
encoding: "base64",
|
|
@@ -931,7 +1064,7 @@ async function fetchConfig(rpc, programId = PROGRAM_ID, commitment) {
|
|
|
931
1064
|
}
|
|
932
1065
|
return decodeAmmConfig(base64ToBytes(response.value.data[0]));
|
|
933
1066
|
}
|
|
934
|
-
async function fetchConfigWithAddress(rpc, programId =
|
|
1067
|
+
async function fetchConfigWithAddress(rpc, programId = CPMM_PROGRAM_ID, commitment) {
|
|
935
1068
|
const [configAddress] = await getConfigAddress(programId);
|
|
936
1069
|
const account = await fetchConfig(rpc, programId, commitment);
|
|
937
1070
|
if (!account) {
|
|
@@ -944,6 +1077,7 @@ async function fetchConfigWithAddress(rpc, programId = PROGRAM_ID, commitment) {
|
|
|
944
1077
|
var initializer_exports = {};
|
|
945
1078
|
__export(initializer_exports, {
|
|
946
1079
|
BPF_LOADER_UPGRADEABLE_PROGRAM_ID: () => BPF_LOADER_UPGRADEABLE_PROGRAM_ID,
|
|
1080
|
+
CPMM_SENTINEL_PROGRAM_ID: () => CPMM_SENTINEL_PROGRAM_ID,
|
|
947
1081
|
CURVE_KIND_XYK: () => CURVE_KIND_XYK,
|
|
948
1082
|
CURVE_PARAMS_FORMAT_XYK_V0: () => CURVE_PARAMS_FORMAT_XYK_V0,
|
|
949
1083
|
DIRECTION_BUY: () => DIRECTION_BUY,
|
|
@@ -959,12 +1093,14 @@ __export(initializer_exports, {
|
|
|
959
1093
|
PHASE_ABORTED: () => PHASE_ABORTED,
|
|
960
1094
|
PHASE_MIGRATED: () => PHASE_MIGRATED,
|
|
961
1095
|
PHASE_TRADING: () => PHASE_TRADING,
|
|
1096
|
+
PREDICTION_SENTINEL_PROGRAM_ID: () => PREDICTION_SENTINEL_PROGRAM_ID,
|
|
962
1097
|
SEED_CONFIG: () => SEED_CONFIG2,
|
|
963
1098
|
SEED_LAUNCH: () => SEED_LAUNCH,
|
|
964
1099
|
SEED_LAUNCH_AUTHORITY: () => SEED_LAUNCH_AUTHORITY,
|
|
965
1100
|
SENTINEL_NO_CHANGE: () => SENTINEL_NO_CHANGE2,
|
|
966
1101
|
SF_AFTER_SWAP: () => SF_AFTER_SWAP2,
|
|
967
1102
|
SF_BEFORE_SWAP: () => SF_BEFORE_SWAP2,
|
|
1103
|
+
computeRemainingAccountsHash: () => computeRemainingAccountsHash,
|
|
968
1104
|
createAbortLaunchInstruction: () => createAbortLaunchInstruction,
|
|
969
1105
|
createCurveSwapExactInInstruction: () => createCurveSwapExactInInstruction,
|
|
970
1106
|
createInitializeConfigInstruction: () => createInitializeConfigInstruction2,
|
|
@@ -978,7 +1114,7 @@ __export(initializer_exports, {
|
|
|
978
1114
|
decodePreviewSwapExactInResult: () => decodePreviewSwapExactInResult,
|
|
979
1115
|
encodeU64LE: () => encodeU64LE,
|
|
980
1116
|
fetchAllLaunches: () => fetchAllLaunches,
|
|
981
|
-
fetchLaunch: () =>
|
|
1117
|
+
fetchLaunch: () => fetchLaunch2,
|
|
982
1118
|
fetchLaunchesByAuthority: () => fetchLaunchesByAuthority,
|
|
983
1119
|
getConfigAddress: () => getConfigAddress2,
|
|
984
1120
|
getInitConfigCodec: () => getInitConfigCodec,
|
|
@@ -998,7 +1134,8 @@ __export(initializer_exports, {
|
|
|
998
1134
|
getProgramDataAddress: () => getProgramDataAddress,
|
|
999
1135
|
getTokenMetadataAddress: () => getTokenMetadataAddress,
|
|
1000
1136
|
launchExists: () => launchExists,
|
|
1001
|
-
launchIdFromU64: () => launchIdFromU64
|
|
1137
|
+
launchIdFromU64: () => launchIdFromU64,
|
|
1138
|
+
phaseLabel: () => phaseLabel
|
|
1002
1139
|
});
|
|
1003
1140
|
var INITIALIZER_PROGRAM_ID = address(
|
|
1004
1141
|
"4h3Dqyo5qmteJoMxXt3tdtfXELDB6pdRTPU9mWruiKp1"
|
|
@@ -1006,42 +1143,48 @@ var INITIALIZER_PROGRAM_ID = address(
|
|
|
1006
1143
|
var BPF_LOADER_UPGRADEABLE_PROGRAM_ID = address(
|
|
1007
1144
|
"BPFLoaderUpgradeab1e11111111111111111111111"
|
|
1008
1145
|
);
|
|
1146
|
+
var CPMM_SENTINEL_PROGRAM_ID = address(
|
|
1147
|
+
"2vJ1c62knEwZbxp3XdHB4RSmCfz55pA6tRkCho63gW7u"
|
|
1148
|
+
);
|
|
1149
|
+
var PREDICTION_SENTINEL_PROGRAM_ID = address(
|
|
1150
|
+
"7QcQDANJVC17Jgc6KjjeagSkm2zAphgHVPK5agJzyihB"
|
|
1151
|
+
);
|
|
1009
1152
|
var SEED_CONFIG2 = "config_v3";
|
|
1010
1153
|
var SEED_LAUNCH = "launch_v3";
|
|
1011
1154
|
var SEED_LAUNCH_AUTHORITY = "launch_authority_v3";
|
|
1012
1155
|
var EMPTY_REMAINING_ACCOUNTS_HASH = new Uint8Array([
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1156
|
+
232,
|
|
1157
|
+
231,
|
|
1158
|
+
118,
|
|
1159
|
+
38,
|
|
1160
|
+
88,
|
|
1161
|
+
111,
|
|
1162
|
+
115,
|
|
1163
|
+
185,
|
|
1164
|
+
85,
|
|
1165
|
+
54,
|
|
1166
|
+
76,
|
|
1167
|
+
123,
|
|
1168
|
+
75,
|
|
1169
|
+
191,
|
|
1170
|
+
11,
|
|
1171
|
+
183,
|
|
1172
|
+
247,
|
|
1173
|
+
104,
|
|
1174
|
+
94,
|
|
1175
|
+
189,
|
|
1021
1176
|
64,
|
|
1022
|
-
87,
|
|
1023
|
-
25,
|
|
1024
|
-
45,
|
|
1025
|
-
196,
|
|
1026
|
-
61,
|
|
1027
|
-
215,
|
|
1028
|
-
72,
|
|
1029
|
-
234,
|
|
1030
|
-
119,
|
|
1031
|
-
138,
|
|
1032
|
-
220,
|
|
1033
|
-
82,
|
|
1034
|
-
188,
|
|
1035
|
-
73,
|
|
1036
|
-
140,
|
|
1037
1177
|
232,
|
|
1038
|
-
|
|
1178
|
+
82,
|
|
1179
|
+
177,
|
|
1180
|
+
100,
|
|
1181
|
+
99,
|
|
1182
|
+
58,
|
|
1183
|
+
74,
|
|
1184
|
+
203,
|
|
1185
|
+
211,
|
|
1039
1186
|
36,
|
|
1040
|
-
|
|
1041
|
-
20,
|
|
1042
|
-
184,
|
|
1043
|
-
17,
|
|
1044
|
-
25
|
|
1187
|
+
76
|
|
1045
1188
|
]);
|
|
1046
1189
|
var DOPPLER_DEVNET_ALT = address(
|
|
1047
1190
|
"7r5rdLkGMzTq5Q2kBhkePw4ZTeZEooHgTXktYoamNmVq"
|
|
@@ -1617,8 +1760,6 @@ function launchIdFromU64(launchId) {
|
|
|
1617
1760
|
out.set(encodeU64LE(launchId), 0);
|
|
1618
1761
|
return out;
|
|
1619
1762
|
}
|
|
1620
|
-
|
|
1621
|
-
// src/solana/initializer/instructions/initializeConfig.ts
|
|
1622
1763
|
function isTransactionSigner2(value) {
|
|
1623
1764
|
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
1624
1765
|
}
|
|
@@ -1633,21 +1774,19 @@ function createInitializeConfigInstruction2(accounts, args, programId = INITIALI
|
|
|
1633
1774
|
admin,
|
|
1634
1775
|
config,
|
|
1635
1776
|
programData,
|
|
1636
|
-
systemProgram =
|
|
1777
|
+
systemProgram = SYSTEM_PROGRAM_ADDRESS
|
|
1637
1778
|
} = accounts;
|
|
1638
1779
|
const keys = [
|
|
1639
|
-
createSignerAccountMeta2(admin,
|
|
1640
|
-
{ address: config, role:
|
|
1641
|
-
{ address: programData, role:
|
|
1642
|
-
{ address: systemProgram, role:
|
|
1780
|
+
createSignerAccountMeta2(admin, AccountRole.WRITABLE_SIGNER),
|
|
1781
|
+
{ address: config, role: AccountRole.WRITABLE },
|
|
1782
|
+
{ address: programData, role: AccountRole.READONLY },
|
|
1783
|
+
{ address: systemProgram, role: AccountRole.READONLY }
|
|
1643
1784
|
];
|
|
1644
1785
|
const data = new Uint8Array(
|
|
1645
1786
|
getInitializeConfigInstructionDataEncoder().encode(args)
|
|
1646
1787
|
);
|
|
1647
1788
|
return { programAddress: programId, accounts: keys, data };
|
|
1648
1789
|
}
|
|
1649
|
-
|
|
1650
|
-
// src/solana/initializer/instructions/setMigratorAllowlist.ts
|
|
1651
1790
|
function isTransactionSigner3(value) {
|
|
1652
1791
|
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
1653
1792
|
}
|
|
@@ -1660,16 +1799,14 @@ function createSignerAccountMeta3(value, role) {
|
|
|
1660
1799
|
function createSetMigratorAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
|
|
1661
1800
|
const { admin, config } = accounts;
|
|
1662
1801
|
const keys = [
|
|
1663
|
-
createSignerAccountMeta3(admin,
|
|
1664
|
-
{ address: config, role:
|
|
1802
|
+
createSignerAccountMeta3(admin, AccountRole.WRITABLE_SIGNER),
|
|
1803
|
+
{ address: config, role: AccountRole.WRITABLE }
|
|
1665
1804
|
];
|
|
1666
1805
|
const data = new Uint8Array(
|
|
1667
1806
|
getSetMigratorAllowlistInstructionDataEncoder().encode({ allowlist })
|
|
1668
1807
|
);
|
|
1669
1808
|
return { programAddress: programId, accounts: keys, data };
|
|
1670
1809
|
}
|
|
1671
|
-
|
|
1672
|
-
// src/solana/initializer/instructions/setSentinelAllowlist.ts
|
|
1673
1810
|
function isTransactionSigner4(value) {
|
|
1674
1811
|
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
1675
1812
|
}
|
|
@@ -1682,8 +1819,8 @@ function createSignerAccountMeta4(value, role) {
|
|
|
1682
1819
|
function createSetSentinelAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
|
|
1683
1820
|
const { admin, config } = accounts;
|
|
1684
1821
|
const keys = [
|
|
1685
|
-
createSignerAccountMeta4(admin,
|
|
1686
|
-
{ address: config, role:
|
|
1822
|
+
createSignerAccountMeta4(admin, AccountRole.WRITABLE_SIGNER),
|
|
1823
|
+
{ address: config, role: AccountRole.WRITABLE }
|
|
1687
1824
|
];
|
|
1688
1825
|
const data = new Uint8Array(
|
|
1689
1826
|
getSetSentinelAllowlistInstructionDataEncoder().encode({ allowlist })
|
|
@@ -1723,251 +1860,2105 @@ var CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS = {
|
|
|
1723
1860
|
176
|
|
1724
1861
|
])
|
|
1725
1862
|
};
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
1733
|
-
}
|
|
1734
|
-
function createAccountMeta(value, role) {
|
|
1735
|
-
if (isTransactionSigner5(value)) {
|
|
1736
|
-
return { address: value.address, role, signer: value };
|
|
1737
|
-
}
|
|
1738
|
-
return { address: value, role };
|
|
1739
|
-
}
|
|
1740
|
-
async function getTokenMetadataAddress(mint) {
|
|
1741
|
-
const encoder = getAddressEncoder();
|
|
1742
|
-
const [metadataAddress] = await getProgramDerivedAddress({
|
|
1743
|
-
programAddress: TOKEN_METADATA_PROGRAM_ID,
|
|
1744
|
-
seeds: [
|
|
1745
|
-
new TextEncoder().encode("metadata"),
|
|
1746
|
-
encoder.encode(TOKEN_METADATA_PROGRAM_ID),
|
|
1747
|
-
encoder.encode(mint)
|
|
1748
|
-
]
|
|
1863
|
+
var addressCodec3 = getAddressCodec();
|
|
1864
|
+
var textEncoder3 = new TextEncoder();
|
|
1865
|
+
async function getCpmmMigratorStateAddress(launch, programId = CPMM_MIGRATOR_PROGRAM_ID) {
|
|
1866
|
+
return getProgramDerivedAddress({
|
|
1867
|
+
programAddress: programId,
|
|
1868
|
+
seeds: [textEncoder3.encode(SEED_STATE), addressCodec3.encode(launch)]
|
|
1749
1869
|
});
|
|
1750
|
-
return metadataAddress;
|
|
1751
|
-
}
|
|
1752
|
-
var ALT_INDEX = {
|
|
1753
|
-
[TOKEN_PROGRAM_ID]: 0,
|
|
1754
|
-
[SYSTEM_PROGRAM_ID]: 1,
|
|
1755
|
-
SysvarRent111111111111111111111111111111111: 2,
|
|
1756
|
-
[INITIALIZER_PROGRAM_ID]: 3,
|
|
1757
|
-
[TOKEN_METADATA_PROGRAM_ID]: 4,
|
|
1758
|
-
[CPMM_MIGRATOR_PROGRAM_ID]: 5,
|
|
1759
|
-
So11111111111111111111111111111111111111112: 6,
|
|
1760
|
-
// index 7 = config PDA — resolved at call time from accounts.config
|
|
1761
|
-
[PREDICTION_MIGRATOR_PROGRAM_ADDRESS]: 8
|
|
1762
|
-
};
|
|
1763
|
-
function validateInitializeLaunchCurveParams(args) {
|
|
1764
|
-
if (args.curveKind !== CURVE_KIND_XYK) {
|
|
1765
|
-
throw new Error(
|
|
1766
|
-
`unsupported curve kind: ${args.curveKind}; only CURVE_KIND_XYK is currently enabled`
|
|
1767
|
-
);
|
|
1768
|
-
}
|
|
1769
|
-
if (args.curveParams.length !== 1 || args.curveParams[0] !== CURVE_PARAMS_FORMAT_XYK_V0) {
|
|
1770
|
-
throw new Error("xyk curve params must be [CURVE_PARAMS_FORMAT_XYK_V0]");
|
|
1771
|
-
}
|
|
1772
1870
|
}
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
tokenProgram = TOKEN_PROGRAM_ID,
|
|
1787
|
-
systemProgram = SYSTEM_PROGRAM_ID,
|
|
1788
|
-
rent,
|
|
1789
|
-
metadataAccount,
|
|
1790
|
-
addressLookupTable: alt
|
|
1791
|
-
} = accounts;
|
|
1792
|
-
const withMetadata = Boolean(
|
|
1793
|
-
args.metadataName && args.metadataName.length > 0
|
|
1871
|
+
var CLAIM_RECEIPT_DISCRIMINATOR = new Uint8Array([
|
|
1872
|
+
223,
|
|
1873
|
+
233,
|
|
1874
|
+
11,
|
|
1875
|
+
229,
|
|
1876
|
+
124,
|
|
1877
|
+
165,
|
|
1878
|
+
207,
|
|
1879
|
+
28
|
|
1880
|
+
]);
|
|
1881
|
+
function getClaimReceiptDiscriminatorBytes() {
|
|
1882
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
1883
|
+
CLAIM_RECEIPT_DISCRIMINATOR
|
|
1794
1884
|
);
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
};
|
|
1809
|
-
}
|
|
1810
|
-
return { address: addr, role };
|
|
1811
|
-
}
|
|
1812
|
-
const keys = [
|
|
1813
|
-
staticOrLookup(config, AccountRole.READONLY),
|
|
1814
|
-
{ address: launch, role: ACCOUNT_ROLE_WRITABLE },
|
|
1815
|
-
{ address: launchAuthority, role: ACCOUNT_ROLE_READONLY },
|
|
1816
|
-
createAccountMeta(baseMint, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
1817
|
-
staticOrLookup(quoteMint, AccountRole.READONLY),
|
|
1818
|
-
createAccountMeta(baseVault, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
1819
|
-
createAccountMeta(quoteVault, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
1820
|
-
createAccountMeta(payer, ACCOUNT_ROLE_WRITABLE_SIGNER)
|
|
1821
|
-
];
|
|
1822
|
-
if (authority) {
|
|
1823
|
-
keys.push(createAccountMeta(authority, ACCOUNT_ROLE_SIGNER));
|
|
1824
|
-
}
|
|
1825
|
-
if (migratorProgram) {
|
|
1826
|
-
keys.push(staticOrLookup(migratorProgram, AccountRole.READONLY));
|
|
1827
|
-
}
|
|
1828
|
-
keys.push(staticOrLookup(tokenProgram, AccountRole.READONLY));
|
|
1829
|
-
keys.push(staticOrLookup(systemProgram, AccountRole.READONLY));
|
|
1830
|
-
keys.push(staticOrLookup(rent, AccountRole.READONLY));
|
|
1831
|
-
if (withMetadata) {
|
|
1832
|
-
keys.push({ address: metadataAccount, role: ACCOUNT_ROLE_WRITABLE });
|
|
1833
|
-
keys.push(staticOrLookup(TOKEN_METADATA_PROGRAM_ID, AccountRole.READONLY));
|
|
1834
|
-
}
|
|
1835
|
-
const data = new Uint8Array(
|
|
1836
|
-
getInitializeLaunchInstructionDataEncoder().encode(args)
|
|
1885
|
+
}
|
|
1886
|
+
function getClaimReceiptEncoder() {
|
|
1887
|
+
return transformEncoder(
|
|
1888
|
+
getStructEncoder([
|
|
1889
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
1890
|
+
["market", getAddressEncoder()],
|
|
1891
|
+
["claimer", getAddressEncoder()],
|
|
1892
|
+
["burnedAmount", getU64Encoder()],
|
|
1893
|
+
["rewardDebt", getU128Encoder()],
|
|
1894
|
+
["bump", getU8Encoder()],
|
|
1895
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 7)]
|
|
1896
|
+
]),
|
|
1897
|
+
(value) => ({ ...value, discriminator: CLAIM_RECEIPT_DISCRIMINATOR })
|
|
1837
1898
|
);
|
|
1838
|
-
return { programAddress: programId, accounts: keys, data };
|
|
1839
1899
|
}
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1900
|
+
function getClaimReceiptDecoder() {
|
|
1901
|
+
return getStructDecoder([
|
|
1902
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
1903
|
+
["market", getAddressDecoder()],
|
|
1904
|
+
["claimer", getAddressDecoder()],
|
|
1905
|
+
["burnedAmount", getU64Decoder()],
|
|
1906
|
+
["rewardDebt", getU128Decoder()],
|
|
1907
|
+
["bump", getU8Decoder()],
|
|
1908
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 7)]
|
|
1909
|
+
]);
|
|
1844
1910
|
}
|
|
1845
|
-
function
|
|
1846
|
-
|
|
1847
|
-
return { address: value.address, role, signer: value };
|
|
1848
|
-
}
|
|
1849
|
-
return { address: value, role };
|
|
1911
|
+
function getClaimReceiptCodec() {
|
|
1912
|
+
return combineCodec(getClaimReceiptEncoder(), getClaimReceiptDecoder());
|
|
1850
1913
|
}
|
|
1851
|
-
function
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
launchAuthority,
|
|
1856
|
-
baseVault,
|
|
1857
|
-
quoteVault,
|
|
1858
|
-
userBaseAccount,
|
|
1859
|
-
userQuoteAccount,
|
|
1860
|
-
baseMint,
|
|
1861
|
-
quoteMint,
|
|
1862
|
-
user,
|
|
1863
|
-
sentinelProgram = SYSTEM_PROGRAM_ID,
|
|
1864
|
-
tokenProgram = TOKEN_PROGRAM_ID
|
|
1865
|
-
} = accounts;
|
|
1866
|
-
const keys = [
|
|
1867
|
-
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
1868
|
-
{ address: launch, role: ACCOUNT_ROLE_WRITABLE },
|
|
1869
|
-
{ address: launchAuthority, role: ACCOUNT_ROLE_READONLY },
|
|
1870
|
-
{ address: baseVault, role: ACCOUNT_ROLE_WRITABLE },
|
|
1871
|
-
{ address: quoteVault, role: ACCOUNT_ROLE_WRITABLE },
|
|
1872
|
-
{ address: userBaseAccount, role: ACCOUNT_ROLE_WRITABLE },
|
|
1873
|
-
{ address: userQuoteAccount, role: ACCOUNT_ROLE_WRITABLE },
|
|
1874
|
-
{ address: baseMint, role: ACCOUNT_ROLE_READONLY },
|
|
1875
|
-
{ address: quoteMint, role: ACCOUNT_ROLE_READONLY },
|
|
1876
|
-
createAccountMeta2(user, ACCOUNT_ROLE_SIGNER),
|
|
1877
|
-
// sentinel_program is Optional in the on-chain struct but still occupies a fixed
|
|
1878
|
-
// slot (token_program follows it). Always emit it — use SYSTEM_PROGRAM_ID as the
|
|
1879
|
-
// no-op placeholder when no real sentinel is configured.
|
|
1880
|
-
{ address: sentinelProgram, role: ACCOUNT_ROLE_READONLY },
|
|
1881
|
-
{ address: tokenProgram, role: ACCOUNT_ROLE_READONLY }
|
|
1882
|
-
];
|
|
1883
|
-
const data = new Uint8Array(
|
|
1884
|
-
getCurveSwapExactInInstructionDataEncoder().encode(args)
|
|
1914
|
+
function decodeClaimReceipt(encodedAccount) {
|
|
1915
|
+
return decodeAccount(
|
|
1916
|
+
encodedAccount,
|
|
1917
|
+
getClaimReceiptDecoder()
|
|
1885
1918
|
);
|
|
1886
|
-
return { programAddress: programId, accounts: keys, data };
|
|
1887
1919
|
}
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
return
|
|
1920
|
+
async function fetchClaimReceipt(rpc, address3, config) {
|
|
1921
|
+
const maybeAccount = await fetchMaybeClaimReceipt(rpc, address3, config);
|
|
1922
|
+
assertAccountExists(maybeAccount);
|
|
1923
|
+
return maybeAccount;
|
|
1892
1924
|
}
|
|
1893
|
-
function
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
}
|
|
1897
|
-
return { address: value, role };
|
|
1925
|
+
async function fetchMaybeClaimReceipt(rpc, address3, config) {
|
|
1926
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address3, config);
|
|
1927
|
+
return decodeClaimReceipt(maybeAccount);
|
|
1898
1928
|
}
|
|
1899
|
-
function
|
|
1900
|
-
const
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
launchAuthority,
|
|
1904
|
-
baseMint,
|
|
1905
|
-
quoteMint,
|
|
1906
|
-
baseVault,
|
|
1907
|
-
quoteVault,
|
|
1908
|
-
migratorProgram,
|
|
1909
|
-
payer,
|
|
1910
|
-
tokenProgram = TOKEN_PROGRAM_ID,
|
|
1911
|
-
systemProgram = SYSTEM_PROGRAM_ID,
|
|
1912
|
-
rent
|
|
1913
|
-
} = accounts;
|
|
1914
|
-
const keys = [
|
|
1915
|
-
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
1916
|
-
{ address: launch, role: ACCOUNT_ROLE_WRITABLE },
|
|
1917
|
-
{ address: launchAuthority, role: ACCOUNT_ROLE_READONLY },
|
|
1918
|
-
{ address: baseMint, role: ACCOUNT_ROLE_READONLY },
|
|
1919
|
-
{ address: quoteMint, role: ACCOUNT_ROLE_READONLY },
|
|
1920
|
-
{ address: baseVault, role: ACCOUNT_ROLE_WRITABLE },
|
|
1921
|
-
{ address: quoteVault, role: ACCOUNT_ROLE_WRITABLE },
|
|
1922
|
-
{ address: migratorProgram, role: ACCOUNT_ROLE_READONLY },
|
|
1923
|
-
createSignerAccountMeta5(payer, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
1924
|
-
{ address: tokenProgram, role: ACCOUNT_ROLE_READONLY },
|
|
1925
|
-
{ address: systemProgram, role: ACCOUNT_ROLE_READONLY },
|
|
1926
|
-
{ address: rent, role: ACCOUNT_ROLE_READONLY }
|
|
1927
|
-
];
|
|
1928
|
-
const data = encodeInstructionData(
|
|
1929
|
-
INITIALIZER_INSTRUCTION_DISCRIMINATORS.migrateLaunch
|
|
1930
|
-
);
|
|
1931
|
-
return { programAddress: programId, accounts: keys, data };
|
|
1929
|
+
async function fetchAllClaimReceipt(rpc, addresses, config) {
|
|
1930
|
+
const maybeAccounts = await fetchAllMaybeClaimReceipt(rpc, addresses, config);
|
|
1931
|
+
assertAccountsExist(maybeAccounts);
|
|
1932
|
+
return maybeAccounts;
|
|
1932
1933
|
}
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
1934
|
+
async function fetchAllMaybeClaimReceipt(rpc, addresses, config) {
|
|
1935
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
1936
|
+
return maybeAccounts.map((maybeAccount) => decodeClaimReceipt(maybeAccount));
|
|
1937
1937
|
}
|
|
1938
|
-
function
|
|
1939
|
-
|
|
1940
|
-
return { address: value.address, role, signer: value };
|
|
1941
|
-
}
|
|
1942
|
-
return { address: value, role };
|
|
1938
|
+
function getClaimReceiptSize() {
|
|
1939
|
+
return 104;
|
|
1943
1940
|
}
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1941
|
+
var ENTRY_DISCRIMINATOR = new Uint8Array([
|
|
1942
|
+
63,
|
|
1943
|
+
18,
|
|
1944
|
+
152,
|
|
1945
|
+
113,
|
|
1946
|
+
215,
|
|
1947
|
+
246,
|
|
1948
|
+
221,
|
|
1949
|
+
250
|
|
1950
|
+
]);
|
|
1951
|
+
function getEntryDiscriminatorBytes() {
|
|
1952
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(ENTRY_DISCRIMINATOR);
|
|
1953
|
+
}
|
|
1954
|
+
function getEntryEncoder() {
|
|
1955
|
+
return transformEncoder(
|
|
1956
|
+
getStructEncoder([
|
|
1957
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
1958
|
+
["oracle", getAddressEncoder()],
|
|
1959
|
+
["entryId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
1960
|
+
["baseMint", getAddressEncoder()],
|
|
1961
|
+
["contribution", getU64Encoder()],
|
|
1962
|
+
["isMigrated", getBooleanEncoder()],
|
|
1963
|
+
["bump", getU8Encoder()],
|
|
1964
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 14)]
|
|
1965
|
+
]),
|
|
1966
|
+
(value) => ({ ...value, discriminator: ENTRY_DISCRIMINATOR })
|
|
1969
1967
|
);
|
|
1970
|
-
|
|
1968
|
+
}
|
|
1969
|
+
function getEntryDecoder() {
|
|
1970
|
+
return getStructDecoder([
|
|
1971
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
1972
|
+
["oracle", getAddressDecoder()],
|
|
1973
|
+
["entryId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
1974
|
+
["baseMint", getAddressDecoder()],
|
|
1975
|
+
["contribution", getU64Decoder()],
|
|
1976
|
+
["isMigrated", getBooleanDecoder()],
|
|
1977
|
+
["bump", getU8Decoder()],
|
|
1978
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 14)]
|
|
1979
|
+
]);
|
|
1980
|
+
}
|
|
1981
|
+
function getEntryCodec() {
|
|
1982
|
+
return combineCodec(getEntryEncoder(), getEntryDecoder());
|
|
1983
|
+
}
|
|
1984
|
+
function decodeEntry(encodedAccount) {
|
|
1985
|
+
return decodeAccount(
|
|
1986
|
+
encodedAccount,
|
|
1987
|
+
getEntryDecoder()
|
|
1988
|
+
);
|
|
1989
|
+
}
|
|
1990
|
+
async function fetchEntry(rpc, address3, config) {
|
|
1991
|
+
const maybeAccount = await fetchMaybeEntry(rpc, address3, config);
|
|
1992
|
+
assertAccountExists(maybeAccount);
|
|
1993
|
+
return maybeAccount;
|
|
1994
|
+
}
|
|
1995
|
+
async function fetchMaybeEntry(rpc, address3, config) {
|
|
1996
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address3, config);
|
|
1997
|
+
return decodeEntry(maybeAccount);
|
|
1998
|
+
}
|
|
1999
|
+
async function fetchAllEntry(rpc, addresses, config) {
|
|
2000
|
+
const maybeAccounts = await fetchAllMaybeEntry(rpc, addresses, config);
|
|
2001
|
+
assertAccountsExist(maybeAccounts);
|
|
2002
|
+
return maybeAccounts;
|
|
2003
|
+
}
|
|
2004
|
+
async function fetchAllMaybeEntry(rpc, addresses, config) {
|
|
2005
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
2006
|
+
return maybeAccounts.map((maybeAccount) => decodeEntry(maybeAccount));
|
|
2007
|
+
}
|
|
2008
|
+
function getEntrySize() {
|
|
2009
|
+
return 128;
|
|
2010
|
+
}
|
|
2011
|
+
var ENTRY_BY_MINT_DISCRIMINATOR = new Uint8Array([
|
|
2012
|
+
188,
|
|
2013
|
+
191,
|
|
2014
|
+
157,
|
|
2015
|
+
194,
|
|
2016
|
+
68,
|
|
2017
|
+
82,
|
|
2018
|
+
181,
|
|
2019
|
+
126
|
|
2020
|
+
]);
|
|
2021
|
+
function getEntryByMintDiscriminatorBytes() {
|
|
2022
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
2023
|
+
ENTRY_BY_MINT_DISCRIMINATOR
|
|
2024
|
+
);
|
|
2025
|
+
}
|
|
2026
|
+
function getEntryByMintEncoder() {
|
|
2027
|
+
return transformEncoder(
|
|
2028
|
+
getStructEncoder([
|
|
2029
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
2030
|
+
["oracle", getAddressEncoder()],
|
|
2031
|
+
["baseMint", getAddressEncoder()],
|
|
2032
|
+
["entryId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
2033
|
+
["bump", getU8Encoder()],
|
|
2034
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 7)]
|
|
2035
|
+
]),
|
|
2036
|
+
(value) => ({ ...value, discriminator: ENTRY_BY_MINT_DISCRIMINATOR })
|
|
2037
|
+
);
|
|
2038
|
+
}
|
|
2039
|
+
function getEntryByMintDecoder() {
|
|
2040
|
+
return getStructDecoder([
|
|
2041
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
2042
|
+
["oracle", getAddressDecoder()],
|
|
2043
|
+
["baseMint", getAddressDecoder()],
|
|
2044
|
+
["entryId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
2045
|
+
["bump", getU8Decoder()],
|
|
2046
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 7)]
|
|
2047
|
+
]);
|
|
2048
|
+
}
|
|
2049
|
+
function getEntryByMintCodec() {
|
|
2050
|
+
return combineCodec(getEntryByMintEncoder(), getEntryByMintDecoder());
|
|
2051
|
+
}
|
|
2052
|
+
function decodeEntryByMint(encodedAccount) {
|
|
2053
|
+
return decodeAccount(
|
|
2054
|
+
encodedAccount,
|
|
2055
|
+
getEntryByMintDecoder()
|
|
2056
|
+
);
|
|
2057
|
+
}
|
|
2058
|
+
async function fetchEntryByMint(rpc, address3, config) {
|
|
2059
|
+
const maybeAccount = await fetchMaybeEntryByMint(rpc, address3, config);
|
|
2060
|
+
assertAccountExists(maybeAccount);
|
|
2061
|
+
return maybeAccount;
|
|
2062
|
+
}
|
|
2063
|
+
async function fetchMaybeEntryByMint(rpc, address3, config) {
|
|
2064
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address3, config);
|
|
2065
|
+
return decodeEntryByMint(maybeAccount);
|
|
2066
|
+
}
|
|
2067
|
+
async function fetchAllEntryByMint(rpc, addresses, config) {
|
|
2068
|
+
const maybeAccounts = await fetchAllMaybeEntryByMint(rpc, addresses, config);
|
|
2069
|
+
assertAccountsExist(maybeAccounts);
|
|
2070
|
+
return maybeAccounts;
|
|
2071
|
+
}
|
|
2072
|
+
async function fetchAllMaybeEntryByMint(rpc, addresses, config) {
|
|
2073
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
2074
|
+
return maybeAccounts.map((maybeAccount) => decodeEntryByMint(maybeAccount));
|
|
2075
|
+
}
|
|
2076
|
+
function getEntryByMintSize() {
|
|
2077
|
+
return 112;
|
|
2078
|
+
}
|
|
2079
|
+
function getAccumulatorUpdatedEncoder() {
|
|
2080
|
+
return getStructEncoder([
|
|
2081
|
+
["market", getAddressEncoder()],
|
|
2082
|
+
["newTotalPot", getU64Encoder()],
|
|
2083
|
+
["newAccQuotePerToken", getU128Encoder()]
|
|
2084
|
+
]);
|
|
2085
|
+
}
|
|
2086
|
+
function getAccumulatorUpdatedDecoder() {
|
|
2087
|
+
return getStructDecoder([
|
|
2088
|
+
["market", getAddressDecoder()],
|
|
2089
|
+
["newTotalPot", getU64Decoder()],
|
|
2090
|
+
["newAccQuotePerToken", getU128Decoder()]
|
|
2091
|
+
]);
|
|
2092
|
+
}
|
|
2093
|
+
function getAccumulatorUpdatedCodec() {
|
|
2094
|
+
return combineCodec(
|
|
2095
|
+
getAccumulatorUpdatedEncoder(),
|
|
2096
|
+
getAccumulatorUpdatedDecoder()
|
|
2097
|
+
);
|
|
2098
|
+
}
|
|
2099
|
+
function getCalldataBufEncoder2() {
|
|
2100
|
+
return getStructEncoder([
|
|
2101
|
+
["len", getU16Encoder()],
|
|
2102
|
+
["bytes", fixEncoderSize(getBytesEncoder(), 256)]
|
|
2103
|
+
]);
|
|
2104
|
+
}
|
|
2105
|
+
function getCalldataBufDecoder2() {
|
|
2106
|
+
return getStructDecoder([
|
|
2107
|
+
["len", getU16Decoder()],
|
|
2108
|
+
["bytes", fixDecoderSize(getBytesDecoder(), 256)]
|
|
2109
|
+
]);
|
|
2110
|
+
}
|
|
2111
|
+
function getCalldataBufCodec() {
|
|
2112
|
+
return combineCodec(getCalldataBufEncoder2(), getCalldataBufDecoder2());
|
|
2113
|
+
}
|
|
2114
|
+
function getEntryMigratedEncoder() {
|
|
2115
|
+
return getStructEncoder([
|
|
2116
|
+
["market", getAddressEncoder()],
|
|
2117
|
+
["oracle", getAddressEncoder()],
|
|
2118
|
+
["entryId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
2119
|
+
["baseMint", getAddressEncoder()],
|
|
2120
|
+
["contribution", getU64Encoder()],
|
|
2121
|
+
["isWinner", getBooleanEncoder()]
|
|
2122
|
+
]);
|
|
2123
|
+
}
|
|
2124
|
+
function getEntryMigratedDecoder() {
|
|
2125
|
+
return getStructDecoder([
|
|
2126
|
+
["market", getAddressDecoder()],
|
|
2127
|
+
["oracle", getAddressDecoder()],
|
|
2128
|
+
["entryId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
2129
|
+
["baseMint", getAddressDecoder()],
|
|
2130
|
+
["contribution", getU64Decoder()],
|
|
2131
|
+
["isWinner", getBooleanDecoder()]
|
|
2132
|
+
]);
|
|
2133
|
+
}
|
|
2134
|
+
function getEntryMigratedCodec() {
|
|
2135
|
+
return combineCodec(getEntryMigratedEncoder(), getEntryMigratedDecoder());
|
|
2136
|
+
}
|
|
2137
|
+
function getEntryRegisteredEncoder() {
|
|
2138
|
+
return getStructEncoder([
|
|
2139
|
+
["market", getAddressEncoder()],
|
|
2140
|
+
["oracle", getAddressEncoder()],
|
|
2141
|
+
["entryId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
2142
|
+
["baseMint", getAddressEncoder()]
|
|
2143
|
+
]);
|
|
2144
|
+
}
|
|
2145
|
+
function getEntryRegisteredDecoder() {
|
|
2146
|
+
return getStructDecoder([
|
|
2147
|
+
["market", getAddressDecoder()],
|
|
2148
|
+
["oracle", getAddressDecoder()],
|
|
2149
|
+
["entryId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
2150
|
+
["baseMint", getAddressDecoder()]
|
|
2151
|
+
]);
|
|
2152
|
+
}
|
|
2153
|
+
function getEntryRegisteredCodec() {
|
|
2154
|
+
return combineCodec(getEntryRegisteredEncoder(), getEntryRegisteredDecoder());
|
|
2155
|
+
}
|
|
2156
|
+
function getMarketCreatedEncoder() {
|
|
2157
|
+
return getStructEncoder([
|
|
2158
|
+
["market", getAddressEncoder()],
|
|
2159
|
+
["oracle", getAddressEncoder()],
|
|
2160
|
+
["quoteMint", getAddressEncoder()]
|
|
2161
|
+
]);
|
|
2162
|
+
}
|
|
2163
|
+
function getMarketCreatedDecoder() {
|
|
2164
|
+
return getStructDecoder([
|
|
2165
|
+
["market", getAddressDecoder()],
|
|
2166
|
+
["oracle", getAddressDecoder()],
|
|
2167
|
+
["quoteMint", getAddressDecoder()]
|
|
2168
|
+
]);
|
|
2169
|
+
}
|
|
2170
|
+
function getMarketCreatedCodec() {
|
|
2171
|
+
return combineCodec(getMarketCreatedEncoder(), getMarketCreatedDecoder());
|
|
2172
|
+
}
|
|
2173
|
+
function getMarketResolvedEncoder() {
|
|
2174
|
+
return getStructEncoder([
|
|
2175
|
+
["market", getAddressEncoder()],
|
|
2176
|
+
["oracle", getAddressEncoder()],
|
|
2177
|
+
["winnerMint", getAddressEncoder()],
|
|
2178
|
+
["claimableSupply", getU64Encoder()],
|
|
2179
|
+
["totalPot", getU64Encoder()]
|
|
2180
|
+
]);
|
|
2181
|
+
}
|
|
2182
|
+
function getMarketResolvedDecoder() {
|
|
2183
|
+
return getStructDecoder([
|
|
2184
|
+
["market", getAddressDecoder()],
|
|
2185
|
+
["oracle", getAddressDecoder()],
|
|
2186
|
+
["winnerMint", getAddressDecoder()],
|
|
2187
|
+
["claimableSupply", getU64Decoder()],
|
|
2188
|
+
["totalPot", getU64Decoder()]
|
|
2189
|
+
]);
|
|
2190
|
+
}
|
|
2191
|
+
function getMarketResolvedCodec() {
|
|
2192
|
+
return combineCodec(getMarketResolvedEncoder(), getMarketResolvedDecoder());
|
|
2193
|
+
}
|
|
2194
|
+
function getMigrateEntryArgsEncoder() {
|
|
2195
|
+
return getStructEncoder([["entryId", fixEncoderSize(getBytesEncoder(), 32)]]);
|
|
2196
|
+
}
|
|
2197
|
+
function getMigrateEntryArgsDecoder() {
|
|
2198
|
+
return getStructDecoder([["entryId", fixDecoderSize(getBytesDecoder(), 32)]]);
|
|
2199
|
+
}
|
|
2200
|
+
function getMigrateEntryArgsCodec() {
|
|
2201
|
+
return combineCodec(
|
|
2202
|
+
getMigrateEntryArgsEncoder(),
|
|
2203
|
+
getMigrateEntryArgsDecoder()
|
|
2204
|
+
);
|
|
2205
|
+
}
|
|
2206
|
+
function getPreviewPayoutIfWinnerArgsEncoder() {
|
|
2207
|
+
return getStructEncoder([
|
|
2208
|
+
["candidateWinnerMint", getAddressEncoder()],
|
|
2209
|
+
["tokenAmount", getU64Encoder()]
|
|
2210
|
+
]);
|
|
2211
|
+
}
|
|
2212
|
+
function getPreviewPayoutIfWinnerArgsDecoder() {
|
|
2213
|
+
return getStructDecoder([
|
|
2214
|
+
["candidateWinnerMint", getAddressDecoder()],
|
|
2215
|
+
["tokenAmount", getU64Decoder()]
|
|
2216
|
+
]);
|
|
2217
|
+
}
|
|
2218
|
+
function getPreviewPayoutIfWinnerArgsCodec() {
|
|
2219
|
+
return combineCodec(
|
|
2220
|
+
getPreviewPayoutIfWinnerArgsEncoder(),
|
|
2221
|
+
getPreviewPayoutIfWinnerArgsDecoder()
|
|
2222
|
+
);
|
|
2223
|
+
}
|
|
2224
|
+
function getRegisterEntryArgsEncoder() {
|
|
2225
|
+
return getStructEncoder([["entryId", fixEncoderSize(getBytesEncoder(), 32)]]);
|
|
2226
|
+
}
|
|
2227
|
+
function getRegisterEntryArgsDecoder() {
|
|
2228
|
+
return getStructDecoder([["entryId", fixDecoderSize(getBytesDecoder(), 32)]]);
|
|
2229
|
+
}
|
|
2230
|
+
function getRegisterEntryArgsCodec() {
|
|
2231
|
+
return combineCodec(
|
|
2232
|
+
getRegisterEntryArgsEncoder(),
|
|
2233
|
+
getRegisterEntryArgsDecoder()
|
|
2234
|
+
);
|
|
2235
|
+
}
|
|
2236
|
+
function getRewardsClaimedEncoder() {
|
|
2237
|
+
return getStructEncoder([
|
|
2238
|
+
["market", getAddressEncoder()],
|
|
2239
|
+
["claimer", getAddressEncoder()],
|
|
2240
|
+
["burnedAmount", getU64Encoder()],
|
|
2241
|
+
["rewardAmount", getU64Encoder()],
|
|
2242
|
+
["totalBurned", getU64Encoder()]
|
|
2243
|
+
]);
|
|
2244
|
+
}
|
|
2245
|
+
function getRewardsClaimedDecoder() {
|
|
2246
|
+
return getStructDecoder([
|
|
2247
|
+
["market", getAddressDecoder()],
|
|
2248
|
+
["claimer", getAddressDecoder()],
|
|
2249
|
+
["burnedAmount", getU64Decoder()],
|
|
2250
|
+
["rewardAmount", getU64Decoder()],
|
|
2251
|
+
["totalBurned", getU64Decoder()]
|
|
2252
|
+
]);
|
|
2253
|
+
}
|
|
2254
|
+
function getRewardsClaimedCodec() {
|
|
2255
|
+
return combineCodec(getRewardsClaimedEncoder(), getRewardsClaimedDecoder());
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
// src/solana/generated/predictionMigrator/accounts/launch.ts
|
|
2259
|
+
var LAUNCH_DISCRIMINATOR2 = new Uint8Array([
|
|
2260
|
+
144,
|
|
2261
|
+
51,
|
|
2262
|
+
51,
|
|
2263
|
+
163,
|
|
2264
|
+
206,
|
|
2265
|
+
85,
|
|
2266
|
+
213,
|
|
2267
|
+
38
|
|
2268
|
+
]);
|
|
2269
|
+
function getLaunchDiscriminatorBytes() {
|
|
2270
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(LAUNCH_DISCRIMINATOR2);
|
|
2271
|
+
}
|
|
2272
|
+
function getLaunchEncoder2() {
|
|
2273
|
+
return transformEncoder(
|
|
2274
|
+
getStructEncoder([
|
|
2275
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
2276
|
+
["authority", getAddressEncoder()],
|
|
2277
|
+
["namespace", getAddressEncoder()],
|
|
2278
|
+
["launchId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
2279
|
+
["phase", getU8Encoder()],
|
|
2280
|
+
["bump", getU8Encoder()],
|
|
2281
|
+
["launchAuthorityBump", getU8Encoder()],
|
|
2282
|
+
["pad0", fixEncoderSize(getBytesEncoder(), 5)],
|
|
2283
|
+
["baseMint", getAddressEncoder()],
|
|
2284
|
+
["quoteMint", getAddressEncoder()],
|
|
2285
|
+
["baseVault", getAddressEncoder()],
|
|
2286
|
+
["quoteVault", getAddressEncoder()],
|
|
2287
|
+
["baseTotalSupply", getU64Encoder()],
|
|
2288
|
+
["baseForDistribution", getU64Encoder()],
|
|
2289
|
+
["baseForLiquidity", getU64Encoder()],
|
|
2290
|
+
["baseForCurve", getU64Encoder()],
|
|
2291
|
+
["curveVirtualBase", getU64Encoder()],
|
|
2292
|
+
["curveVirtualQuote", getU64Encoder()],
|
|
2293
|
+
["curveFeeBps", getU16Encoder()],
|
|
2294
|
+
["pad1", fixEncoderSize(getBytesEncoder(), 6)],
|
|
2295
|
+
["allowBuy", getU8Encoder()],
|
|
2296
|
+
["allowSell", getU8Encoder()],
|
|
2297
|
+
["pad2", fixEncoderSize(getBytesEncoder(), 6)],
|
|
2298
|
+
["sentinelProgram", getAddressEncoder()],
|
|
2299
|
+
["sentinelFlags", getU32Encoder()],
|
|
2300
|
+
["pad3", fixEncoderSize(getBytesEncoder(), 4)],
|
|
2301
|
+
["sentinelCalldata", getCalldataBufEncoder2()],
|
|
2302
|
+
["migratorProgram", getAddressEncoder()],
|
|
2303
|
+
["migratorInitCalldata", getCalldataBufEncoder2()],
|
|
2304
|
+
["migratorMigrateCalldata", getCalldataBufEncoder2()],
|
|
2305
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 64)]
|
|
2306
|
+
]),
|
|
2307
|
+
(value) => ({ ...value, discriminator: LAUNCH_DISCRIMINATOR2 })
|
|
2308
|
+
);
|
|
2309
|
+
}
|
|
2310
|
+
function getLaunchDecoder2() {
|
|
2311
|
+
return getStructDecoder([
|
|
2312
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
2313
|
+
["authority", getAddressDecoder()],
|
|
2314
|
+
["namespace", getAddressDecoder()],
|
|
2315
|
+
["launchId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
2316
|
+
["phase", getU8Decoder()],
|
|
2317
|
+
["bump", getU8Decoder()],
|
|
2318
|
+
["launchAuthorityBump", getU8Decoder()],
|
|
2319
|
+
["pad0", fixDecoderSize(getBytesDecoder(), 5)],
|
|
2320
|
+
["baseMint", getAddressDecoder()],
|
|
2321
|
+
["quoteMint", getAddressDecoder()],
|
|
2322
|
+
["baseVault", getAddressDecoder()],
|
|
2323
|
+
["quoteVault", getAddressDecoder()],
|
|
2324
|
+
["baseTotalSupply", getU64Decoder()],
|
|
2325
|
+
["baseForDistribution", getU64Decoder()],
|
|
2326
|
+
["baseForLiquidity", getU64Decoder()],
|
|
2327
|
+
["baseForCurve", getU64Decoder()],
|
|
2328
|
+
["curveVirtualBase", getU64Decoder()],
|
|
2329
|
+
["curveVirtualQuote", getU64Decoder()],
|
|
2330
|
+
["curveFeeBps", getU16Decoder()],
|
|
2331
|
+
["pad1", fixDecoderSize(getBytesDecoder(), 6)],
|
|
2332
|
+
["allowBuy", getU8Decoder()],
|
|
2333
|
+
["allowSell", getU8Decoder()],
|
|
2334
|
+
["pad2", fixDecoderSize(getBytesDecoder(), 6)],
|
|
2335
|
+
["sentinelProgram", getAddressDecoder()],
|
|
2336
|
+
["sentinelFlags", getU32Decoder()],
|
|
2337
|
+
["pad3", fixDecoderSize(getBytesDecoder(), 4)],
|
|
2338
|
+
["sentinelCalldata", getCalldataBufDecoder2()],
|
|
2339
|
+
["migratorProgram", getAddressDecoder()],
|
|
2340
|
+
["migratorInitCalldata", getCalldataBufDecoder2()],
|
|
2341
|
+
["migratorMigrateCalldata", getCalldataBufDecoder2()],
|
|
2342
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 64)]
|
|
2343
|
+
]);
|
|
2344
|
+
}
|
|
2345
|
+
function getLaunchCodec2() {
|
|
2346
|
+
return combineCodec(getLaunchEncoder2(), getLaunchDecoder2());
|
|
2347
|
+
}
|
|
2348
|
+
function decodeLaunch(encodedAccount) {
|
|
2349
|
+
return decodeAccount(
|
|
2350
|
+
encodedAccount,
|
|
2351
|
+
getLaunchDecoder2()
|
|
2352
|
+
);
|
|
2353
|
+
}
|
|
2354
|
+
async function fetchLaunch(rpc, address3, config) {
|
|
2355
|
+
const maybeAccount = await fetchMaybeLaunch(rpc, address3, config);
|
|
2356
|
+
assertAccountExists(maybeAccount);
|
|
2357
|
+
return maybeAccount;
|
|
2358
|
+
}
|
|
2359
|
+
async function fetchMaybeLaunch(rpc, address3, config) {
|
|
2360
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address3, config);
|
|
2361
|
+
return decodeLaunch(maybeAccount);
|
|
2362
|
+
}
|
|
2363
|
+
async function fetchAllLaunch(rpc, addresses, config) {
|
|
2364
|
+
const maybeAccounts = await fetchAllMaybeLaunch(rpc, addresses, config);
|
|
2365
|
+
assertAccountsExist(maybeAccounts);
|
|
2366
|
+
return maybeAccounts;
|
|
2367
|
+
}
|
|
2368
|
+
async function fetchAllMaybeLaunch(rpc, addresses, config) {
|
|
2369
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
2370
|
+
return maybeAccounts.map((maybeAccount) => decodeLaunch(maybeAccount));
|
|
2371
|
+
}
|
|
2372
|
+
function getLaunchSize() {
|
|
2373
|
+
return 1214;
|
|
2374
|
+
}
|
|
2375
|
+
var MARKET_DISCRIMINATOR = new Uint8Array([
|
|
2376
|
+
219,
|
|
2377
|
+
190,
|
|
2378
|
+
213,
|
|
2379
|
+
55,
|
|
2380
|
+
0,
|
|
2381
|
+
227,
|
|
2382
|
+
198,
|
|
2383
|
+
154
|
|
2384
|
+
]);
|
|
2385
|
+
function getMarketDiscriminatorBytes() {
|
|
2386
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(MARKET_DISCRIMINATOR);
|
|
2387
|
+
}
|
|
2388
|
+
function getMarketEncoder() {
|
|
2389
|
+
return transformEncoder(
|
|
2390
|
+
getStructEncoder([
|
|
2391
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
2392
|
+
["oracle", getAddressEncoder()],
|
|
2393
|
+
["quoteMint", getAddressEncoder()],
|
|
2394
|
+
["potVault", getAddressEncoder()],
|
|
2395
|
+
["totalPot", getU64Encoder()],
|
|
2396
|
+
["totalClaimed", getU64Encoder()],
|
|
2397
|
+
["winnerMint", getAddressEncoder()],
|
|
2398
|
+
["claimableSupply", getU64Encoder()],
|
|
2399
|
+
["accQuotePerToken", getU128Encoder()],
|
|
2400
|
+
["isResolved", getBooleanEncoder()],
|
|
2401
|
+
["bump", getU8Encoder()],
|
|
2402
|
+
["marketAuthorityBump", getU8Encoder()],
|
|
2403
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 29)]
|
|
2404
|
+
]),
|
|
2405
|
+
(value) => ({ ...value, discriminator: MARKET_DISCRIMINATOR })
|
|
2406
|
+
);
|
|
2407
|
+
}
|
|
2408
|
+
function getMarketDecoder() {
|
|
2409
|
+
return getStructDecoder([
|
|
2410
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
2411
|
+
["oracle", getAddressDecoder()],
|
|
2412
|
+
["quoteMint", getAddressDecoder()],
|
|
2413
|
+
["potVault", getAddressDecoder()],
|
|
2414
|
+
["totalPot", getU64Decoder()],
|
|
2415
|
+
["totalClaimed", getU64Decoder()],
|
|
2416
|
+
["winnerMint", getAddressDecoder()],
|
|
2417
|
+
["claimableSupply", getU64Decoder()],
|
|
2418
|
+
["accQuotePerToken", getU128Decoder()],
|
|
2419
|
+
["isResolved", getBooleanDecoder()],
|
|
2420
|
+
["bump", getU8Decoder()],
|
|
2421
|
+
["marketAuthorityBump", getU8Decoder()],
|
|
2422
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 29)]
|
|
2423
|
+
]);
|
|
2424
|
+
}
|
|
2425
|
+
function getMarketCodec() {
|
|
2426
|
+
return combineCodec(getMarketEncoder(), getMarketDecoder());
|
|
2427
|
+
}
|
|
2428
|
+
function decodeMarket(encodedAccount) {
|
|
2429
|
+
return decodeAccount(
|
|
2430
|
+
encodedAccount,
|
|
2431
|
+
getMarketDecoder()
|
|
2432
|
+
);
|
|
2433
|
+
}
|
|
2434
|
+
async function fetchMarket(rpc, address3, config) {
|
|
2435
|
+
const maybeAccount = await fetchMaybeMarket(rpc, address3, config);
|
|
2436
|
+
assertAccountExists(maybeAccount);
|
|
2437
|
+
return maybeAccount;
|
|
2438
|
+
}
|
|
2439
|
+
async function fetchMaybeMarket(rpc, address3, config) {
|
|
2440
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address3, config);
|
|
2441
|
+
return decodeMarket(maybeAccount);
|
|
2442
|
+
}
|
|
2443
|
+
async function fetchAllMarket(rpc, addresses, config) {
|
|
2444
|
+
const maybeAccounts = await fetchAllMaybeMarket(rpc, addresses, config);
|
|
2445
|
+
assertAccountsExist(maybeAccounts);
|
|
2446
|
+
return maybeAccounts;
|
|
2447
|
+
}
|
|
2448
|
+
async function fetchAllMaybeMarket(rpc, addresses, config) {
|
|
2449
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
2450
|
+
return maybeAccounts.map((maybeAccount) => decodeMarket(maybeAccount));
|
|
2451
|
+
}
|
|
2452
|
+
function getMarketSize() {
|
|
2453
|
+
return 208;
|
|
2454
|
+
}
|
|
2455
|
+
var ORACLE_STATE_DISCRIMINATOR = new Uint8Array([
|
|
2456
|
+
97,
|
|
2457
|
+
156,
|
|
2458
|
+
157,
|
|
2459
|
+
189,
|
|
2460
|
+
194,
|
|
2461
|
+
73,
|
|
2462
|
+
8,
|
|
2463
|
+
15
|
|
2464
|
+
]);
|
|
2465
|
+
function getOracleStateDiscriminatorBytes() {
|
|
2466
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
2467
|
+
ORACLE_STATE_DISCRIMINATOR
|
|
2468
|
+
);
|
|
2469
|
+
}
|
|
2470
|
+
function getOracleStateEncoder() {
|
|
2471
|
+
return transformEncoder(
|
|
2472
|
+
getStructEncoder([
|
|
2473
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
2474
|
+
["oracleAuthority", getAddressEncoder()],
|
|
2475
|
+
["quoteMint", getAddressEncoder()],
|
|
2476
|
+
["isFinalized", getBooleanEncoder()],
|
|
2477
|
+
["winningMint", getAddressEncoder()],
|
|
2478
|
+
["nonce", getU64Encoder()],
|
|
2479
|
+
["bump", getU8Encoder()],
|
|
2480
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 31)]
|
|
2481
|
+
]),
|
|
2482
|
+
(value) => ({ ...value, discriminator: ORACLE_STATE_DISCRIMINATOR })
|
|
2483
|
+
);
|
|
2484
|
+
}
|
|
2485
|
+
function getOracleStateDecoder() {
|
|
2486
|
+
return getStructDecoder([
|
|
2487
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
2488
|
+
["oracleAuthority", getAddressDecoder()],
|
|
2489
|
+
["quoteMint", getAddressDecoder()],
|
|
2490
|
+
["isFinalized", getBooleanDecoder()],
|
|
2491
|
+
["winningMint", getAddressDecoder()],
|
|
2492
|
+
["nonce", getU64Decoder()],
|
|
2493
|
+
["bump", getU8Decoder()],
|
|
2494
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 31)]
|
|
2495
|
+
]);
|
|
2496
|
+
}
|
|
2497
|
+
function getOracleStateCodec() {
|
|
2498
|
+
return combineCodec(getOracleStateEncoder(), getOracleStateDecoder());
|
|
2499
|
+
}
|
|
2500
|
+
function decodeOracleState2(encodedAccount) {
|
|
2501
|
+
return decodeAccount(
|
|
2502
|
+
encodedAccount,
|
|
2503
|
+
getOracleStateDecoder()
|
|
2504
|
+
);
|
|
2505
|
+
}
|
|
2506
|
+
async function fetchOracleState(rpc, address3, config) {
|
|
2507
|
+
const maybeAccount = await fetchMaybeOracleState(rpc, address3, config);
|
|
2508
|
+
assertAccountExists(maybeAccount);
|
|
2509
|
+
return maybeAccount;
|
|
2510
|
+
}
|
|
2511
|
+
async function fetchMaybeOracleState(rpc, address3, config) {
|
|
2512
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address3, config);
|
|
2513
|
+
return decodeOracleState2(maybeAccount);
|
|
2514
|
+
}
|
|
2515
|
+
async function fetchAllOracleState(rpc, addresses, config) {
|
|
2516
|
+
const maybeAccounts = await fetchAllMaybeOracleState(rpc, addresses, config);
|
|
2517
|
+
assertAccountsExist(maybeAccounts);
|
|
2518
|
+
return maybeAccounts;
|
|
2519
|
+
}
|
|
2520
|
+
async function fetchAllMaybeOracleState(rpc, addresses, config) {
|
|
2521
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
2522
|
+
return maybeAccounts.map((maybeAccount) => decodeOracleState2(maybeAccount));
|
|
2523
|
+
}
|
|
2524
|
+
function getOracleStateSize() {
|
|
2525
|
+
return 145;
|
|
2526
|
+
}
|
|
2527
|
+
var CLAIM_DISCRIMINATOR = new Uint8Array([
|
|
2528
|
+
62,
|
|
2529
|
+
198,
|
|
2530
|
+
214,
|
|
2531
|
+
193,
|
|
2532
|
+
213,
|
|
2533
|
+
159,
|
|
2534
|
+
108,
|
|
2535
|
+
210
|
|
2536
|
+
]);
|
|
2537
|
+
function getClaimDiscriminatorBytes() {
|
|
2538
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(CLAIM_DISCRIMINATOR);
|
|
2539
|
+
}
|
|
2540
|
+
function getClaimInstructionDataEncoder() {
|
|
2541
|
+
return transformEncoder(
|
|
2542
|
+
getStructEncoder([
|
|
2543
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
2544
|
+
["burnAmount", getU64Encoder()]
|
|
2545
|
+
]),
|
|
2546
|
+
(value) => ({ ...value, discriminator: CLAIM_DISCRIMINATOR })
|
|
2547
|
+
);
|
|
2548
|
+
}
|
|
2549
|
+
function getClaimInstructionDataDecoder() {
|
|
2550
|
+
return getStructDecoder([
|
|
2551
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
2552
|
+
["burnAmount", getU64Decoder()]
|
|
2553
|
+
]);
|
|
2554
|
+
}
|
|
2555
|
+
function getClaimInstructionDataCodec() {
|
|
2556
|
+
return combineCodec(
|
|
2557
|
+
getClaimInstructionDataEncoder(),
|
|
2558
|
+
getClaimInstructionDataDecoder()
|
|
2559
|
+
);
|
|
2560
|
+
}
|
|
2561
|
+
async function getClaimInstructionAsync(input, config) {
|
|
2562
|
+
const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
|
|
2563
|
+
const originalAccounts = {
|
|
2564
|
+
market: { value: input.market ?? null, isWritable: true },
|
|
2565
|
+
marketAuthority: {
|
|
2566
|
+
value: input.marketAuthority ?? null,
|
|
2567
|
+
isWritable: false
|
|
2568
|
+
},
|
|
2569
|
+
potVault: { value: input.potVault ?? null, isWritable: true },
|
|
2570
|
+
winnerMint: { value: input.winnerMint ?? null, isWritable: true },
|
|
2571
|
+
entryByMint: { value: input.entryByMint ?? null, isWritable: false },
|
|
2572
|
+
claimerWinnerAta: {
|
|
2573
|
+
value: input.claimerWinnerAta ?? null,
|
|
2574
|
+
isWritable: true
|
|
2575
|
+
},
|
|
2576
|
+
claimerQuoteAta: { value: input.claimerQuoteAta ?? null, isWritable: true },
|
|
2577
|
+
claimer: { value: input.claimer ?? null, isWritable: false },
|
|
2578
|
+
receipt: { value: input.receipt ?? null, isWritable: true },
|
|
2579
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
2580
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
2581
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false }
|
|
2582
|
+
};
|
|
2583
|
+
const accounts = originalAccounts;
|
|
2584
|
+
const args = { ...input };
|
|
2585
|
+
if (!accounts.marketAuthority.value) {
|
|
2586
|
+
accounts.marketAuthority.value = await getProgramDerivedAddress({
|
|
2587
|
+
programAddress,
|
|
2588
|
+
seeds: [
|
|
2589
|
+
getBytesEncoder().encode(
|
|
2590
|
+
new Uint8Array([
|
|
2591
|
+
109,
|
|
2592
|
+
97,
|
|
2593
|
+
114,
|
|
2594
|
+
107,
|
|
2595
|
+
101,
|
|
2596
|
+
116,
|
|
2597
|
+
95,
|
|
2598
|
+
97,
|
|
2599
|
+
117,
|
|
2600
|
+
116,
|
|
2601
|
+
104,
|
|
2602
|
+
111,
|
|
2603
|
+
114,
|
|
2604
|
+
105,
|
|
2605
|
+
116,
|
|
2606
|
+
121
|
|
2607
|
+
])
|
|
2608
|
+
),
|
|
2609
|
+
getAddressEncoder().encode(
|
|
2610
|
+
getAddressFromResolvedInstructionAccount(
|
|
2611
|
+
"market",
|
|
2612
|
+
accounts.market.value
|
|
2613
|
+
)
|
|
2614
|
+
)
|
|
2615
|
+
]
|
|
2616
|
+
});
|
|
2617
|
+
}
|
|
2618
|
+
if (!accounts.receipt.value) {
|
|
2619
|
+
accounts.receipt.value = await getProgramDerivedAddress({
|
|
2620
|
+
programAddress,
|
|
2621
|
+
seeds: [
|
|
2622
|
+
getBytesEncoder().encode(
|
|
2623
|
+
new Uint8Array([114, 101, 99, 101, 105, 112, 116])
|
|
2624
|
+
),
|
|
2625
|
+
getAddressEncoder().encode(
|
|
2626
|
+
getAddressFromResolvedInstructionAccount(
|
|
2627
|
+
"market",
|
|
2628
|
+
accounts.market.value
|
|
2629
|
+
)
|
|
2630
|
+
),
|
|
2631
|
+
getAddressEncoder().encode(
|
|
2632
|
+
getAddressFromResolvedInstructionAccount(
|
|
2633
|
+
"claimer",
|
|
2634
|
+
accounts.claimer.value
|
|
2635
|
+
)
|
|
2636
|
+
)
|
|
2637
|
+
]
|
|
2638
|
+
});
|
|
2639
|
+
}
|
|
2640
|
+
if (!accounts.tokenProgram.value) {
|
|
2641
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
2642
|
+
}
|
|
2643
|
+
if (!accounts.systemProgram.value) {
|
|
2644
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
2645
|
+
}
|
|
2646
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
2647
|
+
return Object.freeze({
|
|
2648
|
+
accounts: [
|
|
2649
|
+
getAccountMeta("market", accounts.market),
|
|
2650
|
+
getAccountMeta("marketAuthority", accounts.marketAuthority),
|
|
2651
|
+
getAccountMeta("potVault", accounts.potVault),
|
|
2652
|
+
getAccountMeta("winnerMint", accounts.winnerMint),
|
|
2653
|
+
getAccountMeta("entryByMint", accounts.entryByMint),
|
|
2654
|
+
getAccountMeta("claimerWinnerAta", accounts.claimerWinnerAta),
|
|
2655
|
+
getAccountMeta("claimerQuoteAta", accounts.claimerQuoteAta),
|
|
2656
|
+
getAccountMeta("claimer", accounts.claimer),
|
|
2657
|
+
getAccountMeta("receipt", accounts.receipt),
|
|
2658
|
+
getAccountMeta("payer", accounts.payer),
|
|
2659
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
2660
|
+
getAccountMeta("systemProgram", accounts.systemProgram)
|
|
2661
|
+
],
|
|
2662
|
+
data: getClaimInstructionDataEncoder().encode(
|
|
2663
|
+
args
|
|
2664
|
+
),
|
|
2665
|
+
programAddress
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
function getClaimInstruction(input, config) {
|
|
2669
|
+
const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
|
|
2670
|
+
const originalAccounts = {
|
|
2671
|
+
market: { value: input.market ?? null, isWritable: true },
|
|
2672
|
+
marketAuthority: {
|
|
2673
|
+
value: input.marketAuthority ?? null,
|
|
2674
|
+
isWritable: false
|
|
2675
|
+
},
|
|
2676
|
+
potVault: { value: input.potVault ?? null, isWritable: true },
|
|
2677
|
+
winnerMint: { value: input.winnerMint ?? null, isWritable: true },
|
|
2678
|
+
entryByMint: { value: input.entryByMint ?? null, isWritable: false },
|
|
2679
|
+
claimerWinnerAta: {
|
|
2680
|
+
value: input.claimerWinnerAta ?? null,
|
|
2681
|
+
isWritable: true
|
|
2682
|
+
},
|
|
2683
|
+
claimerQuoteAta: { value: input.claimerQuoteAta ?? null, isWritable: true },
|
|
2684
|
+
claimer: { value: input.claimer ?? null, isWritable: false },
|
|
2685
|
+
receipt: { value: input.receipt ?? null, isWritable: true },
|
|
2686
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
2687
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
2688
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false }
|
|
2689
|
+
};
|
|
2690
|
+
const accounts = originalAccounts;
|
|
2691
|
+
const args = { ...input };
|
|
2692
|
+
if (!accounts.tokenProgram.value) {
|
|
2693
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
2694
|
+
}
|
|
2695
|
+
if (!accounts.systemProgram.value) {
|
|
2696
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
2697
|
+
}
|
|
2698
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
2699
|
+
return Object.freeze({
|
|
2700
|
+
accounts: [
|
|
2701
|
+
getAccountMeta("market", accounts.market),
|
|
2702
|
+
getAccountMeta("marketAuthority", accounts.marketAuthority),
|
|
2703
|
+
getAccountMeta("potVault", accounts.potVault),
|
|
2704
|
+
getAccountMeta("winnerMint", accounts.winnerMint),
|
|
2705
|
+
getAccountMeta("entryByMint", accounts.entryByMint),
|
|
2706
|
+
getAccountMeta("claimerWinnerAta", accounts.claimerWinnerAta),
|
|
2707
|
+
getAccountMeta("claimerQuoteAta", accounts.claimerQuoteAta),
|
|
2708
|
+
getAccountMeta("claimer", accounts.claimer),
|
|
2709
|
+
getAccountMeta("receipt", accounts.receipt),
|
|
2710
|
+
getAccountMeta("payer", accounts.payer),
|
|
2711
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
2712
|
+
getAccountMeta("systemProgram", accounts.systemProgram)
|
|
2713
|
+
],
|
|
2714
|
+
data: getClaimInstructionDataEncoder().encode(
|
|
2715
|
+
args
|
|
2716
|
+
),
|
|
2717
|
+
programAddress
|
|
2718
|
+
});
|
|
2719
|
+
}
|
|
2720
|
+
function parseClaimInstruction(instruction) {
|
|
2721
|
+
if (instruction.accounts.length < 12) {
|
|
2722
|
+
throw new SolanaError(
|
|
2723
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
2724
|
+
{
|
|
2725
|
+
actualAccountMetas: instruction.accounts.length,
|
|
2726
|
+
expectedAccountMetas: 12
|
|
2727
|
+
}
|
|
2728
|
+
);
|
|
2729
|
+
}
|
|
2730
|
+
let accountIndex = 0;
|
|
2731
|
+
const getNextAccount = () => {
|
|
2732
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
2733
|
+
accountIndex += 1;
|
|
2734
|
+
return accountMeta;
|
|
2735
|
+
};
|
|
2736
|
+
return {
|
|
2737
|
+
programAddress: instruction.programAddress,
|
|
2738
|
+
accounts: {
|
|
2739
|
+
market: getNextAccount(),
|
|
2740
|
+
marketAuthority: getNextAccount(),
|
|
2741
|
+
potVault: getNextAccount(),
|
|
2742
|
+
winnerMint: getNextAccount(),
|
|
2743
|
+
entryByMint: getNextAccount(),
|
|
2744
|
+
claimerWinnerAta: getNextAccount(),
|
|
2745
|
+
claimerQuoteAta: getNextAccount(),
|
|
2746
|
+
claimer: getNextAccount(),
|
|
2747
|
+
receipt: getNextAccount(),
|
|
2748
|
+
payer: getNextAccount(),
|
|
2749
|
+
tokenProgram: getNextAccount(),
|
|
2750
|
+
systemProgram: getNextAccount()
|
|
2751
|
+
},
|
|
2752
|
+
data: getClaimInstructionDataDecoder().decode(instruction.data)
|
|
2753
|
+
};
|
|
2754
|
+
}
|
|
2755
|
+
var MIGRATE_ENTRY_DISCRIMINATOR = new Uint8Array([
|
|
2756
|
+
239,
|
|
2757
|
+
154,
|
|
2758
|
+
55,
|
|
2759
|
+
173,
|
|
2760
|
+
110,
|
|
2761
|
+
36,
|
|
2762
|
+
188,
|
|
2763
|
+
214
|
|
2764
|
+
]);
|
|
2765
|
+
function getMigrateEntryDiscriminatorBytes() {
|
|
2766
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
2767
|
+
MIGRATE_ENTRY_DISCRIMINATOR
|
|
2768
|
+
);
|
|
2769
|
+
}
|
|
2770
|
+
function getMigrateEntryInstructionDataEncoder() {
|
|
2771
|
+
return transformEncoder(
|
|
2772
|
+
getStructEncoder([
|
|
2773
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
2774
|
+
["entryId", fixEncoderSize(getBytesEncoder(), 32)]
|
|
2775
|
+
]),
|
|
2776
|
+
(value) => ({ ...value, discriminator: MIGRATE_ENTRY_DISCRIMINATOR })
|
|
2777
|
+
);
|
|
2778
|
+
}
|
|
2779
|
+
function getMigrateEntryInstructionDataDecoder() {
|
|
2780
|
+
return getStructDecoder([
|
|
2781
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
2782
|
+
["entryId", fixDecoderSize(getBytesDecoder(), 32)]
|
|
2783
|
+
]);
|
|
2784
|
+
}
|
|
2785
|
+
function getMigrateEntryInstructionDataCodec() {
|
|
2786
|
+
return combineCodec(
|
|
2787
|
+
getMigrateEntryInstructionDataEncoder(),
|
|
2788
|
+
getMigrateEntryInstructionDataDecoder()
|
|
2789
|
+
);
|
|
2790
|
+
}
|
|
2791
|
+
async function getMigrateEntryInstructionAsync(input, config) {
|
|
2792
|
+
const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
|
|
2793
|
+
const originalAccounts = {
|
|
2794
|
+
initializerConfig: {
|
|
2795
|
+
value: input.initializerConfig ?? null,
|
|
2796
|
+
isWritable: false
|
|
2797
|
+
},
|
|
2798
|
+
launch: { value: input.launch ?? null, isWritable: false },
|
|
2799
|
+
launchAuthority: {
|
|
2800
|
+
value: input.launchAuthority ?? null,
|
|
2801
|
+
isWritable: false
|
|
2802
|
+
},
|
|
2803
|
+
baseMint: { value: input.baseMint ?? null, isWritable: true },
|
|
2804
|
+
quoteMint: { value: input.quoteMint ?? null, isWritable: false },
|
|
2805
|
+
baseVault: { value: input.baseVault ?? null, isWritable: true },
|
|
2806
|
+
quoteVault: { value: input.quoteVault ?? null, isWritable: true },
|
|
2807
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
2808
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
2809
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
2810
|
+
rent: { value: input.rent ?? null, isWritable: false },
|
|
2811
|
+
oracle: { value: input.oracle ?? null, isWritable: false },
|
|
2812
|
+
market: { value: input.market ?? null, isWritable: true },
|
|
2813
|
+
potVault: { value: input.potVault ?? null, isWritable: true },
|
|
2814
|
+
marketAuthority: {
|
|
2815
|
+
value: input.marketAuthority ?? null,
|
|
2816
|
+
isWritable: false
|
|
2817
|
+
},
|
|
2818
|
+
entry: { value: input.entry ?? null, isWritable: true },
|
|
2819
|
+
entryByMint: { value: input.entryByMint ?? null, isWritable: false }
|
|
2820
|
+
};
|
|
2821
|
+
const accounts = originalAccounts;
|
|
2822
|
+
const args = { ...input };
|
|
2823
|
+
if (!accounts.tokenProgram.value) {
|
|
2824
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
2825
|
+
}
|
|
2826
|
+
if (!accounts.systemProgram.value) {
|
|
2827
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
2828
|
+
}
|
|
2829
|
+
if (!accounts.rent.value) {
|
|
2830
|
+
accounts.rent.value = "SysvarRent111111111111111111111111111111111";
|
|
2831
|
+
}
|
|
2832
|
+
if (!accounts.market.value) {
|
|
2833
|
+
accounts.market.value = await getProgramDerivedAddress({
|
|
2834
|
+
programAddress,
|
|
2835
|
+
seeds: [
|
|
2836
|
+
getBytesEncoder().encode(new Uint8Array([109, 97, 114, 107, 101, 116])),
|
|
2837
|
+
getAddressEncoder().encode(
|
|
2838
|
+
getAddressFromResolvedInstructionAccount(
|
|
2839
|
+
"oracle",
|
|
2840
|
+
accounts.oracle.value
|
|
2841
|
+
)
|
|
2842
|
+
)
|
|
2843
|
+
]
|
|
2844
|
+
});
|
|
2845
|
+
}
|
|
2846
|
+
if (!accounts.marketAuthority.value) {
|
|
2847
|
+
accounts.marketAuthority.value = await getProgramDerivedAddress({
|
|
2848
|
+
programAddress,
|
|
2849
|
+
seeds: [
|
|
2850
|
+
getBytesEncoder().encode(
|
|
2851
|
+
new Uint8Array([
|
|
2852
|
+
109,
|
|
2853
|
+
97,
|
|
2854
|
+
114,
|
|
2855
|
+
107,
|
|
2856
|
+
101,
|
|
2857
|
+
116,
|
|
2858
|
+
95,
|
|
2859
|
+
97,
|
|
2860
|
+
117,
|
|
2861
|
+
116,
|
|
2862
|
+
104,
|
|
2863
|
+
111,
|
|
2864
|
+
114,
|
|
2865
|
+
105,
|
|
2866
|
+
116,
|
|
2867
|
+
121
|
|
2868
|
+
])
|
|
2869
|
+
),
|
|
2870
|
+
getAddressEncoder().encode(
|
|
2871
|
+
getAddressFromResolvedInstructionAccount(
|
|
2872
|
+
"market",
|
|
2873
|
+
accounts.market.value
|
|
2874
|
+
)
|
|
2875
|
+
)
|
|
2876
|
+
]
|
|
2877
|
+
});
|
|
2878
|
+
}
|
|
2879
|
+
if (!accounts.entryByMint.value) {
|
|
2880
|
+
accounts.entryByMint.value = await getProgramDerivedAddress({
|
|
2881
|
+
programAddress,
|
|
2882
|
+
seeds: [
|
|
2883
|
+
getBytesEncoder().encode(
|
|
2884
|
+
new Uint8Array([
|
|
2885
|
+
101,
|
|
2886
|
+
110,
|
|
2887
|
+
116,
|
|
2888
|
+
114,
|
|
2889
|
+
121,
|
|
2890
|
+
95,
|
|
2891
|
+
98,
|
|
2892
|
+
121,
|
|
2893
|
+
95,
|
|
2894
|
+
109,
|
|
2895
|
+
105,
|
|
2896
|
+
110,
|
|
2897
|
+
116
|
|
2898
|
+
])
|
|
2899
|
+
),
|
|
2900
|
+
getAddressEncoder().encode(
|
|
2901
|
+
getAddressFromResolvedInstructionAccount(
|
|
2902
|
+
"oracle",
|
|
2903
|
+
accounts.oracle.value
|
|
2904
|
+
)
|
|
2905
|
+
),
|
|
2906
|
+
getAddressEncoder().encode(
|
|
2907
|
+
getAddressFromResolvedInstructionAccount(
|
|
2908
|
+
"baseMint",
|
|
2909
|
+
accounts.baseMint.value
|
|
2910
|
+
)
|
|
2911
|
+
)
|
|
2912
|
+
]
|
|
2913
|
+
});
|
|
2914
|
+
}
|
|
2915
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
2916
|
+
return Object.freeze({
|
|
2917
|
+
accounts: [
|
|
2918
|
+
getAccountMeta("initializerConfig", accounts.initializerConfig),
|
|
2919
|
+
getAccountMeta("launch", accounts.launch),
|
|
2920
|
+
getAccountMeta("launchAuthority", accounts.launchAuthority),
|
|
2921
|
+
getAccountMeta("baseMint", accounts.baseMint),
|
|
2922
|
+
getAccountMeta("quoteMint", accounts.quoteMint),
|
|
2923
|
+
getAccountMeta("baseVault", accounts.baseVault),
|
|
2924
|
+
getAccountMeta("quoteVault", accounts.quoteVault),
|
|
2925
|
+
getAccountMeta("payer", accounts.payer),
|
|
2926
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
2927
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
2928
|
+
getAccountMeta("rent", accounts.rent),
|
|
2929
|
+
getAccountMeta("oracle", accounts.oracle),
|
|
2930
|
+
getAccountMeta("market", accounts.market),
|
|
2931
|
+
getAccountMeta("potVault", accounts.potVault),
|
|
2932
|
+
getAccountMeta("marketAuthority", accounts.marketAuthority),
|
|
2933
|
+
getAccountMeta("entry", accounts.entry),
|
|
2934
|
+
getAccountMeta("entryByMint", accounts.entryByMint)
|
|
2935
|
+
],
|
|
2936
|
+
data: getMigrateEntryInstructionDataEncoder().encode(
|
|
2937
|
+
args
|
|
2938
|
+
),
|
|
2939
|
+
programAddress
|
|
2940
|
+
});
|
|
2941
|
+
}
|
|
2942
|
+
function getMigrateEntryInstruction(input, config) {
|
|
2943
|
+
const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
|
|
2944
|
+
const originalAccounts = {
|
|
2945
|
+
initializerConfig: {
|
|
2946
|
+
value: input.initializerConfig ?? null,
|
|
2947
|
+
isWritable: false
|
|
2948
|
+
},
|
|
2949
|
+
launch: { value: input.launch ?? null, isWritable: false },
|
|
2950
|
+
launchAuthority: {
|
|
2951
|
+
value: input.launchAuthority ?? null,
|
|
2952
|
+
isWritable: false
|
|
2953
|
+
},
|
|
2954
|
+
baseMint: { value: input.baseMint ?? null, isWritable: true },
|
|
2955
|
+
quoteMint: { value: input.quoteMint ?? null, isWritable: false },
|
|
2956
|
+
baseVault: { value: input.baseVault ?? null, isWritable: true },
|
|
2957
|
+
quoteVault: { value: input.quoteVault ?? null, isWritable: true },
|
|
2958
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
2959
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
2960
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
2961
|
+
rent: { value: input.rent ?? null, isWritable: false },
|
|
2962
|
+
oracle: { value: input.oracle ?? null, isWritable: false },
|
|
2963
|
+
market: { value: input.market ?? null, isWritable: true },
|
|
2964
|
+
potVault: { value: input.potVault ?? null, isWritable: true },
|
|
2965
|
+
marketAuthority: {
|
|
2966
|
+
value: input.marketAuthority ?? null,
|
|
2967
|
+
isWritable: false
|
|
2968
|
+
},
|
|
2969
|
+
entry: { value: input.entry ?? null, isWritable: true },
|
|
2970
|
+
entryByMint: { value: input.entryByMint ?? null, isWritable: false }
|
|
2971
|
+
};
|
|
2972
|
+
const accounts = originalAccounts;
|
|
2973
|
+
const args = { ...input };
|
|
2974
|
+
if (!accounts.tokenProgram.value) {
|
|
2975
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
2976
|
+
}
|
|
2977
|
+
if (!accounts.systemProgram.value) {
|
|
2978
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
2979
|
+
}
|
|
2980
|
+
if (!accounts.rent.value) {
|
|
2981
|
+
accounts.rent.value = "SysvarRent111111111111111111111111111111111";
|
|
2982
|
+
}
|
|
2983
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
2984
|
+
return Object.freeze({
|
|
2985
|
+
accounts: [
|
|
2986
|
+
getAccountMeta("initializerConfig", accounts.initializerConfig),
|
|
2987
|
+
getAccountMeta("launch", accounts.launch),
|
|
2988
|
+
getAccountMeta("launchAuthority", accounts.launchAuthority),
|
|
2989
|
+
getAccountMeta("baseMint", accounts.baseMint),
|
|
2990
|
+
getAccountMeta("quoteMint", accounts.quoteMint),
|
|
2991
|
+
getAccountMeta("baseVault", accounts.baseVault),
|
|
2992
|
+
getAccountMeta("quoteVault", accounts.quoteVault),
|
|
2993
|
+
getAccountMeta("payer", accounts.payer),
|
|
2994
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
2995
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
2996
|
+
getAccountMeta("rent", accounts.rent),
|
|
2997
|
+
getAccountMeta("oracle", accounts.oracle),
|
|
2998
|
+
getAccountMeta("market", accounts.market),
|
|
2999
|
+
getAccountMeta("potVault", accounts.potVault),
|
|
3000
|
+
getAccountMeta("marketAuthority", accounts.marketAuthority),
|
|
3001
|
+
getAccountMeta("entry", accounts.entry),
|
|
3002
|
+
getAccountMeta("entryByMint", accounts.entryByMint)
|
|
3003
|
+
],
|
|
3004
|
+
data: getMigrateEntryInstructionDataEncoder().encode(
|
|
3005
|
+
args
|
|
3006
|
+
),
|
|
3007
|
+
programAddress
|
|
3008
|
+
});
|
|
3009
|
+
}
|
|
3010
|
+
function parseMigrateEntryInstruction(instruction) {
|
|
3011
|
+
if (instruction.accounts.length < 17) {
|
|
3012
|
+
throw new SolanaError(
|
|
3013
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
3014
|
+
{
|
|
3015
|
+
actualAccountMetas: instruction.accounts.length,
|
|
3016
|
+
expectedAccountMetas: 17
|
|
3017
|
+
}
|
|
3018
|
+
);
|
|
3019
|
+
}
|
|
3020
|
+
let accountIndex = 0;
|
|
3021
|
+
const getNextAccount = () => {
|
|
3022
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
3023
|
+
accountIndex += 1;
|
|
3024
|
+
return accountMeta;
|
|
3025
|
+
};
|
|
3026
|
+
return {
|
|
3027
|
+
programAddress: instruction.programAddress,
|
|
3028
|
+
accounts: {
|
|
3029
|
+
initializerConfig: getNextAccount(),
|
|
3030
|
+
launch: getNextAccount(),
|
|
3031
|
+
launchAuthority: getNextAccount(),
|
|
3032
|
+
baseMint: getNextAccount(),
|
|
3033
|
+
quoteMint: getNextAccount(),
|
|
3034
|
+
baseVault: getNextAccount(),
|
|
3035
|
+
quoteVault: getNextAccount(),
|
|
3036
|
+
payer: getNextAccount(),
|
|
3037
|
+
tokenProgram: getNextAccount(),
|
|
3038
|
+
systemProgram: getNextAccount(),
|
|
3039
|
+
rent: getNextAccount(),
|
|
3040
|
+
oracle: getNextAccount(),
|
|
3041
|
+
market: getNextAccount(),
|
|
3042
|
+
potVault: getNextAccount(),
|
|
3043
|
+
marketAuthority: getNextAccount(),
|
|
3044
|
+
entry: getNextAccount(),
|
|
3045
|
+
entryByMint: getNextAccount()
|
|
3046
|
+
},
|
|
3047
|
+
data: getMigrateEntryInstructionDataDecoder().decode(instruction.data)
|
|
3048
|
+
};
|
|
3049
|
+
}
|
|
3050
|
+
var PREVIEW_PAYOUT_IF_WINNER_DISCRIMINATOR = new Uint8Array([
|
|
3051
|
+
228,
|
|
3052
|
+
144,
|
|
3053
|
+
72,
|
|
3054
|
+
185,
|
|
3055
|
+
234,
|
|
3056
|
+
186,
|
|
3057
|
+
183,
|
|
3058
|
+
143
|
|
3059
|
+
]);
|
|
3060
|
+
function getPreviewPayoutIfWinnerDiscriminatorBytes() {
|
|
3061
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
3062
|
+
PREVIEW_PAYOUT_IF_WINNER_DISCRIMINATOR
|
|
3063
|
+
);
|
|
3064
|
+
}
|
|
3065
|
+
function getPreviewPayoutIfWinnerInstructionDataEncoder() {
|
|
3066
|
+
return transformEncoder(
|
|
3067
|
+
getStructEncoder([
|
|
3068
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
3069
|
+
["candidateWinnerMint", getAddressEncoder()],
|
|
3070
|
+
["tokenAmount", getU64Encoder()]
|
|
3071
|
+
]),
|
|
3072
|
+
(value) => ({
|
|
3073
|
+
...value,
|
|
3074
|
+
discriminator: PREVIEW_PAYOUT_IF_WINNER_DISCRIMINATOR
|
|
3075
|
+
})
|
|
3076
|
+
);
|
|
3077
|
+
}
|
|
3078
|
+
function getPreviewPayoutIfWinnerInstructionDataDecoder() {
|
|
3079
|
+
return getStructDecoder([
|
|
3080
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
3081
|
+
["candidateWinnerMint", getAddressDecoder()],
|
|
3082
|
+
["tokenAmount", getU64Decoder()]
|
|
3083
|
+
]);
|
|
3084
|
+
}
|
|
3085
|
+
function getPreviewPayoutIfWinnerInstructionDataCodec() {
|
|
3086
|
+
return combineCodec(
|
|
3087
|
+
getPreviewPayoutIfWinnerInstructionDataEncoder(),
|
|
3088
|
+
getPreviewPayoutIfWinnerInstructionDataDecoder()
|
|
3089
|
+
);
|
|
3090
|
+
}
|
|
3091
|
+
function getPreviewPayoutIfWinnerInstruction(input, config) {
|
|
3092
|
+
const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
|
|
3093
|
+
const originalAccounts = {
|
|
3094
|
+
market: { value: input.market ?? null, isWritable: false },
|
|
3095
|
+
candidateMint: { value: input.candidateMint ?? null, isWritable: false }
|
|
3096
|
+
};
|
|
3097
|
+
const accounts = originalAccounts;
|
|
3098
|
+
const args = { ...input };
|
|
3099
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
3100
|
+
return Object.freeze({
|
|
3101
|
+
accounts: [
|
|
3102
|
+
getAccountMeta("market", accounts.market),
|
|
3103
|
+
getAccountMeta("candidateMint", accounts.candidateMint)
|
|
3104
|
+
],
|
|
3105
|
+
data: getPreviewPayoutIfWinnerInstructionDataEncoder().encode(
|
|
3106
|
+
args
|
|
3107
|
+
),
|
|
3108
|
+
programAddress
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
function parsePreviewPayoutIfWinnerInstruction(instruction) {
|
|
3112
|
+
if (instruction.accounts.length < 2) {
|
|
3113
|
+
throw new SolanaError(
|
|
3114
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
3115
|
+
{
|
|
3116
|
+
actualAccountMetas: instruction.accounts.length,
|
|
3117
|
+
expectedAccountMetas: 2
|
|
3118
|
+
}
|
|
3119
|
+
);
|
|
3120
|
+
}
|
|
3121
|
+
let accountIndex = 0;
|
|
3122
|
+
const getNextAccount = () => {
|
|
3123
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
3124
|
+
accountIndex += 1;
|
|
3125
|
+
return accountMeta;
|
|
3126
|
+
};
|
|
3127
|
+
return {
|
|
3128
|
+
programAddress: instruction.programAddress,
|
|
3129
|
+
accounts: { market: getNextAccount(), candidateMint: getNextAccount() },
|
|
3130
|
+
data: getPreviewPayoutIfWinnerInstructionDataDecoder().decode(
|
|
3131
|
+
instruction.data
|
|
3132
|
+
)
|
|
3133
|
+
};
|
|
3134
|
+
}
|
|
3135
|
+
var REGISTER_ENTRY_DISCRIMINATOR = new Uint8Array([
|
|
3136
|
+
198,
|
|
3137
|
+
25,
|
|
3138
|
+
1,
|
|
3139
|
+
183,
|
|
3140
|
+
73,
|
|
3141
|
+
219,
|
|
3142
|
+
215,
|
|
3143
|
+
14
|
|
3144
|
+
]);
|
|
3145
|
+
function getRegisterEntryDiscriminatorBytes() {
|
|
3146
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
3147
|
+
REGISTER_ENTRY_DISCRIMINATOR
|
|
3148
|
+
);
|
|
3149
|
+
}
|
|
3150
|
+
function getRegisterEntryInstructionDataEncoder() {
|
|
3151
|
+
return transformEncoder(
|
|
3152
|
+
getStructEncoder([
|
|
3153
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
3154
|
+
["entryId", fixEncoderSize(getBytesEncoder(), 32)]
|
|
3155
|
+
]),
|
|
3156
|
+
(value) => ({ ...value, discriminator: REGISTER_ENTRY_DISCRIMINATOR })
|
|
3157
|
+
);
|
|
3158
|
+
}
|
|
3159
|
+
function getRegisterEntryInstructionDataDecoder() {
|
|
3160
|
+
return getStructDecoder([
|
|
3161
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
3162
|
+
["entryId", fixDecoderSize(getBytesDecoder(), 32)]
|
|
3163
|
+
]);
|
|
3164
|
+
}
|
|
3165
|
+
function getRegisterEntryInstructionDataCodec() {
|
|
3166
|
+
return combineCodec(
|
|
3167
|
+
getRegisterEntryInstructionDataEncoder(),
|
|
3168
|
+
getRegisterEntryInstructionDataDecoder()
|
|
3169
|
+
);
|
|
3170
|
+
}
|
|
3171
|
+
async function getRegisterEntryInstructionAsync(input, config) {
|
|
3172
|
+
const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
|
|
3173
|
+
const originalAccounts = {
|
|
3174
|
+
initializerConfig: {
|
|
3175
|
+
value: input.initializerConfig ?? null,
|
|
3176
|
+
isWritable: false
|
|
3177
|
+
},
|
|
3178
|
+
launch: { value: input.launch ?? null, isWritable: false },
|
|
3179
|
+
launchAuthority: {
|
|
3180
|
+
value: input.launchAuthority ?? null,
|
|
3181
|
+
isWritable: false
|
|
3182
|
+
},
|
|
3183
|
+
baseMint: { value: input.baseMint ?? null, isWritable: false },
|
|
3184
|
+
quoteMint: { value: input.quoteMint ?? null, isWritable: false },
|
|
3185
|
+
baseVault: { value: input.baseVault ?? null, isWritable: false },
|
|
3186
|
+
quoteVault: { value: input.quoteVault ?? null, isWritable: false },
|
|
3187
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
3188
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
3189
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
3190
|
+
rent: { value: input.rent ?? null, isWritable: false },
|
|
3191
|
+
oracle: { value: input.oracle ?? null, isWritable: false },
|
|
3192
|
+
market: { value: input.market ?? null, isWritable: true },
|
|
3193
|
+
potVault: { value: input.potVault ?? null, isWritable: true },
|
|
3194
|
+
marketAuthority: {
|
|
3195
|
+
value: input.marketAuthority ?? null,
|
|
3196
|
+
isWritable: false
|
|
3197
|
+
},
|
|
3198
|
+
entry: { value: input.entry ?? null, isWritable: true },
|
|
3199
|
+
entryByMint: { value: input.entryByMint ?? null, isWritable: true }
|
|
3200
|
+
};
|
|
3201
|
+
const accounts = originalAccounts;
|
|
3202
|
+
const args = { ...input };
|
|
3203
|
+
if (!accounts.tokenProgram.value) {
|
|
3204
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
3205
|
+
}
|
|
3206
|
+
if (!accounts.systemProgram.value) {
|
|
3207
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
3208
|
+
}
|
|
3209
|
+
if (!accounts.rent.value) {
|
|
3210
|
+
accounts.rent.value = "SysvarRent111111111111111111111111111111111";
|
|
3211
|
+
}
|
|
3212
|
+
if (!accounts.market.value) {
|
|
3213
|
+
accounts.market.value = await getProgramDerivedAddress({
|
|
3214
|
+
programAddress,
|
|
3215
|
+
seeds: [
|
|
3216
|
+
getBytesEncoder().encode(new Uint8Array([109, 97, 114, 107, 101, 116])),
|
|
3217
|
+
getAddressEncoder().encode(
|
|
3218
|
+
getAddressFromResolvedInstructionAccount(
|
|
3219
|
+
"oracle",
|
|
3220
|
+
accounts.oracle.value
|
|
3221
|
+
)
|
|
3222
|
+
)
|
|
3223
|
+
]
|
|
3224
|
+
});
|
|
3225
|
+
}
|
|
3226
|
+
if (!accounts.potVault.value) {
|
|
3227
|
+
accounts.potVault.value = await getProgramDerivedAddress({
|
|
3228
|
+
programAddress,
|
|
3229
|
+
seeds: [
|
|
3230
|
+
getBytesEncoder().encode(
|
|
3231
|
+
new Uint8Array([112, 111, 116, 95, 118, 97, 117, 108, 116])
|
|
3232
|
+
),
|
|
3233
|
+
getAddressEncoder().encode(
|
|
3234
|
+
getAddressFromResolvedInstructionAccount(
|
|
3235
|
+
"market",
|
|
3236
|
+
accounts.market.value
|
|
3237
|
+
)
|
|
3238
|
+
)
|
|
3239
|
+
]
|
|
3240
|
+
});
|
|
3241
|
+
}
|
|
3242
|
+
if (!accounts.marketAuthority.value) {
|
|
3243
|
+
accounts.marketAuthority.value = await getProgramDerivedAddress({
|
|
3244
|
+
programAddress,
|
|
3245
|
+
seeds: [
|
|
3246
|
+
getBytesEncoder().encode(
|
|
3247
|
+
new Uint8Array([
|
|
3248
|
+
109,
|
|
3249
|
+
97,
|
|
3250
|
+
114,
|
|
3251
|
+
107,
|
|
3252
|
+
101,
|
|
3253
|
+
116,
|
|
3254
|
+
95,
|
|
3255
|
+
97,
|
|
3256
|
+
117,
|
|
3257
|
+
116,
|
|
3258
|
+
104,
|
|
3259
|
+
111,
|
|
3260
|
+
114,
|
|
3261
|
+
105,
|
|
3262
|
+
116,
|
|
3263
|
+
121
|
|
3264
|
+
])
|
|
3265
|
+
),
|
|
3266
|
+
getAddressEncoder().encode(
|
|
3267
|
+
getAddressFromResolvedInstructionAccount(
|
|
3268
|
+
"market",
|
|
3269
|
+
accounts.market.value
|
|
3270
|
+
)
|
|
3271
|
+
)
|
|
3272
|
+
]
|
|
3273
|
+
});
|
|
3274
|
+
}
|
|
3275
|
+
if (!accounts.entryByMint.value) {
|
|
3276
|
+
accounts.entryByMint.value = await getProgramDerivedAddress({
|
|
3277
|
+
programAddress,
|
|
3278
|
+
seeds: [
|
|
3279
|
+
getBytesEncoder().encode(
|
|
3280
|
+
new Uint8Array([
|
|
3281
|
+
101,
|
|
3282
|
+
110,
|
|
3283
|
+
116,
|
|
3284
|
+
114,
|
|
3285
|
+
121,
|
|
3286
|
+
95,
|
|
3287
|
+
98,
|
|
3288
|
+
121,
|
|
3289
|
+
95,
|
|
3290
|
+
109,
|
|
3291
|
+
105,
|
|
3292
|
+
110,
|
|
3293
|
+
116
|
|
3294
|
+
])
|
|
3295
|
+
),
|
|
3296
|
+
getAddressEncoder().encode(
|
|
3297
|
+
getAddressFromResolvedInstructionAccount(
|
|
3298
|
+
"oracle",
|
|
3299
|
+
accounts.oracle.value
|
|
3300
|
+
)
|
|
3301
|
+
),
|
|
3302
|
+
getAddressEncoder().encode(
|
|
3303
|
+
getAddressFromResolvedInstructionAccount(
|
|
3304
|
+
"baseMint",
|
|
3305
|
+
accounts.baseMint.value
|
|
3306
|
+
)
|
|
3307
|
+
)
|
|
3308
|
+
]
|
|
3309
|
+
});
|
|
3310
|
+
}
|
|
3311
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
3312
|
+
return Object.freeze({
|
|
3313
|
+
accounts: [
|
|
3314
|
+
getAccountMeta("initializerConfig", accounts.initializerConfig),
|
|
3315
|
+
getAccountMeta("launch", accounts.launch),
|
|
3316
|
+
getAccountMeta("launchAuthority", accounts.launchAuthority),
|
|
3317
|
+
getAccountMeta("baseMint", accounts.baseMint),
|
|
3318
|
+
getAccountMeta("quoteMint", accounts.quoteMint),
|
|
3319
|
+
getAccountMeta("baseVault", accounts.baseVault),
|
|
3320
|
+
getAccountMeta("quoteVault", accounts.quoteVault),
|
|
3321
|
+
getAccountMeta("payer", accounts.payer),
|
|
3322
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
3323
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
3324
|
+
getAccountMeta("rent", accounts.rent),
|
|
3325
|
+
getAccountMeta("oracle", accounts.oracle),
|
|
3326
|
+
getAccountMeta("market", accounts.market),
|
|
3327
|
+
getAccountMeta("potVault", accounts.potVault),
|
|
3328
|
+
getAccountMeta("marketAuthority", accounts.marketAuthority),
|
|
3329
|
+
getAccountMeta("entry", accounts.entry),
|
|
3330
|
+
getAccountMeta("entryByMint", accounts.entryByMint)
|
|
3331
|
+
],
|
|
3332
|
+
data: getRegisterEntryInstructionDataEncoder().encode(
|
|
3333
|
+
args
|
|
3334
|
+
),
|
|
3335
|
+
programAddress
|
|
3336
|
+
});
|
|
3337
|
+
}
|
|
3338
|
+
function getRegisterEntryInstruction(input, config) {
|
|
3339
|
+
const programAddress = config?.programAddress ?? PREDICTION_MIGRATOR_PROGRAM_ADDRESS;
|
|
3340
|
+
const originalAccounts = {
|
|
3341
|
+
initializerConfig: {
|
|
3342
|
+
value: input.initializerConfig ?? null,
|
|
3343
|
+
isWritable: false
|
|
3344
|
+
},
|
|
3345
|
+
launch: { value: input.launch ?? null, isWritable: false },
|
|
3346
|
+
launchAuthority: {
|
|
3347
|
+
value: input.launchAuthority ?? null,
|
|
3348
|
+
isWritable: false
|
|
3349
|
+
},
|
|
3350
|
+
baseMint: { value: input.baseMint ?? null, isWritable: false },
|
|
3351
|
+
quoteMint: { value: input.quoteMint ?? null, isWritable: false },
|
|
3352
|
+
baseVault: { value: input.baseVault ?? null, isWritable: false },
|
|
3353
|
+
quoteVault: { value: input.quoteVault ?? null, isWritable: false },
|
|
3354
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
3355
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
3356
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
3357
|
+
rent: { value: input.rent ?? null, isWritable: false },
|
|
3358
|
+
oracle: { value: input.oracle ?? null, isWritable: false },
|
|
3359
|
+
market: { value: input.market ?? null, isWritable: true },
|
|
3360
|
+
potVault: { value: input.potVault ?? null, isWritable: true },
|
|
3361
|
+
marketAuthority: {
|
|
3362
|
+
value: input.marketAuthority ?? null,
|
|
3363
|
+
isWritable: false
|
|
3364
|
+
},
|
|
3365
|
+
entry: { value: input.entry ?? null, isWritable: true },
|
|
3366
|
+
entryByMint: { value: input.entryByMint ?? null, isWritable: true }
|
|
3367
|
+
};
|
|
3368
|
+
const accounts = originalAccounts;
|
|
3369
|
+
const args = { ...input };
|
|
3370
|
+
if (!accounts.tokenProgram.value) {
|
|
3371
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
3372
|
+
}
|
|
3373
|
+
if (!accounts.systemProgram.value) {
|
|
3374
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
3375
|
+
}
|
|
3376
|
+
if (!accounts.rent.value) {
|
|
3377
|
+
accounts.rent.value = "SysvarRent111111111111111111111111111111111";
|
|
3378
|
+
}
|
|
3379
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
3380
|
+
return Object.freeze({
|
|
3381
|
+
accounts: [
|
|
3382
|
+
getAccountMeta("initializerConfig", accounts.initializerConfig),
|
|
3383
|
+
getAccountMeta("launch", accounts.launch),
|
|
3384
|
+
getAccountMeta("launchAuthority", accounts.launchAuthority),
|
|
3385
|
+
getAccountMeta("baseMint", accounts.baseMint),
|
|
3386
|
+
getAccountMeta("quoteMint", accounts.quoteMint),
|
|
3387
|
+
getAccountMeta("baseVault", accounts.baseVault),
|
|
3388
|
+
getAccountMeta("quoteVault", accounts.quoteVault),
|
|
3389
|
+
getAccountMeta("payer", accounts.payer),
|
|
3390
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
3391
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
3392
|
+
getAccountMeta("rent", accounts.rent),
|
|
3393
|
+
getAccountMeta("oracle", accounts.oracle),
|
|
3394
|
+
getAccountMeta("market", accounts.market),
|
|
3395
|
+
getAccountMeta("potVault", accounts.potVault),
|
|
3396
|
+
getAccountMeta("marketAuthority", accounts.marketAuthority),
|
|
3397
|
+
getAccountMeta("entry", accounts.entry),
|
|
3398
|
+
getAccountMeta("entryByMint", accounts.entryByMint)
|
|
3399
|
+
],
|
|
3400
|
+
data: getRegisterEntryInstructionDataEncoder().encode(
|
|
3401
|
+
args
|
|
3402
|
+
),
|
|
3403
|
+
programAddress
|
|
3404
|
+
});
|
|
3405
|
+
}
|
|
3406
|
+
function parseRegisterEntryInstruction(instruction) {
|
|
3407
|
+
if (instruction.accounts.length < 17) {
|
|
3408
|
+
throw new SolanaError(
|
|
3409
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
3410
|
+
{
|
|
3411
|
+
actualAccountMetas: instruction.accounts.length,
|
|
3412
|
+
expectedAccountMetas: 17
|
|
3413
|
+
}
|
|
3414
|
+
);
|
|
3415
|
+
}
|
|
3416
|
+
let accountIndex = 0;
|
|
3417
|
+
const getNextAccount = () => {
|
|
3418
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
3419
|
+
accountIndex += 1;
|
|
3420
|
+
return accountMeta;
|
|
3421
|
+
};
|
|
3422
|
+
return {
|
|
3423
|
+
programAddress: instruction.programAddress,
|
|
3424
|
+
accounts: {
|
|
3425
|
+
initializerConfig: getNextAccount(),
|
|
3426
|
+
launch: getNextAccount(),
|
|
3427
|
+
launchAuthority: getNextAccount(),
|
|
3428
|
+
baseMint: getNextAccount(),
|
|
3429
|
+
quoteMint: getNextAccount(),
|
|
3430
|
+
baseVault: getNextAccount(),
|
|
3431
|
+
quoteVault: getNextAccount(),
|
|
3432
|
+
payer: getNextAccount(),
|
|
3433
|
+
tokenProgram: getNextAccount(),
|
|
3434
|
+
systemProgram: getNextAccount(),
|
|
3435
|
+
rent: getNextAccount(),
|
|
3436
|
+
oracle: getNextAccount(),
|
|
3437
|
+
market: getNextAccount(),
|
|
3438
|
+
potVault: getNextAccount(),
|
|
3439
|
+
marketAuthority: getNextAccount(),
|
|
3440
|
+
entry: getNextAccount(),
|
|
3441
|
+
entryByMint: getNextAccount()
|
|
3442
|
+
},
|
|
3443
|
+
data: getRegisterEntryInstructionDataDecoder().decode(instruction.data)
|
|
3444
|
+
};
|
|
3445
|
+
}
|
|
3446
|
+
|
|
3447
|
+
// src/solana/generated/predictionMigrator/programs/predictionMigrator.ts
|
|
3448
|
+
var PREDICTION_MIGRATOR_PROGRAM_ADDRESS = "HYHdyy7QZg8Ucky9Z97xNtSCvrZxVNkeoney8xEPXjiZ";
|
|
3449
|
+
var PredictionMigratorAccount = /* @__PURE__ */ ((PredictionMigratorAccount2) => {
|
|
3450
|
+
PredictionMigratorAccount2[PredictionMigratorAccount2["ClaimReceipt"] = 0] = "ClaimReceipt";
|
|
3451
|
+
PredictionMigratorAccount2[PredictionMigratorAccount2["Entry"] = 1] = "Entry";
|
|
3452
|
+
PredictionMigratorAccount2[PredictionMigratorAccount2["EntryByMint"] = 2] = "EntryByMint";
|
|
3453
|
+
PredictionMigratorAccount2[PredictionMigratorAccount2["Launch"] = 3] = "Launch";
|
|
3454
|
+
PredictionMigratorAccount2[PredictionMigratorAccount2["Market"] = 4] = "Market";
|
|
3455
|
+
PredictionMigratorAccount2[PredictionMigratorAccount2["OracleState"] = 5] = "OracleState";
|
|
3456
|
+
return PredictionMigratorAccount2;
|
|
3457
|
+
})(PredictionMigratorAccount || {});
|
|
3458
|
+
function identifyPredictionMigratorAccount(account) {
|
|
3459
|
+
const data = "data" in account ? account.data : account;
|
|
3460
|
+
if (containsBytes(
|
|
3461
|
+
data,
|
|
3462
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
3463
|
+
new Uint8Array([223, 233, 11, 229, 124, 165, 207, 28])
|
|
3464
|
+
),
|
|
3465
|
+
0
|
|
3466
|
+
)) {
|
|
3467
|
+
return 0 /* ClaimReceipt */;
|
|
3468
|
+
}
|
|
3469
|
+
if (containsBytes(
|
|
3470
|
+
data,
|
|
3471
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
3472
|
+
new Uint8Array([63, 18, 152, 113, 215, 246, 221, 250])
|
|
3473
|
+
),
|
|
3474
|
+
0
|
|
3475
|
+
)) {
|
|
3476
|
+
return 1 /* Entry */;
|
|
3477
|
+
}
|
|
3478
|
+
if (containsBytes(
|
|
3479
|
+
data,
|
|
3480
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
3481
|
+
new Uint8Array([188, 191, 157, 194, 68, 82, 181, 126])
|
|
3482
|
+
),
|
|
3483
|
+
0
|
|
3484
|
+
)) {
|
|
3485
|
+
return 2 /* EntryByMint */;
|
|
3486
|
+
}
|
|
3487
|
+
if (containsBytes(
|
|
3488
|
+
data,
|
|
3489
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
3490
|
+
new Uint8Array([144, 51, 51, 163, 206, 85, 213, 38])
|
|
3491
|
+
),
|
|
3492
|
+
0
|
|
3493
|
+
)) {
|
|
3494
|
+
return 3 /* Launch */;
|
|
3495
|
+
}
|
|
3496
|
+
if (containsBytes(
|
|
3497
|
+
data,
|
|
3498
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
3499
|
+
new Uint8Array([219, 190, 213, 55, 0, 227, 198, 154])
|
|
3500
|
+
),
|
|
3501
|
+
0
|
|
3502
|
+
)) {
|
|
3503
|
+
return 4 /* Market */;
|
|
3504
|
+
}
|
|
3505
|
+
if (containsBytes(
|
|
3506
|
+
data,
|
|
3507
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
3508
|
+
new Uint8Array([97, 156, 157, 189, 194, 73, 8, 15])
|
|
3509
|
+
),
|
|
3510
|
+
0
|
|
3511
|
+
)) {
|
|
3512
|
+
return 5 /* OracleState */;
|
|
3513
|
+
}
|
|
3514
|
+
throw new SolanaError(
|
|
3515
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT,
|
|
3516
|
+
{ accountData: data, programName: "predictionMigrator" }
|
|
3517
|
+
);
|
|
3518
|
+
}
|
|
3519
|
+
var PredictionMigratorInstruction = /* @__PURE__ */ ((PredictionMigratorInstruction2) => {
|
|
3520
|
+
PredictionMigratorInstruction2[PredictionMigratorInstruction2["Claim"] = 0] = "Claim";
|
|
3521
|
+
PredictionMigratorInstruction2[PredictionMigratorInstruction2["MigrateEntry"] = 1] = "MigrateEntry";
|
|
3522
|
+
PredictionMigratorInstruction2[PredictionMigratorInstruction2["PreviewPayoutIfWinner"] = 2] = "PreviewPayoutIfWinner";
|
|
3523
|
+
PredictionMigratorInstruction2[PredictionMigratorInstruction2["RegisterEntry"] = 3] = "RegisterEntry";
|
|
3524
|
+
return PredictionMigratorInstruction2;
|
|
3525
|
+
})(PredictionMigratorInstruction || {});
|
|
3526
|
+
function identifyPredictionMigratorInstruction(instruction) {
|
|
3527
|
+
const data = "data" in instruction ? instruction.data : instruction;
|
|
3528
|
+
if (containsBytes(
|
|
3529
|
+
data,
|
|
3530
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
3531
|
+
new Uint8Array([62, 198, 214, 193, 213, 159, 108, 210])
|
|
3532
|
+
),
|
|
3533
|
+
0
|
|
3534
|
+
)) {
|
|
3535
|
+
return 0 /* Claim */;
|
|
3536
|
+
}
|
|
3537
|
+
if (containsBytes(
|
|
3538
|
+
data,
|
|
3539
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
3540
|
+
new Uint8Array([239, 154, 55, 173, 110, 36, 188, 214])
|
|
3541
|
+
),
|
|
3542
|
+
0
|
|
3543
|
+
)) {
|
|
3544
|
+
return 1 /* MigrateEntry */;
|
|
3545
|
+
}
|
|
3546
|
+
if (containsBytes(
|
|
3547
|
+
data,
|
|
3548
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
3549
|
+
new Uint8Array([228, 144, 72, 185, 234, 186, 183, 143])
|
|
3550
|
+
),
|
|
3551
|
+
0
|
|
3552
|
+
)) {
|
|
3553
|
+
return 2 /* PreviewPayoutIfWinner */;
|
|
3554
|
+
}
|
|
3555
|
+
if (containsBytes(
|
|
3556
|
+
data,
|
|
3557
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
3558
|
+
new Uint8Array([198, 25, 1, 183, 73, 219, 215, 14])
|
|
3559
|
+
),
|
|
3560
|
+
0
|
|
3561
|
+
)) {
|
|
3562
|
+
return 3 /* RegisterEntry */;
|
|
3563
|
+
}
|
|
3564
|
+
throw new SolanaError(
|
|
3565
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
|
|
3566
|
+
{ instructionData: data, programName: "predictionMigrator" }
|
|
3567
|
+
);
|
|
3568
|
+
}
|
|
3569
|
+
function parsePredictionMigratorInstruction(instruction) {
|
|
3570
|
+
const instructionType = identifyPredictionMigratorInstruction(instruction);
|
|
3571
|
+
switch (instructionType) {
|
|
3572
|
+
case 0 /* Claim */: {
|
|
3573
|
+
assertIsInstructionWithAccounts(instruction);
|
|
3574
|
+
return {
|
|
3575
|
+
instructionType: 0 /* Claim */,
|
|
3576
|
+
...parseClaimInstruction(instruction)
|
|
3577
|
+
};
|
|
3578
|
+
}
|
|
3579
|
+
case 1 /* MigrateEntry */: {
|
|
3580
|
+
assertIsInstructionWithAccounts(instruction);
|
|
3581
|
+
return {
|
|
3582
|
+
instructionType: 1 /* MigrateEntry */,
|
|
3583
|
+
...parseMigrateEntryInstruction(instruction)
|
|
3584
|
+
};
|
|
3585
|
+
}
|
|
3586
|
+
case 2 /* PreviewPayoutIfWinner */: {
|
|
3587
|
+
assertIsInstructionWithAccounts(instruction);
|
|
3588
|
+
return {
|
|
3589
|
+
instructionType: 2 /* PreviewPayoutIfWinner */,
|
|
3590
|
+
...parsePreviewPayoutIfWinnerInstruction(instruction)
|
|
3591
|
+
};
|
|
3592
|
+
}
|
|
3593
|
+
case 3 /* RegisterEntry */: {
|
|
3594
|
+
assertIsInstructionWithAccounts(instruction);
|
|
3595
|
+
return {
|
|
3596
|
+
instructionType: 3 /* RegisterEntry */,
|
|
3597
|
+
...parseRegisterEntryInstruction(instruction)
|
|
3598
|
+
};
|
|
3599
|
+
}
|
|
3600
|
+
default:
|
|
3601
|
+
throw new SolanaError(
|
|
3602
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
|
|
3603
|
+
{
|
|
3604
|
+
instructionType,
|
|
3605
|
+
programName: "predictionMigrator"
|
|
3606
|
+
}
|
|
3607
|
+
);
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3610
|
+
function predictionMigratorProgram() {
|
|
3611
|
+
return (client) => {
|
|
3612
|
+
return {
|
|
3613
|
+
...client,
|
|
3614
|
+
predictionMigrator: {
|
|
3615
|
+
accounts: {
|
|
3616
|
+
claimReceipt: addSelfFetchFunctions(client, getClaimReceiptCodec()),
|
|
3617
|
+
entry: addSelfFetchFunctions(client, getEntryCodec()),
|
|
3618
|
+
entryByMint: addSelfFetchFunctions(client, getEntryByMintCodec()),
|
|
3619
|
+
launch: addSelfFetchFunctions(client, getLaunchCodec2()),
|
|
3620
|
+
market: addSelfFetchFunctions(client, getMarketCodec()),
|
|
3621
|
+
oracleState: addSelfFetchFunctions(client, getOracleStateCodec())
|
|
3622
|
+
},
|
|
3623
|
+
instructions: {
|
|
3624
|
+
claim: (input) => addSelfPlanAndSendFunctions(
|
|
3625
|
+
client,
|
|
3626
|
+
getClaimInstructionAsync({
|
|
3627
|
+
...input,
|
|
3628
|
+
payer: input.payer ?? client.payer
|
|
3629
|
+
})
|
|
3630
|
+
),
|
|
3631
|
+
migrateEntry: (input) => addSelfPlanAndSendFunctions(
|
|
3632
|
+
client,
|
|
3633
|
+
getMigrateEntryInstructionAsync({
|
|
3634
|
+
...input,
|
|
3635
|
+
payer: input.payer ?? client.payer
|
|
3636
|
+
})
|
|
3637
|
+
),
|
|
3638
|
+
previewPayoutIfWinner: (input) => addSelfPlanAndSendFunctions(
|
|
3639
|
+
client,
|
|
3640
|
+
getPreviewPayoutIfWinnerInstruction(input)
|
|
3641
|
+
),
|
|
3642
|
+
registerEntry: (input) => addSelfPlanAndSendFunctions(
|
|
3643
|
+
client,
|
|
3644
|
+
getRegisterEntryInstructionAsync({
|
|
3645
|
+
...input,
|
|
3646
|
+
payer: input.payer ?? client.payer
|
|
3647
|
+
})
|
|
3648
|
+
)
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
};
|
|
3652
|
+
};
|
|
3653
|
+
}
|
|
3654
|
+
var addressCodec4 = getAddressCodec();
|
|
3655
|
+
var textEncoder4 = new TextEncoder();
|
|
3656
|
+
async function getPredictionMarketAddress(oracleState, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
|
|
3657
|
+
return getProgramDerivedAddress({
|
|
3658
|
+
programAddress: programId,
|
|
3659
|
+
seeds: [textEncoder4.encode("market"), addressCodec4.encode(oracleState)]
|
|
3660
|
+
});
|
|
3661
|
+
}
|
|
3662
|
+
async function getPredictionMarketAuthorityAddress(market, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
|
|
3663
|
+
return getProgramDerivedAddress({
|
|
3664
|
+
programAddress: programId,
|
|
3665
|
+
seeds: [
|
|
3666
|
+
textEncoder4.encode("market_authority"),
|
|
3667
|
+
addressCodec4.encode(market)
|
|
3668
|
+
]
|
|
3669
|
+
});
|
|
3670
|
+
}
|
|
3671
|
+
async function getPredictionPotVaultAddress(market, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
|
|
3672
|
+
return getProgramDerivedAddress({
|
|
3673
|
+
programAddress: programId,
|
|
3674
|
+
seeds: [textEncoder4.encode("pot_vault"), addressCodec4.encode(market)]
|
|
3675
|
+
});
|
|
3676
|
+
}
|
|
3677
|
+
async function getPredictionEntryAddress(oracleState, entryId, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
|
|
3678
|
+
return getProgramDerivedAddress({
|
|
3679
|
+
programAddress: programId,
|
|
3680
|
+
seeds: [
|
|
3681
|
+
textEncoder4.encode("entry"),
|
|
3682
|
+
addressCodec4.encode(oracleState),
|
|
3683
|
+
entryId
|
|
3684
|
+
]
|
|
3685
|
+
});
|
|
3686
|
+
}
|
|
3687
|
+
async function getPredictionEntryByMintAddress(oracleState, mint, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
|
|
3688
|
+
return getProgramDerivedAddress({
|
|
3689
|
+
programAddress: programId,
|
|
3690
|
+
seeds: [
|
|
3691
|
+
textEncoder4.encode("entry_by_mint"),
|
|
3692
|
+
addressCodec4.encode(oracleState),
|
|
3693
|
+
addressCodec4.encode(mint)
|
|
3694
|
+
]
|
|
3695
|
+
});
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3698
|
+
// src/solana/initializer/instructions/initializeLaunch.ts
|
|
3699
|
+
function isTransactionSigner5(value) {
|
|
3700
|
+
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
3701
|
+
}
|
|
3702
|
+
function createAccountMeta(value, role) {
|
|
3703
|
+
if (isTransactionSigner5(value)) {
|
|
3704
|
+
return { address: value.address, role, signer: value };
|
|
3705
|
+
}
|
|
3706
|
+
return { address: value, role };
|
|
3707
|
+
}
|
|
3708
|
+
async function getTokenMetadataAddress(mint) {
|
|
3709
|
+
const encoder = getAddressEncoder();
|
|
3710
|
+
const [metadataAddress] = await getProgramDerivedAddress({
|
|
3711
|
+
programAddress: TOKEN_METADATA_PROGRAM_ID,
|
|
3712
|
+
seeds: [
|
|
3713
|
+
new TextEncoder().encode("metadata"),
|
|
3714
|
+
encoder.encode(TOKEN_METADATA_PROGRAM_ID),
|
|
3715
|
+
encoder.encode(mint)
|
|
3716
|
+
]
|
|
3717
|
+
});
|
|
3718
|
+
return metadataAddress;
|
|
3719
|
+
}
|
|
3720
|
+
var ALT_INDEX = {
|
|
3721
|
+
[TOKEN_PROGRAM_ADDRESS]: 0,
|
|
3722
|
+
[SYSTEM_PROGRAM_ADDRESS]: 1,
|
|
3723
|
+
SysvarRent111111111111111111111111111111111: 2,
|
|
3724
|
+
[INITIALIZER_PROGRAM_ID]: 3,
|
|
3725
|
+
[TOKEN_METADATA_PROGRAM_ID]: 4,
|
|
3726
|
+
[CPMM_MIGRATOR_PROGRAM_ID]: 5,
|
|
3727
|
+
So11111111111111111111111111111111111111112: 6,
|
|
3728
|
+
// index 7 = config PDA — resolved at call time from accounts.config
|
|
3729
|
+
[PREDICTION_MIGRATOR_PROGRAM_ADDRESS]: 8
|
|
3730
|
+
};
|
|
3731
|
+
function validateInitializeLaunchCurveParams(args) {
|
|
3732
|
+
if (args.curveKind !== CURVE_KIND_XYK) {
|
|
3733
|
+
throw new Error(
|
|
3734
|
+
`unsupported curve kind: ${args.curveKind}; only CURVE_KIND_XYK is currently enabled`
|
|
3735
|
+
);
|
|
3736
|
+
}
|
|
3737
|
+
if (args.curveParams.length !== 1 || args.curveParams[0] !== CURVE_PARAMS_FORMAT_XYK_V0) {
|
|
3738
|
+
throw new Error("xyk curve params must be [CURVE_PARAMS_FORMAT_XYK_V0]");
|
|
3739
|
+
}
|
|
3740
|
+
}
|
|
3741
|
+
async function createInitializeLaunchInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
|
|
3742
|
+
validateInitializeLaunchCurveParams(args);
|
|
3743
|
+
const {
|
|
3744
|
+
config,
|
|
3745
|
+
launch,
|
|
3746
|
+
launchAuthority,
|
|
3747
|
+
baseMint,
|
|
3748
|
+
quoteMint,
|
|
3749
|
+
baseVault,
|
|
3750
|
+
quoteVault,
|
|
3751
|
+
payer,
|
|
3752
|
+
authority,
|
|
3753
|
+
migratorProgram,
|
|
3754
|
+
tokenProgram = TOKEN_PROGRAM_ADDRESS,
|
|
3755
|
+
systemProgram = SYSTEM_PROGRAM_ADDRESS,
|
|
3756
|
+
rent,
|
|
3757
|
+
metadataAccount,
|
|
3758
|
+
addressLookupTable: alt
|
|
3759
|
+
} = accounts;
|
|
3760
|
+
const withMetadata = Boolean(
|
|
3761
|
+
args.metadataName && args.metadataName.length > 0
|
|
3762
|
+
);
|
|
3763
|
+
if (withMetadata && !metadataAccount) {
|
|
3764
|
+
throw new Error(
|
|
3765
|
+
"metadataName is set but metadataAccount was not provided. Derive it with await initializer.getTokenMetadataAddress(baseMintAddress)."
|
|
3766
|
+
);
|
|
3767
|
+
}
|
|
3768
|
+
const altIndexMap = alt ? { ...ALT_INDEX, [config]: 7 } : {};
|
|
3769
|
+
function staticOrLookup(addr, role) {
|
|
3770
|
+
if (alt && altIndexMap[addr] !== void 0) {
|
|
3771
|
+
return {
|
|
3772
|
+
address: addr,
|
|
3773
|
+
role,
|
|
3774
|
+
lookupTableAddress: alt,
|
|
3775
|
+
addressIndex: altIndexMap[addr]
|
|
3776
|
+
};
|
|
3777
|
+
}
|
|
3778
|
+
return { address: addr, role };
|
|
3779
|
+
}
|
|
3780
|
+
const keys = [
|
|
3781
|
+
staticOrLookup(config, AccountRole.READONLY),
|
|
3782
|
+
{ address: launch, role: AccountRole.WRITABLE },
|
|
3783
|
+
{ address: launchAuthority, role: AccountRole.READONLY },
|
|
3784
|
+
createAccountMeta(baseMint, AccountRole.WRITABLE_SIGNER),
|
|
3785
|
+
staticOrLookup(quoteMint, AccountRole.READONLY),
|
|
3786
|
+
createAccountMeta(baseVault, AccountRole.WRITABLE_SIGNER),
|
|
3787
|
+
createAccountMeta(quoteVault, AccountRole.WRITABLE_SIGNER),
|
|
3788
|
+
createAccountMeta(payer, AccountRole.WRITABLE_SIGNER)
|
|
3789
|
+
];
|
|
3790
|
+
if (authority) {
|
|
3791
|
+
keys.push(createAccountMeta(authority, AccountRole.READONLY_SIGNER));
|
|
3792
|
+
}
|
|
3793
|
+
if (migratorProgram) {
|
|
3794
|
+
keys.push(staticOrLookup(migratorProgram, AccountRole.READONLY));
|
|
3795
|
+
}
|
|
3796
|
+
keys.push(staticOrLookup(tokenProgram, AccountRole.READONLY));
|
|
3797
|
+
keys.push(staticOrLookup(systemProgram, AccountRole.READONLY));
|
|
3798
|
+
keys.push(staticOrLookup(rent, AccountRole.READONLY));
|
|
3799
|
+
if (withMetadata) {
|
|
3800
|
+
keys.push({ address: metadataAccount, role: AccountRole.WRITABLE });
|
|
3801
|
+
keys.push(staticOrLookup(TOKEN_METADATA_PROGRAM_ID, AccountRole.READONLY));
|
|
3802
|
+
}
|
|
3803
|
+
const encoderArgs = {
|
|
3804
|
+
...args,
|
|
3805
|
+
allowBuy: args.allowBuy ? 1 : 0,
|
|
3806
|
+
allowSell: args.allowSell ? 1 : 0,
|
|
3807
|
+
migratorProgram: migratorProgram ?? SYSTEM_PROGRAM_ADDRESS
|
|
3808
|
+
};
|
|
3809
|
+
const data = new Uint8Array(
|
|
3810
|
+
getInitializeLaunchInstructionDataEncoder().encode(encoderArgs)
|
|
3811
|
+
);
|
|
3812
|
+
if (migratorProgram === CPMM_MIGRATOR_PROGRAM_ID) {
|
|
3813
|
+
const [cpmmMigratorState] = await getCpmmMigratorStateAddress(launch);
|
|
3814
|
+
keys.push({ address: cpmmMigratorState, role: AccountRole.WRITABLE });
|
|
3815
|
+
}
|
|
3816
|
+
if (migratorProgram === PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
|
|
3817
|
+
const oracleState = args.namespace;
|
|
3818
|
+
const entryId = args.launchId;
|
|
3819
|
+
const baseMintAddress = isTransactionSigner5(baseMint) ? baseMint.address : baseMint;
|
|
3820
|
+
const [market] = await getPredictionMarketAddress(oracleState);
|
|
3821
|
+
const [potVault] = await getPredictionPotVaultAddress(market);
|
|
3822
|
+
const [marketAuthority] = await getPredictionMarketAuthorityAddress(market);
|
|
3823
|
+
const [entry] = await getPredictionEntryAddress(oracleState, entryId);
|
|
3824
|
+
const [entryByMint] = await getPredictionEntryByMintAddress(
|
|
3825
|
+
oracleState,
|
|
3826
|
+
baseMintAddress
|
|
3827
|
+
);
|
|
3828
|
+
keys.push({ address: oracleState, role: AccountRole.READONLY });
|
|
3829
|
+
keys.push({ address: market, role: AccountRole.WRITABLE });
|
|
3830
|
+
keys.push({ address: potVault, role: AccountRole.WRITABLE });
|
|
3831
|
+
keys.push({ address: marketAuthority, role: AccountRole.READONLY });
|
|
3832
|
+
keys.push({ address: entry, role: AccountRole.WRITABLE });
|
|
3833
|
+
keys.push({ address: entryByMint, role: AccountRole.WRITABLE });
|
|
3834
|
+
}
|
|
3835
|
+
return { programAddress: programId, accounts: keys, data };
|
|
3836
|
+
}
|
|
3837
|
+
function isTransactionSigner6(value) {
|
|
3838
|
+
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
3839
|
+
}
|
|
3840
|
+
function createAccountMeta2(value, role) {
|
|
3841
|
+
if (isTransactionSigner6(value)) {
|
|
3842
|
+
return { address: value.address, role, signer: value };
|
|
3843
|
+
}
|
|
3844
|
+
return { address: value, role };
|
|
3845
|
+
}
|
|
3846
|
+
function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
|
|
3847
|
+
const {
|
|
3848
|
+
config,
|
|
3849
|
+
launch,
|
|
3850
|
+
launchAuthority,
|
|
3851
|
+
baseVault,
|
|
3852
|
+
quoteVault,
|
|
3853
|
+
userBaseAccount,
|
|
3854
|
+
userQuoteAccount,
|
|
3855
|
+
baseMint,
|
|
3856
|
+
quoteMint,
|
|
3857
|
+
user,
|
|
3858
|
+
sentinelProgram = SYSTEM_PROGRAM_ADDRESS,
|
|
3859
|
+
tokenProgram = TOKEN_PROGRAM_ADDRESS
|
|
3860
|
+
} = accounts;
|
|
3861
|
+
const keys = [
|
|
3862
|
+
{ address: config, role: AccountRole.READONLY },
|
|
3863
|
+
{ address: launch, role: AccountRole.WRITABLE },
|
|
3864
|
+
{ address: launchAuthority, role: AccountRole.READONLY },
|
|
3865
|
+
{ address: baseVault, role: AccountRole.WRITABLE },
|
|
3866
|
+
{ address: quoteVault, role: AccountRole.WRITABLE },
|
|
3867
|
+
{ address: userBaseAccount, role: AccountRole.WRITABLE },
|
|
3868
|
+
{ address: userQuoteAccount, role: AccountRole.WRITABLE },
|
|
3869
|
+
{ address: baseMint, role: AccountRole.READONLY },
|
|
3870
|
+
{ address: quoteMint, role: AccountRole.READONLY },
|
|
3871
|
+
createAccountMeta2(user, AccountRole.READONLY_SIGNER),
|
|
3872
|
+
// sentinel_program is Optional in the on-chain struct but still occupies a fixed
|
|
3873
|
+
// slot (token_program follows it). Always emit it — use SYSTEM_PROGRAM_ADDRESS as the
|
|
3874
|
+
// no-op placeholder when no real sentinel is configured.
|
|
3875
|
+
{ address: sentinelProgram, role: AccountRole.READONLY },
|
|
3876
|
+
{ address: tokenProgram, role: AccountRole.READONLY }
|
|
3877
|
+
];
|
|
3878
|
+
const data = new Uint8Array(
|
|
3879
|
+
getCurveSwapExactInInstructionDataEncoder().encode(args)
|
|
3880
|
+
);
|
|
3881
|
+
return { programAddress: programId, accounts: keys, data };
|
|
3882
|
+
}
|
|
3883
|
+
function isTransactionSigner7(value) {
|
|
3884
|
+
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
3885
|
+
}
|
|
3886
|
+
function createSignerAccountMeta5(value, role) {
|
|
3887
|
+
if (isTransactionSigner7(value)) {
|
|
3888
|
+
return { address: value.address, role, signer: value };
|
|
3889
|
+
}
|
|
3890
|
+
return { address: value, role };
|
|
3891
|
+
}
|
|
3892
|
+
function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRAM_ID) {
|
|
3893
|
+
const {
|
|
3894
|
+
config,
|
|
3895
|
+
launch,
|
|
3896
|
+
launchAuthority,
|
|
3897
|
+
baseMint,
|
|
3898
|
+
quoteMint,
|
|
3899
|
+
baseVault,
|
|
3900
|
+
quoteVault,
|
|
3901
|
+
migratorProgram,
|
|
3902
|
+
payer,
|
|
3903
|
+
tokenProgram = TOKEN_PROGRAM_ADDRESS,
|
|
3904
|
+
systemProgram = SYSTEM_PROGRAM_ADDRESS,
|
|
3905
|
+
rent
|
|
3906
|
+
} = accounts;
|
|
3907
|
+
const keys = [
|
|
3908
|
+
{ address: config, role: AccountRole.READONLY },
|
|
3909
|
+
{ address: launch, role: AccountRole.WRITABLE },
|
|
3910
|
+
{ address: launchAuthority, role: AccountRole.READONLY },
|
|
3911
|
+
{ address: baseMint, role: AccountRole.READONLY },
|
|
3912
|
+
{ address: quoteMint, role: AccountRole.READONLY },
|
|
3913
|
+
{ address: baseVault, role: AccountRole.WRITABLE },
|
|
3914
|
+
{ address: quoteVault, role: AccountRole.WRITABLE },
|
|
3915
|
+
{ address: migratorProgram, role: AccountRole.READONLY },
|
|
3916
|
+
createSignerAccountMeta5(payer, AccountRole.WRITABLE_SIGNER),
|
|
3917
|
+
{ address: tokenProgram, role: AccountRole.READONLY },
|
|
3918
|
+
{ address: systemProgram, role: AccountRole.READONLY },
|
|
3919
|
+
{ address: rent, role: AccountRole.READONLY }
|
|
3920
|
+
];
|
|
3921
|
+
const data = encodeInstructionData(
|
|
3922
|
+
INITIALIZER_INSTRUCTION_DISCRIMINATORS.migrateLaunch
|
|
3923
|
+
);
|
|
3924
|
+
return { programAddress: programId, accounts: keys, data };
|
|
3925
|
+
}
|
|
3926
|
+
function isTransactionSigner8(value) {
|
|
3927
|
+
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
3928
|
+
}
|
|
3929
|
+
function createAccountMeta3(value, role) {
|
|
3930
|
+
if (isTransactionSigner8(value)) {
|
|
3931
|
+
return { address: value.address, role, signer: value };
|
|
3932
|
+
}
|
|
3933
|
+
return { address: value, role };
|
|
3934
|
+
}
|
|
3935
|
+
function createAbortLaunchInstruction(accounts, programId = INITIALIZER_PROGRAM_ID) {
|
|
3936
|
+
const {
|
|
3937
|
+
config,
|
|
3938
|
+
launch,
|
|
3939
|
+
launchAuthority,
|
|
3940
|
+
baseVault,
|
|
3941
|
+
quoteVault,
|
|
3942
|
+
authority,
|
|
3943
|
+
authorityBaseAccount,
|
|
3944
|
+
baseMint,
|
|
3945
|
+
tokenProgram = TOKEN_PROGRAM_ADDRESS
|
|
3946
|
+
} = accounts;
|
|
3947
|
+
const keys = [
|
|
3948
|
+
{ address: config, role: AccountRole.READONLY },
|
|
3949
|
+
{ address: launch, role: AccountRole.WRITABLE },
|
|
3950
|
+
{ address: launchAuthority, role: AccountRole.READONLY },
|
|
3951
|
+
{ address: baseVault, role: AccountRole.WRITABLE },
|
|
3952
|
+
{ address: quoteVault, role: AccountRole.READONLY },
|
|
3953
|
+
createAccountMeta3(authority, AccountRole.READONLY_SIGNER),
|
|
3954
|
+
{ address: authorityBaseAccount, role: AccountRole.WRITABLE },
|
|
3955
|
+
{ address: baseMint, role: AccountRole.READONLY },
|
|
3956
|
+
{ address: tokenProgram, role: AccountRole.READONLY }
|
|
3957
|
+
];
|
|
3958
|
+
const data = encodeInstructionData(
|
|
3959
|
+
INITIALIZER_INSTRUCTION_DISCRIMINATORS.abortLaunch
|
|
3960
|
+
);
|
|
3961
|
+
return { programAddress: programId, accounts: keys, data };
|
|
1971
3962
|
}
|
|
1972
3963
|
var previewSwapExactInResultCodec = getStructCodec([
|
|
1973
3964
|
["amountOut", getU64Codec()],
|
|
@@ -1976,11 +3967,11 @@ var previewSwapExactInResultCodec = getStructCodec([
|
|
|
1976
3967
|
function createPreviewSwapExactInInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
|
|
1977
3968
|
const { launch, baseVault, quoteVault, sentinelProgram } = accounts;
|
|
1978
3969
|
const keys = [
|
|
1979
|
-
{ address: launch, role:
|
|
1980
|
-
{ address: baseVault, role:
|
|
1981
|
-
{ address: quoteVault, role:
|
|
3970
|
+
{ address: launch, role: AccountRole.READONLY },
|
|
3971
|
+
{ address: baseVault, role: AccountRole.READONLY },
|
|
3972
|
+
{ address: quoteVault, role: AccountRole.READONLY }
|
|
1982
3973
|
];
|
|
1983
|
-
const accountsList = sentinelProgram ? [...keys, { address: sentinelProgram, role:
|
|
3974
|
+
const accountsList = sentinelProgram ? [...keys, { address: sentinelProgram, role: AccountRole.READONLY }] : keys;
|
|
1984
3975
|
const data = new Uint8Array(
|
|
1985
3976
|
getPreviewSwapExactInInstructionDataEncoder().encode(args)
|
|
1986
3977
|
);
|
|
@@ -1997,10 +3988,10 @@ var previewMigrationResultCodec = getStructCodec([
|
|
|
1997
3988
|
function createPreviewMigrationInstruction(accounts, programId = INITIALIZER_PROGRAM_ID) {
|
|
1998
3989
|
const { launch, baseMint, baseVault, quoteVault } = accounts;
|
|
1999
3990
|
const keys = [
|
|
2000
|
-
{ address: launch, role:
|
|
2001
|
-
{ address: baseMint, role:
|
|
2002
|
-
{ address: baseVault, role:
|
|
2003
|
-
{ address: quoteVault, role:
|
|
3991
|
+
{ address: launch, role: AccountRole.READONLY },
|
|
3992
|
+
{ address: baseMint, role: AccountRole.READONLY },
|
|
3993
|
+
{ address: baseVault, role: AccountRole.READONLY },
|
|
3994
|
+
{ address: quoteVault, role: AccountRole.READONLY }
|
|
2004
3995
|
];
|
|
2005
3996
|
const data = encodeInstructionData(
|
|
2006
3997
|
INITIALIZER_INSTRUCTION_DISCRIMINATORS.previewMigration
|
|
@@ -2010,7 +4001,28 @@ function createPreviewMigrationInstruction(accounts, programId = INITIALIZER_PRO
|
|
|
2010
4001
|
function decodePreviewMigrationResult(data) {
|
|
2011
4002
|
return previewMigrationResultCodec.decode(data);
|
|
2012
4003
|
}
|
|
2013
|
-
|
|
4004
|
+
function computeRemainingAccountsHash(addresses) {
|
|
4005
|
+
const addressEncoder = getAddressEncoder();
|
|
4006
|
+
const buf = new Uint8Array(4 + addresses.length * 32);
|
|
4007
|
+
new DataView(buf.buffer).setUint32(0, addresses.length, true);
|
|
4008
|
+
for (let i = 0; i < addresses.length; i++) {
|
|
4009
|
+
buf.set(addressEncoder.encode(addresses[i]), 4 + i * 32);
|
|
4010
|
+
}
|
|
4011
|
+
return keccak_256(buf);
|
|
4012
|
+
}
|
|
4013
|
+
function phaseLabel(phase) {
|
|
4014
|
+
switch (phase) {
|
|
4015
|
+
case PHASE_TRADING:
|
|
4016
|
+
return "TRADING";
|
|
4017
|
+
case PHASE_MIGRATED:
|
|
4018
|
+
return "MIGRATED";
|
|
4019
|
+
case PHASE_ABORTED:
|
|
4020
|
+
return "ABORTED";
|
|
4021
|
+
default:
|
|
4022
|
+
return String(phase);
|
|
4023
|
+
}
|
|
4024
|
+
}
|
|
4025
|
+
var addressCodec5 = getAddressCodec();
|
|
2014
4026
|
function bytesToBase64(bytes) {
|
|
2015
4027
|
let binary = "";
|
|
2016
4028
|
for (let i = 0; i < bytes.length; i++) {
|
|
@@ -2026,7 +4038,7 @@ function base64ToBytes2(base64) {
|
|
|
2026
4038
|
}
|
|
2027
4039
|
return bytes;
|
|
2028
4040
|
}
|
|
2029
|
-
async function
|
|
4041
|
+
async function fetchLaunch2(rpc, address3, config) {
|
|
2030
4042
|
const response = await rpc.getAccountInfo(address3, {
|
|
2031
4043
|
encoding: "base64",
|
|
2032
4044
|
commitment: config?.commitment
|
|
@@ -2080,7 +4092,7 @@ async function fetchLaunchesByAuthority(rpc, authority, config) {
|
|
|
2080
4092
|
memcmp: {
|
|
2081
4093
|
offset: 8n,
|
|
2082
4094
|
bytes: bytesToBase64(
|
|
2083
|
-
|
|
4095
|
+
addressCodec5.encode(authority)
|
|
2084
4096
|
),
|
|
2085
4097
|
encoding: "base64"
|
|
2086
4098
|
}
|
|
@@ -2110,7 +4122,7 @@ async function launchExists(rpc, namespace, launchId, config) {
|
|
|
2110
4122
|
launchId,
|
|
2111
4123
|
programId
|
|
2112
4124
|
);
|
|
2113
|
-
const launch = await
|
|
4125
|
+
const launch = await fetchLaunch2(rpc, launchAddress, config);
|
|
2114
4126
|
return launch !== null;
|
|
2115
4127
|
}
|
|
2116
4128
|
|
|
@@ -2251,14 +4263,6 @@ function getCpmmMigratorStateCodec() {
|
|
|
2251
4263
|
);
|
|
2252
4264
|
}
|
|
2253
4265
|
if (process.env.NODE_ENV !== "production") ;
|
|
2254
|
-
var addressCodec4 = getAddressCodec();
|
|
2255
|
-
var textEncoder3 = new TextEncoder();
|
|
2256
|
-
async function getCpmmMigratorStateAddress(launch, programId = CPMM_MIGRATOR_PROGRAM_ID) {
|
|
2257
|
-
return getProgramDerivedAddress({
|
|
2258
|
-
programAddress: programId,
|
|
2259
|
-
seeds: [textEncoder3.encode(SEED_STATE), addressCodec4.encode(launch)]
|
|
2260
|
-
});
|
|
2261
|
-
}
|
|
2262
4266
|
|
|
2263
4267
|
// src/solana/migrators/cpmmMigrator/client.ts
|
|
2264
4268
|
function base64ToBytes3(base64) {
|
|
@@ -2293,6 +4297,679 @@ function encodeMigrateCalldata(args) {
|
|
|
2293
4297
|
]);
|
|
2294
4298
|
}
|
|
2295
4299
|
|
|
2296
|
-
|
|
4300
|
+
// src/solana/migrators/predictionMigrator/index.ts
|
|
4301
|
+
var predictionMigrator_exports = {};
|
|
4302
|
+
__export(predictionMigrator_exports, {
|
|
4303
|
+
CLAIM_DISCRIMINATOR: () => CLAIM_DISCRIMINATOR,
|
|
4304
|
+
CLAIM_RECEIPT_DISCRIMINATOR: () => CLAIM_RECEIPT_DISCRIMINATOR,
|
|
4305
|
+
ENTRY_BY_MINT_DISCRIMINATOR: () => ENTRY_BY_MINT_DISCRIMINATOR,
|
|
4306
|
+
ENTRY_DISCRIMINATOR: () => ENTRY_DISCRIMINATOR,
|
|
4307
|
+
LAUNCH_DISCRIMINATOR: () => LAUNCH_DISCRIMINATOR2,
|
|
4308
|
+
MARKET_DISCRIMINATOR: () => MARKET_DISCRIMINATOR,
|
|
4309
|
+
MIGRATE_ENTRY_DISCRIMINATOR: () => MIGRATE_ENTRY_DISCRIMINATOR,
|
|
4310
|
+
ORACLE_STATE_DISCRIMINATOR: () => ORACLE_STATE_DISCRIMINATOR,
|
|
4311
|
+
PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_MIGRATED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_MIGRATED,
|
|
4312
|
+
PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_REGISTERED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_REGISTERED,
|
|
4313
|
+
PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_MIGRATED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_MIGRATED,
|
|
4314
|
+
PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_REGISTERED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_REGISTERED,
|
|
4315
|
+
PREDICTION_MIGRATOR_ERROR__INSUFFICIENT_BALANCE: () => PREDICTION_MIGRATOR_ERROR__INSUFFICIENT_BALANCE,
|
|
4316
|
+
PREDICTION_MIGRATOR_ERROR__INVALID_ENTRY_ID: () => PREDICTION_MIGRATOR_ERROR__INVALID_ENTRY_ID,
|
|
4317
|
+
PREDICTION_MIGRATOR_ERROR__INVALID_INPUT: () => PREDICTION_MIGRATOR_ERROR__INVALID_INPUT,
|
|
4318
|
+
PREDICTION_MIGRATOR_ERROR__INVALID_MARKET: () => PREDICTION_MIGRATOR_ERROR__INVALID_MARKET,
|
|
4319
|
+
PREDICTION_MIGRATOR_ERROR__INVALID_MINT: () => PREDICTION_MIGRATOR_ERROR__INVALID_MINT,
|
|
4320
|
+
PREDICTION_MIGRATOR_ERROR__INVALID_ORACLE: () => PREDICTION_MIGRATOR_ERROR__INVALID_ORACLE,
|
|
4321
|
+
PREDICTION_MIGRATOR_ERROR__INVALID_VAULT: () => PREDICTION_MIGRATOR_ERROR__INVALID_VAULT,
|
|
4322
|
+
PREDICTION_MIGRATOR_ERROR__INVALID_WINNER_MINT: () => PREDICTION_MIGRATOR_ERROR__INVALID_WINNER_MINT,
|
|
4323
|
+
PREDICTION_MIGRATOR_ERROR__MARKET_NOT_RESOLVED: () => PREDICTION_MIGRATOR_ERROR__MARKET_NOT_RESOLVED,
|
|
4324
|
+
PREDICTION_MIGRATOR_ERROR__MATH_OVERFLOW: () => PREDICTION_MIGRATOR_ERROR__MATH_OVERFLOW,
|
|
4325
|
+
PREDICTION_MIGRATOR_ERROR__NO_PENDING_REWARDS: () => PREDICTION_MIGRATOR_ERROR__NO_PENDING_REWARDS,
|
|
4326
|
+
PREDICTION_MIGRATOR_ERROR__ORACLE_NOT_FINALIZED: () => PREDICTION_MIGRATOR_ERROR__ORACLE_NOT_FINALIZED,
|
|
4327
|
+
PREDICTION_MIGRATOR_ERROR__QUOTE_MINT_MISMATCH: () => PREDICTION_MIGRATOR_ERROR__QUOTE_MINT_MISMATCH,
|
|
4328
|
+
PREDICTION_MIGRATOR_ERROR__UNAUTHORIZED: () => PREDICTION_MIGRATOR_ERROR__UNAUTHORIZED,
|
|
4329
|
+
PREDICTION_MIGRATOR_ERROR__WINNING_ENTRY_NOT_MIGRATED: () => PREDICTION_MIGRATOR_ERROR__WINNING_ENTRY_NOT_MIGRATED,
|
|
4330
|
+
PREDICTION_MIGRATOR_ERROR__ZERO_CLAIMABLE_SUPPLY: () => PREDICTION_MIGRATOR_ERROR__ZERO_CLAIMABLE_SUPPLY,
|
|
4331
|
+
PREDICTION_MIGRATOR_PROGRAM_ADDRESS: () => PREDICTION_MIGRATOR_PROGRAM_ADDRESS,
|
|
4332
|
+
PREVIEW_PAYOUT_IF_WINNER_DISCRIMINATOR: () => PREVIEW_PAYOUT_IF_WINNER_DISCRIMINATOR,
|
|
4333
|
+
PredictionMigratorAccount: () => PredictionMigratorAccount,
|
|
4334
|
+
PredictionMigratorInstruction: () => PredictionMigratorInstruction,
|
|
4335
|
+
REGISTER_ENTRY_DISCRIMINATOR: () => REGISTER_ENTRY_DISCRIMINATOR,
|
|
4336
|
+
decodeClaimReceipt: () => decodeClaimReceipt,
|
|
4337
|
+
decodeEntry: () => decodeEntry,
|
|
4338
|
+
decodeEntryByMint: () => decodeEntryByMint,
|
|
4339
|
+
decodeLaunch: () => decodeLaunch,
|
|
4340
|
+
decodeMarket: () => decodeMarket,
|
|
4341
|
+
decodeOracleState: () => decodeOracleState2,
|
|
4342
|
+
fetchAllClaimReceipt: () => fetchAllClaimReceipt,
|
|
4343
|
+
fetchAllEntry: () => fetchAllEntry,
|
|
4344
|
+
fetchAllEntryByMint: () => fetchAllEntryByMint,
|
|
4345
|
+
fetchAllLaunch: () => fetchAllLaunch,
|
|
4346
|
+
fetchAllMarket: () => fetchAllMarket,
|
|
4347
|
+
fetchAllMaybeClaimReceipt: () => fetchAllMaybeClaimReceipt,
|
|
4348
|
+
fetchAllMaybeEntry: () => fetchAllMaybeEntry,
|
|
4349
|
+
fetchAllMaybeEntryByMint: () => fetchAllMaybeEntryByMint,
|
|
4350
|
+
fetchAllMaybeLaunch: () => fetchAllMaybeLaunch,
|
|
4351
|
+
fetchAllMaybeMarket: () => fetchAllMaybeMarket,
|
|
4352
|
+
fetchAllMaybeOracleState: () => fetchAllMaybeOracleState,
|
|
4353
|
+
fetchAllOracleState: () => fetchAllOracleState,
|
|
4354
|
+
fetchClaimReceipt: () => fetchClaimReceipt,
|
|
4355
|
+
fetchEntry: () => fetchEntry,
|
|
4356
|
+
fetchEntryByMint: () => fetchEntryByMint,
|
|
4357
|
+
fetchLaunch: () => fetchLaunch,
|
|
4358
|
+
fetchMarket: () => fetchMarket,
|
|
4359
|
+
fetchMaybeClaimReceipt: () => fetchMaybeClaimReceipt,
|
|
4360
|
+
fetchMaybeEntry: () => fetchMaybeEntry,
|
|
4361
|
+
fetchMaybeEntryByMint: () => fetchMaybeEntryByMint,
|
|
4362
|
+
fetchMaybeLaunch: () => fetchMaybeLaunch,
|
|
4363
|
+
fetchMaybeMarket: () => fetchMaybeMarket,
|
|
4364
|
+
fetchMaybeOracleState: () => fetchMaybeOracleState,
|
|
4365
|
+
fetchOracleState: () => fetchOracleState,
|
|
4366
|
+
getAccumulatorUpdatedCodec: () => getAccumulatorUpdatedCodec,
|
|
4367
|
+
getAccumulatorUpdatedDecoder: () => getAccumulatorUpdatedDecoder,
|
|
4368
|
+
getAccumulatorUpdatedEncoder: () => getAccumulatorUpdatedEncoder,
|
|
4369
|
+
getCalldataBufCodec: () => getCalldataBufCodec,
|
|
4370
|
+
getCalldataBufDecoder: () => getCalldataBufDecoder2,
|
|
4371
|
+
getCalldataBufEncoder: () => getCalldataBufEncoder2,
|
|
4372
|
+
getClaimDiscriminatorBytes: () => getClaimDiscriminatorBytes,
|
|
4373
|
+
getClaimInstruction: () => getClaimInstruction,
|
|
4374
|
+
getClaimInstructionAsync: () => getClaimInstructionAsync,
|
|
4375
|
+
getClaimInstructionDataCodec: () => getClaimInstructionDataCodec,
|
|
4376
|
+
getClaimInstructionDataDecoder: () => getClaimInstructionDataDecoder,
|
|
4377
|
+
getClaimInstructionDataEncoder: () => getClaimInstructionDataEncoder,
|
|
4378
|
+
getClaimReceiptCodec: () => getClaimReceiptCodec,
|
|
4379
|
+
getClaimReceiptDecoder: () => getClaimReceiptDecoder,
|
|
4380
|
+
getClaimReceiptDiscriminatorBytes: () => getClaimReceiptDiscriminatorBytes,
|
|
4381
|
+
getClaimReceiptEncoder: () => getClaimReceiptEncoder,
|
|
4382
|
+
getClaimReceiptSize: () => getClaimReceiptSize,
|
|
4383
|
+
getEntryByMintCodec: () => getEntryByMintCodec,
|
|
4384
|
+
getEntryByMintDecoder: () => getEntryByMintDecoder,
|
|
4385
|
+
getEntryByMintDiscriminatorBytes: () => getEntryByMintDiscriminatorBytes,
|
|
4386
|
+
getEntryByMintEncoder: () => getEntryByMintEncoder,
|
|
4387
|
+
getEntryByMintSize: () => getEntryByMintSize,
|
|
4388
|
+
getEntryCodec: () => getEntryCodec,
|
|
4389
|
+
getEntryDecoder: () => getEntryDecoder,
|
|
4390
|
+
getEntryDiscriminatorBytes: () => getEntryDiscriminatorBytes,
|
|
4391
|
+
getEntryEncoder: () => getEntryEncoder,
|
|
4392
|
+
getEntryMigratedCodec: () => getEntryMigratedCodec,
|
|
4393
|
+
getEntryMigratedDecoder: () => getEntryMigratedDecoder,
|
|
4394
|
+
getEntryMigratedEncoder: () => getEntryMigratedEncoder,
|
|
4395
|
+
getEntryRegisteredCodec: () => getEntryRegisteredCodec,
|
|
4396
|
+
getEntryRegisteredDecoder: () => getEntryRegisteredDecoder,
|
|
4397
|
+
getEntryRegisteredEncoder: () => getEntryRegisteredEncoder,
|
|
4398
|
+
getEntrySize: () => getEntrySize,
|
|
4399
|
+
getLaunchCodec: () => getLaunchCodec2,
|
|
4400
|
+
getLaunchDecoder: () => getLaunchDecoder2,
|
|
4401
|
+
getLaunchDiscriminatorBytes: () => getLaunchDiscriminatorBytes,
|
|
4402
|
+
getLaunchEncoder: () => getLaunchEncoder2,
|
|
4403
|
+
getLaunchSize: () => getLaunchSize,
|
|
4404
|
+
getMarketCodec: () => getMarketCodec,
|
|
4405
|
+
getMarketCreatedCodec: () => getMarketCreatedCodec,
|
|
4406
|
+
getMarketCreatedDecoder: () => getMarketCreatedDecoder,
|
|
4407
|
+
getMarketCreatedEncoder: () => getMarketCreatedEncoder,
|
|
4408
|
+
getMarketDecoder: () => getMarketDecoder,
|
|
4409
|
+
getMarketDiscriminatorBytes: () => getMarketDiscriminatorBytes,
|
|
4410
|
+
getMarketEncoder: () => getMarketEncoder,
|
|
4411
|
+
getMarketResolvedCodec: () => getMarketResolvedCodec,
|
|
4412
|
+
getMarketResolvedDecoder: () => getMarketResolvedDecoder,
|
|
4413
|
+
getMarketResolvedEncoder: () => getMarketResolvedEncoder,
|
|
4414
|
+
getMarketSize: () => getMarketSize,
|
|
4415
|
+
getMigrateEntryArgsCodec: () => getMigrateEntryArgsCodec,
|
|
4416
|
+
getMigrateEntryArgsDecoder: () => getMigrateEntryArgsDecoder,
|
|
4417
|
+
getMigrateEntryArgsEncoder: () => getMigrateEntryArgsEncoder,
|
|
4418
|
+
getMigrateEntryDiscriminatorBytes: () => getMigrateEntryDiscriminatorBytes,
|
|
4419
|
+
getMigrateEntryInstruction: () => getMigrateEntryInstruction,
|
|
4420
|
+
getMigrateEntryInstructionAsync: () => getMigrateEntryInstructionAsync,
|
|
4421
|
+
getMigrateEntryInstructionDataCodec: () => getMigrateEntryInstructionDataCodec,
|
|
4422
|
+
getMigrateEntryInstructionDataDecoder: () => getMigrateEntryInstructionDataDecoder,
|
|
4423
|
+
getMigrateEntryInstructionDataEncoder: () => getMigrateEntryInstructionDataEncoder,
|
|
4424
|
+
getOracleStateCodec: () => getOracleStateCodec,
|
|
4425
|
+
getOracleStateDecoder: () => getOracleStateDecoder,
|
|
4426
|
+
getOracleStateDiscriminatorBytes: () => getOracleStateDiscriminatorBytes,
|
|
4427
|
+
getOracleStateEncoder: () => getOracleStateEncoder,
|
|
4428
|
+
getOracleStateSize: () => getOracleStateSize,
|
|
4429
|
+
getPredictionEntryAddress: () => getPredictionEntryAddress,
|
|
4430
|
+
getPredictionEntryByMintAddress: () => getPredictionEntryByMintAddress,
|
|
4431
|
+
getPredictionMarketAddress: () => getPredictionMarketAddress,
|
|
4432
|
+
getPredictionMarketAuthorityAddress: () => getPredictionMarketAuthorityAddress,
|
|
4433
|
+
getPredictionMigratorErrorMessage: () => getPredictionMigratorErrorMessage,
|
|
4434
|
+
getPredictionPotVaultAddress: () => getPredictionPotVaultAddress,
|
|
4435
|
+
getPreviewPayoutIfWinnerArgsCodec: () => getPreviewPayoutIfWinnerArgsCodec,
|
|
4436
|
+
getPreviewPayoutIfWinnerArgsDecoder: () => getPreviewPayoutIfWinnerArgsDecoder,
|
|
4437
|
+
getPreviewPayoutIfWinnerArgsEncoder: () => getPreviewPayoutIfWinnerArgsEncoder,
|
|
4438
|
+
getPreviewPayoutIfWinnerDiscriminatorBytes: () => getPreviewPayoutIfWinnerDiscriminatorBytes,
|
|
4439
|
+
getPreviewPayoutIfWinnerInstruction: () => getPreviewPayoutIfWinnerInstruction,
|
|
4440
|
+
getPreviewPayoutIfWinnerInstructionDataCodec: () => getPreviewPayoutIfWinnerInstructionDataCodec,
|
|
4441
|
+
getPreviewPayoutIfWinnerInstructionDataDecoder: () => getPreviewPayoutIfWinnerInstructionDataDecoder,
|
|
4442
|
+
getPreviewPayoutIfWinnerInstructionDataEncoder: () => getPreviewPayoutIfWinnerInstructionDataEncoder,
|
|
4443
|
+
getRegisterEntryArgsCodec: () => getRegisterEntryArgsCodec,
|
|
4444
|
+
getRegisterEntryArgsDecoder: () => getRegisterEntryArgsDecoder,
|
|
4445
|
+
getRegisterEntryArgsEncoder: () => getRegisterEntryArgsEncoder,
|
|
4446
|
+
getRegisterEntryDiscriminatorBytes: () => getRegisterEntryDiscriminatorBytes,
|
|
4447
|
+
getRegisterEntryInstruction: () => getRegisterEntryInstruction,
|
|
4448
|
+
getRegisterEntryInstructionAsync: () => getRegisterEntryInstructionAsync,
|
|
4449
|
+
getRegisterEntryInstructionDataCodec: () => getRegisterEntryInstructionDataCodec,
|
|
4450
|
+
getRegisterEntryInstructionDataDecoder: () => getRegisterEntryInstructionDataDecoder,
|
|
4451
|
+
getRegisterEntryInstructionDataEncoder: () => getRegisterEntryInstructionDataEncoder,
|
|
4452
|
+
getRewardsClaimedCodec: () => getRewardsClaimedCodec,
|
|
4453
|
+
getRewardsClaimedDecoder: () => getRewardsClaimedDecoder,
|
|
4454
|
+
getRewardsClaimedEncoder: () => getRewardsClaimedEncoder,
|
|
4455
|
+
identifyPredictionMigratorAccount: () => identifyPredictionMigratorAccount,
|
|
4456
|
+
identifyPredictionMigratorInstruction: () => identifyPredictionMigratorInstruction,
|
|
4457
|
+
isPredictionMigratorError: () => isPredictionMigratorError,
|
|
4458
|
+
parseClaimInstruction: () => parseClaimInstruction,
|
|
4459
|
+
parseMigrateEntryInstruction: () => parseMigrateEntryInstruction,
|
|
4460
|
+
parsePredictionMigratorInstruction: () => parsePredictionMigratorInstruction,
|
|
4461
|
+
parsePreviewPayoutIfWinnerInstruction: () => parsePreviewPayoutIfWinnerInstruction,
|
|
4462
|
+
parseRegisterEntryInstruction: () => parseRegisterEntryInstruction,
|
|
4463
|
+
predictionMigratorProgram: () => predictionMigratorProgram
|
|
4464
|
+
});
|
|
4465
|
+
var PREDICTION_MIGRATOR_ERROR__UNAUTHORIZED = 6e3;
|
|
4466
|
+
var PREDICTION_MIGRATOR_ERROR__QUOTE_MINT_MISMATCH = 6001;
|
|
4467
|
+
var PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_REGISTERED = 6002;
|
|
4468
|
+
var PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_REGISTERED = 6003;
|
|
4469
|
+
var PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_MIGRATED = 6004;
|
|
4470
|
+
var PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_MIGRATED = 6005;
|
|
4471
|
+
var PREDICTION_MIGRATOR_ERROR__ORACLE_NOT_FINALIZED = 6006;
|
|
4472
|
+
var PREDICTION_MIGRATOR_ERROR__MARKET_NOT_RESOLVED = 6007;
|
|
4473
|
+
var PREDICTION_MIGRATOR_ERROR__INVALID_WINNER_MINT = 6008;
|
|
4474
|
+
var PREDICTION_MIGRATOR_ERROR__INSUFFICIENT_BALANCE = 6009;
|
|
4475
|
+
var PREDICTION_MIGRATOR_ERROR__MATH_OVERFLOW = 6010;
|
|
4476
|
+
var PREDICTION_MIGRATOR_ERROR__INVALID_ENTRY_ID = 6011;
|
|
4477
|
+
var PREDICTION_MIGRATOR_ERROR__INVALID_MARKET = 6012;
|
|
4478
|
+
var PREDICTION_MIGRATOR_ERROR__INVALID_VAULT = 6013;
|
|
4479
|
+
var PREDICTION_MIGRATOR_ERROR__INVALID_MINT = 6014;
|
|
4480
|
+
var PREDICTION_MIGRATOR_ERROR__WINNING_ENTRY_NOT_MIGRATED = 6015;
|
|
4481
|
+
var PREDICTION_MIGRATOR_ERROR__NO_PENDING_REWARDS = 6016;
|
|
4482
|
+
var PREDICTION_MIGRATOR_ERROR__INVALID_ORACLE = 6017;
|
|
4483
|
+
var PREDICTION_MIGRATOR_ERROR__ZERO_CLAIMABLE_SUPPLY = 6018;
|
|
4484
|
+
var PREDICTION_MIGRATOR_ERROR__INVALID_INPUT = 6019;
|
|
4485
|
+
var predictionMigratorErrorMessages;
|
|
4486
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4487
|
+
predictionMigratorErrorMessages = {
|
|
4488
|
+
[PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_MIGRATED]: `Entry already migrated`,
|
|
4489
|
+
[PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_REGISTERED]: `Entry already registered`,
|
|
4490
|
+
[PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_MIGRATED]: `Entry not migrated`,
|
|
4491
|
+
[PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_REGISTERED]: `Entry not registered`,
|
|
4492
|
+
[PREDICTION_MIGRATOR_ERROR__INSUFFICIENT_BALANCE]: `Insufficient balance`,
|
|
4493
|
+
[PREDICTION_MIGRATOR_ERROR__INVALID_ENTRY_ID]: `Invalid entry ID`,
|
|
4494
|
+
[PREDICTION_MIGRATOR_ERROR__INVALID_INPUT]: `Invalid input`,
|
|
4495
|
+
[PREDICTION_MIGRATOR_ERROR__INVALID_MARKET]: `Invalid market`,
|
|
4496
|
+
[PREDICTION_MIGRATOR_ERROR__INVALID_MINT]: `Invalid mint`,
|
|
4497
|
+
[PREDICTION_MIGRATOR_ERROR__INVALID_ORACLE]: `Invalid oracle`,
|
|
4498
|
+
[PREDICTION_MIGRATOR_ERROR__INVALID_VAULT]: `Invalid vault`,
|
|
4499
|
+
[PREDICTION_MIGRATOR_ERROR__INVALID_WINNER_MINT]: `Invalid winner mint`,
|
|
4500
|
+
[PREDICTION_MIGRATOR_ERROR__MARKET_NOT_RESOLVED]: `Market not resolved`,
|
|
4501
|
+
[PREDICTION_MIGRATOR_ERROR__MATH_OVERFLOW]: `Math overflow`,
|
|
4502
|
+
[PREDICTION_MIGRATOR_ERROR__NO_PENDING_REWARDS]: `No pending rewards`,
|
|
4503
|
+
[PREDICTION_MIGRATOR_ERROR__ORACLE_NOT_FINALIZED]: `Oracle not finalized`,
|
|
4504
|
+
[PREDICTION_MIGRATOR_ERROR__QUOTE_MINT_MISMATCH]: `Quote mint mismatch`,
|
|
4505
|
+
[PREDICTION_MIGRATOR_ERROR__UNAUTHORIZED]: `Unauthorized`,
|
|
4506
|
+
[PREDICTION_MIGRATOR_ERROR__WINNING_ENTRY_NOT_MIGRATED]: `Winning entry not migrated`,
|
|
4507
|
+
[PREDICTION_MIGRATOR_ERROR__ZERO_CLAIMABLE_SUPPLY]: `Zero claimable supply`
|
|
4508
|
+
};
|
|
4509
|
+
}
|
|
4510
|
+
function getPredictionMigratorErrorMessage(code) {
|
|
4511
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4512
|
+
return predictionMigratorErrorMessages[code];
|
|
4513
|
+
}
|
|
4514
|
+
return "Error message not available in production bundles.";
|
|
4515
|
+
}
|
|
4516
|
+
function isPredictionMigratorError(error, transactionMessage, code) {
|
|
4517
|
+
return isProgramError(
|
|
4518
|
+
error,
|
|
4519
|
+
transactionMessage,
|
|
4520
|
+
PREDICTION_MIGRATOR_PROGRAM_ADDRESS,
|
|
4521
|
+
code
|
|
4522
|
+
);
|
|
4523
|
+
}
|
|
4524
|
+
|
|
4525
|
+
// src/solana/trustedOracle/index.ts
|
|
4526
|
+
var trustedOracle_exports = {};
|
|
4527
|
+
__export(trustedOracle_exports, {
|
|
4528
|
+
FINALIZE_DISCRIMINATOR: () => FINALIZE_DISCRIMINATOR,
|
|
4529
|
+
INITIALIZE_ORACLE_DISCRIMINATOR: () => INITIALIZE_ORACLE_DISCRIMINATOR,
|
|
4530
|
+
ORACLE_STATE_DISCRIMINATOR: () => ORACLE_STATE_DISCRIMINATOR2,
|
|
4531
|
+
TRUSTED_ORACLE_ERROR__ALREADY_FINALIZED: () => TRUSTED_ORACLE_ERROR__ALREADY_FINALIZED,
|
|
4532
|
+
TRUSTED_ORACLE_ERROR__INVALID_WINNING_MINT: () => TRUSTED_ORACLE_ERROR__INVALID_WINNING_MINT,
|
|
4533
|
+
TRUSTED_ORACLE_ERROR__NOT_FINALIZED: () => TRUSTED_ORACLE_ERROR__NOT_FINALIZED,
|
|
4534
|
+
TRUSTED_ORACLE_ERROR__UNAUTHORIZED: () => TRUSTED_ORACLE_ERROR__UNAUTHORIZED,
|
|
4535
|
+
TRUSTED_ORACLE_PROGRAM_ADDRESS: () => TRUSTED_ORACLE_PROGRAM_ADDRESS,
|
|
4536
|
+
TrustedOracleAccount: () => TrustedOracleAccount,
|
|
4537
|
+
TrustedOracleInstruction: () => TrustedOracleInstruction,
|
|
4538
|
+
decodeOracleState: () => decodeOracleState3,
|
|
4539
|
+
fetchAllMaybeOracleState: () => fetchAllMaybeOracleState2,
|
|
4540
|
+
fetchAllOracleState: () => fetchAllOracleState2,
|
|
4541
|
+
fetchMaybeOracleState: () => fetchMaybeOracleState2,
|
|
4542
|
+
fetchOracleState: () => fetchOracleState2,
|
|
4543
|
+
getFinalizeDiscriminatorBytes: () => getFinalizeDiscriminatorBytes,
|
|
4544
|
+
getFinalizeInstruction: () => getFinalizeInstruction,
|
|
4545
|
+
getFinalizeInstructionDataCodec: () => getFinalizeInstructionDataCodec,
|
|
4546
|
+
getFinalizeInstructionDataDecoder: () => getFinalizeInstructionDataDecoder,
|
|
4547
|
+
getFinalizeInstructionDataEncoder: () => getFinalizeInstructionDataEncoder,
|
|
4548
|
+
getInitializeOracleArgsCodec: () => getInitializeOracleArgsCodec,
|
|
4549
|
+
getInitializeOracleArgsDecoder: () => getInitializeOracleArgsDecoder,
|
|
4550
|
+
getInitializeOracleArgsEncoder: () => getInitializeOracleArgsEncoder,
|
|
4551
|
+
getInitializeOracleDiscriminatorBytes: () => getInitializeOracleDiscriminatorBytes,
|
|
4552
|
+
getInitializeOracleInstruction: () => getInitializeOracleInstruction,
|
|
4553
|
+
getInitializeOracleInstructionDataCodec: () => getInitializeOracleInstructionDataCodec,
|
|
4554
|
+
getInitializeOracleInstructionDataDecoder: () => getInitializeOracleInstructionDataDecoder,
|
|
4555
|
+
getInitializeOracleInstructionDataEncoder: () => getInitializeOracleInstructionDataEncoder,
|
|
4556
|
+
getOracleStateAddress: () => getOracleStateAddress,
|
|
4557
|
+
getOracleStateCodec: () => getOracleStateCodec2,
|
|
4558
|
+
getOracleStateDecoder: () => getOracleStateDecoder2,
|
|
4559
|
+
getOracleStateDiscriminatorBytes: () => getOracleStateDiscriminatorBytes2,
|
|
4560
|
+
getOracleStateEncoder: () => getOracleStateEncoder2,
|
|
4561
|
+
getOracleStateSize: () => getOracleStateSize2,
|
|
4562
|
+
getTrustedOracleErrorMessage: () => getTrustedOracleErrorMessage,
|
|
4563
|
+
identifyTrustedOracleAccount: () => identifyTrustedOracleAccount,
|
|
4564
|
+
identifyTrustedOracleInstruction: () => identifyTrustedOracleInstruction,
|
|
4565
|
+
isTrustedOracleError: () => isTrustedOracleError,
|
|
4566
|
+
parseFinalizeInstruction: () => parseFinalizeInstruction,
|
|
4567
|
+
parseInitializeOracleInstruction: () => parseInitializeOracleInstruction,
|
|
4568
|
+
parseTrustedOracleInstruction: () => parseTrustedOracleInstruction,
|
|
4569
|
+
trustedOracleProgram: () => trustedOracleProgram
|
|
4570
|
+
});
|
|
4571
|
+
var ORACLE_STATE_DISCRIMINATOR2 = new Uint8Array([
|
|
4572
|
+
97,
|
|
4573
|
+
156,
|
|
4574
|
+
157,
|
|
4575
|
+
189,
|
|
4576
|
+
194,
|
|
4577
|
+
73,
|
|
4578
|
+
8,
|
|
4579
|
+
15
|
|
4580
|
+
]);
|
|
4581
|
+
function getOracleStateDiscriminatorBytes2() {
|
|
4582
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
4583
|
+
ORACLE_STATE_DISCRIMINATOR2
|
|
4584
|
+
);
|
|
4585
|
+
}
|
|
4586
|
+
function getOracleStateEncoder2() {
|
|
4587
|
+
return transformEncoder(
|
|
4588
|
+
getStructEncoder([
|
|
4589
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
4590
|
+
["oracleAuthority", getAddressEncoder()],
|
|
4591
|
+
["quoteMint", getAddressEncoder()],
|
|
4592
|
+
["isFinalized", getBooleanEncoder()],
|
|
4593
|
+
["winningMint", getAddressEncoder()],
|
|
4594
|
+
["nonce", getU64Encoder()],
|
|
4595
|
+
["bump", getU8Encoder()],
|
|
4596
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 31)]
|
|
4597
|
+
]),
|
|
4598
|
+
(value) => ({ ...value, discriminator: ORACLE_STATE_DISCRIMINATOR2 })
|
|
4599
|
+
);
|
|
4600
|
+
}
|
|
4601
|
+
function getOracleStateDecoder2() {
|
|
4602
|
+
return getStructDecoder([
|
|
4603
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
4604
|
+
["oracleAuthority", getAddressDecoder()],
|
|
4605
|
+
["quoteMint", getAddressDecoder()],
|
|
4606
|
+
["isFinalized", getBooleanDecoder()],
|
|
4607
|
+
["winningMint", getAddressDecoder()],
|
|
4608
|
+
["nonce", getU64Decoder()],
|
|
4609
|
+
["bump", getU8Decoder()],
|
|
4610
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 31)]
|
|
4611
|
+
]);
|
|
4612
|
+
}
|
|
4613
|
+
function getOracleStateCodec2() {
|
|
4614
|
+
return combineCodec(getOracleStateEncoder2(), getOracleStateDecoder2());
|
|
4615
|
+
}
|
|
4616
|
+
function decodeOracleState3(encodedAccount) {
|
|
4617
|
+
return decodeAccount(
|
|
4618
|
+
encodedAccount,
|
|
4619
|
+
getOracleStateDecoder2()
|
|
4620
|
+
);
|
|
4621
|
+
}
|
|
4622
|
+
async function fetchOracleState2(rpc, address3, config) {
|
|
4623
|
+
const maybeAccount = await fetchMaybeOracleState2(rpc, address3, config);
|
|
4624
|
+
assertAccountExists(maybeAccount);
|
|
4625
|
+
return maybeAccount;
|
|
4626
|
+
}
|
|
4627
|
+
async function fetchMaybeOracleState2(rpc, address3, config) {
|
|
4628
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address3, config);
|
|
4629
|
+
return decodeOracleState3(maybeAccount);
|
|
4630
|
+
}
|
|
4631
|
+
async function fetchAllOracleState2(rpc, addresses, config) {
|
|
4632
|
+
const maybeAccounts = await fetchAllMaybeOracleState2(rpc, addresses, config);
|
|
4633
|
+
assertAccountsExist(maybeAccounts);
|
|
4634
|
+
return maybeAccounts;
|
|
4635
|
+
}
|
|
4636
|
+
async function fetchAllMaybeOracleState2(rpc, addresses, config) {
|
|
4637
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
4638
|
+
return maybeAccounts.map((maybeAccount) => decodeOracleState3(maybeAccount));
|
|
4639
|
+
}
|
|
4640
|
+
function getOracleStateSize2() {
|
|
4641
|
+
return 145;
|
|
4642
|
+
}
|
|
4643
|
+
var FINALIZE_DISCRIMINATOR = new Uint8Array([
|
|
4644
|
+
171,
|
|
4645
|
+
61,
|
|
4646
|
+
218,
|
|
4647
|
+
56,
|
|
4648
|
+
127,
|
|
4649
|
+
115,
|
|
4650
|
+
12,
|
|
4651
|
+
217
|
|
4652
|
+
]);
|
|
4653
|
+
function getFinalizeDiscriminatorBytes() {
|
|
4654
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(FINALIZE_DISCRIMINATOR);
|
|
4655
|
+
}
|
|
4656
|
+
function getFinalizeInstructionDataEncoder() {
|
|
4657
|
+
return transformEncoder(
|
|
4658
|
+
getStructEncoder([
|
|
4659
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
4660
|
+
["winningMint", getAddressEncoder()]
|
|
4661
|
+
]),
|
|
4662
|
+
(value) => ({ ...value, discriminator: FINALIZE_DISCRIMINATOR })
|
|
4663
|
+
);
|
|
4664
|
+
}
|
|
4665
|
+
function getFinalizeInstructionDataDecoder() {
|
|
4666
|
+
return getStructDecoder([
|
|
4667
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
4668
|
+
["winningMint", getAddressDecoder()]
|
|
4669
|
+
]);
|
|
4670
|
+
}
|
|
4671
|
+
function getFinalizeInstructionDataCodec() {
|
|
4672
|
+
return combineCodec(
|
|
4673
|
+
getFinalizeInstructionDataEncoder(),
|
|
4674
|
+
getFinalizeInstructionDataDecoder()
|
|
4675
|
+
);
|
|
4676
|
+
}
|
|
4677
|
+
function getFinalizeInstruction(input, config) {
|
|
4678
|
+
const programAddress = config?.programAddress ?? TRUSTED_ORACLE_PROGRAM_ADDRESS;
|
|
4679
|
+
const originalAccounts = {
|
|
4680
|
+
oracleAuthority: {
|
|
4681
|
+
value: input.oracleAuthority ?? null,
|
|
4682
|
+
isWritable: false
|
|
4683
|
+
},
|
|
4684
|
+
oracleState: { value: input.oracleState ?? null, isWritable: true }
|
|
4685
|
+
};
|
|
4686
|
+
const accounts = originalAccounts;
|
|
4687
|
+
const args = { ...input };
|
|
4688
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
4689
|
+
return Object.freeze({
|
|
4690
|
+
accounts: [
|
|
4691
|
+
getAccountMeta("oracleAuthority", accounts.oracleAuthority),
|
|
4692
|
+
getAccountMeta("oracleState", accounts.oracleState)
|
|
4693
|
+
],
|
|
4694
|
+
data: getFinalizeInstructionDataEncoder().encode(
|
|
4695
|
+
args
|
|
4696
|
+
),
|
|
4697
|
+
programAddress
|
|
4698
|
+
});
|
|
4699
|
+
}
|
|
4700
|
+
function parseFinalizeInstruction(instruction) {
|
|
4701
|
+
if (instruction.accounts.length < 2) {
|
|
4702
|
+
throw new SolanaError(
|
|
4703
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
4704
|
+
{
|
|
4705
|
+
actualAccountMetas: instruction.accounts.length,
|
|
4706
|
+
expectedAccountMetas: 2
|
|
4707
|
+
}
|
|
4708
|
+
);
|
|
4709
|
+
}
|
|
4710
|
+
let accountIndex = 0;
|
|
4711
|
+
const getNextAccount = () => {
|
|
4712
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
4713
|
+
accountIndex += 1;
|
|
4714
|
+
return accountMeta;
|
|
4715
|
+
};
|
|
4716
|
+
return {
|
|
4717
|
+
programAddress: instruction.programAddress,
|
|
4718
|
+
accounts: {
|
|
4719
|
+
oracleAuthority: getNextAccount(),
|
|
4720
|
+
oracleState: getNextAccount()
|
|
4721
|
+
},
|
|
4722
|
+
data: getFinalizeInstructionDataDecoder().decode(instruction.data)
|
|
4723
|
+
};
|
|
4724
|
+
}
|
|
4725
|
+
var INITIALIZE_ORACLE_DISCRIMINATOR = new Uint8Array([
|
|
4726
|
+
144,
|
|
4727
|
+
223,
|
|
4728
|
+
131,
|
|
4729
|
+
120,
|
|
4730
|
+
196,
|
|
4731
|
+
253,
|
|
4732
|
+
181,
|
|
4733
|
+
99
|
|
4734
|
+
]);
|
|
4735
|
+
function getInitializeOracleDiscriminatorBytes() {
|
|
4736
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
4737
|
+
INITIALIZE_ORACLE_DISCRIMINATOR
|
|
4738
|
+
);
|
|
4739
|
+
}
|
|
4740
|
+
function getInitializeOracleInstructionDataEncoder() {
|
|
4741
|
+
return transformEncoder(
|
|
4742
|
+
getStructEncoder([
|
|
4743
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
4744
|
+
["nonce", getU64Encoder()],
|
|
4745
|
+
["quoteMint", getAddressEncoder()]
|
|
4746
|
+
]),
|
|
4747
|
+
(value) => ({ ...value, discriminator: INITIALIZE_ORACLE_DISCRIMINATOR })
|
|
4748
|
+
);
|
|
4749
|
+
}
|
|
4750
|
+
function getInitializeOracleInstructionDataDecoder() {
|
|
4751
|
+
return getStructDecoder([
|
|
4752
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
4753
|
+
["nonce", getU64Decoder()],
|
|
4754
|
+
["quoteMint", getAddressDecoder()]
|
|
4755
|
+
]);
|
|
4756
|
+
}
|
|
4757
|
+
function getInitializeOracleInstructionDataCodec() {
|
|
4758
|
+
return combineCodec(
|
|
4759
|
+
getInitializeOracleInstructionDataEncoder(),
|
|
4760
|
+
getInitializeOracleInstructionDataDecoder()
|
|
4761
|
+
);
|
|
4762
|
+
}
|
|
4763
|
+
function getInitializeOracleInstruction(input, config) {
|
|
4764
|
+
const programAddress = config?.programAddress ?? TRUSTED_ORACLE_PROGRAM_ADDRESS;
|
|
4765
|
+
const originalAccounts = {
|
|
4766
|
+
oracleAuthority: { value: input.oracleAuthority ?? null, isWritable: true },
|
|
4767
|
+
oracleState: { value: input.oracleState ?? null, isWritable: true },
|
|
4768
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false }
|
|
4769
|
+
};
|
|
4770
|
+
const accounts = originalAccounts;
|
|
4771
|
+
const args = { ...input };
|
|
4772
|
+
if (!accounts.systemProgram.value) {
|
|
4773
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
4774
|
+
}
|
|
4775
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
4776
|
+
return Object.freeze({
|
|
4777
|
+
accounts: [
|
|
4778
|
+
getAccountMeta("oracleAuthority", accounts.oracleAuthority),
|
|
4779
|
+
getAccountMeta("oracleState", accounts.oracleState),
|
|
4780
|
+
getAccountMeta("systemProgram", accounts.systemProgram)
|
|
4781
|
+
],
|
|
4782
|
+
data: getInitializeOracleInstructionDataEncoder().encode(
|
|
4783
|
+
args
|
|
4784
|
+
),
|
|
4785
|
+
programAddress
|
|
4786
|
+
});
|
|
4787
|
+
}
|
|
4788
|
+
function parseInitializeOracleInstruction(instruction) {
|
|
4789
|
+
if (instruction.accounts.length < 3) {
|
|
4790
|
+
throw new SolanaError(
|
|
4791
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
4792
|
+
{
|
|
4793
|
+
actualAccountMetas: instruction.accounts.length,
|
|
4794
|
+
expectedAccountMetas: 3
|
|
4795
|
+
}
|
|
4796
|
+
);
|
|
4797
|
+
}
|
|
4798
|
+
let accountIndex = 0;
|
|
4799
|
+
const getNextAccount = () => {
|
|
4800
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
4801
|
+
accountIndex += 1;
|
|
4802
|
+
return accountMeta;
|
|
4803
|
+
};
|
|
4804
|
+
return {
|
|
4805
|
+
programAddress: instruction.programAddress,
|
|
4806
|
+
accounts: {
|
|
4807
|
+
oracleAuthority: getNextAccount(),
|
|
4808
|
+
oracleState: getNextAccount(),
|
|
4809
|
+
systemProgram: getNextAccount()
|
|
4810
|
+
},
|
|
4811
|
+
data: getInitializeOracleInstructionDataDecoder().decode(instruction.data)
|
|
4812
|
+
};
|
|
4813
|
+
}
|
|
4814
|
+
|
|
4815
|
+
// src/solana/generated/trustedOracle/programs/trustedOracle.ts
|
|
4816
|
+
var TRUSTED_ORACLE_PROGRAM_ADDRESS = "HhUzN7VvonNUevATyugZUepzxpeEZMXQbV92X2xvsp5m";
|
|
4817
|
+
var TrustedOracleAccount = /* @__PURE__ */ ((TrustedOracleAccount2) => {
|
|
4818
|
+
TrustedOracleAccount2[TrustedOracleAccount2["OracleState"] = 0] = "OracleState";
|
|
4819
|
+
return TrustedOracleAccount2;
|
|
4820
|
+
})(TrustedOracleAccount || {});
|
|
4821
|
+
function identifyTrustedOracleAccount(account) {
|
|
4822
|
+
const data = "data" in account ? account.data : account;
|
|
4823
|
+
if (containsBytes(
|
|
4824
|
+
data,
|
|
4825
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
4826
|
+
new Uint8Array([97, 156, 157, 189, 194, 73, 8, 15])
|
|
4827
|
+
),
|
|
4828
|
+
0
|
|
4829
|
+
)) {
|
|
4830
|
+
return 0 /* OracleState */;
|
|
4831
|
+
}
|
|
4832
|
+
throw new SolanaError(
|
|
4833
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT,
|
|
4834
|
+
{ accountData: data, programName: "trustedOracle" }
|
|
4835
|
+
);
|
|
4836
|
+
}
|
|
4837
|
+
var TrustedOracleInstruction = /* @__PURE__ */ ((TrustedOracleInstruction2) => {
|
|
4838
|
+
TrustedOracleInstruction2[TrustedOracleInstruction2["Finalize"] = 0] = "Finalize";
|
|
4839
|
+
TrustedOracleInstruction2[TrustedOracleInstruction2["InitializeOracle"] = 1] = "InitializeOracle";
|
|
4840
|
+
return TrustedOracleInstruction2;
|
|
4841
|
+
})(TrustedOracleInstruction || {});
|
|
4842
|
+
function identifyTrustedOracleInstruction(instruction) {
|
|
4843
|
+
const data = "data" in instruction ? instruction.data : instruction;
|
|
4844
|
+
if (containsBytes(
|
|
4845
|
+
data,
|
|
4846
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
4847
|
+
new Uint8Array([171, 61, 218, 56, 127, 115, 12, 217])
|
|
4848
|
+
),
|
|
4849
|
+
0
|
|
4850
|
+
)) {
|
|
4851
|
+
return 0 /* Finalize */;
|
|
4852
|
+
}
|
|
4853
|
+
if (containsBytes(
|
|
4854
|
+
data,
|
|
4855
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
4856
|
+
new Uint8Array([144, 223, 131, 120, 196, 253, 181, 99])
|
|
4857
|
+
),
|
|
4858
|
+
0
|
|
4859
|
+
)) {
|
|
4860
|
+
return 1 /* InitializeOracle */;
|
|
4861
|
+
}
|
|
4862
|
+
throw new SolanaError(
|
|
4863
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
|
|
4864
|
+
{ instructionData: data, programName: "trustedOracle" }
|
|
4865
|
+
);
|
|
4866
|
+
}
|
|
4867
|
+
function parseTrustedOracleInstruction(instruction) {
|
|
4868
|
+
const instructionType = identifyTrustedOracleInstruction(instruction);
|
|
4869
|
+
switch (instructionType) {
|
|
4870
|
+
case 0 /* Finalize */: {
|
|
4871
|
+
assertIsInstructionWithAccounts(instruction);
|
|
4872
|
+
return {
|
|
4873
|
+
instructionType: 0 /* Finalize */,
|
|
4874
|
+
...parseFinalizeInstruction(instruction)
|
|
4875
|
+
};
|
|
4876
|
+
}
|
|
4877
|
+
case 1 /* InitializeOracle */: {
|
|
4878
|
+
assertIsInstructionWithAccounts(instruction);
|
|
4879
|
+
return {
|
|
4880
|
+
instructionType: 1 /* InitializeOracle */,
|
|
4881
|
+
...parseInitializeOracleInstruction(instruction)
|
|
4882
|
+
};
|
|
4883
|
+
}
|
|
4884
|
+
default:
|
|
4885
|
+
throw new SolanaError(
|
|
4886
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
|
|
4887
|
+
{
|
|
4888
|
+
instructionType,
|
|
4889
|
+
programName: "trustedOracle"
|
|
4890
|
+
}
|
|
4891
|
+
);
|
|
4892
|
+
}
|
|
4893
|
+
}
|
|
4894
|
+
function trustedOracleProgram() {
|
|
4895
|
+
return (client) => {
|
|
4896
|
+
return {
|
|
4897
|
+
...client,
|
|
4898
|
+
trustedOracle: {
|
|
4899
|
+
accounts: {
|
|
4900
|
+
oracleState: addSelfFetchFunctions(client, getOracleStateCodec2())
|
|
4901
|
+
},
|
|
4902
|
+
instructions: {
|
|
4903
|
+
finalize: (input) => addSelfPlanAndSendFunctions(client, getFinalizeInstruction(input)),
|
|
4904
|
+
initializeOracle: (input) => addSelfPlanAndSendFunctions(
|
|
4905
|
+
client,
|
|
4906
|
+
getInitializeOracleInstruction(input)
|
|
4907
|
+
)
|
|
4908
|
+
}
|
|
4909
|
+
}
|
|
4910
|
+
};
|
|
4911
|
+
};
|
|
4912
|
+
}
|
|
4913
|
+
|
|
4914
|
+
// src/solana/generated/trustedOracle/errors/trustedOracle.ts
|
|
4915
|
+
var TRUSTED_ORACLE_ERROR__UNAUTHORIZED = 6e3;
|
|
4916
|
+
var TRUSTED_ORACLE_ERROR__ALREADY_FINALIZED = 6001;
|
|
4917
|
+
var TRUSTED_ORACLE_ERROR__NOT_FINALIZED = 6002;
|
|
4918
|
+
var TRUSTED_ORACLE_ERROR__INVALID_WINNING_MINT = 6003;
|
|
4919
|
+
var trustedOracleErrorMessages;
|
|
4920
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4921
|
+
trustedOracleErrorMessages = {
|
|
4922
|
+
[TRUSTED_ORACLE_ERROR__ALREADY_FINALIZED]: `Oracle already finalized`,
|
|
4923
|
+
[TRUSTED_ORACLE_ERROR__INVALID_WINNING_MINT]: `Invalid winning mint`,
|
|
4924
|
+
[TRUSTED_ORACLE_ERROR__NOT_FINALIZED]: `Oracle not finalized`,
|
|
4925
|
+
[TRUSTED_ORACLE_ERROR__UNAUTHORIZED]: `Unauthorized: only oracle authority can perform this action`
|
|
4926
|
+
};
|
|
4927
|
+
}
|
|
4928
|
+
function getTrustedOracleErrorMessage(code) {
|
|
4929
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4930
|
+
return trustedOracleErrorMessages[code];
|
|
4931
|
+
}
|
|
4932
|
+
return "Error message not available in production bundles.";
|
|
4933
|
+
}
|
|
4934
|
+
function isTrustedOracleError(error, transactionMessage, code) {
|
|
4935
|
+
return isProgramError(
|
|
4936
|
+
error,
|
|
4937
|
+
transactionMessage,
|
|
4938
|
+
TRUSTED_ORACLE_PROGRAM_ADDRESS,
|
|
4939
|
+
code
|
|
4940
|
+
);
|
|
4941
|
+
}
|
|
4942
|
+
function getInitializeOracleArgsEncoder() {
|
|
4943
|
+
return getStructEncoder([
|
|
4944
|
+
["nonce", getU64Encoder()],
|
|
4945
|
+
["quoteMint", getAddressEncoder()]
|
|
4946
|
+
]);
|
|
4947
|
+
}
|
|
4948
|
+
function getInitializeOracleArgsDecoder() {
|
|
4949
|
+
return getStructDecoder([
|
|
4950
|
+
["nonce", getU64Decoder()],
|
|
4951
|
+
["quoteMint", getAddressDecoder()]
|
|
4952
|
+
]);
|
|
4953
|
+
}
|
|
4954
|
+
function getInitializeOracleArgsCodec() {
|
|
4955
|
+
return combineCodec(
|
|
4956
|
+
getInitializeOracleArgsEncoder(),
|
|
4957
|
+
getInitializeOracleArgsDecoder()
|
|
4958
|
+
);
|
|
4959
|
+
}
|
|
4960
|
+
async function getOracleStateAddress(oracleAuthority, nonce) {
|
|
4961
|
+
const nonceBytes = new Uint8Array(8);
|
|
4962
|
+
new DataView(nonceBytes.buffer).setBigUint64(0, nonce, true);
|
|
4963
|
+
return getProgramDerivedAddress({
|
|
4964
|
+
programAddress: TRUSTED_ORACLE_PROGRAM_ADDRESS,
|
|
4965
|
+
seeds: [
|
|
4966
|
+
new TextEncoder().encode("oracle"),
|
|
4967
|
+
getAddressEncoder().encode(oracleAuthority),
|
|
4968
|
+
nonceBytes
|
|
4969
|
+
]
|
|
4970
|
+
});
|
|
4971
|
+
}
|
|
4972
|
+
|
|
4973
|
+
export { cpmm_exports as cpmm, cpmmMigrator_exports as cpmmMigrator, initializer_exports as initializer, predictionMigrator_exports as predictionMigrator, trustedOracle_exports as trustedOracle };
|
|
2297
4974
|
//# sourceMappingURL=index.js.map
|
|
2298
4975
|
//# sourceMappingURL=index.js.map
|