@whetstone-research/doppler-sdk 1.0.10 → 1.0.11

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.
@@ -1,8 +1,8 @@
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-RF4NM4ES.js';
2
- import { sortMints, getSwapAddresses, getProtocolPositionAddress, getPositionAddress, getPoolVault1Address, getPoolVault0Address, 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, SYSVAR_INSTRUCTIONS_ADDRESS } from '../chunk-YWZCHTXQ.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, consultTwap, computePrice1Q64, computePrice0Q64, comparePoolAndOraclePrices, collectProtocolFeesArgsCodec, collectFeesArgsCodec, ceilDiv, calculateTwapNumber, calculateTwap, calculateAccruedFees, ammConfigDataCodec, addLiquidityArgsCodec } from '../chunk-MPM2L56F.js';
2
+ import { sortMints, getSwapAddresses, getProtocolPositionAddress, getPositionAddress, getPoolVault1Address, getPoolVault0Address, 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, TOKEN_PROGRAM_ADDRESS, SYSTEM_PROGRAM_ADDRESS } from '../chunk-QGJA5CFL.js';
3
3
  import { __export } from '../chunk-PZ5AY32C.js';
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';
4
+ import { getAddressCodec, getProgramDerivedAddress, fixEncoderSize, getBytesEncoder, transformEncoder, getStructEncoder, getU64Encoder, getU128Encoder, getBooleanEncoder, getStructDecoder, fixDecoderSize, getU64Decoder, getU128Decoder, getBooleanDecoder, getBytesDecoder, combineCodec, getAddressEncoder, SolanaError, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, getU16Encoder, getU8Encoder, getArrayEncoder, getAddressDecoder, getU16Decoder, getU8Decoder, getArrayDecoder, getU32Encoder, getU32Decoder, getOptionEncoder, getOptionDecoder, createNoopSigner, AccountRole, address, addEncoderSizePrefix, getUtf8Encoder, addDecoderSizePrefix, getUtf8Decoder, getStructCodec, getU64Codec, mergeBytes, isProgramError, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, 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 { getAddressFromResolvedInstructionAccount, getAccountMetaFactory, getNonNullResolvedInstructionInput, addSelfPlanAndSendFunctions, addSelfFetchFunctions } from '@solana/program-client-core';
6
6
  import { keccak_256 } from '@noble/hashes/sha3.js';
7
7
 
8
8
  // src/solana/cpmm/index.ts
@@ -10,16 +10,30 @@ var cpmm_exports = {};
10
10
  __export(cpmm_exports, {
11
11
  ACCOUNT_DISCRIMINATORS: () => ACCOUNT_DISCRIMINATORS,
12
12
  ACCOUNT_VERSION: () => ACCOUNT_VERSION,
13
+ ADD_LIQUIDITY_DISCRIMINATOR: () => ADD_LIQUIDITY_DISCRIMINATOR,
13
14
  BPS_DENOM: () => BPS_DENOM,
15
+ CLOSE_POSITION_DISCRIMINATOR: () => CLOSE_POSITION_DISCRIMINATOR,
16
+ COLLECT_FEES_DISCRIMINATOR: () => COLLECT_FEES_DISCRIMINATOR,
17
+ COLLECT_PROTOCOL_FEES_DISCRIMINATOR: () => COLLECT_PROTOCOL_FEES_DISCRIMINATOR,
14
18
  CPMM_ERROR_MESSAGES: () => CPMM_ERROR_MESSAGES,
15
19
  CPMM_PROGRAM_ID: () => CPMM_PROGRAM_ID,
20
+ CREATE_POSITION_DISCRIMINATOR: () => CREATE_POSITION_DISCRIMINATOR,
16
21
  CpmmError: () => CpmmError,
17
22
  CpmmErrorCode: () => CpmmErrorCode,
23
+ INITIALIZE_CONFIG_DISCRIMINATOR: () => INITIALIZE_CONFIG_DISCRIMINATOR,
24
+ INITIALIZE_ORACLE_DISCRIMINATOR: () => INITIALIZE_ORACLE_DISCRIMINATOR,
25
+ INITIALIZE_POOL_DISCRIMINATOR: () => INITIALIZE_POOL_DISCRIMINATOR,
18
26
  INSTRUCTION_DISCRIMINATORS: () => INSTRUCTION_DISCRIMINATORS,
19
27
  MAX_FEE_AMOUNT: () => MAX_FEE_AMOUNT,
20
28
  MAX_ORACLE_OBSERVATIONS: () => MAX_ORACLE_OBSERVATIONS,
21
29
  MAX_SENTINEL_ALLOWLIST: () => MAX_SENTINEL_ALLOWLIST,
30
+ ORACLE_CONSULT_DISCRIMINATOR: () => ORACLE_CONSULT_DISCRIMINATOR,
31
+ ORACLE_UPDATE_DISCRIMINATOR: () => ORACLE_UPDATE_DISCRIMINATOR,
32
+ PAUSE_DISCRIMINATOR: () => PAUSE_DISCRIMINATOR,
33
+ PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR: () => PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR,
22
34
  Q64_ONE: () => Q64_ONE,
35
+ QUOTE_TO_NUMERAIRE_DISCRIMINATOR: () => QUOTE_TO_NUMERAIRE_DISCRIMINATOR,
36
+ REMOVE_LIQUIDITY_DISCRIMINATOR: () => REMOVE_LIQUIDITY_DISCRIMINATOR,
23
37
  SEED_AUTHORITY: () => SEED_AUTHORITY,
24
38
  SEED_CONFIG: () => SEED_CONFIG,
25
39
  SEED_ORACLE: () => SEED_ORACLE,
@@ -27,13 +41,21 @@ __export(cpmm_exports, {
27
41
  SEED_POSITION: () => SEED_POSITION,
28
42
  SEED_PROTOCOL_POSITION: () => SEED_PROTOCOL_POSITION,
29
43
  SENTINEL_NO_CHANGE: () => SENTINEL_NO_CHANGE,
44
+ SET_FEES_DISCRIMINATOR: () => SET_FEES_DISCRIMINATOR,
45
+ SET_ROUTE_DISCRIMINATOR: () => SET_ROUTE_DISCRIMINATOR,
46
+ SET_SENTINEL_DISCRIMINATOR: () => SET_SENTINEL_DISCRIMINATOR,
30
47
  SF_AFTER_ADD_LIQ: () => SF_AFTER_ADD_LIQ,
31
48
  SF_AFTER_REMOVE_LIQ: () => SF_AFTER_REMOVE_LIQ,
32
49
  SF_AFTER_SWAP: () => SF_AFTER_SWAP,
33
50
  SF_BEFORE_ADD_LIQ: () => SF_BEFORE_ADD_LIQ,
34
51
  SF_BEFORE_REMOVE_LIQ: () => SF_BEFORE_REMOVE_LIQ,
35
52
  SF_BEFORE_SWAP: () => SF_BEFORE_SWAP,
53
+ SKIM_DISCRIMINATOR: () => SKIM_DISCRIMINATOR,
54
+ SWAP_EXACT_IN_DISCRIMINATOR: () => SWAP_EXACT_IN_DISCRIMINATOR,
36
55
  TOKEN_METADATA_PROGRAM_ID: () => TOKEN_METADATA_PROGRAM_ID,
56
+ TRANSFER_ADMIN_DISCRIMINATOR: () => TRANSFER_ADMIN_DISCRIMINATOR,
57
+ UNPAUSE_DISCRIMINATOR: () => UNPAUSE_DISCRIMINATOR,
58
+ UPDATE_CONFIG_DISCRIMINATOR: () => UPDATE_CONFIG_DISCRIMINATOR,
37
59
  addLiquidityArgsCodec: () => addLiquidityArgsCodec,
38
60
  ammConfigDataCodec: () => ammConfigDataCodec,
39
61
  areMintsOrdered: () => areMintsOrdered,
@@ -47,35 +69,33 @@ __export(cpmm_exports, {
47
69
  computePrice0Q64: () => computePrice0Q64,
48
70
  computePrice1Q64: () => computePrice1Q64,
49
71
  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,
72
+ createAddLiquidityInstruction: () => getAddLiquidityInstruction,
73
+ createClosePositionInstruction: () => getClosePositionInstruction,
74
+ createCollectFeesInstruction: () => getCollectFeesInstruction,
75
+ createCollectProtocolFeesInstruction: () => getCollectProtocolFeesInstruction,
76
+ createCreatePositionInstruction: () => getCreatePositionInstruction,
77
+ createInitializeConfigInstruction: () => getInitializeConfigInstruction,
78
+ createInitializeOracleInstruction: () => getInitializeOracleInstruction,
79
+ createInitializePoolInstruction: () => getInitializePoolInstruction,
80
+ createOracleConsultInstruction: () => getOracleConsultInstruction,
81
+ createOracleUpdateInstruction: () => getOracleUpdateInstruction,
82
+ createPauseInstruction: () => getPauseInstruction,
61
83
  createPositionArgsCodec: () => createPositionArgsCodec,
62
- createQuoteToNumeraireInstruction: () => createQuoteToNumeraireInstruction,
63
- createRemoveLiquidityInstruction: () => createRemoveLiquidityInstruction,
64
- createSetFeesInstruction: () => createSetFeesInstruction,
65
- createSetRouteInstruction: () => createSetRouteInstruction,
66
- createSetSentinelInstruction: () => createSetSentinelInstruction,
67
- createSkimInstruction: () => createSkimInstruction,
68
- createSwapExactInInstruction: () => createSwapExactInInstruction,
84
+ createQuoteToNumeraireInstruction: () => getQuoteToNumeraireInstruction,
85
+ createRemoveLiquidityInstruction: () => getRemoveLiquidityInstruction,
86
+ createSetFeesInstruction: () => getSetFeesInstruction,
87
+ createSetRouteInstruction: () => getSetRouteInstruction,
88
+ createSetSentinelInstruction: () => getSetSentinelInstruction,
89
+ createSkimInstruction: () => getSkimInstruction,
90
+ createSwapExactInInstruction: () => getSwapExactInInstruction,
69
91
  createSwapInstruction: () => createSwapInstruction,
70
- createTransferAdminInstruction: () => createTransferAdminInstruction,
71
- createUnpauseInstruction: () => createUnpauseInstruction,
92
+ createTransferAdminInstruction: () => getTransferAdminInstruction,
93
+ createUnpauseInstruction: () => getUnpauseInstruction,
72
94
  curveParamsToMarketCap: () => curveParamsToMarketCap,
73
95
  decodeAmmConfig: () => decodeAmmConfig,
74
- decodeOracleConsultResult: () => decodeOracleConsultResult,
75
96
  decodeOracleState: () => decodeOracleState,
76
97
  decodePool: () => decodePool,
77
98
  decodePosition: () => decodePosition,
78
- decodeQuoteToNumeraireResult: () => decodeQuoteToNumeraireResult,
79
99
  encodeAddLiquidityArgs: () => encodeAddLiquidityArgs,
80
100
  encodeCollectFeesArgs: () => encodeCollectFeesArgs,
81
101
  encodeCollectProtocolFeesArgs: () => encodeCollectProtocolFeesArgs,
@@ -106,9 +126,56 @@ __export(cpmm_exports, {
106
126
  fetchUserPositions: () => fetchUserPositions,
107
127
  filterActivePositions: () => filterActivePositions,
108
128
  filterPoolsByMint: () => filterPoolsByMint,
129
+ getAddLiquidityDiscriminatorBytes: () => getAddLiquidityDiscriminatorBytes,
130
+ getAddLiquidityInstruction: () => getAddLiquidityInstruction,
131
+ getAddLiquidityInstructionAsync: () => getAddLiquidityInstructionAsync,
132
+ getAddLiquidityInstructionDataCodec: () => getAddLiquidityInstructionDataCodec,
133
+ getAddLiquidityInstructionDataDecoder: () => getAddLiquidityInstructionDataDecoder,
134
+ getAddLiquidityInstructionDataEncoder: () => getAddLiquidityInstructionDataEncoder,
109
135
  getAddLiquidityQuote: () => getAddLiquidityQuote,
136
+ getClosePositionDiscriminatorBytes: () => getClosePositionDiscriminatorBytes,
137
+ getClosePositionInstruction: () => getClosePositionInstruction,
138
+ getClosePositionInstructionDataCodec: () => getClosePositionInstructionDataCodec,
139
+ getClosePositionInstructionDataDecoder: () => getClosePositionInstructionDataDecoder,
140
+ getClosePositionInstructionDataEncoder: () => getClosePositionInstructionDataEncoder,
141
+ getCollectFeesDiscriminatorBytes: () => getCollectFeesDiscriminatorBytes,
142
+ getCollectFeesInstruction: () => getCollectFeesInstruction,
143
+ getCollectFeesInstructionAsync: () => getCollectFeesInstructionAsync,
144
+ getCollectFeesInstructionDataCodec: () => getCollectFeesInstructionDataCodec,
145
+ getCollectFeesInstructionDataDecoder: () => getCollectFeesInstructionDataDecoder,
146
+ getCollectFeesInstructionDataEncoder: () => getCollectFeesInstructionDataEncoder,
147
+ getCollectProtocolFeesDiscriminatorBytes: () => getCollectProtocolFeesDiscriminatorBytes,
148
+ getCollectProtocolFeesInstruction: () => getCollectProtocolFeesInstruction,
149
+ getCollectProtocolFeesInstructionAsync: () => getCollectProtocolFeesInstructionAsync,
150
+ getCollectProtocolFeesInstructionDataCodec: () => getCollectProtocolFeesInstructionDataCodec,
151
+ getCollectProtocolFeesInstructionDataDecoder: () => getCollectProtocolFeesInstructionDataDecoder,
152
+ getCollectProtocolFeesInstructionDataEncoder: () => getCollectProtocolFeesInstructionDataEncoder,
110
153
  getConfigAddress: () => getConfigAddress,
154
+ getCreatePositionDiscriminatorBytes: () => getCreatePositionDiscriminatorBytes,
155
+ getCreatePositionInstruction: () => getCreatePositionInstruction,
156
+ getCreatePositionInstructionAsync: () => getCreatePositionInstructionAsync,
157
+ getCreatePositionInstructionDataCodec: () => getCreatePositionInstructionDataCodec,
158
+ getCreatePositionInstructionDataDecoder: () => getCreatePositionInstructionDataDecoder,
159
+ getCreatePositionInstructionDataEncoder: () => getCreatePositionInstructionDataEncoder,
111
160
  getErrorMessage: () => getErrorMessage,
161
+ getInitializeConfigDiscriminatorBytes: () => getInitializeConfigDiscriminatorBytes,
162
+ getInitializeConfigInstruction: () => getInitializeConfigInstruction,
163
+ getInitializeConfigInstructionAsync: () => getInitializeConfigInstructionAsync,
164
+ getInitializeConfigInstructionDataCodec: () => getInitializeConfigInstructionDataCodec,
165
+ getInitializeConfigInstructionDataDecoder: () => getInitializeConfigInstructionDataDecoder,
166
+ getInitializeConfigInstructionDataEncoder: () => getInitializeConfigInstructionDataEncoder,
167
+ getInitializeOracleDiscriminatorBytes: () => getInitializeOracleDiscriminatorBytes,
168
+ getInitializeOracleInstruction: () => getInitializeOracleInstruction,
169
+ getInitializeOracleInstructionAsync: () => getInitializeOracleInstructionAsync,
170
+ getInitializeOracleInstructionDataCodec: () => getInitializeOracleInstructionDataCodec,
171
+ getInitializeOracleInstructionDataDecoder: () => getInitializeOracleInstructionDataDecoder,
172
+ getInitializeOracleInstructionDataEncoder: () => getInitializeOracleInstructionDataEncoder,
173
+ getInitializePoolDiscriminatorBytes: () => getInitializePoolDiscriminatorBytes,
174
+ getInitializePoolInstruction: () => getInitializePoolInstruction,
175
+ getInitializePoolInstructionAsync: () => getInitializePoolInstructionAsync,
176
+ getInitializePoolInstructionDataCodec: () => getInitializePoolInstructionDataCodec,
177
+ getInitializePoolInstructionDataDecoder: () => getInitializePoolInstructionDataDecoder,
178
+ getInitializePoolInstructionDataEncoder: () => getInitializePoolInstructionDataEncoder,
112
179
  getK: () => getK,
113
180
  getLiquidityAddresses: () => getLiquidityAddresses,
114
181
  getMetadataAddress: () => getMetadataAddress,
@@ -116,9 +183,26 @@ __export(cpmm_exports, {
116
183
  getOracleAddressFromPool: () => getOracleAddressFromPool,
117
184
  getOracleAge: () => getOracleAge,
118
185
  getOracleBufferStats: () => getOracleBufferStats,
186
+ getOracleConsultDiscriminatorBytes: () => getOracleConsultDiscriminatorBytes,
187
+ getOracleConsultInstruction: () => getOracleConsultInstruction,
188
+ getOracleConsultInstructionAsync: () => getOracleConsultInstructionAsync,
189
+ getOracleConsultInstructionDataCodec: () => getOracleConsultInstructionDataCodec,
190
+ getOracleConsultInstructionDataDecoder: () => getOracleConsultInstructionDataDecoder,
191
+ getOracleConsultInstructionDataEncoder: () => getOracleConsultInstructionDataEncoder,
119
192
  getOracleDeviation: () => getOracleDeviation,
120
193
  getOracleForPool: () => getOracleForPool,
121
194
  getOracleSpotPrices: () => getOracleSpotPrices,
195
+ getOracleUpdateDiscriminatorBytes: () => getOracleUpdateDiscriminatorBytes,
196
+ getOracleUpdateInstruction: () => getOracleUpdateInstruction,
197
+ getOracleUpdateInstructionAsync: () => getOracleUpdateInstructionAsync,
198
+ getOracleUpdateInstructionDataCodec: () => getOracleUpdateInstructionDataCodec,
199
+ getOracleUpdateInstructionDataDecoder: () => getOracleUpdateInstructionDataDecoder,
200
+ getOracleUpdateInstructionDataEncoder: () => getOracleUpdateInstructionDataEncoder,
201
+ getPauseDiscriminatorBytes: () => getPauseDiscriminatorBytes,
202
+ getPauseInstruction: () => getPauseInstruction,
203
+ getPauseInstructionDataCodec: () => getPauseInstructionDataCodec,
204
+ getPauseInstructionDataDecoder: () => getPauseInstructionDataDecoder,
205
+ getPauseInstructionDataEncoder: () => getPauseInstructionDataEncoder,
122
206
  getPendingFees: () => getPendingFees,
123
207
  getPoolAddress: () => getPoolAddress,
124
208
  getPoolAddressFromMints: () => getPoolAddressFromMints,
@@ -130,14 +214,72 @@ __export(cpmm_exports, {
130
214
  getPositionAddress: () => getPositionAddress,
131
215
  getPositionAddressFromParams: () => getPositionAddressFromParams,
132
216
  getPositionValue: () => getPositionValue,
217
+ getPreviewSwapExactInDiscriminatorBytes: () => getPreviewSwapExactInDiscriminatorBytes,
218
+ getPreviewSwapExactInInstruction: () => getPreviewSwapExactInInstruction,
219
+ getPreviewSwapExactInInstructionDataCodec: () => getPreviewSwapExactInInstructionDataCodec,
220
+ getPreviewSwapExactInInstructionDataDecoder: () => getPreviewSwapExactInInstructionDataDecoder,
221
+ getPreviewSwapExactInInstructionDataEncoder: () => getPreviewSwapExactInInstructionDataEncoder,
133
222
  getProtocolPositionAddress: () => getProtocolPositionAddress,
223
+ getQuoteToNumeraireDiscriminatorBytes: () => getQuoteToNumeraireDiscriminatorBytes,
224
+ getQuoteToNumeraireInstruction: () => getQuoteToNumeraireInstruction,
225
+ getQuoteToNumeraireInstructionDataCodec: () => getQuoteToNumeraireInstructionDataCodec,
226
+ getQuoteToNumeraireInstructionDataDecoder: () => getQuoteToNumeraireInstructionDataDecoder,
227
+ getQuoteToNumeraireInstructionDataEncoder: () => getQuoteToNumeraireInstructionDataEncoder,
228
+ getRemoveLiquidityDiscriminatorBytes: () => getRemoveLiquidityDiscriminatorBytes,
229
+ getRemoveLiquidityInstruction: () => getRemoveLiquidityInstruction,
230
+ getRemoveLiquidityInstructionAsync: () => getRemoveLiquidityInstructionAsync,
231
+ getRemoveLiquidityInstructionDataCodec: () => getRemoveLiquidityInstructionDataCodec,
232
+ getRemoveLiquidityInstructionDataDecoder: () => getRemoveLiquidityInstructionDataDecoder,
233
+ getRemoveLiquidityInstructionDataEncoder: () => getRemoveLiquidityInstructionDataEncoder,
134
234
  getRemoveLiquidityQuote: () => getRemoveLiquidityQuote,
235
+ getSetFeesDiscriminatorBytes: () => getSetFeesDiscriminatorBytes,
236
+ getSetFeesInstruction: () => getSetFeesInstruction,
237
+ getSetFeesInstructionDataCodec: () => getSetFeesInstructionDataCodec,
238
+ getSetFeesInstructionDataDecoder: () => getSetFeesInstructionDataDecoder,
239
+ getSetFeesInstructionDataEncoder: () => getSetFeesInstructionDataEncoder,
240
+ getSetRouteDiscriminatorBytes: () => getSetRouteDiscriminatorBytes,
241
+ getSetRouteInstruction: () => getSetRouteInstruction,
242
+ getSetRouteInstructionDataCodec: () => getSetRouteInstructionDataCodec,
243
+ getSetRouteInstructionDataDecoder: () => getSetRouteInstructionDataDecoder,
244
+ getSetRouteInstructionDataEncoder: () => getSetRouteInstructionDataEncoder,
245
+ getSetSentinelDiscriminatorBytes: () => getSetSentinelDiscriminatorBytes,
246
+ getSetSentinelInstruction: () => getSetSentinelInstruction,
247
+ getSetSentinelInstructionDataCodec: () => getSetSentinelInstructionDataCodec,
248
+ getSetSentinelInstructionDataDecoder: () => getSetSentinelInstructionDataDecoder,
249
+ getSetSentinelInstructionDataEncoder: () => getSetSentinelInstructionDataEncoder,
250
+ getSkimDiscriminatorBytes: () => getSkimDiscriminatorBytes,
251
+ getSkimInstruction: () => getSkimInstruction,
252
+ getSkimInstructionAsync: () => getSkimInstructionAsync,
253
+ getSkimInstructionDataCodec: () => getSkimInstructionDataCodec,
254
+ getSkimInstructionDataDecoder: () => getSkimInstructionDataDecoder,
255
+ getSkimInstructionDataEncoder: () => getSkimInstructionDataEncoder,
135
256
  getSpotPrice0: () => getSpotPrice0,
136
257
  getSpotPrice1: () => getSpotPrice1,
137
258
  getSwapAddresses: () => getSwapAddresses,
259
+ getSwapExactInDiscriminatorBytes: () => getSwapExactInDiscriminatorBytes,
260
+ getSwapExactInInstruction: () => getSwapExactInInstruction,
261
+ getSwapExactInInstructionAsync: () => getSwapExactInInstructionAsync,
262
+ getSwapExactInInstructionDataCodec: () => getSwapExactInInstructionDataCodec,
263
+ getSwapExactInInstructionDataDecoder: () => getSwapExactInInstructionDataDecoder,
264
+ getSwapExactInInstructionDataEncoder: () => getSwapExactInInstructionDataEncoder,
138
265
  getSwapQuote: () => getSwapQuote,
139
266
  getSwapQuoteExactOut: () => getSwapQuoteExactOut,
267
+ getTransferAdminDiscriminatorBytes: () => getTransferAdminDiscriminatorBytes,
268
+ getTransferAdminInstruction: () => getTransferAdminInstruction,
269
+ getTransferAdminInstructionDataCodec: () => getTransferAdminInstructionDataCodec,
270
+ getTransferAdminInstructionDataDecoder: () => getTransferAdminInstructionDataDecoder,
271
+ getTransferAdminInstructionDataEncoder: () => getTransferAdminInstructionDataEncoder,
140
272
  getTvl: () => getTvl,
273
+ getUnpauseDiscriminatorBytes: () => getUnpauseDiscriminatorBytes,
274
+ getUnpauseInstruction: () => getUnpauseInstruction,
275
+ getUnpauseInstructionDataCodec: () => getUnpauseInstructionDataCodec,
276
+ getUnpauseInstructionDataDecoder: () => getUnpauseInstructionDataDecoder,
277
+ getUnpauseInstructionDataEncoder: () => getUnpauseInstructionDataEncoder,
278
+ getUpdateConfigDiscriminatorBytes: () => getUpdateConfigDiscriminatorBytes,
279
+ getUpdateConfigInstruction: () => getUpdateConfigInstruction,
280
+ getUpdateConfigInstructionDataCodec: () => getUpdateConfigInstructionDataCodec,
281
+ getUpdateConfigInstructionDataDecoder: () => getUpdateConfigInstructionDataDecoder,
282
+ getUpdateConfigInstructionDataEncoder: () => getUpdateConfigInstructionDataEncoder,
141
283
  initializeConfigArgsCodec: () => initializeConfigArgsCodec,
142
284
  initializeOracleArgsCodec: () => initializeOracleArgsCodec,
143
285
  initializePoolArgsCodec: () => initializePoolArgsCodec,
@@ -153,7 +295,29 @@ __export(cpmm_exports, {
153
295
  observationCodec: () => observationCodec,
154
296
  oracleConsultArgsCodec: () => oracleConsultArgsCodec,
155
297
  oracleStateDataCodec: () => oracleStateDataCodec,
298
+ parseAddLiquidityInstruction: () => parseAddLiquidityInstruction,
299
+ parseClosePositionInstruction: () => parseClosePositionInstruction,
300
+ parseCollectFeesInstruction: () => parseCollectFeesInstruction,
301
+ parseCollectProtocolFeesInstruction: () => parseCollectProtocolFeesInstruction,
302
+ parseCreatePositionInstruction: () => parseCreatePositionInstruction,
156
303
  parseErrorFromLogs: () => parseErrorFromLogs,
304
+ parseInitializeConfigInstruction: () => parseInitializeConfigInstruction,
305
+ parseInitializeOracleInstruction: () => parseInitializeOracleInstruction,
306
+ parseInitializePoolInstruction: () => parseInitializePoolInstruction,
307
+ parseOracleConsultInstruction: () => parseOracleConsultInstruction,
308
+ parseOracleUpdateInstruction: () => parseOracleUpdateInstruction,
309
+ parsePauseInstruction: () => parsePauseInstruction,
310
+ parsePreviewSwapExactInInstruction: () => parsePreviewSwapExactInInstruction,
311
+ parseQuoteToNumeraireInstruction: () => parseQuoteToNumeraireInstruction,
312
+ parseRemoveLiquidityInstruction: () => parseRemoveLiquidityInstruction,
313
+ parseSetFeesInstruction: () => parseSetFeesInstruction,
314
+ parseSetRouteInstruction: () => parseSetRouteInstruction,
315
+ parseSetSentinelInstruction: () => parseSetSentinelInstruction,
316
+ parseSkimInstruction: () => parseSkimInstruction,
317
+ parseSwapExactInInstruction: () => parseSwapExactInInstruction,
318
+ parseTransferAdminInstruction: () => parseTransferAdminInstruction,
319
+ parseUnpauseInstruction: () => parseUnpauseInstruction,
320
+ parseUpdateConfigInstruction: () => parseUpdateConfigInstruction,
157
321
  poolDataCodec: () => poolDataCodec,
158
322
  poolExists: () => poolExists,
159
323
  positionDataCodec: () => positionDataCodec,
@@ -468,297 +632,2858 @@ function getErrorMessage(code) {
468
632
  }
469
633
  return `Unknown error code: ${code}`;
470
634
  }
471
- function createInitializeConfigInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
472
- const { config, payer, systemProgram = SYSTEM_PROGRAM_ADDRESS } = accounts;
473
- const keys = [
474
- { address: config, role: AccountRole.WRITABLE },
475
- { address: payer, role: AccountRole.WRITABLE_SIGNER },
476
- { address: systemProgram, role: AccountRole.READONLY }
477
- ];
478
- const data = encodeInstructionData(
479
- INSTRUCTION_DISCRIMINATORS.initializeConfig,
480
- initializeConfigArgsCodec,
481
- args
635
+
636
+ // src/solana/generated/cpmm/programs/cpmm.ts
637
+ var CPMM_PROGRAM_ADDRESS = "9PSxVPoPfnbZ8Q1uQhgS6ZxvBjFboZtebNsu34umxkgQ";
638
+
639
+ // src/solana/generated/cpmm/instructions/addLiquidity.ts
640
+ var ADD_LIQUIDITY_DISCRIMINATOR = new Uint8Array([
641
+ 181,
642
+ 157,
643
+ 89,
644
+ 67,
645
+ 143,
646
+ 182,
647
+ 52,
648
+ 72
649
+ ]);
650
+ function getAddLiquidityDiscriminatorBytes() {
651
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
652
+ ADD_LIQUIDITY_DISCRIMINATOR
482
653
  );
483
- return {
484
- programAddress: programId,
485
- accounts: keys,
486
- data
487
- };
488
654
  }
489
- function isTransactionSigner(value) {
490
- return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
655
+ function getAddLiquidityInstructionDataEncoder() {
656
+ return transformEncoder(
657
+ getStructEncoder([
658
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
659
+ ["amount0Max", getU64Encoder()],
660
+ ["amount1Max", getU64Encoder()],
661
+ ["minSharesOut", getU128Encoder()],
662
+ ["updateOracle", getBooleanEncoder()]
663
+ ]),
664
+ (value) => ({ ...value, discriminator: ADD_LIQUIDITY_DISCRIMINATOR })
665
+ );
491
666
  }
492
- function createSignerAccountMeta(value, role) {
493
- if (isTransactionSigner(value)) {
494
- return {
495
- address: value.address,
496
- role,
497
- signer: value
498
- };
499
- }
500
- return { address: value, role };
667
+ function getAddLiquidityInstructionDataDecoder() {
668
+ return getStructDecoder([
669
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
670
+ ["amount0Max", getU64Decoder()],
671
+ ["amount1Max", getU64Decoder()],
672
+ ["minSharesOut", getU128Decoder()],
673
+ ["updateOracle", getBooleanDecoder()]
674
+ ]);
501
675
  }
502
- function createInitializePoolInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
503
- const {
504
- config,
505
- pool,
506
- protocolPosition,
507
- authority,
508
- vault0,
509
- vault1,
510
- token0Mint,
511
- token1Mint,
512
- payer,
513
- token0Program,
514
- token1Program,
515
- tokenProgram = TOKEN_PROGRAM_ADDRESS,
516
- systemProgram = SYSTEM_PROGRAM_ADDRESS,
517
- rent,
518
- migrationAuthority
519
- } = accounts;
520
- const resolvedToken0Program = token0Program ?? tokenProgram;
521
- const resolvedToken1Program = token1Program ?? tokenProgram;
522
- const keys = [
523
- { address: config, role: AccountRole.READONLY },
524
- { address: pool, role: AccountRole.WRITABLE },
525
- { address: protocolPosition, role: AccountRole.WRITABLE },
526
- { address: authority, role: AccountRole.READONLY },
527
- { address: vault0, role: AccountRole.WRITABLE },
528
- { address: vault1, role: AccountRole.WRITABLE },
529
- { address: token0Mint, role: AccountRole.READONLY },
530
- { address: token1Mint, role: AccountRole.READONLY },
531
- createSignerAccountMeta(payer, AccountRole.WRITABLE_SIGNER),
532
- { address: resolvedToken0Program, role: AccountRole.READONLY },
533
- { address: resolvedToken1Program, role: AccountRole.READONLY },
534
- { address: systemProgram, role: AccountRole.READONLY },
535
- { address: rent, role: AccountRole.READONLY },
536
- createSignerAccountMeta(migrationAuthority, AccountRole.READONLY_SIGNER)
537
- ];
538
- const data = encodeInstructionData(
539
- INSTRUCTION_DISCRIMINATORS.initializePool,
540
- initializePoolArgsCodec,
541
- args
676
+ function getAddLiquidityInstructionDataCodec() {
677
+ return combineCodec(
678
+ getAddLiquidityInstructionDataEncoder(),
679
+ getAddLiquidityInstructionDataDecoder()
542
680
  );
543
- return {
544
- programAddress: programId,
545
- accounts: keys,
546
- data
681
+ }
682
+ async function getAddLiquidityInstructionAsync(input, config) {
683
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
684
+ const originalAccounts = {
685
+ config: { value: input.config ?? null, isWritable: false },
686
+ pool: { value: input.pool ?? null, isWritable: true },
687
+ position: { value: input.position ?? null, isWritable: true },
688
+ protocolPosition: {
689
+ value: input.protocolPosition ?? null,
690
+ isWritable: true
691
+ },
692
+ owner: { value: input.owner ?? null, isWritable: false },
693
+ authority: { value: input.authority ?? null, isWritable: false },
694
+ vault0: { value: input.vault0 ?? null, isWritable: true },
695
+ vault1: { value: input.vault1 ?? null, isWritable: true },
696
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
697
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
698
+ user0: { value: input.user0 ?? null, isWritable: true },
699
+ user1: { value: input.user1 ?? null, isWritable: true },
700
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
701
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
702
+ oracle: { value: input.oracle ?? null, isWritable: true }
547
703
  };
704
+ const accounts = originalAccounts;
705
+ const args = { ...input };
706
+ if (!accounts.authority.value) {
707
+ accounts.authority.value = await getProgramDerivedAddress({
708
+ programAddress,
709
+ seeds: [
710
+ getBytesEncoder().encode(
711
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
712
+ ),
713
+ getAddressEncoder().encode(
714
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
715
+ )
716
+ ]
717
+ });
718
+ }
719
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
720
+ return Object.freeze({
721
+ accounts: [
722
+ getAccountMeta("config", accounts.config),
723
+ getAccountMeta("pool", accounts.pool),
724
+ getAccountMeta("position", accounts.position),
725
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
726
+ getAccountMeta("owner", accounts.owner),
727
+ getAccountMeta("authority", accounts.authority),
728
+ getAccountMeta("vault0", accounts.vault0),
729
+ getAccountMeta("vault1", accounts.vault1),
730
+ getAccountMeta("token0Mint", accounts.token0Mint),
731
+ getAccountMeta("token1Mint", accounts.token1Mint),
732
+ getAccountMeta("user0", accounts.user0),
733
+ getAccountMeta("user1", accounts.user1),
734
+ getAccountMeta("token0Program", accounts.token0Program),
735
+ getAccountMeta("token1Program", accounts.token1Program),
736
+ getAccountMeta("oracle", accounts.oracle)
737
+ ],
738
+ data: getAddLiquidityInstructionDataEncoder().encode(
739
+ args
740
+ ),
741
+ programAddress
742
+ });
548
743
  }
549
- function createInitializeOracleInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
550
- const {
551
- config,
552
- pool,
553
- oracle,
554
- admin,
555
- payer,
556
- systemProgram = SYSTEM_PROGRAM_ADDRESS
557
- } = accounts;
558
- const keys = [
559
- { address: config, role: AccountRole.READONLY },
560
- { address: pool, role: AccountRole.READONLY },
561
- { address: oracle, role: AccountRole.WRITABLE },
562
- { address: admin, role: AccountRole.READONLY_SIGNER },
563
- { address: payer, role: AccountRole.WRITABLE_SIGNER },
564
- { address: systemProgram, role: AccountRole.READONLY }
565
- ];
566
- const data = encodeInstructionData(
567
- INSTRUCTION_DISCRIMINATORS.initializeOracle,
568
- initializeOracleArgsCodec,
569
- args
570
- );
571
- return {
572
- programAddress: programId,
573
- accounts: keys,
574
- data
744
+ function getAddLiquidityInstruction(input, config) {
745
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
746
+ const originalAccounts = {
747
+ config: { value: input.config ?? null, isWritable: false },
748
+ pool: { value: input.pool ?? null, isWritable: true },
749
+ position: { value: input.position ?? null, isWritable: true },
750
+ protocolPosition: {
751
+ value: input.protocolPosition ?? null,
752
+ isWritable: true
753
+ },
754
+ owner: { value: input.owner ?? null, isWritable: false },
755
+ authority: { value: input.authority ?? null, isWritable: false },
756
+ vault0: { value: input.vault0 ?? null, isWritable: true },
757
+ vault1: { value: input.vault1 ?? null, isWritable: true },
758
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
759
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
760
+ user0: { value: input.user0 ?? null, isWritable: true },
761
+ user1: { value: input.user1 ?? null, isWritable: true },
762
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
763
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
764
+ oracle: { value: input.oracle ?? null, isWritable: true }
575
765
  };
766
+ const accounts = originalAccounts;
767
+ const args = { ...input };
768
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
769
+ return Object.freeze({
770
+ accounts: [
771
+ getAccountMeta("config", accounts.config),
772
+ getAccountMeta("pool", accounts.pool),
773
+ getAccountMeta("position", accounts.position),
774
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
775
+ getAccountMeta("owner", accounts.owner),
776
+ getAccountMeta("authority", accounts.authority),
777
+ getAccountMeta("vault0", accounts.vault0),
778
+ getAccountMeta("vault1", accounts.vault1),
779
+ getAccountMeta("token0Mint", accounts.token0Mint),
780
+ getAccountMeta("token1Mint", accounts.token1Mint),
781
+ getAccountMeta("user0", accounts.user0),
782
+ getAccountMeta("user1", accounts.user1),
783
+ getAccountMeta("token0Program", accounts.token0Program),
784
+ getAccountMeta("token1Program", accounts.token1Program),
785
+ getAccountMeta("oracle", accounts.oracle)
786
+ ],
787
+ data: getAddLiquidityInstructionDataEncoder().encode(
788
+ args
789
+ ),
790
+ programAddress
791
+ });
576
792
  }
577
- function createSetFeesInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
578
- const { config, pool, admin } = accounts;
579
- const keys = [
580
- { address: config, role: AccountRole.READONLY },
581
- { address: pool, role: AccountRole.WRITABLE },
582
- { address: admin, role: AccountRole.READONLY_SIGNER }
583
- ];
584
- const data = encodeInstructionData(
585
- INSTRUCTION_DISCRIMINATORS.setFees,
586
- setFeesArgsCodec,
587
- args
588
- );
793
+ function parseAddLiquidityInstruction(instruction) {
794
+ if (instruction.accounts.length < 15) {
795
+ throw new SolanaError(
796
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
797
+ {
798
+ actualAccountMetas: instruction.accounts.length,
799
+ expectedAccountMetas: 15
800
+ }
801
+ );
802
+ }
803
+ let accountIndex = 0;
804
+ const getNextAccount = () => {
805
+ const accountMeta = instruction.accounts[accountIndex];
806
+ accountIndex += 1;
807
+ return accountMeta;
808
+ };
809
+ const getNextOptionalAccount = () => {
810
+ const accountMeta = getNextAccount();
811
+ return accountMeta.address === CPMM_PROGRAM_ADDRESS ? void 0 : accountMeta;
812
+ };
589
813
  return {
590
- programAddress: programId,
591
- accounts: keys,
592
- data
814
+ programAddress: instruction.programAddress,
815
+ accounts: {
816
+ config: getNextAccount(),
817
+ pool: getNextAccount(),
818
+ position: getNextAccount(),
819
+ protocolPosition: getNextAccount(),
820
+ owner: getNextAccount(),
821
+ authority: getNextAccount(),
822
+ vault0: getNextAccount(),
823
+ vault1: getNextAccount(),
824
+ token0Mint: getNextAccount(),
825
+ token1Mint: getNextAccount(),
826
+ user0: getNextAccount(),
827
+ user1: getNextAccount(),
828
+ token0Program: getNextAccount(),
829
+ token1Program: getNextAccount(),
830
+ oracle: getNextOptionalAccount()
831
+ },
832
+ data: getAddLiquidityInstructionDataDecoder().decode(instruction.data)
593
833
  };
594
834
  }
595
- function createSetSentinelInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
596
- const { config, pool, admin } = accounts;
597
- const keys = [
598
- { address: config, role: AccountRole.READONLY },
599
- { address: pool, role: AccountRole.WRITABLE },
600
- { address: admin, role: AccountRole.READONLY_SIGNER }
601
- ];
602
- const data = encodeInstructionData(
603
- INSTRUCTION_DISCRIMINATORS.setSentinel,
604
- setSentinelArgsCodec,
605
- args
835
+ var CLOSE_POSITION_DISCRIMINATOR = new Uint8Array([
836
+ 123,
837
+ 134,
838
+ 81,
839
+ 0,
840
+ 49,
841
+ 68,
842
+ 98,
843
+ 98
844
+ ]);
845
+ function getClosePositionDiscriminatorBytes() {
846
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
847
+ CLOSE_POSITION_DISCRIMINATOR
606
848
  );
607
- return {
608
- programAddress: programId,
609
- accounts: keys,
610
- data
611
- };
612
849
  }
613
- function createSetRouteInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
614
- const { config, pool, nextPool, admin } = accounts;
615
- const keys = [
616
- { address: config, role: AccountRole.READONLY },
617
- { address: pool, role: AccountRole.WRITABLE }
618
- ];
619
- if (nextPool) {
620
- keys.push({ address: nextPool, role: AccountRole.READONLY });
621
- }
622
- keys.push({ address: admin, role: AccountRole.READONLY_SIGNER });
623
- const data = encodeInstructionData(
624
- INSTRUCTION_DISCRIMINATORS.setRoute,
625
- setRouteArgsCodec,
626
- args
850
+ function getClosePositionInstructionDataEncoder() {
851
+ return transformEncoder(
852
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
853
+ (value) => ({ ...value, discriminator: CLOSE_POSITION_DISCRIMINATOR })
627
854
  );
628
- return {
629
- programAddress: programId,
630
- accounts: keys,
631
- data
632
- };
633
855
  }
634
- function createPauseInstruction(accounts, programId = CPMM_PROGRAM_ID) {
635
- const { config, admin } = accounts;
636
- const keys = [
637
- { address: config, role: AccountRole.WRITABLE },
638
- { address: admin, role: AccountRole.READONLY_SIGNER }
639
- ];
640
- const data = INSTRUCTION_DISCRIMINATORS.pause;
641
- return {
642
- programAddress: programId,
643
- accounts: keys,
644
- data
856
+ function getClosePositionInstructionDataDecoder() {
857
+ return getStructDecoder([
858
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)]
859
+ ]);
860
+ }
861
+ function getClosePositionInstructionDataCodec() {
862
+ return combineCodec(
863
+ getClosePositionInstructionDataEncoder(),
864
+ getClosePositionInstructionDataDecoder()
865
+ );
866
+ }
867
+ function getClosePositionInstruction(input, config) {
868
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
869
+ const originalAccounts = {
870
+ pool: { value: input.pool ?? null, isWritable: false },
871
+ position: { value: input.position ?? null, isWritable: true },
872
+ owner: { value: input.owner ?? null, isWritable: false },
873
+ rentRecipient: { value: input.rentRecipient ?? null, isWritable: true }
645
874
  };
875
+ const accounts = originalAccounts;
876
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
877
+ return Object.freeze({
878
+ accounts: [
879
+ getAccountMeta("pool", accounts.pool),
880
+ getAccountMeta("position", accounts.position),
881
+ getAccountMeta("owner", accounts.owner),
882
+ getAccountMeta("rentRecipient", accounts.rentRecipient)
883
+ ],
884
+ data: getClosePositionInstructionDataEncoder().encode({}),
885
+ programAddress
886
+ });
646
887
  }
647
- function createUnpauseInstruction(accounts, programId = CPMM_PROGRAM_ID) {
648
- const { config, admin } = accounts;
649
- const keys = [
650
- { address: config, role: AccountRole.WRITABLE },
651
- { address: admin, role: AccountRole.READONLY_SIGNER }
652
- ];
653
- const data = INSTRUCTION_DISCRIMINATORS.unpause;
888
+ function parseClosePositionInstruction(instruction) {
889
+ if (instruction.accounts.length < 4) {
890
+ throw new SolanaError(
891
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
892
+ {
893
+ actualAccountMetas: instruction.accounts.length,
894
+ expectedAccountMetas: 4
895
+ }
896
+ );
897
+ }
898
+ let accountIndex = 0;
899
+ const getNextAccount = () => {
900
+ const accountMeta = instruction.accounts[accountIndex];
901
+ accountIndex += 1;
902
+ return accountMeta;
903
+ };
654
904
  return {
655
- programAddress: programId,
656
- accounts: keys,
657
- data
905
+ programAddress: instruction.programAddress,
906
+ accounts: {
907
+ pool: getNextAccount(),
908
+ position: getNextAccount(),
909
+ owner: getNextAccount(),
910
+ rentRecipient: getNextAccount()
911
+ },
912
+ data: getClosePositionInstructionDataDecoder().decode(instruction.data)
658
913
  };
659
914
  }
660
- function createTransferAdminInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
661
- const { config, admin } = accounts;
662
- const keys = [
663
- { address: config, role: AccountRole.WRITABLE },
664
- { address: admin, role: AccountRole.READONLY_SIGNER }
665
- ];
666
- const data = encodeInstructionData(
667
- INSTRUCTION_DISCRIMINATORS.transferAdmin,
668
- transferAdminArgsCodec,
669
- args
915
+ var COLLECT_FEES_DISCRIMINATOR = new Uint8Array([
916
+ 164,
917
+ 152,
918
+ 207,
919
+ 99,
920
+ 30,
921
+ 186,
922
+ 19,
923
+ 182
924
+ ]);
925
+ function getCollectFeesDiscriminatorBytes() {
926
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
927
+ COLLECT_FEES_DISCRIMINATOR
670
928
  );
671
- return {
672
- programAddress: programId,
673
- accounts: keys,
674
- data
675
- };
676
929
  }
677
- function createSkimInstruction(accounts, programId = CPMM_PROGRAM_ID) {
678
- const {
679
- config,
680
- pool,
681
- admin,
682
- authority,
683
- vault0,
684
- vault1,
685
- token0Mint,
686
- token1Mint,
687
- adminAta0,
688
- adminAta1,
689
- tokenProgram = TOKEN_PROGRAM_ADDRESS
690
- } = accounts;
691
- const keys = [
692
- { address: config, role: AccountRole.READONLY },
693
- { address: pool, role: AccountRole.READONLY },
694
- { address: admin, role: AccountRole.READONLY_SIGNER },
695
- { address: authority, role: AccountRole.READONLY },
696
- { address: vault0, role: AccountRole.WRITABLE },
697
- { address: vault1, role: AccountRole.WRITABLE },
698
- { address: token0Mint, role: AccountRole.READONLY },
699
- { address: token1Mint, role: AccountRole.READONLY },
700
- { address: adminAta0, role: AccountRole.WRITABLE },
701
- { address: adminAta1, role: AccountRole.WRITABLE },
702
- { address: tokenProgram, role: AccountRole.READONLY }
703
- ];
704
- const data = INSTRUCTION_DISCRIMINATORS.skim;
705
- return {
706
- programAddress: programId,
707
- accounts: keys,
708
- data
709
- };
930
+ function getCollectFeesInstructionDataEncoder() {
931
+ return transformEncoder(
932
+ getStructEncoder([
933
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
934
+ ["max0", getU64Encoder()],
935
+ ["max1", getU64Encoder()]
936
+ ]),
937
+ (value) => ({ ...value, discriminator: COLLECT_FEES_DISCRIMINATOR })
938
+ );
710
939
  }
711
- function createSwapExactInInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
712
- const {
713
- config,
714
- pool,
715
- authority,
716
- vaultIn,
717
- vaultOut,
718
- token0Mint,
719
- token1Mint,
720
- userIn,
721
- userOut,
722
- user,
723
- token0Program,
724
- token1Program,
725
- tokenProgram = TOKEN_PROGRAM_ADDRESS,
726
- instructionsSysvar = SYSVAR_INSTRUCTIONS_ADDRESS,
727
- oracle,
728
- remainingAccounts = []
729
- } = accounts;
730
- const resolvedToken0Program = token0Program ?? tokenProgram;
731
- const resolvedToken1Program = token1Program ?? tokenProgram;
732
- const keys = [
733
- { address: config, role: AccountRole.READONLY },
734
- { address: pool, role: AccountRole.WRITABLE },
735
- { address: authority, role: AccountRole.READONLY },
736
- { address: vaultIn, role: AccountRole.WRITABLE },
737
- { address: vaultOut, role: AccountRole.WRITABLE },
738
- { address: token0Mint, role: AccountRole.READONLY },
739
- { address: token1Mint, role: AccountRole.READONLY },
740
- { address: userIn, role: AccountRole.WRITABLE },
741
- { address: userOut, role: AccountRole.WRITABLE },
742
- { address: user, role: AccountRole.READONLY_SIGNER },
743
- { address: resolvedToken0Program, role: AccountRole.READONLY },
744
- { address: resolvedToken1Program, role: AccountRole.READONLY },
745
- { address: instructionsSysvar, role: AccountRole.READONLY }
746
- ];
747
- if (oracle) {
748
- keys.push({ address: oracle, role: AccountRole.WRITABLE });
749
- }
750
- for (const account of remainingAccounts) {
751
- keys.push({ address: account, role: AccountRole.READONLY });
940
+ function getCollectFeesInstructionDataDecoder() {
941
+ return getStructDecoder([
942
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
943
+ ["max0", getU64Decoder()],
944
+ ["max1", getU64Decoder()]
945
+ ]);
946
+ }
947
+ function getCollectFeesInstructionDataCodec() {
948
+ return combineCodec(
949
+ getCollectFeesInstructionDataEncoder(),
950
+ getCollectFeesInstructionDataDecoder()
951
+ );
952
+ }
953
+ async function getCollectFeesInstructionAsync(input, config) {
954
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
955
+ const originalAccounts = {
956
+ pool: { value: input.pool ?? null, isWritable: true },
957
+ position: { value: input.position ?? null, isWritable: true },
958
+ owner: { value: input.owner ?? null, isWritable: false },
959
+ authority: { value: input.authority ?? null, isWritable: false },
960
+ vault0: { value: input.vault0 ?? null, isWritable: true },
961
+ vault1: { value: input.vault1 ?? null, isWritable: true },
962
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
963
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
964
+ user0: { value: input.user0 ?? null, isWritable: true },
965
+ user1: { value: input.user1 ?? null, isWritable: true },
966
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
967
+ token1Program: { value: input.token1Program ?? null, isWritable: false }
968
+ };
969
+ const accounts = originalAccounts;
970
+ const args = { ...input };
971
+ if (!accounts.authority.value) {
972
+ accounts.authority.value = await getProgramDerivedAddress({
973
+ programAddress,
974
+ seeds: [
975
+ getBytesEncoder().encode(
976
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
977
+ ),
978
+ getAddressEncoder().encode(
979
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
980
+ )
981
+ ]
982
+ });
983
+ }
984
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
985
+ return Object.freeze({
986
+ accounts: [
987
+ getAccountMeta("pool", accounts.pool),
988
+ getAccountMeta("position", accounts.position),
989
+ getAccountMeta("owner", accounts.owner),
990
+ getAccountMeta("authority", accounts.authority),
991
+ getAccountMeta("vault0", accounts.vault0),
992
+ getAccountMeta("vault1", accounts.vault1),
993
+ getAccountMeta("token0Mint", accounts.token0Mint),
994
+ getAccountMeta("token1Mint", accounts.token1Mint),
995
+ getAccountMeta("user0", accounts.user0),
996
+ getAccountMeta("user1", accounts.user1),
997
+ getAccountMeta("token0Program", accounts.token0Program),
998
+ getAccountMeta("token1Program", accounts.token1Program)
999
+ ],
1000
+ data: getCollectFeesInstructionDataEncoder().encode(
1001
+ args
1002
+ ),
1003
+ programAddress
1004
+ });
1005
+ }
1006
+ function getCollectFeesInstruction(input, config) {
1007
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1008
+ const originalAccounts = {
1009
+ pool: { value: input.pool ?? null, isWritable: true },
1010
+ position: { value: input.position ?? null, isWritable: true },
1011
+ owner: { value: input.owner ?? null, isWritable: false },
1012
+ authority: { value: input.authority ?? null, isWritable: false },
1013
+ vault0: { value: input.vault0 ?? null, isWritable: true },
1014
+ vault1: { value: input.vault1 ?? null, isWritable: true },
1015
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
1016
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
1017
+ user0: { value: input.user0 ?? null, isWritable: true },
1018
+ user1: { value: input.user1 ?? null, isWritable: true },
1019
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
1020
+ token1Program: { value: input.token1Program ?? null, isWritable: false }
1021
+ };
1022
+ const accounts = originalAccounts;
1023
+ const args = { ...input };
1024
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1025
+ return Object.freeze({
1026
+ accounts: [
1027
+ getAccountMeta("pool", accounts.pool),
1028
+ getAccountMeta("position", accounts.position),
1029
+ getAccountMeta("owner", accounts.owner),
1030
+ getAccountMeta("authority", accounts.authority),
1031
+ getAccountMeta("vault0", accounts.vault0),
1032
+ getAccountMeta("vault1", accounts.vault1),
1033
+ getAccountMeta("token0Mint", accounts.token0Mint),
1034
+ getAccountMeta("token1Mint", accounts.token1Mint),
1035
+ getAccountMeta("user0", accounts.user0),
1036
+ getAccountMeta("user1", accounts.user1),
1037
+ getAccountMeta("token0Program", accounts.token0Program),
1038
+ getAccountMeta("token1Program", accounts.token1Program)
1039
+ ],
1040
+ data: getCollectFeesInstructionDataEncoder().encode(
1041
+ args
1042
+ ),
1043
+ programAddress
1044
+ });
1045
+ }
1046
+ function parseCollectFeesInstruction(instruction) {
1047
+ if (instruction.accounts.length < 12) {
1048
+ throw new SolanaError(
1049
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
1050
+ {
1051
+ actualAccountMetas: instruction.accounts.length,
1052
+ expectedAccountMetas: 12
1053
+ }
1054
+ );
1055
+ }
1056
+ let accountIndex = 0;
1057
+ const getNextAccount = () => {
1058
+ const accountMeta = instruction.accounts[accountIndex];
1059
+ accountIndex += 1;
1060
+ return accountMeta;
1061
+ };
1062
+ return {
1063
+ programAddress: instruction.programAddress,
1064
+ accounts: {
1065
+ pool: getNextAccount(),
1066
+ position: getNextAccount(),
1067
+ owner: getNextAccount(),
1068
+ authority: getNextAccount(),
1069
+ vault0: getNextAccount(),
1070
+ vault1: getNextAccount(),
1071
+ token0Mint: getNextAccount(),
1072
+ token1Mint: getNextAccount(),
1073
+ user0: getNextAccount(),
1074
+ user1: getNextAccount(),
1075
+ token0Program: getNextAccount(),
1076
+ token1Program: getNextAccount()
1077
+ },
1078
+ data: getCollectFeesInstructionDataDecoder().decode(instruction.data)
1079
+ };
1080
+ }
1081
+ var COLLECT_PROTOCOL_FEES_DISCRIMINATOR = new Uint8Array([
1082
+ 22,
1083
+ 67,
1084
+ 23,
1085
+ 98,
1086
+ 150,
1087
+ 178,
1088
+ 70,
1089
+ 220
1090
+ ]);
1091
+ function getCollectProtocolFeesDiscriminatorBytes() {
1092
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
1093
+ COLLECT_PROTOCOL_FEES_DISCRIMINATOR
1094
+ );
1095
+ }
1096
+ function getCollectProtocolFeesInstructionDataEncoder() {
1097
+ return transformEncoder(
1098
+ getStructEncoder([
1099
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1100
+ ["max0", getU64Encoder()],
1101
+ ["max1", getU64Encoder()]
1102
+ ]),
1103
+ (value) => ({
1104
+ ...value,
1105
+ discriminator: COLLECT_PROTOCOL_FEES_DISCRIMINATOR
1106
+ })
1107
+ );
1108
+ }
1109
+ function getCollectProtocolFeesInstructionDataDecoder() {
1110
+ return getStructDecoder([
1111
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
1112
+ ["max0", getU64Decoder()],
1113
+ ["max1", getU64Decoder()]
1114
+ ]);
1115
+ }
1116
+ function getCollectProtocolFeesInstructionDataCodec() {
1117
+ return combineCodec(
1118
+ getCollectProtocolFeesInstructionDataEncoder(),
1119
+ getCollectProtocolFeesInstructionDataDecoder()
1120
+ );
1121
+ }
1122
+ async function getCollectProtocolFeesInstructionAsync(input, config) {
1123
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1124
+ const originalAccounts = {
1125
+ config: { value: input.config ?? null, isWritable: false },
1126
+ pool: { value: input.pool ?? null, isWritable: true },
1127
+ protocolPosition: {
1128
+ value: input.protocolPosition ?? null,
1129
+ isWritable: true
1130
+ },
1131
+ admin: { value: input.admin ?? null, isWritable: false },
1132
+ authority: { value: input.authority ?? null, isWritable: false },
1133
+ vault0: { value: input.vault0 ?? null, isWritable: true },
1134
+ vault1: { value: input.vault1 ?? null, isWritable: true },
1135
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
1136
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
1137
+ recipient0: { value: input.recipient0 ?? null, isWritable: true },
1138
+ recipient1: { value: input.recipient1 ?? null, isWritable: true },
1139
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
1140
+ token1Program: { value: input.token1Program ?? null, isWritable: false }
1141
+ };
1142
+ const accounts = originalAccounts;
1143
+ const args = { ...input };
1144
+ if (!accounts.authority.value) {
1145
+ accounts.authority.value = await getProgramDerivedAddress({
1146
+ programAddress,
1147
+ seeds: [
1148
+ getBytesEncoder().encode(
1149
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
1150
+ ),
1151
+ getAddressEncoder().encode(
1152
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1153
+ )
1154
+ ]
1155
+ });
1156
+ }
1157
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1158
+ return Object.freeze({
1159
+ accounts: [
1160
+ getAccountMeta("config", accounts.config),
1161
+ getAccountMeta("pool", accounts.pool),
1162
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
1163
+ getAccountMeta("admin", accounts.admin),
1164
+ getAccountMeta("authority", accounts.authority),
1165
+ getAccountMeta("vault0", accounts.vault0),
1166
+ getAccountMeta("vault1", accounts.vault1),
1167
+ getAccountMeta("token0Mint", accounts.token0Mint),
1168
+ getAccountMeta("token1Mint", accounts.token1Mint),
1169
+ getAccountMeta("recipient0", accounts.recipient0),
1170
+ getAccountMeta("recipient1", accounts.recipient1),
1171
+ getAccountMeta("token0Program", accounts.token0Program),
1172
+ getAccountMeta("token1Program", accounts.token1Program)
1173
+ ],
1174
+ data: getCollectProtocolFeesInstructionDataEncoder().encode(
1175
+ args
1176
+ ),
1177
+ programAddress
1178
+ });
1179
+ }
1180
+ function getCollectProtocolFeesInstruction(input, config) {
1181
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1182
+ const originalAccounts = {
1183
+ config: { value: input.config ?? null, isWritable: false },
1184
+ pool: { value: input.pool ?? null, isWritable: true },
1185
+ protocolPosition: {
1186
+ value: input.protocolPosition ?? null,
1187
+ isWritable: true
1188
+ },
1189
+ admin: { value: input.admin ?? null, isWritable: false },
1190
+ authority: { value: input.authority ?? null, isWritable: false },
1191
+ vault0: { value: input.vault0 ?? null, isWritable: true },
1192
+ vault1: { value: input.vault1 ?? null, isWritable: true },
1193
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
1194
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
1195
+ recipient0: { value: input.recipient0 ?? null, isWritable: true },
1196
+ recipient1: { value: input.recipient1 ?? null, isWritable: true },
1197
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
1198
+ token1Program: { value: input.token1Program ?? null, isWritable: false }
1199
+ };
1200
+ const accounts = originalAccounts;
1201
+ const args = { ...input };
1202
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1203
+ return Object.freeze({
1204
+ accounts: [
1205
+ getAccountMeta("config", accounts.config),
1206
+ getAccountMeta("pool", accounts.pool),
1207
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
1208
+ getAccountMeta("admin", accounts.admin),
1209
+ getAccountMeta("authority", accounts.authority),
1210
+ getAccountMeta("vault0", accounts.vault0),
1211
+ getAccountMeta("vault1", accounts.vault1),
1212
+ getAccountMeta("token0Mint", accounts.token0Mint),
1213
+ getAccountMeta("token1Mint", accounts.token1Mint),
1214
+ getAccountMeta("recipient0", accounts.recipient0),
1215
+ getAccountMeta("recipient1", accounts.recipient1),
1216
+ getAccountMeta("token0Program", accounts.token0Program),
1217
+ getAccountMeta("token1Program", accounts.token1Program)
1218
+ ],
1219
+ data: getCollectProtocolFeesInstructionDataEncoder().encode(
1220
+ args
1221
+ ),
1222
+ programAddress
1223
+ });
1224
+ }
1225
+ function parseCollectProtocolFeesInstruction(instruction) {
1226
+ if (instruction.accounts.length < 13) {
1227
+ throw new SolanaError(
1228
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
1229
+ {
1230
+ actualAccountMetas: instruction.accounts.length,
1231
+ expectedAccountMetas: 13
1232
+ }
1233
+ );
1234
+ }
1235
+ let accountIndex = 0;
1236
+ const getNextAccount = () => {
1237
+ const accountMeta = instruction.accounts[accountIndex];
1238
+ accountIndex += 1;
1239
+ return accountMeta;
1240
+ };
1241
+ return {
1242
+ programAddress: instruction.programAddress,
1243
+ accounts: {
1244
+ config: getNextAccount(),
1245
+ pool: getNextAccount(),
1246
+ protocolPosition: getNextAccount(),
1247
+ admin: getNextAccount(),
1248
+ authority: getNextAccount(),
1249
+ vault0: getNextAccount(),
1250
+ vault1: getNextAccount(),
1251
+ token0Mint: getNextAccount(),
1252
+ token1Mint: getNextAccount(),
1253
+ recipient0: getNextAccount(),
1254
+ recipient1: getNextAccount(),
1255
+ token0Program: getNextAccount(),
1256
+ token1Program: getNextAccount()
1257
+ },
1258
+ data: getCollectProtocolFeesInstructionDataDecoder().decode(
1259
+ instruction.data
1260
+ )
1261
+ };
1262
+ }
1263
+ var CREATE_POSITION_DISCRIMINATOR = new Uint8Array([
1264
+ 48,
1265
+ 215,
1266
+ 197,
1267
+ 153,
1268
+ 96,
1269
+ 203,
1270
+ 180,
1271
+ 133
1272
+ ]);
1273
+ function getCreatePositionDiscriminatorBytes() {
1274
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
1275
+ CREATE_POSITION_DISCRIMINATOR
1276
+ );
1277
+ }
1278
+ function getCreatePositionInstructionDataEncoder() {
1279
+ return transformEncoder(
1280
+ getStructEncoder([
1281
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1282
+ ["positionId", getU64Encoder()]
1283
+ ]),
1284
+ (value) => ({ ...value, discriminator: CREATE_POSITION_DISCRIMINATOR })
1285
+ );
1286
+ }
1287
+ function getCreatePositionInstructionDataDecoder() {
1288
+ return getStructDecoder([
1289
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
1290
+ ["positionId", getU64Decoder()]
1291
+ ]);
1292
+ }
1293
+ function getCreatePositionInstructionDataCodec() {
1294
+ return combineCodec(
1295
+ getCreatePositionInstructionDataEncoder(),
1296
+ getCreatePositionInstructionDataDecoder()
1297
+ );
1298
+ }
1299
+ async function getCreatePositionInstructionAsync(input, config) {
1300
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1301
+ const originalAccounts = {
1302
+ pool: { value: input.pool ?? null, isWritable: false },
1303
+ position: { value: input.position ?? null, isWritable: true },
1304
+ owner: { value: input.owner ?? null, isWritable: false },
1305
+ payer: { value: input.payer ?? null, isWritable: true },
1306
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1307
+ };
1308
+ const accounts = originalAccounts;
1309
+ const args = { ...input };
1310
+ if (!accounts.position.value) {
1311
+ accounts.position.value = await getProgramDerivedAddress({
1312
+ programAddress,
1313
+ seeds: [
1314
+ getBytesEncoder().encode(
1315
+ new Uint8Array([112, 111, 115, 105, 116, 105, 111, 110])
1316
+ ),
1317
+ getAddressEncoder().encode(
1318
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1319
+ ),
1320
+ getAddressEncoder().encode(
1321
+ getAddressFromResolvedInstructionAccount(
1322
+ "owner",
1323
+ accounts.owner.value
1324
+ )
1325
+ ),
1326
+ getU64Encoder().encode(
1327
+ getNonNullResolvedInstructionInput("positionId", args.positionId)
1328
+ )
1329
+ ]
1330
+ });
1331
+ }
1332
+ if (!accounts.systemProgram.value) {
1333
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1334
+ }
1335
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1336
+ return Object.freeze({
1337
+ accounts: [
1338
+ getAccountMeta("pool", accounts.pool),
1339
+ getAccountMeta("position", accounts.position),
1340
+ getAccountMeta("owner", accounts.owner),
1341
+ getAccountMeta("payer", accounts.payer),
1342
+ getAccountMeta("systemProgram", accounts.systemProgram)
1343
+ ],
1344
+ data: getCreatePositionInstructionDataEncoder().encode(
1345
+ args
1346
+ ),
1347
+ programAddress
1348
+ });
1349
+ }
1350
+ function getCreatePositionInstruction(input, config) {
1351
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1352
+ const originalAccounts = {
1353
+ pool: { value: input.pool ?? null, isWritable: false },
1354
+ position: { value: input.position ?? null, isWritable: true },
1355
+ owner: { value: input.owner ?? null, isWritable: false },
1356
+ payer: { value: input.payer ?? null, isWritable: true },
1357
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1358
+ };
1359
+ const accounts = originalAccounts;
1360
+ const args = { ...input };
1361
+ if (!accounts.systemProgram.value) {
1362
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1363
+ }
1364
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1365
+ return Object.freeze({
1366
+ accounts: [
1367
+ getAccountMeta("pool", accounts.pool),
1368
+ getAccountMeta("position", accounts.position),
1369
+ getAccountMeta("owner", accounts.owner),
1370
+ getAccountMeta("payer", accounts.payer),
1371
+ getAccountMeta("systemProgram", accounts.systemProgram)
1372
+ ],
1373
+ data: getCreatePositionInstructionDataEncoder().encode(
1374
+ args
1375
+ ),
1376
+ programAddress
1377
+ });
1378
+ }
1379
+ function parseCreatePositionInstruction(instruction) {
1380
+ if (instruction.accounts.length < 5) {
1381
+ throw new SolanaError(
1382
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
1383
+ {
1384
+ actualAccountMetas: instruction.accounts.length,
1385
+ expectedAccountMetas: 5
1386
+ }
1387
+ );
1388
+ }
1389
+ let accountIndex = 0;
1390
+ const getNextAccount = () => {
1391
+ const accountMeta = instruction.accounts[accountIndex];
1392
+ accountIndex += 1;
1393
+ return accountMeta;
1394
+ };
1395
+ return {
1396
+ programAddress: instruction.programAddress,
1397
+ accounts: {
1398
+ pool: getNextAccount(),
1399
+ position: getNextAccount(),
1400
+ owner: getNextAccount(),
1401
+ payer: getNextAccount(),
1402
+ systemProgram: getNextAccount()
1403
+ },
1404
+ data: getCreatePositionInstructionDataDecoder().decode(instruction.data)
1405
+ };
1406
+ }
1407
+ var INITIALIZE_CONFIG_DISCRIMINATOR = new Uint8Array([
1408
+ 208,
1409
+ 127,
1410
+ 21,
1411
+ 1,
1412
+ 194,
1413
+ 190,
1414
+ 196,
1415
+ 70
1416
+ ]);
1417
+ function getInitializeConfigDiscriminatorBytes() {
1418
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
1419
+ INITIALIZE_CONFIG_DISCRIMINATOR
1420
+ );
1421
+ }
1422
+ function getInitializeConfigInstructionDataEncoder() {
1423
+ return transformEncoder(
1424
+ getStructEncoder([
1425
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1426
+ ["admin", getAddressEncoder()],
1427
+ ["numeraireMint", getAddressEncoder()],
1428
+ ["maxSwapFeeBps", getU16Encoder()],
1429
+ ["maxFeeSplitBps", getU16Encoder()],
1430
+ ["maxRouteHops", getU8Encoder()],
1431
+ ["protocolFeeEnabled", getBooleanEncoder()],
1432
+ ["protocolFeeBps", getU16Encoder()],
1433
+ ["sentinelAllowlist", getArrayEncoder(getAddressEncoder())]
1434
+ ]),
1435
+ (value) => ({ ...value, discriminator: INITIALIZE_CONFIG_DISCRIMINATOR })
1436
+ );
1437
+ }
1438
+ function getInitializeConfigInstructionDataDecoder() {
1439
+ return getStructDecoder([
1440
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
1441
+ ["admin", getAddressDecoder()],
1442
+ ["numeraireMint", getAddressDecoder()],
1443
+ ["maxSwapFeeBps", getU16Decoder()],
1444
+ ["maxFeeSplitBps", getU16Decoder()],
1445
+ ["maxRouteHops", getU8Decoder()],
1446
+ ["protocolFeeEnabled", getBooleanDecoder()],
1447
+ ["protocolFeeBps", getU16Decoder()],
1448
+ ["sentinelAllowlist", getArrayDecoder(getAddressDecoder())]
1449
+ ]);
1450
+ }
1451
+ function getInitializeConfigInstructionDataCodec() {
1452
+ return combineCodec(
1453
+ getInitializeConfigInstructionDataEncoder(),
1454
+ getInitializeConfigInstructionDataDecoder()
1455
+ );
1456
+ }
1457
+ async function getInitializeConfigInstructionAsync(input, config) {
1458
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1459
+ const originalAccounts = {
1460
+ config: { value: input.config ?? null, isWritable: true },
1461
+ programData: { value: input.programData ?? null, isWritable: false },
1462
+ payer: { value: input.payer ?? null, isWritable: true },
1463
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1464
+ };
1465
+ const accounts = originalAccounts;
1466
+ const args = { ...input };
1467
+ if (!accounts.config.value) {
1468
+ accounts.config.value = await getProgramDerivedAddress({
1469
+ programAddress,
1470
+ seeds: [
1471
+ getBytesEncoder().encode(new Uint8Array([99, 111, 110, 102, 105, 103]))
1472
+ ]
1473
+ });
1474
+ }
1475
+ if (!accounts.systemProgram.value) {
1476
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1477
+ }
1478
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1479
+ return Object.freeze({
1480
+ accounts: [
1481
+ getAccountMeta("config", accounts.config),
1482
+ getAccountMeta("programData", accounts.programData),
1483
+ getAccountMeta("payer", accounts.payer),
1484
+ getAccountMeta("systemProgram", accounts.systemProgram)
1485
+ ],
1486
+ data: getInitializeConfigInstructionDataEncoder().encode(
1487
+ args
1488
+ ),
1489
+ programAddress
1490
+ });
1491
+ }
1492
+ function getInitializeConfigInstruction(input, config) {
1493
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1494
+ const originalAccounts = {
1495
+ config: { value: input.config ?? null, isWritable: true },
1496
+ programData: { value: input.programData ?? null, isWritable: false },
1497
+ payer: { value: input.payer ?? null, isWritable: true },
1498
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1499
+ };
1500
+ const accounts = originalAccounts;
1501
+ const args = { ...input };
1502
+ if (!accounts.systemProgram.value) {
1503
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1504
+ }
1505
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1506
+ return Object.freeze({
1507
+ accounts: [
1508
+ getAccountMeta("config", accounts.config),
1509
+ getAccountMeta("programData", accounts.programData),
1510
+ getAccountMeta("payer", accounts.payer),
1511
+ getAccountMeta("systemProgram", accounts.systemProgram)
1512
+ ],
1513
+ data: getInitializeConfigInstructionDataEncoder().encode(
1514
+ args
1515
+ ),
1516
+ programAddress
1517
+ });
1518
+ }
1519
+ function parseInitializeConfigInstruction(instruction) {
1520
+ if (instruction.accounts.length < 4) {
1521
+ throw new SolanaError(
1522
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
1523
+ {
1524
+ actualAccountMetas: instruction.accounts.length,
1525
+ expectedAccountMetas: 4
1526
+ }
1527
+ );
1528
+ }
1529
+ let accountIndex = 0;
1530
+ const getNextAccount = () => {
1531
+ const accountMeta = instruction.accounts[accountIndex];
1532
+ accountIndex += 1;
1533
+ return accountMeta;
1534
+ };
1535
+ return {
1536
+ programAddress: instruction.programAddress,
1537
+ accounts: {
1538
+ config: getNextAccount(),
1539
+ programData: getNextAccount(),
1540
+ payer: getNextAccount(),
1541
+ systemProgram: getNextAccount()
1542
+ },
1543
+ data: getInitializeConfigInstructionDataDecoder().decode(instruction.data)
1544
+ };
1545
+ }
1546
+ var INITIALIZE_ORACLE_DISCRIMINATOR = new Uint8Array([
1547
+ 144,
1548
+ 223,
1549
+ 131,
1550
+ 120,
1551
+ 196,
1552
+ 253,
1553
+ 181,
1554
+ 99
1555
+ ]);
1556
+ function getInitializeOracleDiscriminatorBytes() {
1557
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
1558
+ INITIALIZE_ORACLE_DISCRIMINATOR
1559
+ );
1560
+ }
1561
+ function getInitializeOracleInstructionDataEncoder() {
1562
+ return transformEncoder(
1563
+ getStructEncoder([
1564
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1565
+ ["maxPriceChangeRatioQ64", getU128Encoder()],
1566
+ ["observationIntervalSec", getU32Encoder()]
1567
+ ]),
1568
+ (value) => ({ ...value, discriminator: INITIALIZE_ORACLE_DISCRIMINATOR })
1569
+ );
1570
+ }
1571
+ function getInitializeOracleInstructionDataDecoder() {
1572
+ return getStructDecoder([
1573
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
1574
+ ["maxPriceChangeRatioQ64", getU128Decoder()],
1575
+ ["observationIntervalSec", getU32Decoder()]
1576
+ ]);
1577
+ }
1578
+ function getInitializeOracleInstructionDataCodec() {
1579
+ return combineCodec(
1580
+ getInitializeOracleInstructionDataEncoder(),
1581
+ getInitializeOracleInstructionDataDecoder()
1582
+ );
1583
+ }
1584
+ async function getInitializeOracleInstructionAsync(input, config) {
1585
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1586
+ const originalAccounts = {
1587
+ config: { value: input.config ?? null, isWritable: false },
1588
+ pool: { value: input.pool ?? null, isWritable: false },
1589
+ oracle: { value: input.oracle ?? null, isWritable: true },
1590
+ admin: { value: input.admin ?? null, isWritable: false },
1591
+ payer: { value: input.payer ?? null, isWritable: true },
1592
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1593
+ };
1594
+ const accounts = originalAccounts;
1595
+ const args = { ...input };
1596
+ if (!accounts.oracle.value) {
1597
+ accounts.oracle.value = await getProgramDerivedAddress({
1598
+ programAddress,
1599
+ seeds: [
1600
+ getBytesEncoder().encode(new Uint8Array([111, 114, 97, 99, 108, 101])),
1601
+ getAddressEncoder().encode(
1602
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1603
+ )
1604
+ ]
1605
+ });
1606
+ }
1607
+ if (!accounts.systemProgram.value) {
1608
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1609
+ }
1610
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1611
+ return Object.freeze({
1612
+ accounts: [
1613
+ getAccountMeta("config", accounts.config),
1614
+ getAccountMeta("pool", accounts.pool),
1615
+ getAccountMeta("oracle", accounts.oracle),
1616
+ getAccountMeta("admin", accounts.admin),
1617
+ getAccountMeta("payer", accounts.payer),
1618
+ getAccountMeta("systemProgram", accounts.systemProgram)
1619
+ ],
1620
+ data: getInitializeOracleInstructionDataEncoder().encode(
1621
+ args
1622
+ ),
1623
+ programAddress
1624
+ });
1625
+ }
1626
+ function getInitializeOracleInstruction(input, config) {
1627
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1628
+ const originalAccounts = {
1629
+ config: { value: input.config ?? null, isWritable: false },
1630
+ pool: { value: input.pool ?? null, isWritable: false },
1631
+ oracle: { value: input.oracle ?? null, isWritable: true },
1632
+ admin: { value: input.admin ?? null, isWritable: false },
1633
+ payer: { value: input.payer ?? null, isWritable: true },
1634
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1635
+ };
1636
+ const accounts = originalAccounts;
1637
+ const args = { ...input };
1638
+ if (!accounts.systemProgram.value) {
1639
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1640
+ }
1641
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1642
+ return Object.freeze({
1643
+ accounts: [
1644
+ getAccountMeta("config", accounts.config),
1645
+ getAccountMeta("pool", accounts.pool),
1646
+ getAccountMeta("oracle", accounts.oracle),
1647
+ getAccountMeta("admin", accounts.admin),
1648
+ getAccountMeta("payer", accounts.payer),
1649
+ getAccountMeta("systemProgram", accounts.systemProgram)
1650
+ ],
1651
+ data: getInitializeOracleInstructionDataEncoder().encode(
1652
+ args
1653
+ ),
1654
+ programAddress
1655
+ });
1656
+ }
1657
+ function parseInitializeOracleInstruction(instruction) {
1658
+ if (instruction.accounts.length < 6) {
1659
+ throw new SolanaError(
1660
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
1661
+ {
1662
+ actualAccountMetas: instruction.accounts.length,
1663
+ expectedAccountMetas: 6
1664
+ }
1665
+ );
1666
+ }
1667
+ let accountIndex = 0;
1668
+ const getNextAccount = () => {
1669
+ const accountMeta = instruction.accounts[accountIndex];
1670
+ accountIndex += 1;
1671
+ return accountMeta;
1672
+ };
1673
+ return {
1674
+ programAddress: instruction.programAddress,
1675
+ accounts: {
1676
+ config: getNextAccount(),
1677
+ pool: getNextAccount(),
1678
+ oracle: getNextAccount(),
1679
+ admin: getNextAccount(),
1680
+ payer: getNextAccount(),
1681
+ systemProgram: getNextAccount()
1682
+ },
1683
+ data: getInitializeOracleInstructionDataDecoder().decode(instruction.data)
1684
+ };
1685
+ }
1686
+ var INITIALIZE_POOL_DISCRIMINATOR = new Uint8Array([
1687
+ 95,
1688
+ 180,
1689
+ 10,
1690
+ 172,
1691
+ 84,
1692
+ 174,
1693
+ 232,
1694
+ 40
1695
+ ]);
1696
+ function getInitializePoolDiscriminatorBytes() {
1697
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
1698
+ INITIALIZE_POOL_DISCRIMINATOR
1699
+ );
1700
+ }
1701
+ function getInitializePoolInstructionDataEncoder() {
1702
+ return transformEncoder(
1703
+ getStructEncoder([
1704
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1705
+ ["mintA", getAddressEncoder()],
1706
+ ["mintB", getAddressEncoder()],
1707
+ ["initialSwapFeeBps", getU16Encoder()],
1708
+ ["initialFeeSplitBps", getU16Encoder()],
1709
+ ["liquidityMeasureSide", getU8Encoder()],
1710
+ ["numeraireMintOverride", getOptionEncoder(getAddressEncoder())]
1711
+ ]),
1712
+ (value) => ({ ...value, discriminator: INITIALIZE_POOL_DISCRIMINATOR })
1713
+ );
1714
+ }
1715
+ function getInitializePoolInstructionDataDecoder() {
1716
+ return getStructDecoder([
1717
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
1718
+ ["mintA", getAddressDecoder()],
1719
+ ["mintB", getAddressDecoder()],
1720
+ ["initialSwapFeeBps", getU16Decoder()],
1721
+ ["initialFeeSplitBps", getU16Decoder()],
1722
+ ["liquidityMeasureSide", getU8Decoder()],
1723
+ ["numeraireMintOverride", getOptionDecoder(getAddressDecoder())]
1724
+ ]);
1725
+ }
1726
+ function getInitializePoolInstructionDataCodec() {
1727
+ return combineCodec(
1728
+ getInitializePoolInstructionDataEncoder(),
1729
+ getInitializePoolInstructionDataDecoder()
1730
+ );
1731
+ }
1732
+ async function getInitializePoolInstructionAsync(input, config) {
1733
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1734
+ const originalAccounts = {
1735
+ config: { value: input.config ?? null, isWritable: false },
1736
+ pool: { value: input.pool ?? null, isWritable: true },
1737
+ protocolPosition: {
1738
+ value: input.protocolPosition ?? null,
1739
+ isWritable: true
1740
+ },
1741
+ authority: { value: input.authority ?? null, isWritable: false },
1742
+ vault0: { value: input.vault0 ?? null, isWritable: true },
1743
+ vault1: { value: input.vault1 ?? null, isWritable: true },
1744
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
1745
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
1746
+ payer: { value: input.payer ?? null, isWritable: true },
1747
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
1748
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
1749
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1750
+ rent: { value: input.rent ?? null, isWritable: false },
1751
+ migrationAuthority: {
1752
+ value: input.migrationAuthority ?? null,
1753
+ isWritable: false
1754
+ }
1755
+ };
1756
+ const accounts = originalAccounts;
1757
+ const args = { ...input };
1758
+ if (!accounts.pool.value) {
1759
+ accounts.pool.value = await getProgramDerivedAddress({
1760
+ programAddress,
1761
+ seeds: [
1762
+ getBytesEncoder().encode(new Uint8Array([112, 111, 111, 108])),
1763
+ getAddressEncoder().encode(
1764
+ getAddressFromResolvedInstructionAccount(
1765
+ "token0Mint",
1766
+ accounts.token0Mint.value
1767
+ )
1768
+ ),
1769
+ getAddressEncoder().encode(
1770
+ getAddressFromResolvedInstructionAccount(
1771
+ "token1Mint",
1772
+ accounts.token1Mint.value
1773
+ )
1774
+ )
1775
+ ]
1776
+ });
1777
+ }
1778
+ if (!accounts.protocolPosition.value) {
1779
+ accounts.protocolPosition.value = await getProgramDerivedAddress({
1780
+ programAddress,
1781
+ seeds: [
1782
+ getBytesEncoder().encode(
1783
+ new Uint8Array([
1784
+ 112,
1785
+ 114,
1786
+ 111,
1787
+ 116,
1788
+ 111,
1789
+ 99,
1790
+ 111,
1791
+ 108,
1792
+ 95,
1793
+ 112,
1794
+ 111,
1795
+ 115,
1796
+ 105,
1797
+ 116,
1798
+ 105,
1799
+ 111,
1800
+ 110
1801
+ ])
1802
+ ),
1803
+ getAddressEncoder().encode(
1804
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1805
+ )
1806
+ ]
1807
+ });
1808
+ }
1809
+ if (!accounts.authority.value) {
1810
+ accounts.authority.value = await getProgramDerivedAddress({
1811
+ programAddress,
1812
+ seeds: [
1813
+ getBytesEncoder().encode(
1814
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
1815
+ ),
1816
+ getAddressEncoder().encode(
1817
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1818
+ )
1819
+ ]
1820
+ });
1821
+ }
1822
+ if (!accounts.vault0.value) {
1823
+ accounts.vault0.value = await getProgramDerivedAddress({
1824
+ programAddress,
1825
+ seeds: [
1826
+ getBytesEncoder().encode(new Uint8Array([118, 97, 117, 108, 116, 48])),
1827
+ getAddressEncoder().encode(
1828
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1829
+ )
1830
+ ]
1831
+ });
1832
+ }
1833
+ if (!accounts.vault1.value) {
1834
+ accounts.vault1.value = await getProgramDerivedAddress({
1835
+ programAddress,
1836
+ seeds: [
1837
+ getBytesEncoder().encode(new Uint8Array([118, 97, 117, 108, 116, 49])),
1838
+ getAddressEncoder().encode(
1839
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1840
+ )
1841
+ ]
1842
+ });
1843
+ }
1844
+ if (!accounts.systemProgram.value) {
1845
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1846
+ }
1847
+ if (!accounts.rent.value) {
1848
+ accounts.rent.value = "SysvarRent111111111111111111111111111111111";
1849
+ }
1850
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1851
+ return Object.freeze({
1852
+ accounts: [
1853
+ getAccountMeta("config", accounts.config),
1854
+ getAccountMeta("pool", accounts.pool),
1855
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
1856
+ getAccountMeta("authority", accounts.authority),
1857
+ getAccountMeta("vault0", accounts.vault0),
1858
+ getAccountMeta("vault1", accounts.vault1),
1859
+ getAccountMeta("token0Mint", accounts.token0Mint),
1860
+ getAccountMeta("token1Mint", accounts.token1Mint),
1861
+ getAccountMeta("payer", accounts.payer),
1862
+ getAccountMeta("token0Program", accounts.token0Program),
1863
+ getAccountMeta("token1Program", accounts.token1Program),
1864
+ getAccountMeta("systemProgram", accounts.systemProgram),
1865
+ getAccountMeta("rent", accounts.rent),
1866
+ getAccountMeta("migrationAuthority", accounts.migrationAuthority)
1867
+ ],
1868
+ data: getInitializePoolInstructionDataEncoder().encode(
1869
+ args
1870
+ ),
1871
+ programAddress
1872
+ });
1873
+ }
1874
+ function getInitializePoolInstruction(input, config) {
1875
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1876
+ const originalAccounts = {
1877
+ config: { value: input.config ?? null, isWritable: false },
1878
+ pool: { value: input.pool ?? null, isWritable: true },
1879
+ protocolPosition: {
1880
+ value: input.protocolPosition ?? null,
1881
+ isWritable: true
1882
+ },
1883
+ authority: { value: input.authority ?? null, isWritable: false },
1884
+ vault0: { value: input.vault0 ?? null, isWritable: true },
1885
+ vault1: { value: input.vault1 ?? null, isWritable: true },
1886
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
1887
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
1888
+ payer: { value: input.payer ?? null, isWritable: true },
1889
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
1890
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
1891
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1892
+ rent: { value: input.rent ?? null, isWritable: false },
1893
+ migrationAuthority: {
1894
+ value: input.migrationAuthority ?? null,
1895
+ isWritable: false
1896
+ }
1897
+ };
1898
+ const accounts = originalAccounts;
1899
+ const args = { ...input };
1900
+ if (!accounts.systemProgram.value) {
1901
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1902
+ }
1903
+ if (!accounts.rent.value) {
1904
+ accounts.rent.value = "SysvarRent111111111111111111111111111111111";
1905
+ }
1906
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1907
+ return Object.freeze({
1908
+ accounts: [
1909
+ getAccountMeta("config", accounts.config),
1910
+ getAccountMeta("pool", accounts.pool),
1911
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
1912
+ getAccountMeta("authority", accounts.authority),
1913
+ getAccountMeta("vault0", accounts.vault0),
1914
+ getAccountMeta("vault1", accounts.vault1),
1915
+ getAccountMeta("token0Mint", accounts.token0Mint),
1916
+ getAccountMeta("token1Mint", accounts.token1Mint),
1917
+ getAccountMeta("payer", accounts.payer),
1918
+ getAccountMeta("token0Program", accounts.token0Program),
1919
+ getAccountMeta("token1Program", accounts.token1Program),
1920
+ getAccountMeta("systemProgram", accounts.systemProgram),
1921
+ getAccountMeta("rent", accounts.rent),
1922
+ getAccountMeta("migrationAuthority", accounts.migrationAuthority)
1923
+ ],
1924
+ data: getInitializePoolInstructionDataEncoder().encode(
1925
+ args
1926
+ ),
1927
+ programAddress
1928
+ });
1929
+ }
1930
+ function parseInitializePoolInstruction(instruction) {
1931
+ if (instruction.accounts.length < 14) {
1932
+ throw new SolanaError(
1933
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
1934
+ {
1935
+ actualAccountMetas: instruction.accounts.length,
1936
+ expectedAccountMetas: 14
1937
+ }
1938
+ );
1939
+ }
1940
+ let accountIndex = 0;
1941
+ const getNextAccount = () => {
1942
+ const accountMeta = instruction.accounts[accountIndex];
1943
+ accountIndex += 1;
1944
+ return accountMeta;
1945
+ };
1946
+ return {
1947
+ programAddress: instruction.programAddress,
1948
+ accounts: {
1949
+ config: getNextAccount(),
1950
+ pool: getNextAccount(),
1951
+ protocolPosition: getNextAccount(),
1952
+ authority: getNextAccount(),
1953
+ vault0: getNextAccount(),
1954
+ vault1: getNextAccount(),
1955
+ token0Mint: getNextAccount(),
1956
+ token1Mint: getNextAccount(),
1957
+ payer: getNextAccount(),
1958
+ token0Program: getNextAccount(),
1959
+ token1Program: getNextAccount(),
1960
+ systemProgram: getNextAccount(),
1961
+ rent: getNextAccount(),
1962
+ migrationAuthority: getNextAccount()
1963
+ },
1964
+ data: getInitializePoolInstructionDataDecoder().decode(instruction.data)
1965
+ };
1966
+ }
1967
+ var ORACLE_CONSULT_DISCRIMINATOR = new Uint8Array([
1968
+ 239,
1969
+ 237,
1970
+ 255,
1971
+ 177,
1972
+ 142,
1973
+ 72,
1974
+ 96,
1975
+ 175
1976
+ ]);
1977
+ function getOracleConsultDiscriminatorBytes() {
1978
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
1979
+ ORACLE_CONSULT_DISCRIMINATOR
1980
+ );
1981
+ }
1982
+ function getOracleConsultInstructionDataEncoder() {
1983
+ return transformEncoder(
1984
+ getStructEncoder([
1985
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1986
+ ["windowSeconds", getU32Encoder()]
1987
+ ]),
1988
+ (value) => ({ ...value, discriminator: ORACLE_CONSULT_DISCRIMINATOR })
1989
+ );
1990
+ }
1991
+ function getOracleConsultInstructionDataDecoder() {
1992
+ return getStructDecoder([
1993
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
1994
+ ["windowSeconds", getU32Decoder()]
1995
+ ]);
1996
+ }
1997
+ function getOracleConsultInstructionDataCodec() {
1998
+ return combineCodec(
1999
+ getOracleConsultInstructionDataEncoder(),
2000
+ getOracleConsultInstructionDataDecoder()
2001
+ );
2002
+ }
2003
+ async function getOracleConsultInstructionAsync(input, config) {
2004
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2005
+ const originalAccounts = {
2006
+ pool: { value: input.pool ?? null, isWritable: false },
2007
+ oracle: { value: input.oracle ?? null, isWritable: false }
2008
+ };
2009
+ const accounts = originalAccounts;
2010
+ const args = { ...input };
2011
+ if (!accounts.oracle.value) {
2012
+ accounts.oracle.value = await getProgramDerivedAddress({
2013
+ programAddress,
2014
+ seeds: [
2015
+ getBytesEncoder().encode(new Uint8Array([111, 114, 97, 99, 108, 101])),
2016
+ getAddressEncoder().encode(
2017
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
2018
+ )
2019
+ ]
2020
+ });
2021
+ }
2022
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2023
+ return Object.freeze({
2024
+ accounts: [
2025
+ getAccountMeta("pool", accounts.pool),
2026
+ getAccountMeta("oracle", accounts.oracle)
2027
+ ],
2028
+ data: getOracleConsultInstructionDataEncoder().encode(
2029
+ args
2030
+ ),
2031
+ programAddress
2032
+ });
2033
+ }
2034
+ function getOracleConsultInstruction(input, config) {
2035
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2036
+ const originalAccounts = {
2037
+ pool: { value: input.pool ?? null, isWritable: false },
2038
+ oracle: { value: input.oracle ?? null, isWritable: false }
2039
+ };
2040
+ const accounts = originalAccounts;
2041
+ const args = { ...input };
2042
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2043
+ return Object.freeze({
2044
+ accounts: [
2045
+ getAccountMeta("pool", accounts.pool),
2046
+ getAccountMeta("oracle", accounts.oracle)
2047
+ ],
2048
+ data: getOracleConsultInstructionDataEncoder().encode(
2049
+ args
2050
+ ),
2051
+ programAddress
2052
+ });
2053
+ }
2054
+ function parseOracleConsultInstruction(instruction) {
2055
+ if (instruction.accounts.length < 2) {
2056
+ throw new SolanaError(
2057
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2058
+ {
2059
+ actualAccountMetas: instruction.accounts.length,
2060
+ expectedAccountMetas: 2
2061
+ }
2062
+ );
2063
+ }
2064
+ let accountIndex = 0;
2065
+ const getNextAccount = () => {
2066
+ const accountMeta = instruction.accounts[accountIndex];
2067
+ accountIndex += 1;
2068
+ return accountMeta;
2069
+ };
2070
+ return {
2071
+ programAddress: instruction.programAddress,
2072
+ accounts: { pool: getNextAccount(), oracle: getNextAccount() },
2073
+ data: getOracleConsultInstructionDataDecoder().decode(instruction.data)
2074
+ };
2075
+ }
2076
+ var ORACLE_UPDATE_DISCRIMINATOR = new Uint8Array([
2077
+ 85,
2078
+ 209,
2079
+ 248,
2080
+ 142,
2081
+ 186,
2082
+ 249,
2083
+ 120,
2084
+ 239
2085
+ ]);
2086
+ function getOracleUpdateDiscriminatorBytes() {
2087
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
2088
+ ORACLE_UPDATE_DISCRIMINATOR
2089
+ );
2090
+ }
2091
+ function getOracleUpdateInstructionDataEncoder() {
2092
+ return transformEncoder(
2093
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
2094
+ (value) => ({ ...value, discriminator: ORACLE_UPDATE_DISCRIMINATOR })
2095
+ );
2096
+ }
2097
+ function getOracleUpdateInstructionDataDecoder() {
2098
+ return getStructDecoder([
2099
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)]
2100
+ ]);
2101
+ }
2102
+ function getOracleUpdateInstructionDataCodec() {
2103
+ return combineCodec(
2104
+ getOracleUpdateInstructionDataEncoder(),
2105
+ getOracleUpdateInstructionDataDecoder()
2106
+ );
2107
+ }
2108
+ async function getOracleUpdateInstructionAsync(input, config) {
2109
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2110
+ const originalAccounts = {
2111
+ pool: { value: input.pool ?? null, isWritable: false },
2112
+ oracle: { value: input.oracle ?? null, isWritable: true }
2113
+ };
2114
+ const accounts = originalAccounts;
2115
+ if (!accounts.oracle.value) {
2116
+ accounts.oracle.value = await getProgramDerivedAddress({
2117
+ programAddress,
2118
+ seeds: [
2119
+ getBytesEncoder().encode(new Uint8Array([111, 114, 97, 99, 108, 101])),
2120
+ getAddressEncoder().encode(
2121
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
2122
+ )
2123
+ ]
2124
+ });
2125
+ }
2126
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2127
+ return Object.freeze({
2128
+ accounts: [
2129
+ getAccountMeta("pool", accounts.pool),
2130
+ getAccountMeta("oracle", accounts.oracle)
2131
+ ],
2132
+ data: getOracleUpdateInstructionDataEncoder().encode({}),
2133
+ programAddress
2134
+ });
2135
+ }
2136
+ function getOracleUpdateInstruction(input, config) {
2137
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2138
+ const originalAccounts = {
2139
+ pool: { value: input.pool ?? null, isWritable: false },
2140
+ oracle: { value: input.oracle ?? null, isWritable: true }
2141
+ };
2142
+ const accounts = originalAccounts;
2143
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2144
+ return Object.freeze({
2145
+ accounts: [
2146
+ getAccountMeta("pool", accounts.pool),
2147
+ getAccountMeta("oracle", accounts.oracle)
2148
+ ],
2149
+ data: getOracleUpdateInstructionDataEncoder().encode({}),
2150
+ programAddress
2151
+ });
2152
+ }
2153
+ function parseOracleUpdateInstruction(instruction) {
2154
+ if (instruction.accounts.length < 2) {
2155
+ throw new SolanaError(
2156
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2157
+ {
2158
+ actualAccountMetas: instruction.accounts.length,
2159
+ expectedAccountMetas: 2
2160
+ }
2161
+ );
2162
+ }
2163
+ let accountIndex = 0;
2164
+ const getNextAccount = () => {
2165
+ const accountMeta = instruction.accounts[accountIndex];
2166
+ accountIndex += 1;
2167
+ return accountMeta;
2168
+ };
2169
+ return {
2170
+ programAddress: instruction.programAddress,
2171
+ accounts: { pool: getNextAccount(), oracle: getNextAccount() },
2172
+ data: getOracleUpdateInstructionDataDecoder().decode(instruction.data)
2173
+ };
2174
+ }
2175
+ var PAUSE_DISCRIMINATOR = new Uint8Array([
2176
+ 211,
2177
+ 22,
2178
+ 221,
2179
+ 251,
2180
+ 74,
2181
+ 121,
2182
+ 193,
2183
+ 47
2184
+ ]);
2185
+ function getPauseDiscriminatorBytes() {
2186
+ return fixEncoderSize(getBytesEncoder(), 8).encode(PAUSE_DISCRIMINATOR);
2187
+ }
2188
+ function getPauseInstructionDataEncoder() {
2189
+ return transformEncoder(
2190
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
2191
+ (value) => ({ ...value, discriminator: PAUSE_DISCRIMINATOR })
2192
+ );
2193
+ }
2194
+ function getPauseInstructionDataDecoder() {
2195
+ return getStructDecoder([
2196
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)]
2197
+ ]);
2198
+ }
2199
+ function getPauseInstructionDataCodec() {
2200
+ return combineCodec(
2201
+ getPauseInstructionDataEncoder(),
2202
+ getPauseInstructionDataDecoder()
2203
+ );
2204
+ }
2205
+ function getPauseInstruction(input, config) {
2206
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2207
+ const originalAccounts = {
2208
+ config: { value: input.config ?? null, isWritable: true },
2209
+ admin: { value: input.admin ?? null, isWritable: false }
2210
+ };
2211
+ const accounts = originalAccounts;
2212
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2213
+ return Object.freeze({
2214
+ accounts: [
2215
+ getAccountMeta("config", accounts.config),
2216
+ getAccountMeta("admin", accounts.admin)
2217
+ ],
2218
+ data: getPauseInstructionDataEncoder().encode({}),
2219
+ programAddress
2220
+ });
2221
+ }
2222
+ function parsePauseInstruction(instruction) {
2223
+ if (instruction.accounts.length < 2) {
2224
+ throw new SolanaError(
2225
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2226
+ {
2227
+ actualAccountMetas: instruction.accounts.length,
2228
+ expectedAccountMetas: 2
2229
+ }
2230
+ );
2231
+ }
2232
+ let accountIndex = 0;
2233
+ const getNextAccount = () => {
2234
+ const accountMeta = instruction.accounts[accountIndex];
2235
+ accountIndex += 1;
2236
+ return accountMeta;
2237
+ };
2238
+ return {
2239
+ programAddress: instruction.programAddress,
2240
+ accounts: { config: getNextAccount(), admin: getNextAccount() },
2241
+ data: getPauseInstructionDataDecoder().decode(instruction.data)
2242
+ };
2243
+ }
2244
+ var PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR = new Uint8Array([
2245
+ 50,
2246
+ 130,
2247
+ 31,
2248
+ 69,
2249
+ 147,
2250
+ 58,
2251
+ 222,
2252
+ 178
2253
+ ]);
2254
+ function getPreviewSwapExactInDiscriminatorBytes() {
2255
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
2256
+ PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR
2257
+ );
2258
+ }
2259
+ function getPreviewSwapExactInInstructionDataEncoder() {
2260
+ return transformEncoder(
2261
+ getStructEncoder([
2262
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
2263
+ ["amountIn", getU64Encoder()],
2264
+ ["direction", getU8Encoder()]
2265
+ ]),
2266
+ (value) => ({
2267
+ ...value,
2268
+ discriminator: PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR
2269
+ })
2270
+ );
2271
+ }
2272
+ function getPreviewSwapExactInInstructionDataDecoder() {
2273
+ return getStructDecoder([
2274
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
2275
+ ["amountIn", getU64Decoder()],
2276
+ ["direction", getU8Decoder()]
2277
+ ]);
2278
+ }
2279
+ function getPreviewSwapExactInInstructionDataCodec() {
2280
+ return combineCodec(
2281
+ getPreviewSwapExactInInstructionDataEncoder(),
2282
+ getPreviewSwapExactInInstructionDataDecoder()
2283
+ );
2284
+ }
2285
+ function getPreviewSwapExactInInstruction(input, config) {
2286
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2287
+ const originalAccounts = {
2288
+ config: { value: input.config ?? null, isWritable: false },
2289
+ pool: { value: input.pool ?? null, isWritable: false }
2290
+ };
2291
+ const accounts = originalAccounts;
2292
+ const args = { ...input };
2293
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2294
+ return Object.freeze({
2295
+ accounts: [
2296
+ getAccountMeta("config", accounts.config),
2297
+ getAccountMeta("pool", accounts.pool)
2298
+ ],
2299
+ data: getPreviewSwapExactInInstructionDataEncoder().encode(
2300
+ args
2301
+ ),
2302
+ programAddress
2303
+ });
2304
+ }
2305
+ function parsePreviewSwapExactInInstruction(instruction) {
2306
+ if (instruction.accounts.length < 2) {
2307
+ throw new SolanaError(
2308
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2309
+ {
2310
+ actualAccountMetas: instruction.accounts.length,
2311
+ expectedAccountMetas: 2
2312
+ }
2313
+ );
2314
+ }
2315
+ let accountIndex = 0;
2316
+ const getNextAccount = () => {
2317
+ const accountMeta = instruction.accounts[accountIndex];
2318
+ accountIndex += 1;
2319
+ return accountMeta;
2320
+ };
2321
+ return {
2322
+ programAddress: instruction.programAddress,
2323
+ accounts: { config: getNextAccount(), pool: getNextAccount() },
2324
+ data: getPreviewSwapExactInInstructionDataDecoder().decode(
2325
+ instruction.data
2326
+ )
2327
+ };
2328
+ }
2329
+ var QUOTE_TO_NUMERAIRE_DISCRIMINATOR = new Uint8Array([
2330
+ 4,
2331
+ 142,
2332
+ 249,
2333
+ 240,
2334
+ 129,
2335
+ 15,
2336
+ 143,
2337
+ 57
2338
+ ]);
2339
+ function getQuoteToNumeraireDiscriminatorBytes() {
2340
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
2341
+ QUOTE_TO_NUMERAIRE_DISCRIMINATOR
2342
+ );
2343
+ }
2344
+ function getQuoteToNumeraireInstructionDataEncoder() {
2345
+ return transformEncoder(
2346
+ getStructEncoder([
2347
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
2348
+ ["amount", getU128Encoder()],
2349
+ ["side", getU8Encoder()],
2350
+ ["maxHops", getU8Encoder()],
2351
+ ["useTwap", getBooleanEncoder()],
2352
+ ["windowSeconds", getU32Encoder()]
2353
+ ]),
2354
+ (value) => ({ ...value, discriminator: QUOTE_TO_NUMERAIRE_DISCRIMINATOR })
2355
+ );
2356
+ }
2357
+ function getQuoteToNumeraireInstructionDataDecoder() {
2358
+ return getStructDecoder([
2359
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
2360
+ ["amount", getU128Decoder()],
2361
+ ["side", getU8Decoder()],
2362
+ ["maxHops", getU8Decoder()],
2363
+ ["useTwap", getBooleanDecoder()],
2364
+ ["windowSeconds", getU32Decoder()]
2365
+ ]);
2366
+ }
2367
+ function getQuoteToNumeraireInstructionDataCodec() {
2368
+ return combineCodec(
2369
+ getQuoteToNumeraireInstructionDataEncoder(),
2370
+ getQuoteToNumeraireInstructionDataDecoder()
2371
+ );
2372
+ }
2373
+ function getQuoteToNumeraireInstruction(input, config) {
2374
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2375
+ const originalAccounts = {
2376
+ config: { value: input.config ?? null, isWritable: false },
2377
+ startPool: { value: input.startPool ?? null, isWritable: false }
2378
+ };
2379
+ const accounts = originalAccounts;
2380
+ const args = { ...input };
2381
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2382
+ return Object.freeze({
2383
+ accounts: [
2384
+ getAccountMeta("config", accounts.config),
2385
+ getAccountMeta("startPool", accounts.startPool)
2386
+ ],
2387
+ data: getQuoteToNumeraireInstructionDataEncoder().encode(
2388
+ args
2389
+ ),
2390
+ programAddress
2391
+ });
2392
+ }
2393
+ function parseQuoteToNumeraireInstruction(instruction) {
2394
+ if (instruction.accounts.length < 2) {
2395
+ throw new SolanaError(
2396
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2397
+ {
2398
+ actualAccountMetas: instruction.accounts.length,
2399
+ expectedAccountMetas: 2
2400
+ }
2401
+ );
2402
+ }
2403
+ let accountIndex = 0;
2404
+ const getNextAccount = () => {
2405
+ const accountMeta = instruction.accounts[accountIndex];
2406
+ accountIndex += 1;
2407
+ return accountMeta;
2408
+ };
2409
+ return {
2410
+ programAddress: instruction.programAddress,
2411
+ accounts: { config: getNextAccount(), startPool: getNextAccount() },
2412
+ data: getQuoteToNumeraireInstructionDataDecoder().decode(instruction.data)
2413
+ };
2414
+ }
2415
+ var REMOVE_LIQUIDITY_DISCRIMINATOR = new Uint8Array([
2416
+ 80,
2417
+ 85,
2418
+ 209,
2419
+ 72,
2420
+ 24,
2421
+ 206,
2422
+ 177,
2423
+ 108
2424
+ ]);
2425
+ function getRemoveLiquidityDiscriminatorBytes() {
2426
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
2427
+ REMOVE_LIQUIDITY_DISCRIMINATOR
2428
+ );
2429
+ }
2430
+ function getRemoveLiquidityInstructionDataEncoder() {
2431
+ return transformEncoder(
2432
+ getStructEncoder([
2433
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
2434
+ ["sharesIn", getU128Encoder()],
2435
+ ["minAmount0Out", getU64Encoder()],
2436
+ ["minAmount1Out", getU64Encoder()],
2437
+ ["updateOracle", getBooleanEncoder()]
2438
+ ]),
2439
+ (value) => ({ ...value, discriminator: REMOVE_LIQUIDITY_DISCRIMINATOR })
2440
+ );
2441
+ }
2442
+ function getRemoveLiquidityInstructionDataDecoder() {
2443
+ return getStructDecoder([
2444
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
2445
+ ["sharesIn", getU128Decoder()],
2446
+ ["minAmount0Out", getU64Decoder()],
2447
+ ["minAmount1Out", getU64Decoder()],
2448
+ ["updateOracle", getBooleanDecoder()]
2449
+ ]);
2450
+ }
2451
+ function getRemoveLiquidityInstructionDataCodec() {
2452
+ return combineCodec(
2453
+ getRemoveLiquidityInstructionDataEncoder(),
2454
+ getRemoveLiquidityInstructionDataDecoder()
2455
+ );
2456
+ }
2457
+ async function getRemoveLiquidityInstructionAsync(input, config) {
2458
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2459
+ const originalAccounts = {
2460
+ config: { value: input.config ?? null, isWritable: false },
2461
+ pool: { value: input.pool ?? null, isWritable: true },
2462
+ position: { value: input.position ?? null, isWritable: true },
2463
+ protocolPosition: {
2464
+ value: input.protocolPosition ?? null,
2465
+ isWritable: true
2466
+ },
2467
+ owner: { value: input.owner ?? null, isWritable: false },
2468
+ authority: { value: input.authority ?? null, isWritable: false },
2469
+ vault0: { value: input.vault0 ?? null, isWritable: true },
2470
+ vault1: { value: input.vault1 ?? null, isWritable: true },
2471
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
2472
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
2473
+ user0: { value: input.user0 ?? null, isWritable: true },
2474
+ user1: { value: input.user1 ?? null, isWritable: true },
2475
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
2476
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
2477
+ oracle: { value: input.oracle ?? null, isWritable: true }
2478
+ };
2479
+ const accounts = originalAccounts;
2480
+ const args = { ...input };
2481
+ if (!accounts.authority.value) {
2482
+ accounts.authority.value = await getProgramDerivedAddress({
2483
+ programAddress,
2484
+ seeds: [
2485
+ getBytesEncoder().encode(
2486
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
2487
+ ),
2488
+ getAddressEncoder().encode(
2489
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
2490
+ )
2491
+ ]
2492
+ });
2493
+ }
2494
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2495
+ return Object.freeze({
2496
+ accounts: [
2497
+ getAccountMeta("config", accounts.config),
2498
+ getAccountMeta("pool", accounts.pool),
2499
+ getAccountMeta("position", accounts.position),
2500
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
2501
+ getAccountMeta("owner", accounts.owner),
2502
+ getAccountMeta("authority", accounts.authority),
2503
+ getAccountMeta("vault0", accounts.vault0),
2504
+ getAccountMeta("vault1", accounts.vault1),
2505
+ getAccountMeta("token0Mint", accounts.token0Mint),
2506
+ getAccountMeta("token1Mint", accounts.token1Mint),
2507
+ getAccountMeta("user0", accounts.user0),
2508
+ getAccountMeta("user1", accounts.user1),
2509
+ getAccountMeta("token0Program", accounts.token0Program),
2510
+ getAccountMeta("token1Program", accounts.token1Program),
2511
+ getAccountMeta("oracle", accounts.oracle)
2512
+ ],
2513
+ data: getRemoveLiquidityInstructionDataEncoder().encode(
2514
+ args
2515
+ ),
2516
+ programAddress
2517
+ });
2518
+ }
2519
+ function getRemoveLiquidityInstruction(input, config) {
2520
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2521
+ const originalAccounts = {
2522
+ config: { value: input.config ?? null, isWritable: false },
2523
+ pool: { value: input.pool ?? null, isWritable: true },
2524
+ position: { value: input.position ?? null, isWritable: true },
2525
+ protocolPosition: {
2526
+ value: input.protocolPosition ?? null,
2527
+ isWritable: true
2528
+ },
2529
+ owner: { value: input.owner ?? null, isWritable: false },
2530
+ authority: { value: input.authority ?? null, isWritable: false },
2531
+ vault0: { value: input.vault0 ?? null, isWritable: true },
2532
+ vault1: { value: input.vault1 ?? null, isWritable: true },
2533
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
2534
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
2535
+ user0: { value: input.user0 ?? null, isWritable: true },
2536
+ user1: { value: input.user1 ?? null, isWritable: true },
2537
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
2538
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
2539
+ oracle: { value: input.oracle ?? null, isWritable: true }
2540
+ };
2541
+ const accounts = originalAccounts;
2542
+ const args = { ...input };
2543
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2544
+ return Object.freeze({
2545
+ accounts: [
2546
+ getAccountMeta("config", accounts.config),
2547
+ getAccountMeta("pool", accounts.pool),
2548
+ getAccountMeta("position", accounts.position),
2549
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
2550
+ getAccountMeta("owner", accounts.owner),
2551
+ getAccountMeta("authority", accounts.authority),
2552
+ getAccountMeta("vault0", accounts.vault0),
2553
+ getAccountMeta("vault1", accounts.vault1),
2554
+ getAccountMeta("token0Mint", accounts.token0Mint),
2555
+ getAccountMeta("token1Mint", accounts.token1Mint),
2556
+ getAccountMeta("user0", accounts.user0),
2557
+ getAccountMeta("user1", accounts.user1),
2558
+ getAccountMeta("token0Program", accounts.token0Program),
2559
+ getAccountMeta("token1Program", accounts.token1Program),
2560
+ getAccountMeta("oracle", accounts.oracle)
2561
+ ],
2562
+ data: getRemoveLiquidityInstructionDataEncoder().encode(
2563
+ args
2564
+ ),
2565
+ programAddress
2566
+ });
2567
+ }
2568
+ function parseRemoveLiquidityInstruction(instruction) {
2569
+ if (instruction.accounts.length < 15) {
2570
+ throw new SolanaError(
2571
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2572
+ {
2573
+ actualAccountMetas: instruction.accounts.length,
2574
+ expectedAccountMetas: 15
2575
+ }
2576
+ );
2577
+ }
2578
+ let accountIndex = 0;
2579
+ const getNextAccount = () => {
2580
+ const accountMeta = instruction.accounts[accountIndex];
2581
+ accountIndex += 1;
2582
+ return accountMeta;
2583
+ };
2584
+ const getNextOptionalAccount = () => {
2585
+ const accountMeta = getNextAccount();
2586
+ return accountMeta.address === CPMM_PROGRAM_ADDRESS ? void 0 : accountMeta;
2587
+ };
2588
+ return {
2589
+ programAddress: instruction.programAddress,
2590
+ accounts: {
2591
+ config: getNextAccount(),
2592
+ pool: getNextAccount(),
2593
+ position: getNextAccount(),
2594
+ protocolPosition: getNextAccount(),
2595
+ owner: getNextAccount(),
2596
+ authority: getNextAccount(),
2597
+ vault0: getNextAccount(),
2598
+ vault1: getNextAccount(),
2599
+ token0Mint: getNextAccount(),
2600
+ token1Mint: getNextAccount(),
2601
+ user0: getNextAccount(),
2602
+ user1: getNextAccount(),
2603
+ token0Program: getNextAccount(),
2604
+ token1Program: getNextAccount(),
2605
+ oracle: getNextOptionalAccount()
2606
+ },
2607
+ data: getRemoveLiquidityInstructionDataDecoder().decode(instruction.data)
2608
+ };
2609
+ }
2610
+ var SET_FEES_DISCRIMINATOR = new Uint8Array([
2611
+ 137,
2612
+ 178,
2613
+ 49,
2614
+ 58,
2615
+ 0,
2616
+ 245,
2617
+ 242,
2618
+ 190
2619
+ ]);
2620
+ function getSetFeesDiscriminatorBytes() {
2621
+ return fixEncoderSize(getBytesEncoder(), 8).encode(SET_FEES_DISCRIMINATOR);
2622
+ }
2623
+ function getSetFeesInstructionDataEncoder() {
2624
+ return transformEncoder(
2625
+ getStructEncoder([
2626
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
2627
+ ["swapFeeBps", getU16Encoder()],
2628
+ ["feeSplitBps", getU16Encoder()]
2629
+ ]),
2630
+ (value) => ({ ...value, discriminator: SET_FEES_DISCRIMINATOR })
2631
+ );
2632
+ }
2633
+ function getSetFeesInstructionDataDecoder() {
2634
+ return getStructDecoder([
2635
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
2636
+ ["swapFeeBps", getU16Decoder()],
2637
+ ["feeSplitBps", getU16Decoder()]
2638
+ ]);
2639
+ }
2640
+ function getSetFeesInstructionDataCodec() {
2641
+ return combineCodec(
2642
+ getSetFeesInstructionDataEncoder(),
2643
+ getSetFeesInstructionDataDecoder()
2644
+ );
2645
+ }
2646
+ function getSetFeesInstruction(input, config) {
2647
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2648
+ const originalAccounts = {
2649
+ config: { value: input.config ?? null, isWritable: false },
2650
+ pool: { value: input.pool ?? null, isWritable: true },
2651
+ admin: { value: input.admin ?? null, isWritable: false }
2652
+ };
2653
+ const accounts = originalAccounts;
2654
+ const args = { ...input };
2655
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2656
+ return Object.freeze({
2657
+ accounts: [
2658
+ getAccountMeta("config", accounts.config),
2659
+ getAccountMeta("pool", accounts.pool),
2660
+ getAccountMeta("admin", accounts.admin)
2661
+ ],
2662
+ data: getSetFeesInstructionDataEncoder().encode(
2663
+ args
2664
+ ),
2665
+ programAddress
2666
+ });
2667
+ }
2668
+ function parseSetFeesInstruction(instruction) {
2669
+ if (instruction.accounts.length < 3) {
2670
+ throw new SolanaError(
2671
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2672
+ {
2673
+ actualAccountMetas: instruction.accounts.length,
2674
+ expectedAccountMetas: 3
2675
+ }
2676
+ );
2677
+ }
2678
+ let accountIndex = 0;
2679
+ const getNextAccount = () => {
2680
+ const accountMeta = instruction.accounts[accountIndex];
2681
+ accountIndex += 1;
2682
+ return accountMeta;
2683
+ };
2684
+ return {
2685
+ programAddress: instruction.programAddress,
2686
+ accounts: {
2687
+ config: getNextAccount(),
2688
+ pool: getNextAccount(),
2689
+ admin: getNextAccount()
2690
+ },
2691
+ data: getSetFeesInstructionDataDecoder().decode(instruction.data)
2692
+ };
2693
+ }
2694
+ var SET_ROUTE_DISCRIMINATOR = new Uint8Array([
2695
+ 244,
2696
+ 231,
2697
+ 3,
2698
+ 84,
2699
+ 233,
2700
+ 61,
2701
+ 146,
2702
+ 149
2703
+ ]);
2704
+ function getSetRouteDiscriminatorBytes() {
2705
+ return fixEncoderSize(getBytesEncoder(), 8).encode(SET_ROUTE_DISCRIMINATOR);
2706
+ }
2707
+ function getSetRouteInstructionDataEncoder() {
2708
+ return transformEncoder(
2709
+ getStructEncoder([
2710
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
2711
+ ["routeNextPool", getAddressEncoder()],
2712
+ ["routeBridgeMint", getAddressEncoder()]
2713
+ ]),
2714
+ (value) => ({ ...value, discriminator: SET_ROUTE_DISCRIMINATOR })
2715
+ );
2716
+ }
2717
+ function getSetRouteInstructionDataDecoder() {
2718
+ return getStructDecoder([
2719
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
2720
+ ["routeNextPool", getAddressDecoder()],
2721
+ ["routeBridgeMint", getAddressDecoder()]
2722
+ ]);
2723
+ }
2724
+ function getSetRouteInstructionDataCodec() {
2725
+ return combineCodec(
2726
+ getSetRouteInstructionDataEncoder(),
2727
+ getSetRouteInstructionDataDecoder()
2728
+ );
2729
+ }
2730
+ function getSetRouteInstruction(input, config) {
2731
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2732
+ const originalAccounts = {
2733
+ config: { value: input.config ?? null, isWritable: false },
2734
+ pool: { value: input.pool ?? null, isWritable: true },
2735
+ nextPool: { value: input.nextPool ?? null, isWritable: false },
2736
+ admin: { value: input.admin ?? null, isWritable: false }
2737
+ };
2738
+ const accounts = originalAccounts;
2739
+ const args = { ...input };
2740
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2741
+ return Object.freeze({
2742
+ accounts: [
2743
+ getAccountMeta("config", accounts.config),
2744
+ getAccountMeta("pool", accounts.pool),
2745
+ getAccountMeta("nextPool", accounts.nextPool),
2746
+ getAccountMeta("admin", accounts.admin)
2747
+ ],
2748
+ data: getSetRouteInstructionDataEncoder().encode(
2749
+ args
2750
+ ),
2751
+ programAddress
2752
+ });
2753
+ }
2754
+ function parseSetRouteInstruction(instruction) {
2755
+ if (instruction.accounts.length < 4) {
2756
+ throw new SolanaError(
2757
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2758
+ {
2759
+ actualAccountMetas: instruction.accounts.length,
2760
+ expectedAccountMetas: 4
2761
+ }
2762
+ );
2763
+ }
2764
+ let accountIndex = 0;
2765
+ const getNextAccount = () => {
2766
+ const accountMeta = instruction.accounts[accountIndex];
2767
+ accountIndex += 1;
2768
+ return accountMeta;
2769
+ };
2770
+ const getNextOptionalAccount = () => {
2771
+ const accountMeta = getNextAccount();
2772
+ return accountMeta.address === CPMM_PROGRAM_ADDRESS ? void 0 : accountMeta;
2773
+ };
2774
+ return {
2775
+ programAddress: instruction.programAddress,
2776
+ accounts: {
2777
+ config: getNextAccount(),
2778
+ pool: getNextAccount(),
2779
+ nextPool: getNextOptionalAccount(),
2780
+ admin: getNextAccount()
2781
+ },
2782
+ data: getSetRouteInstructionDataDecoder().decode(instruction.data)
2783
+ };
2784
+ }
2785
+ var SET_SENTINEL_DISCRIMINATOR = new Uint8Array([
2786
+ 94,
2787
+ 200,
2788
+ 82,
2789
+ 129,
2790
+ 53,
2791
+ 149,
2792
+ 232,
2793
+ 113
2794
+ ]);
2795
+ function getSetSentinelDiscriminatorBytes() {
2796
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
2797
+ SET_SENTINEL_DISCRIMINATOR
2798
+ );
2799
+ }
2800
+ function getSetSentinelInstructionDataEncoder() {
2801
+ return transformEncoder(
2802
+ getStructEncoder([
2803
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
2804
+ ["sentinelProgram", getAddressEncoder()],
2805
+ ["sentinelFlags", getU32Encoder()]
2806
+ ]),
2807
+ (value) => ({ ...value, discriminator: SET_SENTINEL_DISCRIMINATOR })
2808
+ );
2809
+ }
2810
+ function getSetSentinelInstructionDataDecoder() {
2811
+ return getStructDecoder([
2812
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
2813
+ ["sentinelProgram", getAddressDecoder()],
2814
+ ["sentinelFlags", getU32Decoder()]
2815
+ ]);
2816
+ }
2817
+ function getSetSentinelInstructionDataCodec() {
2818
+ return combineCodec(
2819
+ getSetSentinelInstructionDataEncoder(),
2820
+ getSetSentinelInstructionDataDecoder()
2821
+ );
2822
+ }
2823
+ function getSetSentinelInstruction(input, config) {
2824
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2825
+ const originalAccounts = {
2826
+ config: { value: input.config ?? null, isWritable: false },
2827
+ pool: { value: input.pool ?? null, isWritable: true },
2828
+ admin: { value: input.admin ?? null, isWritable: false }
2829
+ };
2830
+ const accounts = originalAccounts;
2831
+ const args = { ...input };
2832
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2833
+ return Object.freeze({
2834
+ accounts: [
2835
+ getAccountMeta("config", accounts.config),
2836
+ getAccountMeta("pool", accounts.pool),
2837
+ getAccountMeta("admin", accounts.admin)
2838
+ ],
2839
+ data: getSetSentinelInstructionDataEncoder().encode(
2840
+ args
2841
+ ),
2842
+ programAddress
2843
+ });
2844
+ }
2845
+ function parseSetSentinelInstruction(instruction) {
2846
+ if (instruction.accounts.length < 3) {
2847
+ throw new SolanaError(
2848
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2849
+ {
2850
+ actualAccountMetas: instruction.accounts.length,
2851
+ expectedAccountMetas: 3
2852
+ }
2853
+ );
2854
+ }
2855
+ let accountIndex = 0;
2856
+ const getNextAccount = () => {
2857
+ const accountMeta = instruction.accounts[accountIndex];
2858
+ accountIndex += 1;
2859
+ return accountMeta;
2860
+ };
2861
+ return {
2862
+ programAddress: instruction.programAddress,
2863
+ accounts: {
2864
+ config: getNextAccount(),
2865
+ pool: getNextAccount(),
2866
+ admin: getNextAccount()
2867
+ },
2868
+ data: getSetSentinelInstructionDataDecoder().decode(instruction.data)
2869
+ };
2870
+ }
2871
+ var SKIM_DISCRIMINATOR = new Uint8Array([
2872
+ 238,
2873
+ 120,
2874
+ 221,
2875
+ 138,
2876
+ 82,
2877
+ 60,
2878
+ 100,
2879
+ 218
2880
+ ]);
2881
+ function getSkimDiscriminatorBytes() {
2882
+ return fixEncoderSize(getBytesEncoder(), 8).encode(SKIM_DISCRIMINATOR);
2883
+ }
2884
+ function getSkimInstructionDataEncoder() {
2885
+ return transformEncoder(
2886
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
2887
+ (value) => ({ ...value, discriminator: SKIM_DISCRIMINATOR })
2888
+ );
2889
+ }
2890
+ function getSkimInstructionDataDecoder() {
2891
+ return getStructDecoder([
2892
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)]
2893
+ ]);
2894
+ }
2895
+ function getSkimInstructionDataCodec() {
2896
+ return combineCodec(
2897
+ getSkimInstructionDataEncoder(),
2898
+ getSkimInstructionDataDecoder()
2899
+ );
2900
+ }
2901
+ async function getSkimInstructionAsync(input, config) {
2902
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2903
+ const originalAccounts = {
2904
+ config: { value: input.config ?? null, isWritable: false },
2905
+ pool: { value: input.pool ?? null, isWritable: false },
2906
+ admin: { value: input.admin ?? null, isWritable: false },
2907
+ authority: { value: input.authority ?? null, isWritable: false },
2908
+ vault0: { value: input.vault0 ?? null, isWritable: true },
2909
+ vault1: { value: input.vault1 ?? null, isWritable: true },
2910
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
2911
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
2912
+ adminAta0: { value: input.adminAta0 ?? null, isWritable: true },
2913
+ adminAta1: { value: input.adminAta1 ?? null, isWritable: true },
2914
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
2915
+ token1Program: { value: input.token1Program ?? null, isWritable: false }
2916
+ };
2917
+ const accounts = originalAccounts;
2918
+ if (!accounts.authority.value) {
2919
+ accounts.authority.value = await getProgramDerivedAddress({
2920
+ programAddress,
2921
+ seeds: [
2922
+ getBytesEncoder().encode(
2923
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
2924
+ ),
2925
+ getAddressEncoder().encode(
2926
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
2927
+ )
2928
+ ]
2929
+ });
2930
+ }
2931
+ if (!accounts.adminAta0.value) {
2932
+ accounts.adminAta0.value = await getProgramDerivedAddress({
2933
+ programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
2934
+ seeds: [
2935
+ getAddressEncoder().encode(
2936
+ getAddressFromResolvedInstructionAccount(
2937
+ "admin",
2938
+ accounts.admin.value
2939
+ )
2940
+ ),
2941
+ getAddressEncoder().encode(
2942
+ getAddressFromResolvedInstructionAccount(
2943
+ "token0Program",
2944
+ accounts.token0Program.value
2945
+ )
2946
+ ),
2947
+ getAddressEncoder().encode(
2948
+ getAddressFromResolvedInstructionAccount(
2949
+ "token0Mint",
2950
+ accounts.token0Mint.value
2951
+ )
2952
+ )
2953
+ ]
2954
+ });
2955
+ }
2956
+ if (!accounts.adminAta1.value) {
2957
+ accounts.adminAta1.value = await getProgramDerivedAddress({
2958
+ programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
2959
+ seeds: [
2960
+ getAddressEncoder().encode(
2961
+ getAddressFromResolvedInstructionAccount(
2962
+ "admin",
2963
+ accounts.admin.value
2964
+ )
2965
+ ),
2966
+ getAddressEncoder().encode(
2967
+ getAddressFromResolvedInstructionAccount(
2968
+ "token1Program",
2969
+ accounts.token1Program.value
2970
+ )
2971
+ ),
2972
+ getAddressEncoder().encode(
2973
+ getAddressFromResolvedInstructionAccount(
2974
+ "token1Mint",
2975
+ accounts.token1Mint.value
2976
+ )
2977
+ )
2978
+ ]
2979
+ });
2980
+ }
2981
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2982
+ return Object.freeze({
2983
+ accounts: [
2984
+ getAccountMeta("config", accounts.config),
2985
+ getAccountMeta("pool", accounts.pool),
2986
+ getAccountMeta("admin", accounts.admin),
2987
+ getAccountMeta("authority", accounts.authority),
2988
+ getAccountMeta("vault0", accounts.vault0),
2989
+ getAccountMeta("vault1", accounts.vault1),
2990
+ getAccountMeta("token0Mint", accounts.token0Mint),
2991
+ getAccountMeta("token1Mint", accounts.token1Mint),
2992
+ getAccountMeta("adminAta0", accounts.adminAta0),
2993
+ getAccountMeta("adminAta1", accounts.adminAta1),
2994
+ getAccountMeta("token0Program", accounts.token0Program),
2995
+ getAccountMeta("token1Program", accounts.token1Program)
2996
+ ],
2997
+ data: getSkimInstructionDataEncoder().encode({}),
2998
+ programAddress
2999
+ });
3000
+ }
3001
+ function getSkimInstruction(input, config) {
3002
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
3003
+ const originalAccounts = {
3004
+ config: { value: input.config ?? null, isWritable: false },
3005
+ pool: { value: input.pool ?? null, isWritable: false },
3006
+ admin: { value: input.admin ?? null, isWritable: false },
3007
+ authority: { value: input.authority ?? null, isWritable: false },
3008
+ vault0: { value: input.vault0 ?? null, isWritable: true },
3009
+ vault1: { value: input.vault1 ?? null, isWritable: true },
3010
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
3011
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
3012
+ adminAta0: { value: input.adminAta0 ?? null, isWritable: true },
3013
+ adminAta1: { value: input.adminAta1 ?? null, isWritable: true },
3014
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
3015
+ token1Program: { value: input.token1Program ?? null, isWritable: false }
3016
+ };
3017
+ const accounts = originalAccounts;
3018
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3019
+ return Object.freeze({
3020
+ accounts: [
3021
+ getAccountMeta("config", accounts.config),
3022
+ getAccountMeta("pool", accounts.pool),
3023
+ getAccountMeta("admin", accounts.admin),
3024
+ getAccountMeta("authority", accounts.authority),
3025
+ getAccountMeta("vault0", accounts.vault0),
3026
+ getAccountMeta("vault1", accounts.vault1),
3027
+ getAccountMeta("token0Mint", accounts.token0Mint),
3028
+ getAccountMeta("token1Mint", accounts.token1Mint),
3029
+ getAccountMeta("adminAta0", accounts.adminAta0),
3030
+ getAccountMeta("adminAta1", accounts.adminAta1),
3031
+ getAccountMeta("token0Program", accounts.token0Program),
3032
+ getAccountMeta("token1Program", accounts.token1Program)
3033
+ ],
3034
+ data: getSkimInstructionDataEncoder().encode({}),
3035
+ programAddress
3036
+ });
3037
+ }
3038
+ function parseSkimInstruction(instruction) {
3039
+ if (instruction.accounts.length < 12) {
3040
+ throw new SolanaError(
3041
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3042
+ {
3043
+ actualAccountMetas: instruction.accounts.length,
3044
+ expectedAccountMetas: 12
3045
+ }
3046
+ );
3047
+ }
3048
+ let accountIndex = 0;
3049
+ const getNextAccount = () => {
3050
+ const accountMeta = instruction.accounts[accountIndex];
3051
+ accountIndex += 1;
3052
+ return accountMeta;
3053
+ };
3054
+ return {
3055
+ programAddress: instruction.programAddress,
3056
+ accounts: {
3057
+ config: getNextAccount(),
3058
+ pool: getNextAccount(),
3059
+ admin: getNextAccount(),
3060
+ authority: getNextAccount(),
3061
+ vault0: getNextAccount(),
3062
+ vault1: getNextAccount(),
3063
+ token0Mint: getNextAccount(),
3064
+ token1Mint: getNextAccount(),
3065
+ adminAta0: getNextAccount(),
3066
+ adminAta1: getNextAccount(),
3067
+ token0Program: getNextAccount(),
3068
+ token1Program: getNextAccount()
3069
+ },
3070
+ data: getSkimInstructionDataDecoder().decode(instruction.data)
3071
+ };
3072
+ }
3073
+ var SWAP_EXACT_IN_DISCRIMINATOR = new Uint8Array([
3074
+ 104,
3075
+ 104,
3076
+ 131,
3077
+ 86,
3078
+ 161,
3079
+ 189,
3080
+ 180,
3081
+ 216
3082
+ ]);
3083
+ function getSwapExactInDiscriminatorBytes() {
3084
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
3085
+ SWAP_EXACT_IN_DISCRIMINATOR
3086
+ );
3087
+ }
3088
+ function getSwapExactInInstructionDataEncoder() {
3089
+ return transformEncoder(
3090
+ getStructEncoder([
3091
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
3092
+ ["amountIn", getU64Encoder()],
3093
+ ["minAmountOut", getU64Encoder()],
3094
+ ["direction", getU8Encoder()],
3095
+ ["updateOracle", getBooleanEncoder()]
3096
+ ]),
3097
+ (value) => ({ ...value, discriminator: SWAP_EXACT_IN_DISCRIMINATOR })
3098
+ );
3099
+ }
3100
+ function getSwapExactInInstructionDataDecoder() {
3101
+ return getStructDecoder([
3102
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
3103
+ ["amountIn", getU64Decoder()],
3104
+ ["minAmountOut", getU64Decoder()],
3105
+ ["direction", getU8Decoder()],
3106
+ ["updateOracle", getBooleanDecoder()]
3107
+ ]);
3108
+ }
3109
+ function getSwapExactInInstructionDataCodec() {
3110
+ return combineCodec(
3111
+ getSwapExactInInstructionDataEncoder(),
3112
+ getSwapExactInInstructionDataDecoder()
3113
+ );
3114
+ }
3115
+ async function getSwapExactInInstructionAsync(input, config) {
3116
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
3117
+ const originalAccounts = {
3118
+ config: { value: input.config ?? null, isWritable: false },
3119
+ pool: { value: input.pool ?? null, isWritable: true },
3120
+ authority: { value: input.authority ?? null, isWritable: false },
3121
+ vaultIn: { value: input.vaultIn ?? null, isWritable: true },
3122
+ vaultOut: { value: input.vaultOut ?? null, isWritable: true },
3123
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
3124
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
3125
+ userIn: { value: input.userIn ?? null, isWritable: true },
3126
+ userOut: { value: input.userOut ?? null, isWritable: true },
3127
+ trader: { value: input.trader ?? null, isWritable: false },
3128
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
3129
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
3130
+ oracle: { value: input.oracle ?? null, isWritable: true }
3131
+ };
3132
+ const accounts = originalAccounts;
3133
+ const args = { ...input };
3134
+ if (!accounts.authority.value) {
3135
+ accounts.authority.value = await getProgramDerivedAddress({
3136
+ programAddress,
3137
+ seeds: [
3138
+ getBytesEncoder().encode(
3139
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
3140
+ ),
3141
+ getAddressEncoder().encode(
3142
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
3143
+ )
3144
+ ]
3145
+ });
3146
+ }
3147
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3148
+ return Object.freeze({
3149
+ accounts: [
3150
+ getAccountMeta("config", accounts.config),
3151
+ getAccountMeta("pool", accounts.pool),
3152
+ getAccountMeta("authority", accounts.authority),
3153
+ getAccountMeta("vaultIn", accounts.vaultIn),
3154
+ getAccountMeta("vaultOut", accounts.vaultOut),
3155
+ getAccountMeta("token0Mint", accounts.token0Mint),
3156
+ getAccountMeta("token1Mint", accounts.token1Mint),
3157
+ getAccountMeta("userIn", accounts.userIn),
3158
+ getAccountMeta("userOut", accounts.userOut),
3159
+ getAccountMeta("trader", accounts.trader),
3160
+ getAccountMeta("token0Program", accounts.token0Program),
3161
+ getAccountMeta("token1Program", accounts.token1Program),
3162
+ getAccountMeta("oracle", accounts.oracle)
3163
+ ],
3164
+ data: getSwapExactInInstructionDataEncoder().encode(
3165
+ args
3166
+ ),
3167
+ programAddress
3168
+ });
3169
+ }
3170
+ function getSwapExactInInstruction(input, config) {
3171
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
3172
+ const originalAccounts = {
3173
+ config: { value: input.config ?? null, isWritable: false },
3174
+ pool: { value: input.pool ?? null, isWritable: true },
3175
+ authority: { value: input.authority ?? null, isWritable: false },
3176
+ vaultIn: { value: input.vaultIn ?? null, isWritable: true },
3177
+ vaultOut: { value: input.vaultOut ?? null, isWritable: true },
3178
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
3179
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
3180
+ userIn: { value: input.userIn ?? null, isWritable: true },
3181
+ userOut: { value: input.userOut ?? null, isWritable: true },
3182
+ trader: { value: input.trader ?? null, isWritable: false },
3183
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
3184
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
3185
+ oracle: { value: input.oracle ?? null, isWritable: true }
3186
+ };
3187
+ const accounts = originalAccounts;
3188
+ const args = { ...input };
3189
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3190
+ return Object.freeze({
3191
+ accounts: [
3192
+ getAccountMeta("config", accounts.config),
3193
+ getAccountMeta("pool", accounts.pool),
3194
+ getAccountMeta("authority", accounts.authority),
3195
+ getAccountMeta("vaultIn", accounts.vaultIn),
3196
+ getAccountMeta("vaultOut", accounts.vaultOut),
3197
+ getAccountMeta("token0Mint", accounts.token0Mint),
3198
+ getAccountMeta("token1Mint", accounts.token1Mint),
3199
+ getAccountMeta("userIn", accounts.userIn),
3200
+ getAccountMeta("userOut", accounts.userOut),
3201
+ getAccountMeta("trader", accounts.trader),
3202
+ getAccountMeta("token0Program", accounts.token0Program),
3203
+ getAccountMeta("token1Program", accounts.token1Program),
3204
+ getAccountMeta("oracle", accounts.oracle)
3205
+ ],
3206
+ data: getSwapExactInInstructionDataEncoder().encode(
3207
+ args
3208
+ ),
3209
+ programAddress
3210
+ });
3211
+ }
3212
+ function parseSwapExactInInstruction(instruction) {
3213
+ if (instruction.accounts.length < 13) {
3214
+ throw new SolanaError(
3215
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3216
+ {
3217
+ actualAccountMetas: instruction.accounts.length,
3218
+ expectedAccountMetas: 13
3219
+ }
3220
+ );
3221
+ }
3222
+ let accountIndex = 0;
3223
+ const getNextAccount = () => {
3224
+ const accountMeta = instruction.accounts[accountIndex];
3225
+ accountIndex += 1;
3226
+ return accountMeta;
3227
+ };
3228
+ const getNextOptionalAccount = () => {
3229
+ const accountMeta = getNextAccount();
3230
+ return accountMeta.address === CPMM_PROGRAM_ADDRESS ? void 0 : accountMeta;
3231
+ };
3232
+ return {
3233
+ programAddress: instruction.programAddress,
3234
+ accounts: {
3235
+ config: getNextAccount(),
3236
+ pool: getNextAccount(),
3237
+ authority: getNextAccount(),
3238
+ vaultIn: getNextAccount(),
3239
+ vaultOut: getNextAccount(),
3240
+ token0Mint: getNextAccount(),
3241
+ token1Mint: getNextAccount(),
3242
+ userIn: getNextAccount(),
3243
+ userOut: getNextAccount(),
3244
+ trader: getNextAccount(),
3245
+ token0Program: getNextAccount(),
3246
+ token1Program: getNextAccount(),
3247
+ oracle: getNextOptionalAccount()
3248
+ },
3249
+ data: getSwapExactInInstructionDataDecoder().decode(instruction.data)
3250
+ };
3251
+ }
3252
+ var TRANSFER_ADMIN_DISCRIMINATOR = new Uint8Array([
3253
+ 42,
3254
+ 242,
3255
+ 66,
3256
+ 106,
3257
+ 228,
3258
+ 10,
3259
+ 111,
3260
+ 156
3261
+ ]);
3262
+ function getTransferAdminDiscriminatorBytes() {
3263
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
3264
+ TRANSFER_ADMIN_DISCRIMINATOR
3265
+ );
3266
+ }
3267
+ function getTransferAdminInstructionDataEncoder() {
3268
+ return transformEncoder(
3269
+ getStructEncoder([
3270
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
3271
+ ["newAdmin", getAddressEncoder()]
3272
+ ]),
3273
+ (value) => ({ ...value, discriminator: TRANSFER_ADMIN_DISCRIMINATOR })
3274
+ );
3275
+ }
3276
+ function getTransferAdminInstructionDataDecoder() {
3277
+ return getStructDecoder([
3278
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
3279
+ ["newAdmin", getAddressDecoder()]
3280
+ ]);
3281
+ }
3282
+ function getTransferAdminInstructionDataCodec() {
3283
+ return combineCodec(
3284
+ getTransferAdminInstructionDataEncoder(),
3285
+ getTransferAdminInstructionDataDecoder()
3286
+ );
3287
+ }
3288
+ function getTransferAdminInstruction(input, config) {
3289
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
3290
+ const originalAccounts = {
3291
+ config: { value: input.config ?? null, isWritable: true },
3292
+ admin: { value: input.admin ?? null, isWritable: false }
3293
+ };
3294
+ const accounts = originalAccounts;
3295
+ const args = { ...input };
3296
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3297
+ return Object.freeze({
3298
+ accounts: [
3299
+ getAccountMeta("config", accounts.config),
3300
+ getAccountMeta("admin", accounts.admin)
3301
+ ],
3302
+ data: getTransferAdminInstructionDataEncoder().encode(
3303
+ args
3304
+ ),
3305
+ programAddress
3306
+ });
3307
+ }
3308
+ function parseTransferAdminInstruction(instruction) {
3309
+ if (instruction.accounts.length < 2) {
3310
+ throw new SolanaError(
3311
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3312
+ {
3313
+ actualAccountMetas: instruction.accounts.length,
3314
+ expectedAccountMetas: 2
3315
+ }
3316
+ );
3317
+ }
3318
+ let accountIndex = 0;
3319
+ const getNextAccount = () => {
3320
+ const accountMeta = instruction.accounts[accountIndex];
3321
+ accountIndex += 1;
3322
+ return accountMeta;
3323
+ };
3324
+ return {
3325
+ programAddress: instruction.programAddress,
3326
+ accounts: { config: getNextAccount(), admin: getNextAccount() },
3327
+ data: getTransferAdminInstructionDataDecoder().decode(instruction.data)
3328
+ };
3329
+ }
3330
+ var UNPAUSE_DISCRIMINATOR = new Uint8Array([
3331
+ 169,
3332
+ 144,
3333
+ 4,
3334
+ 38,
3335
+ 10,
3336
+ 141,
3337
+ 188,
3338
+ 255
3339
+ ]);
3340
+ function getUnpauseDiscriminatorBytes() {
3341
+ return fixEncoderSize(getBytesEncoder(), 8).encode(UNPAUSE_DISCRIMINATOR);
3342
+ }
3343
+ function getUnpauseInstructionDataEncoder() {
3344
+ return transformEncoder(
3345
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
3346
+ (value) => ({ ...value, discriminator: UNPAUSE_DISCRIMINATOR })
3347
+ );
3348
+ }
3349
+ function getUnpauseInstructionDataDecoder() {
3350
+ return getStructDecoder([
3351
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)]
3352
+ ]);
3353
+ }
3354
+ function getUnpauseInstructionDataCodec() {
3355
+ return combineCodec(
3356
+ getUnpauseInstructionDataEncoder(),
3357
+ getUnpauseInstructionDataDecoder()
3358
+ );
3359
+ }
3360
+ function getUnpauseInstruction(input, config) {
3361
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
3362
+ const originalAccounts = {
3363
+ config: { value: input.config ?? null, isWritable: true },
3364
+ admin: { value: input.admin ?? null, isWritable: false }
3365
+ };
3366
+ const accounts = originalAccounts;
3367
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3368
+ return Object.freeze({
3369
+ accounts: [
3370
+ getAccountMeta("config", accounts.config),
3371
+ getAccountMeta("admin", accounts.admin)
3372
+ ],
3373
+ data: getUnpauseInstructionDataEncoder().encode({}),
3374
+ programAddress
3375
+ });
3376
+ }
3377
+ function parseUnpauseInstruction(instruction) {
3378
+ if (instruction.accounts.length < 2) {
3379
+ throw new SolanaError(
3380
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3381
+ {
3382
+ actualAccountMetas: instruction.accounts.length,
3383
+ expectedAccountMetas: 2
3384
+ }
3385
+ );
3386
+ }
3387
+ let accountIndex = 0;
3388
+ const getNextAccount = () => {
3389
+ const accountMeta = instruction.accounts[accountIndex];
3390
+ accountIndex += 1;
3391
+ return accountMeta;
3392
+ };
3393
+ return {
3394
+ programAddress: instruction.programAddress,
3395
+ accounts: { config: getNextAccount(), admin: getNextAccount() },
3396
+ data: getUnpauseInstructionDataDecoder().decode(instruction.data)
3397
+ };
3398
+ }
3399
+ var UPDATE_CONFIG_DISCRIMINATOR = new Uint8Array([
3400
+ 29,
3401
+ 158,
3402
+ 252,
3403
+ 191,
3404
+ 10,
3405
+ 83,
3406
+ 219,
3407
+ 99
3408
+ ]);
3409
+ function getUpdateConfigDiscriminatorBytes() {
3410
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
3411
+ UPDATE_CONFIG_DISCRIMINATOR
3412
+ );
3413
+ }
3414
+ function getUpdateConfigInstructionDataEncoder() {
3415
+ return transformEncoder(
3416
+ getStructEncoder([
3417
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
3418
+ ["numeraireMint", getAddressEncoder()],
3419
+ ["maxSwapFeeBps", getU16Encoder()],
3420
+ ["maxFeeSplitBps", getU16Encoder()],
3421
+ ["maxRouteHops", getU8Encoder()],
3422
+ ["protocolFeeEnabled", getBooleanEncoder()],
3423
+ ["protocolFeeBps", getU16Encoder()],
3424
+ ["sentinelAllowlist", getArrayEncoder(getAddressEncoder())]
3425
+ ]),
3426
+ (value) => ({ ...value, discriminator: UPDATE_CONFIG_DISCRIMINATOR })
3427
+ );
3428
+ }
3429
+ function getUpdateConfigInstructionDataDecoder() {
3430
+ return getStructDecoder([
3431
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
3432
+ ["numeraireMint", getAddressDecoder()],
3433
+ ["maxSwapFeeBps", getU16Decoder()],
3434
+ ["maxFeeSplitBps", getU16Decoder()],
3435
+ ["maxRouteHops", getU8Decoder()],
3436
+ ["protocolFeeEnabled", getBooleanDecoder()],
3437
+ ["protocolFeeBps", getU16Decoder()],
3438
+ ["sentinelAllowlist", getArrayDecoder(getAddressDecoder())]
3439
+ ]);
3440
+ }
3441
+ function getUpdateConfigInstructionDataCodec() {
3442
+ return combineCodec(
3443
+ getUpdateConfigInstructionDataEncoder(),
3444
+ getUpdateConfigInstructionDataDecoder()
3445
+ );
3446
+ }
3447
+ function getUpdateConfigInstruction(input, config) {
3448
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
3449
+ const originalAccounts = {
3450
+ config: { value: input.config ?? null, isWritable: true },
3451
+ admin: { value: input.admin ?? null, isWritable: false }
3452
+ };
3453
+ const accounts = originalAccounts;
3454
+ const args = { ...input };
3455
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3456
+ return Object.freeze({
3457
+ accounts: [
3458
+ getAccountMeta("config", accounts.config),
3459
+ getAccountMeta("admin", accounts.admin)
3460
+ ],
3461
+ data: getUpdateConfigInstructionDataEncoder().encode(
3462
+ args
3463
+ ),
3464
+ programAddress
3465
+ });
3466
+ }
3467
+ function parseUpdateConfigInstruction(instruction) {
3468
+ if (instruction.accounts.length < 2) {
3469
+ throw new SolanaError(
3470
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3471
+ {
3472
+ actualAccountMetas: instruction.accounts.length,
3473
+ expectedAccountMetas: 2
3474
+ }
3475
+ );
752
3476
  }
753
- const data = encodeInstructionData(
754
- INSTRUCTION_DISCRIMINATORS.swapExactIn,
755
- swapExactInArgsCodec,
756
- args
757
- );
3477
+ let accountIndex = 0;
3478
+ const getNextAccount = () => {
3479
+ const accountMeta = instruction.accounts[accountIndex];
3480
+ accountIndex += 1;
3481
+ return accountMeta;
3482
+ };
758
3483
  return {
759
- programAddress: programId,
760
- accounts: keys,
761
- data
3484
+ programAddress: instruction.programAddress,
3485
+ accounts: { config: getNextAccount(), admin: getNextAccount() },
3486
+ data: getUpdateConfigInstructionDataDecoder().decode(instruction.data)
762
3487
  };
763
3488
  }
764
3489
  function createSwapInstruction(params) {
@@ -777,17 +3502,16 @@ function createSwapInstruction(params) {
777
3502
  minAmountOut,
778
3503
  direction,
779
3504
  oracle,
780
- remainingAccounts,
3505
+ remainingAccounts = [],
781
3506
  updateOracle = false,
782
3507
  token0Program,
783
3508
  token1Program,
784
3509
  tokenProgram,
785
- instructionsSysvar,
786
- programId = CPMM_PROGRAM_ID
3510
+ programId = CPMM_PROGRAM_ADDRESS
787
3511
  } = params;
788
3512
  const [vaultIn, vaultOut] = direction === 0 ? [vault0, vault1] : [vault1, vault0];
789
3513
  const [userIn, userOut] = direction === 0 ? [userToken0, userToken1] : [userToken1, userToken0];
790
- return createSwapExactInInstruction(
3514
+ const instruction = getSwapExactInInstruction(
791
3515
  {
792
3516
  config,
793
3517
  pool,
@@ -798,275 +3522,29 @@ function createSwapInstruction(params) {
798
3522
  token1Mint,
799
3523
  userIn,
800
3524
  userOut,
801
- user,
802
- token0Program,
803
- token1Program,
804
- tokenProgram,
805
- instructionsSysvar,
3525
+ trader: createNoopSigner(user),
3526
+ token0Program: token0Program ?? tokenProgram ?? TOKEN_PROGRAM_ADDRESS,
3527
+ token1Program: token1Program ?? tokenProgram ?? TOKEN_PROGRAM_ADDRESS,
806
3528
  oracle,
807
- remainingAccounts
808
- },
809
- {
810
3529
  amountIn,
811
3530
  minAmountOut,
812
3531
  direction,
813
3532
  updateOracle
814
3533
  },
815
- programId
816
- );
817
- }
818
- function createCreatePositionInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
819
- const {
820
- pool,
821
- position,
822
- owner,
823
- payer,
824
- systemProgram = SYSTEM_PROGRAM_ADDRESS
825
- } = accounts;
826
- const keys = [
827
- { address: pool, role: AccountRole.READONLY },
828
- { address: position, role: AccountRole.WRITABLE },
829
- { address: owner, role: AccountRole.READONLY_SIGNER },
830
- { address: payer, role: AccountRole.WRITABLE_SIGNER },
831
- { address: systemProgram, role: AccountRole.READONLY }
832
- ];
833
- const data = encodeInstructionData(
834
- INSTRUCTION_DISCRIMINATORS.createPosition,
835
- createPositionArgsCodec,
836
- args
837
- );
838
- return {
839
- programAddress: programId,
840
- accounts: keys,
841
- data
842
- };
843
- }
844
- function createClosePositionInstruction(accounts, programId = CPMM_PROGRAM_ID) {
845
- const { pool, position, owner, rentRecipient } = accounts;
846
- const keys = [
847
- { address: pool, role: AccountRole.READONLY },
848
- { address: position, role: AccountRole.WRITABLE },
849
- { address: owner, role: AccountRole.READONLY_SIGNER },
850
- { address: rentRecipient, role: AccountRole.WRITABLE }
851
- ];
852
- const data = INSTRUCTION_DISCRIMINATORS.closePosition;
853
- return {
854
- programAddress: programId,
855
- accounts: keys,
856
- data
857
- };
858
- }
859
- var addLiquidityArgsWithOracleCodec = getStructCodec([
860
- ["amount0Max", getU64Codec()],
861
- ["amount1Max", getU64Codec()],
862
- ["minSharesOut", getU128Codec()],
863
- ["updateOracle", getBooleanCodec()]
864
- ]);
865
- function createAddLiquidityInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
866
- const {
867
- config,
868
- pool,
869
- position,
870
- protocolPosition,
871
- owner,
872
- authority,
873
- vault0,
874
- vault1,
875
- token0Mint,
876
- token1Mint,
877
- user0,
878
- user1,
879
- tokenProgram = TOKEN_PROGRAM_ADDRESS,
880
- oracle,
881
- remainingAccounts = []
882
- } = accounts;
883
- const keys = [
884
- { address: config, role: AccountRole.READONLY },
885
- { address: pool, role: AccountRole.WRITABLE },
886
- { address: position, role: AccountRole.WRITABLE },
887
- { address: protocolPosition, role: AccountRole.WRITABLE },
888
- { address: owner, role: AccountRole.READONLY_SIGNER },
889
- { address: authority, role: AccountRole.READONLY },
890
- { address: vault0, role: AccountRole.WRITABLE },
891
- { address: vault1, role: AccountRole.WRITABLE },
892
- { address: token0Mint, role: AccountRole.READONLY },
893
- { address: token1Mint, role: AccountRole.READONLY },
894
- { address: user0, role: AccountRole.WRITABLE },
895
- { address: user1, role: AccountRole.WRITABLE },
896
- { address: tokenProgram, role: AccountRole.READONLY }
897
- ];
898
- if (oracle) {
899
- keys.push({ address: oracle, role: AccountRole.WRITABLE });
900
- }
901
- for (const account of remainingAccounts) {
902
- keys.push({ address: account, role: AccountRole.READONLY });
903
- }
904
- const data = encodeInstructionData(
905
- INSTRUCTION_DISCRIMINATORS.addLiquidity,
906
- addLiquidityArgsWithOracleCodec,
907
- args
908
- );
909
- return {
910
- programAddress: programId,
911
- accounts: keys,
912
- data
913
- };
914
- }
915
- function createRemoveLiquidityInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
916
- const {
917
- config,
918
- pool,
919
- position,
920
- protocolPosition,
921
- owner,
922
- authority,
923
- vault0,
924
- vault1,
925
- token0Mint,
926
- token1Mint,
927
- user0,
928
- user1,
929
- tokenProgram = TOKEN_PROGRAM_ADDRESS,
930
- oracle,
931
- remainingAccounts = []
932
- } = accounts;
933
- const keys = [
934
- { address: config, role: AccountRole.READONLY },
935
- { address: pool, role: AccountRole.WRITABLE },
936
- { address: position, role: AccountRole.WRITABLE },
937
- { address: protocolPosition, role: AccountRole.WRITABLE },
938
- { address: owner, role: AccountRole.READONLY_SIGNER },
939
- { address: authority, role: AccountRole.READONLY },
940
- { address: vault0, role: AccountRole.WRITABLE },
941
- { address: vault1, role: AccountRole.WRITABLE },
942
- { address: token0Mint, role: AccountRole.READONLY },
943
- { address: token1Mint, role: AccountRole.READONLY },
944
- { address: user0, role: AccountRole.WRITABLE },
945
- { address: user1, role: AccountRole.WRITABLE },
946
- { address: tokenProgram, role: AccountRole.READONLY }
947
- ];
948
- if (oracle) {
949
- keys.push({ address: oracle, role: AccountRole.WRITABLE });
950
- }
951
- for (const account of remainingAccounts) {
952
- keys.push({ address: account, role: AccountRole.READONLY });
953
- }
954
- const data = encodeInstructionData(
955
- INSTRUCTION_DISCRIMINATORS.removeLiquidity,
956
- removeLiquidityArgsCodec,
957
- args
958
- );
959
- return {
960
- programAddress: programId,
961
- accounts: keys,
962
- data
963
- };
964
- }
965
- function createCollectProtocolFeesInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
966
- const {
967
- config,
968
- pool,
969
- protocolPosition,
970
- admin,
971
- authority,
972
- vault0,
973
- vault1,
974
- token0Mint,
975
- token1Mint,
976
- recipient0,
977
- recipient1,
978
- tokenProgram = TOKEN_PROGRAM_ADDRESS
979
- } = accounts;
980
- const keys = [
981
- { address: config, role: AccountRole.READONLY },
982
- { address: pool, role: AccountRole.WRITABLE },
983
- { address: protocolPosition, role: AccountRole.WRITABLE },
984
- { address: admin, role: AccountRole.READONLY_SIGNER },
985
- { address: authority, role: AccountRole.READONLY },
986
- { address: vault0, role: AccountRole.WRITABLE },
987
- { address: vault1, role: AccountRole.WRITABLE },
988
- { address: token0Mint, role: AccountRole.READONLY },
989
- { address: token1Mint, role: AccountRole.READONLY },
990
- { address: recipient0, role: AccountRole.WRITABLE },
991
- { address: recipient1, role: AccountRole.WRITABLE },
992
- { address: tokenProgram, role: AccountRole.READONLY }
993
- ];
994
- const data = encodeInstructionData(
995
- INSTRUCTION_DISCRIMINATORS.collectProtocolFees,
996
- collectProtocolFeesArgsCodec,
997
- args
998
- );
999
- return {
1000
- programAddress: programId,
1001
- accounts: keys,
1002
- data
1003
- };
1004
- }
1005
- function createOracleUpdateInstruction(accounts, programId = CPMM_PROGRAM_ID) {
1006
- const { pool, oracle } = accounts;
1007
- const keys = [
1008
- { address: pool, role: AccountRole.READONLY },
1009
- { address: oracle, role: AccountRole.WRITABLE }
1010
- ];
1011
- const data = INSTRUCTION_DISCRIMINATORS.oracleUpdate;
1012
- return {
1013
- programAddress: programId,
1014
- accounts: keys,
1015
- data
1016
- };
1017
- }
1018
- var oracleConsultResultCodec = getStructCodec([
1019
- ["price0Q64", getU128Codec()],
1020
- ["price1Q64", getU128Codec()]
1021
- ]);
1022
- function decodeOracleConsultResult(data) {
1023
- return oracleConsultResultCodec.decode(data);
1024
- }
1025
- function createOracleConsultInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
1026
- const { pool, oracle } = accounts;
1027
- const keys = [
1028
- { address: pool, role: AccountRole.READONLY },
1029
- { address: oracle, role: AccountRole.READONLY }
1030
- ];
1031
- const data = encodeInstructionData(
1032
- INSTRUCTION_DISCRIMINATORS.oracleConsult,
1033
- oracleConsultArgsCodec,
1034
- args
1035
- );
1036
- return {
1037
- programAddress: programId,
1038
- accounts: keys,
1039
- data
1040
- };
1041
- }
1042
- var quoteToNumeraireResultCodec = getStructCodec([
1043
- ["amountInNumeraire", getU128Codec()],
1044
- ["endMint", getAddressCodec()],
1045
- ["hopsUsed", getU8Codec()]
1046
- ]);
1047
- function decodeQuoteToNumeraireResult(data) {
1048
- return quoteToNumeraireResultCodec.decode(data);
1049
- }
1050
- function createQuoteToNumeraireInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
1051
- const { config, startPool, remainingAccounts = [] } = accounts;
1052
- const keys = [
1053
- { address: config, role: AccountRole.READONLY },
1054
- { address: startPool, role: AccountRole.READONLY }
1055
- ];
1056
- for (const account of remainingAccounts) {
1057
- keys.push({ address: account, role: AccountRole.READONLY });
1058
- }
1059
- const data = encodeInstructionData(
1060
- INSTRUCTION_DISCRIMINATORS.quoteToNumeraire,
1061
- quoteToNumeraireArgsCodec,
1062
- args
3534
+ { programAddress: programId }
1063
3535
  );
1064
3536
  return {
1065
- programAddress: programId,
1066
- accounts: keys,
1067
- data
3537
+ ...instruction,
3538
+ accounts: [
3539
+ ...instruction.accounts ?? [],
3540
+ ...remainingAccounts.map((address3) => ({
3541
+ address: address3,
3542
+ role: AccountRole.READONLY
3543
+ }))
3544
+ ]
1068
3545
  };
1069
3546
  }
3547
+ var MAX_FEE_AMOUNT = BigInt("18446744073709551615");
1070
3548
 
1071
3549
  // src/solana/client/config.ts
1072
3550
  function base64ToBytes(base64) {
@@ -1126,7 +3604,7 @@ __export(initializer_exports, {
1126
3604
  SF_BEFORE_SWAP: () => SF_BEFORE_SWAP2,
1127
3605
  computeRemainingAccountsHash: () => computeRemainingAccountsHash,
1128
3606
  createCurveSwapExactInInstruction: () => createCurveSwapExactInInstruction,
1129
- createInitializeConfigInstruction: () => createInitializeConfigInstruction2,
3607
+ createInitializeConfigInstruction: () => createInitializeConfigInstruction,
1130
3608
  createInitializeLaunchInstruction: () => createInitializeLaunchInstruction,
1131
3609
  createMigrateLaunchInstruction: () => createMigrateLaunchInstruction,
1132
3610
  createPreviewMigrationInstruction: () => createPreviewMigrationInstruction,
@@ -1424,6 +3902,10 @@ function getInitializeLaunchArgsEncoder() {
1424
3902
  addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())
1425
3903
  ],
1426
3904
  ["sentinelRemainingAccountsHash", fixEncoderSize(getBytesEncoder(), 32)],
3905
+ [
3906
+ "migratorInitRemainingAccountsHash",
3907
+ fixEncoderSize(getBytesEncoder(), 32)
3908
+ ],
1427
3909
  ["migratorRemainingAccountsHash", fixEncoderSize(getBytesEncoder(), 32)],
1428
3910
  ["metadataName", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
1429
3911
  ["metadataSymbol", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
@@ -1461,6 +3943,10 @@ function getInitializeLaunchArgsDecoder() {
1461
3943
  addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())
1462
3944
  ],
1463
3945
  ["sentinelRemainingAccountsHash", fixDecoderSize(getBytesDecoder(), 32)],
3946
+ [
3947
+ "migratorInitRemainingAccountsHash",
3948
+ fixDecoderSize(getBytesDecoder(), 32)
3949
+ ],
1464
3950
  ["migratorRemainingAccountsHash", fixDecoderSize(getBytesDecoder(), 32)],
1465
3951
  ["metadataName", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
1466
3952
  ["metadataSymbol", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
@@ -1592,7 +4078,7 @@ function getCurveSwapExactInInstructionDataEncoder() {
1592
4078
  (value) => ({ ...value, discriminator: CURVE_SWAP_EXACT_IN_DISCRIMINATOR })
1593
4079
  );
1594
4080
  }
1595
- var INITIALIZE_CONFIG_DISCRIMINATOR = new Uint8Array([
4081
+ var INITIALIZE_CONFIG_DISCRIMINATOR2 = new Uint8Array([
1596
4082
  208,
1597
4083
  127,
1598
4084
  21,
@@ -1602,14 +4088,14 @@ var INITIALIZE_CONFIG_DISCRIMINATOR = new Uint8Array([
1602
4088
  196,
1603
4089
  70
1604
4090
  ]);
1605
- function getInitializeConfigInstructionDataEncoder() {
4091
+ function getInitializeConfigInstructionDataEncoder2() {
1606
4092
  return transformEncoder(
1607
4093
  getStructEncoder([
1608
4094
  ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1609
4095
  ["migratorAllowlist", getArrayEncoder(getAddressEncoder())],
1610
4096
  ["sentinelAllowlist", getArrayEncoder(getAddressEncoder())]
1611
4097
  ]),
1612
- (value) => ({ ...value, discriminator: INITIALIZE_CONFIG_DISCRIMINATOR })
4098
+ (value) => ({ ...value, discriminator: INITIALIZE_CONFIG_DISCRIMINATOR2 })
1613
4099
  );
1614
4100
  }
1615
4101
  var INITIALIZE_LAUNCH_DISCRIMINATOR = new Uint8Array([
@@ -1655,6 +4141,10 @@ function getInitializeLaunchInstructionDataEncoder() {
1655
4141
  addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())
1656
4142
  ],
1657
4143
  ["sentinelRemainingAccountsHash", fixEncoderSize(getBytesEncoder(), 32)],
4144
+ [
4145
+ "migratorInitRemainingAccountsHash",
4146
+ fixEncoderSize(getBytesEncoder(), 32)
4147
+ ],
1658
4148
  ["migratorRemainingAccountsHash", fixEncoderSize(getBytesEncoder(), 32)],
1659
4149
  ["metadataName", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
1660
4150
  [
@@ -1666,7 +4156,7 @@ function getInitializeLaunchInstructionDataEncoder() {
1666
4156
  (value) => ({ ...value, discriminator: INITIALIZE_LAUNCH_DISCRIMINATOR })
1667
4157
  );
1668
4158
  }
1669
- var PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR = new Uint8Array([
4159
+ var PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR2 = new Uint8Array([
1670
4160
  50,
1671
4161
  130,
1672
4162
  31,
@@ -1676,7 +4166,7 @@ var PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR = new Uint8Array([
1676
4166
  222,
1677
4167
  178
1678
4168
  ]);
1679
- function getPreviewSwapExactInInstructionDataEncoder() {
4169
+ function getPreviewSwapExactInInstructionDataEncoder2() {
1680
4170
  return transformEncoder(
1681
4171
  getStructEncoder([
1682
4172
  ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
@@ -1685,7 +4175,7 @@ function getPreviewSwapExactInInstructionDataEncoder() {
1685
4175
  ]),
1686
4176
  (value) => ({
1687
4177
  ...value,
1688
- discriminator: PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR
4178
+ discriminator: PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR2
1689
4179
  })
1690
4180
  );
1691
4181
  }
@@ -1781,40 +4271,38 @@ function launchIdFromU64(launchId) {
1781
4271
  out.set(encodeU64LE(launchId), 0);
1782
4272
  return out;
1783
4273
  }
1784
- function isTransactionSigner2(value) {
4274
+ function isTransactionSigner(value) {
1785
4275
  return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
1786
4276
  }
1787
- function createSignerAccountMeta2(value, role) {
1788
- if (isTransactionSigner2(value)) {
4277
+ function createSignerAccountMeta(value, role) {
4278
+ if (isTransactionSigner(value)) {
1789
4279
  return { address: value.address, role, signer: value };
1790
4280
  }
1791
4281
  return { address: value, role };
1792
4282
  }
1793
- function createInitializeConfigInstruction2(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
4283
+ function createInitializeConfigInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
1794
4284
  const {
1795
4285
  admin,
1796
4286
  config,
1797
4287
  programData,
1798
- systemProgram = SYSTEM_PROGRAM_ADDRESS,
1799
- instructionsSysvar = SYSVAR_INSTRUCTIONS_ADDRESS
4288
+ systemProgram = SYSTEM_PROGRAM_ADDRESS
1800
4289
  } = accounts;
1801
4290
  const keys = [
1802
- createSignerAccountMeta2(admin, AccountRole.WRITABLE_SIGNER),
4291
+ createSignerAccountMeta(admin, AccountRole.WRITABLE_SIGNER),
1803
4292
  { address: config, role: AccountRole.WRITABLE },
1804
4293
  { address: programData, role: AccountRole.READONLY },
1805
- { address: systemProgram, role: AccountRole.READONLY },
1806
- { address: instructionsSysvar, role: AccountRole.READONLY }
4294
+ { address: systemProgram, role: AccountRole.READONLY }
1807
4295
  ];
1808
4296
  const data = new Uint8Array(
1809
- getInitializeConfigInstructionDataEncoder().encode(args)
4297
+ getInitializeConfigInstructionDataEncoder2().encode(args)
1810
4298
  );
1811
4299
  return { programAddress: programId, accounts: keys, data };
1812
4300
  }
1813
- function isTransactionSigner3(value) {
4301
+ function isTransactionSigner2(value) {
1814
4302
  return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
1815
4303
  }
1816
- function createSignerAccountMeta3(value, role) {
1817
- if (isTransactionSigner3(value)) {
4304
+ function createSignerAccountMeta2(value, role) {
4305
+ if (isTransactionSigner2(value)) {
1818
4306
  return { address: value.address, role, signer: value };
1819
4307
  }
1820
4308
  return { address: value, role };
@@ -1822,7 +4310,7 @@ function createSignerAccountMeta3(value, role) {
1822
4310
  function createSetMigratorAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
1823
4311
  const { admin, config } = accounts;
1824
4312
  const keys = [
1825
- createSignerAccountMeta3(admin, AccountRole.WRITABLE_SIGNER),
4313
+ createSignerAccountMeta2(admin, AccountRole.WRITABLE_SIGNER),
1826
4314
  { address: config, role: AccountRole.WRITABLE }
1827
4315
  ];
1828
4316
  const data = new Uint8Array(
@@ -1830,11 +4318,11 @@ function createSetMigratorAllowlistInstruction(accounts, allowlist, programId =
1830
4318
  );
1831
4319
  return { programAddress: programId, accounts: keys, data };
1832
4320
  }
1833
- function isTransactionSigner4(value) {
4321
+ function isTransactionSigner3(value) {
1834
4322
  return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
1835
4323
  }
1836
- function createSignerAccountMeta4(value, role) {
1837
- if (isTransactionSigner4(value)) {
4324
+ function createSignerAccountMeta3(value, role) {
4325
+ if (isTransactionSigner3(value)) {
1838
4326
  return { address: value.address, role, signer: value };
1839
4327
  }
1840
4328
  return { address: value, role };
@@ -1842,7 +4330,7 @@ function createSignerAccountMeta4(value, role) {
1842
4330
  function createSetSentinelAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
1843
4331
  const { admin, config } = accounts;
1844
4332
  const keys = [
1845
- createSignerAccountMeta4(admin, AccountRole.WRITABLE_SIGNER),
4333
+ createSignerAccountMeta3(admin, AccountRole.WRITABLE_SIGNER),
1846
4334
  { address: config, role: AccountRole.WRITABLE }
1847
4335
  ];
1848
4336
  const data = new Uint8Array(
@@ -2492,7 +4980,7 @@ async function fetchAllMaybeMarket(rpc, addresses, config) {
2492
4980
  function getMarketSize() {
2493
4981
  return 208;
2494
4982
  }
2495
- var ORACLE_STATE_DISCRIMINATOR = new Uint8Array([
4983
+ var ORACLE_STATE_DISCRIMINATOR2 = new Uint8Array([
2496
4984
  97,
2497
4985
  156,
2498
4986
  157,
@@ -2504,7 +4992,7 @@ var ORACLE_STATE_DISCRIMINATOR = new Uint8Array([
2504
4992
  ]);
2505
4993
  function getOracleStateDiscriminatorBytes() {
2506
4994
  return fixEncoderSize(getBytesEncoder(), 8).encode(
2507
- ORACLE_STATE_DISCRIMINATOR
4995
+ ORACLE_STATE_DISCRIMINATOR2
2508
4996
  );
2509
4997
  }
2510
4998
  function getOracleStateEncoder() {
@@ -2519,7 +5007,7 @@ function getOracleStateEncoder() {
2519
5007
  ["bump", getU8Encoder()],
2520
5008
  ["reserved", fixEncoderSize(getBytesEncoder(), 31)]
2521
5009
  ]),
2522
- (value) => ({ ...value, discriminator: ORACLE_STATE_DISCRIMINATOR })
5010
+ (value) => ({ ...value, discriminator: ORACLE_STATE_DISCRIMINATOR2 })
2523
5011
  );
2524
5012
  }
2525
5013
  function getOracleStateDecoder() {
@@ -2534,7 +5022,7 @@ function getOracleStateDecoder() {
2534
5022
  ["reserved", fixDecoderSize(getBytesDecoder(), 31)]
2535
5023
  ]);
2536
5024
  }
2537
- function getOracleStateCodec() {
5025
+ function getOracleStateCodec2() {
2538
5026
  return combineCodec(getOracleStateEncoder(), getOracleStateDecoder());
2539
5027
  }
2540
5028
  function decodeOracleState2(encodedAccount) {
@@ -2608,6 +5096,7 @@ async function getClaimInstructionAsync(input, config) {
2608
5096
  },
2609
5097
  potVault: { value: input.potVault ?? null, isWritable: true },
2610
5098
  winnerMint: { value: input.winnerMint ?? null, isWritable: true },
5099
+ quoteMint: { value: input.quoteMint ?? null, isWritable: false },
2611
5100
  entryByMint: { value: input.entryByMint ?? null, isWritable: false },
2612
5101
  claimerWinnerAta: {
2613
5102
  value: input.claimerWinnerAta ?? null,
@@ -2617,7 +5106,14 @@ async function getClaimInstructionAsync(input, config) {
2617
5106
  claimer: { value: input.claimer ?? null, isWritable: false },
2618
5107
  receipt: { value: input.receipt ?? null, isWritable: true },
2619
5108
  payer: { value: input.payer ?? null, isWritable: true },
2620
- tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
5109
+ baseTokenProgram: {
5110
+ value: input.baseTokenProgram ?? null,
5111
+ isWritable: false
5112
+ },
5113
+ quoteTokenProgram: {
5114
+ value: input.quoteTokenProgram ?? null,
5115
+ isWritable: false
5116
+ },
2621
5117
  systemProgram: { value: input.systemProgram ?? null, isWritable: false }
2622
5118
  };
2623
5119
  const accounts = originalAccounts;
@@ -2713,9 +5209,6 @@ async function getClaimInstructionAsync(input, config) {
2713
5209
  ]
2714
5210
  });
2715
5211
  }
2716
- if (!accounts.tokenProgram.value) {
2717
- accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2718
- }
2719
5212
  if (!accounts.systemProgram.value) {
2720
5213
  accounts.systemProgram.value = "11111111111111111111111111111111";
2721
5214
  }
@@ -2726,13 +5219,15 @@ async function getClaimInstructionAsync(input, config) {
2726
5219
  getAccountMeta("marketAuthority", accounts.marketAuthority),
2727
5220
  getAccountMeta("potVault", accounts.potVault),
2728
5221
  getAccountMeta("winnerMint", accounts.winnerMint),
5222
+ getAccountMeta("quoteMint", accounts.quoteMint),
2729
5223
  getAccountMeta("entryByMint", accounts.entryByMint),
2730
5224
  getAccountMeta("claimerWinnerAta", accounts.claimerWinnerAta),
2731
5225
  getAccountMeta("claimerQuoteAta", accounts.claimerQuoteAta),
2732
5226
  getAccountMeta("claimer", accounts.claimer),
2733
5227
  getAccountMeta("receipt", accounts.receipt),
2734
5228
  getAccountMeta("payer", accounts.payer),
2735
- getAccountMeta("tokenProgram", accounts.tokenProgram),
5229
+ getAccountMeta("baseTokenProgram", accounts.baseTokenProgram),
5230
+ getAccountMeta("quoteTokenProgram", accounts.quoteTokenProgram),
2736
5231
  getAccountMeta("systemProgram", accounts.systemProgram)
2737
5232
  ],
2738
5233
  data: getClaimInstructionDataEncoder().encode(
@@ -2751,6 +5246,7 @@ function getClaimInstruction(input, config) {
2751
5246
  },
2752
5247
  potVault: { value: input.potVault ?? null, isWritable: true },
2753
5248
  winnerMint: { value: input.winnerMint ?? null, isWritable: true },
5249
+ quoteMint: { value: input.quoteMint ?? null, isWritable: false },
2754
5250
  entryByMint: { value: input.entryByMint ?? null, isWritable: false },
2755
5251
  claimerWinnerAta: {
2756
5252
  value: input.claimerWinnerAta ?? null,
@@ -2760,14 +5256,18 @@ function getClaimInstruction(input, config) {
2760
5256
  claimer: { value: input.claimer ?? null, isWritable: false },
2761
5257
  receipt: { value: input.receipt ?? null, isWritable: true },
2762
5258
  payer: { value: input.payer ?? null, isWritable: true },
2763
- tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
5259
+ baseTokenProgram: {
5260
+ value: input.baseTokenProgram ?? null,
5261
+ isWritable: false
5262
+ },
5263
+ quoteTokenProgram: {
5264
+ value: input.quoteTokenProgram ?? null,
5265
+ isWritable: false
5266
+ },
2764
5267
  systemProgram: { value: input.systemProgram ?? null, isWritable: false }
2765
5268
  };
2766
5269
  const accounts = originalAccounts;
2767
5270
  const args = { ...input };
2768
- if (!accounts.tokenProgram.value) {
2769
- accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2770
- }
2771
5271
  if (!accounts.systemProgram.value) {
2772
5272
  accounts.systemProgram.value = "11111111111111111111111111111111";
2773
5273
  }
@@ -2778,13 +5278,15 @@ function getClaimInstruction(input, config) {
2778
5278
  getAccountMeta("marketAuthority", accounts.marketAuthority),
2779
5279
  getAccountMeta("potVault", accounts.potVault),
2780
5280
  getAccountMeta("winnerMint", accounts.winnerMint),
5281
+ getAccountMeta("quoteMint", accounts.quoteMint),
2781
5282
  getAccountMeta("entryByMint", accounts.entryByMint),
2782
5283
  getAccountMeta("claimerWinnerAta", accounts.claimerWinnerAta),
2783
5284
  getAccountMeta("claimerQuoteAta", accounts.claimerQuoteAta),
2784
5285
  getAccountMeta("claimer", accounts.claimer),
2785
5286
  getAccountMeta("receipt", accounts.receipt),
2786
5287
  getAccountMeta("payer", accounts.payer),
2787
- getAccountMeta("tokenProgram", accounts.tokenProgram),
5288
+ getAccountMeta("baseTokenProgram", accounts.baseTokenProgram),
5289
+ getAccountMeta("quoteTokenProgram", accounts.quoteTokenProgram),
2788
5290
  getAccountMeta("systemProgram", accounts.systemProgram)
2789
5291
  ],
2790
5292
  data: getClaimInstructionDataEncoder().encode(
@@ -2794,12 +5296,12 @@ function getClaimInstruction(input, config) {
2794
5296
  });
2795
5297
  }
2796
5298
  function parseClaimInstruction(instruction) {
2797
- if (instruction.accounts.length < 12) {
5299
+ if (instruction.accounts.length < 14) {
2798
5300
  throw new SolanaError(
2799
5301
  SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2800
5302
  {
2801
5303
  actualAccountMetas: instruction.accounts.length,
2802
- expectedAccountMetas: 12
5304
+ expectedAccountMetas: 14
2803
5305
  }
2804
5306
  );
2805
5307
  }
@@ -2816,13 +5318,15 @@ function parseClaimInstruction(instruction) {
2816
5318
  marketAuthority: getNextAccount(),
2817
5319
  potVault: getNextAccount(),
2818
5320
  winnerMint: getNextAccount(),
5321
+ quoteMint: getNextAccount(),
2819
5322
  entryByMint: getNextAccount(),
2820
5323
  claimerWinnerAta: getNextAccount(),
2821
5324
  claimerQuoteAta: getNextAccount(),
2822
5325
  claimer: getNextAccount(),
2823
5326
  receipt: getNextAccount(),
2824
5327
  payer: getNextAccount(),
2825
- tokenProgram: getNextAccount(),
5328
+ baseTokenProgram: getNextAccount(),
5329
+ quoteTokenProgram: getNextAccount(),
2826
5330
  systemProgram: getNextAccount()
2827
5331
  },
2828
5332
  data: getClaimInstructionDataDecoder().decode(instruction.data)
@@ -3728,7 +6232,7 @@ function predictionMigratorProgram() {
3728
6232
  entryByMint: addSelfFetchFunctions(client, getEntryByMintCodec()),
3729
6233
  launch: addSelfFetchFunctions(client, getLaunchCodec2()),
3730
6234
  market: addSelfFetchFunctions(client, getMarketCodec()),
3731
- oracleState: addSelfFetchFunctions(client, getOracleStateCodec())
6235
+ oracleState: addSelfFetchFunctions(client, getOracleStateCodec2())
3732
6236
  },
3733
6237
  instructions: {
3734
6238
  claim: (input) => addSelfPlanAndSendFunctions(
@@ -3806,11 +6310,11 @@ async function getPredictionEntryByMintAddress(market, mint, programId = PREDICT
3806
6310
  }
3807
6311
 
3808
6312
  // src/solana/initializer/instructions/initializeLaunch.ts
3809
- function isTransactionSigner5(value) {
6313
+ function isTransactionSigner4(value) {
3810
6314
  return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
3811
6315
  }
3812
6316
  function createAccountMeta(value, role) {
3813
- if (isTransactionSigner5(value)) {
6317
+ if (isTransactionSigner4(value)) {
3814
6318
  return { address: value.address, role, signer: value };
3815
6319
  }
3816
6320
  return { address: value, role };
@@ -3866,7 +6370,6 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
3866
6370
  rent,
3867
6371
  metadataAccount,
3868
6372
  metadataProgram = TOKEN_METADATA_PROGRAM_ID,
3869
- instructionsSysvar = SYSVAR_INSTRUCTIONS_ADDRESS,
3870
6373
  addressLookupTable: alt
3871
6374
  } = accounts;
3872
6375
  const withMetadata = Boolean(
@@ -3916,7 +6419,6 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
3916
6419
  keys.push({ address: programId, role: AccountRole.READONLY });
3917
6420
  keys.push({ address: programId, role: AccountRole.READONLY });
3918
6421
  }
3919
- keys.push({ address: instructionsSysvar, role: AccountRole.READONLY });
3920
6422
  const encoderArgs = {
3921
6423
  ...args,
3922
6424
  allowBuy: args.allowBuy ? 1 : 0,
@@ -3939,7 +6441,7 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
3939
6441
  if (migratorProgram === PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
3940
6442
  const oracleState = args.namespace;
3941
6443
  const entryId = args.launchId;
3942
- const baseMintAddress = isTransactionSigner5(baseMint) ? baseMint.address : baseMint;
6444
+ const baseMintAddress = isTransactionSigner4(baseMint) ? baseMint.address : baseMint;
3943
6445
  const [market] = await getPredictionMarketAddress(oracleState, quoteMint);
3944
6446
  const [potVault] = await getPredictionPotVaultAddress(market);
3945
6447
  const [marketAuthority] = await getPredictionMarketAuthorityAddress(market);
@@ -3957,11 +6459,11 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
3957
6459
  }
3958
6460
  return { programAddress: programId, accounts: keys, data };
3959
6461
  }
3960
- function isTransactionSigner6(value) {
6462
+ function isTransactionSigner5(value) {
3961
6463
  return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
3962
6464
  }
3963
6465
  function createAccountMeta2(value, role) {
3964
- if (isTransactionSigner6(value)) {
6466
+ if (isTransactionSigner5(value)) {
3965
6467
  return { address: value.address, role, signer: value };
3966
6468
  }
3967
6469
  return { address: value, role };
@@ -3980,8 +6482,7 @@ function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZ
3980
6482
  user,
3981
6483
  sentinelProgram = SYSTEM_PROGRAM_ADDRESS,
3982
6484
  baseTokenProgram = TOKEN_PROGRAM_ADDRESS,
3983
- quoteTokenProgram = TOKEN_PROGRAM_ADDRESS,
3984
- instructionsSysvar = SYSVAR_INSTRUCTIONS_ADDRESS
6485
+ quoteTokenProgram = TOKEN_PROGRAM_ADDRESS
3985
6486
  } = accounts;
3986
6487
  const keys = [
3987
6488
  { address: config, role: AccountRole.READONLY },
@@ -3999,19 +6500,18 @@ function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZ
3999
6500
  // no-op placeholder when no real sentinel is configured.
4000
6501
  { address: sentinelProgram, role: AccountRole.READONLY },
4001
6502
  { address: baseTokenProgram, role: AccountRole.READONLY },
4002
- { address: quoteTokenProgram, role: AccountRole.READONLY },
4003
- { address: instructionsSysvar, role: AccountRole.READONLY }
6503
+ { address: quoteTokenProgram, role: AccountRole.READONLY }
4004
6504
  ];
4005
6505
  const data = new Uint8Array(
4006
6506
  getCurveSwapExactInInstructionDataEncoder().encode(args)
4007
6507
  );
4008
6508
  return { programAddress: programId, accounts: keys, data };
4009
6509
  }
4010
- function isTransactionSigner7(value) {
6510
+ function isTransactionSigner6(value) {
4011
6511
  return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
4012
6512
  }
4013
- function createSignerAccountMeta5(value, role) {
4014
- if (isTransactionSigner7(value)) {
6513
+ function createSignerAccountMeta4(value, role) {
6514
+ if (isTransactionSigner6(value)) {
4015
6515
  return { address: value.address, role, signer: value };
4016
6516
  }
4017
6517
  return { address: value, role };
@@ -4030,8 +6530,7 @@ function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRA
4030
6530
  baseTokenProgram = TOKEN_PROGRAM_ADDRESS,
4031
6531
  quoteTokenProgram = TOKEN_PROGRAM_ADDRESS,
4032
6532
  systemProgram = SYSTEM_PROGRAM_ADDRESS,
4033
- rent,
4034
- instructionsSysvar = SYSVAR_INSTRUCTIONS_ADDRESS
6533
+ rent
4035
6534
  } = accounts;
4036
6535
  const keys = [
4037
6536
  { address: config, role: AccountRole.READONLY },
@@ -4042,12 +6541,11 @@ function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRA
4042
6541
  { address: baseVault, role: AccountRole.WRITABLE },
4043
6542
  { address: quoteVault, role: AccountRole.WRITABLE },
4044
6543
  { address: migratorProgram, role: AccountRole.READONLY },
4045
- createSignerAccountMeta5(payer, AccountRole.WRITABLE_SIGNER),
6544
+ createSignerAccountMeta4(payer, AccountRole.WRITABLE_SIGNER),
4046
6545
  { address: baseTokenProgram, role: AccountRole.READONLY },
4047
6546
  { address: quoteTokenProgram, role: AccountRole.READONLY },
4048
6547
  { address: systemProgram, role: AccountRole.READONLY },
4049
- { address: rent, role: AccountRole.READONLY },
4050
- { address: instructionsSysvar, role: AccountRole.READONLY }
6548
+ { address: rent, role: AccountRole.READONLY }
4051
6549
  ];
4052
6550
  const data = encodeInstructionData(
4053
6551
  INITIALIZER_INSTRUCTION_DISCRIMINATORS.migrateLaunch
@@ -4067,7 +6565,7 @@ function createPreviewSwapExactInInstruction(accounts, args, programId = INITIAL
4067
6565
  ];
4068
6566
  const accountsList = sentinelProgram ? [...keys, { address: sentinelProgram, role: AccountRole.READONLY }] : keys;
4069
6567
  const data = new Uint8Array(
4070
- getPreviewSwapExactInInstructionDataEncoder().encode(args)
6568
+ getPreviewSwapExactInInstructionDataEncoder2().encode(args)
4071
6569
  );
4072
6570
  return { programAddress: programId, accounts: accountsList, data };
4073
6571
  }
@@ -4403,7 +6901,7 @@ __export(predictionMigrator_exports, {
4403
6901
  LAUNCH_DISCRIMINATOR: () => LAUNCH_DISCRIMINATOR2,
4404
6902
  MARKET_DISCRIMINATOR: () => MARKET_DISCRIMINATOR,
4405
6903
  MIGRATE_ENTRY_DISCRIMINATOR: () => MIGRATE_ENTRY_DISCRIMINATOR,
4406
- ORACLE_STATE_DISCRIMINATOR: () => ORACLE_STATE_DISCRIMINATOR,
6904
+ ORACLE_STATE_DISCRIMINATOR: () => ORACLE_STATE_DISCRIMINATOR2,
4407
6905
  PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_MIGRATED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_MIGRATED,
4408
6906
  PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_REGISTERED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_REGISTERED,
4409
6907
  PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_MIGRATED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_MIGRATED,
@@ -4517,7 +7015,7 @@ __export(predictionMigrator_exports, {
4517
7015
  getMigrateEntryInstructionDataCodec: () => getMigrateEntryInstructionDataCodec,
4518
7016
  getMigrateEntryInstructionDataDecoder: () => getMigrateEntryInstructionDataDecoder,
4519
7017
  getMigrateEntryInstructionDataEncoder: () => getMigrateEntryInstructionDataEncoder,
4520
- getOracleStateCodec: () => getOracleStateCodec,
7018
+ getOracleStateCodec: () => getOracleStateCodec2,
4521
7019
  getOracleStateDecoder: () => getOracleStateDecoder,
4522
7020
  getOracleStateDiscriminatorBytes: () => getOracleStateDiscriminatorBytes,
4523
7021
  getOracleStateEncoder: () => getOracleStateEncoder,
@@ -4622,8 +7120,8 @@ function isPredictionMigratorError(error, transactionMessage, code) {
4622
7120
  var trustedOracle_exports = {};
4623
7121
  __export(trustedOracle_exports, {
4624
7122
  FINALIZE_DISCRIMINATOR: () => FINALIZE_DISCRIMINATOR,
4625
- INITIALIZE_ORACLE_DISCRIMINATOR: () => INITIALIZE_ORACLE_DISCRIMINATOR,
4626
- ORACLE_STATE_DISCRIMINATOR: () => ORACLE_STATE_DISCRIMINATOR2,
7123
+ INITIALIZE_ORACLE_DISCRIMINATOR: () => INITIALIZE_ORACLE_DISCRIMINATOR2,
7124
+ ORACLE_STATE_DISCRIMINATOR: () => ORACLE_STATE_DISCRIMINATOR3,
4627
7125
  TRUSTED_ORACLE_ERROR__ALREADY_FINALIZED: () => TRUSTED_ORACLE_ERROR__ALREADY_FINALIZED,
4628
7126
  TRUSTED_ORACLE_ERROR__INVALID_WINNING_MINT: () => TRUSTED_ORACLE_ERROR__INVALID_WINNING_MINT,
4629
7127
  TRUSTED_ORACLE_ERROR__NOT_FINALIZED: () => TRUSTED_ORACLE_ERROR__NOT_FINALIZED,
@@ -4644,13 +7142,13 @@ __export(trustedOracle_exports, {
4644
7142
  getInitializeOracleArgsCodec: () => getInitializeOracleArgsCodec,
4645
7143
  getInitializeOracleArgsDecoder: () => getInitializeOracleArgsDecoder,
4646
7144
  getInitializeOracleArgsEncoder: () => getInitializeOracleArgsEncoder,
4647
- getInitializeOracleDiscriminatorBytes: () => getInitializeOracleDiscriminatorBytes,
4648
- getInitializeOracleInstruction: () => getInitializeOracleInstruction,
4649
- getInitializeOracleInstructionDataCodec: () => getInitializeOracleInstructionDataCodec,
4650
- getInitializeOracleInstructionDataDecoder: () => getInitializeOracleInstructionDataDecoder,
4651
- getInitializeOracleInstructionDataEncoder: () => getInitializeOracleInstructionDataEncoder,
7145
+ getInitializeOracleDiscriminatorBytes: () => getInitializeOracleDiscriminatorBytes2,
7146
+ getInitializeOracleInstruction: () => getInitializeOracleInstruction2,
7147
+ getInitializeOracleInstructionDataCodec: () => getInitializeOracleInstructionDataCodec2,
7148
+ getInitializeOracleInstructionDataDecoder: () => getInitializeOracleInstructionDataDecoder2,
7149
+ getInitializeOracleInstructionDataEncoder: () => getInitializeOracleInstructionDataEncoder2,
4652
7150
  getOracleStateAddress: () => getOracleStateAddress,
4653
- getOracleStateCodec: () => getOracleStateCodec2,
7151
+ getOracleStateCodec: () => getOracleStateCodec3,
4654
7152
  getOracleStateDecoder: () => getOracleStateDecoder2,
4655
7153
  getOracleStateDiscriminatorBytes: () => getOracleStateDiscriminatorBytes2,
4656
7154
  getOracleStateEncoder: () => getOracleStateEncoder2,
@@ -4660,11 +7158,11 @@ __export(trustedOracle_exports, {
4660
7158
  identifyTrustedOracleInstruction: () => identifyTrustedOracleInstruction,
4661
7159
  isTrustedOracleError: () => isTrustedOracleError,
4662
7160
  parseFinalizeInstruction: () => parseFinalizeInstruction,
4663
- parseInitializeOracleInstruction: () => parseInitializeOracleInstruction,
7161
+ parseInitializeOracleInstruction: () => parseInitializeOracleInstruction2,
4664
7162
  parseTrustedOracleInstruction: () => parseTrustedOracleInstruction,
4665
7163
  trustedOracleProgram: () => trustedOracleProgram
4666
7164
  });
4667
- var ORACLE_STATE_DISCRIMINATOR2 = new Uint8Array([
7165
+ var ORACLE_STATE_DISCRIMINATOR3 = new Uint8Array([
4668
7166
  97,
4669
7167
  156,
4670
7168
  157,
@@ -4676,7 +7174,7 @@ var ORACLE_STATE_DISCRIMINATOR2 = new Uint8Array([
4676
7174
  ]);
4677
7175
  function getOracleStateDiscriminatorBytes2() {
4678
7176
  return fixEncoderSize(getBytesEncoder(), 8).encode(
4679
- ORACLE_STATE_DISCRIMINATOR2
7177
+ ORACLE_STATE_DISCRIMINATOR3
4680
7178
  );
4681
7179
  }
4682
7180
  function getOracleStateEncoder2() {
@@ -4691,7 +7189,7 @@ function getOracleStateEncoder2() {
4691
7189
  ["bump", getU8Encoder()],
4692
7190
  ["reserved", fixEncoderSize(getBytesEncoder(), 31)]
4693
7191
  ]),
4694
- (value) => ({ ...value, discriminator: ORACLE_STATE_DISCRIMINATOR2 })
7192
+ (value) => ({ ...value, discriminator: ORACLE_STATE_DISCRIMINATOR3 })
4695
7193
  );
4696
7194
  }
4697
7195
  function getOracleStateDecoder2() {
@@ -4706,7 +7204,7 @@ function getOracleStateDecoder2() {
4706
7204
  ["reserved", fixDecoderSize(getBytesDecoder(), 31)]
4707
7205
  ]);
4708
7206
  }
4709
- function getOracleStateCodec2() {
7207
+ function getOracleStateCodec3() {
4710
7208
  return combineCodec(getOracleStateEncoder2(), getOracleStateDecoder2());
4711
7209
  }
4712
7210
  function decodeOracleState3(encodedAccount) {
@@ -4818,7 +7316,7 @@ function parseFinalizeInstruction(instruction) {
4818
7316
  data: getFinalizeInstructionDataDecoder().decode(instruction.data)
4819
7317
  };
4820
7318
  }
4821
- var INITIALIZE_ORACLE_DISCRIMINATOR = new Uint8Array([
7319
+ var INITIALIZE_ORACLE_DISCRIMINATOR2 = new Uint8Array([
4822
7320
  144,
4823
7321
  223,
4824
7322
  131,
@@ -4828,35 +7326,35 @@ var INITIALIZE_ORACLE_DISCRIMINATOR = new Uint8Array([
4828
7326
  181,
4829
7327
  99
4830
7328
  ]);
4831
- function getInitializeOracleDiscriminatorBytes() {
7329
+ function getInitializeOracleDiscriminatorBytes2() {
4832
7330
  return fixEncoderSize(getBytesEncoder(), 8).encode(
4833
- INITIALIZE_ORACLE_DISCRIMINATOR
7331
+ INITIALIZE_ORACLE_DISCRIMINATOR2
4834
7332
  );
4835
7333
  }
4836
- function getInitializeOracleInstructionDataEncoder() {
7334
+ function getInitializeOracleInstructionDataEncoder2() {
4837
7335
  return transformEncoder(
4838
7336
  getStructEncoder([
4839
7337
  ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
4840
7338
  ["nonce", getU64Encoder()],
4841
7339
  ["quoteMint", getAddressEncoder()]
4842
7340
  ]),
4843
- (value) => ({ ...value, discriminator: INITIALIZE_ORACLE_DISCRIMINATOR })
7341
+ (value) => ({ ...value, discriminator: INITIALIZE_ORACLE_DISCRIMINATOR2 })
4844
7342
  );
4845
7343
  }
4846
- function getInitializeOracleInstructionDataDecoder() {
7344
+ function getInitializeOracleInstructionDataDecoder2() {
4847
7345
  return getStructDecoder([
4848
7346
  ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
4849
7347
  ["nonce", getU64Decoder()],
4850
7348
  ["quoteMint", getAddressDecoder()]
4851
7349
  ]);
4852
7350
  }
4853
- function getInitializeOracleInstructionDataCodec() {
7351
+ function getInitializeOracleInstructionDataCodec2() {
4854
7352
  return combineCodec(
4855
- getInitializeOracleInstructionDataEncoder(),
4856
- getInitializeOracleInstructionDataDecoder()
7353
+ getInitializeOracleInstructionDataEncoder2(),
7354
+ getInitializeOracleInstructionDataDecoder2()
4857
7355
  );
4858
7356
  }
4859
- function getInitializeOracleInstruction(input, config) {
7357
+ function getInitializeOracleInstruction2(input, config) {
4860
7358
  const programAddress = config?.programAddress ?? TRUSTED_ORACLE_PROGRAM_ADDRESS;
4861
7359
  const originalAccounts = {
4862
7360
  oracleAuthority: { value: input.oracleAuthority ?? null, isWritable: true },
@@ -4875,13 +7373,13 @@ function getInitializeOracleInstruction(input, config) {
4875
7373
  getAccountMeta("oracleState", accounts.oracleState),
4876
7374
  getAccountMeta("systemProgram", accounts.systemProgram)
4877
7375
  ],
4878
- data: getInitializeOracleInstructionDataEncoder().encode(
7376
+ data: getInitializeOracleInstructionDataEncoder2().encode(
4879
7377
  args
4880
7378
  ),
4881
7379
  programAddress
4882
7380
  });
4883
7381
  }
4884
- function parseInitializeOracleInstruction(instruction) {
7382
+ function parseInitializeOracleInstruction2(instruction) {
4885
7383
  if (instruction.accounts.length < 3) {
4886
7384
  throw new SolanaError(
4887
7385
  SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
@@ -4904,7 +7402,7 @@ function parseInitializeOracleInstruction(instruction) {
4904
7402
  oracleState: getNextAccount(),
4905
7403
  systemProgram: getNextAccount()
4906
7404
  },
4907
- data: getInitializeOracleInstructionDataDecoder().decode(instruction.data)
7405
+ data: getInitializeOracleInstructionDataDecoder2().decode(instruction.data)
4908
7406
  };
4909
7407
  }
4910
7408
 
@@ -4974,7 +7472,7 @@ function parseTrustedOracleInstruction(instruction) {
4974
7472
  assertIsInstructionWithAccounts(instruction);
4975
7473
  return {
4976
7474
  instructionType: 1 /* InitializeOracle */,
4977
- ...parseInitializeOracleInstruction(instruction)
7475
+ ...parseInitializeOracleInstruction2(instruction)
4978
7476
  };
4979
7477
  }
4980
7478
  default:
@@ -4993,13 +7491,13 @@ function trustedOracleProgram() {
4993
7491
  ...client,
4994
7492
  trustedOracle: {
4995
7493
  accounts: {
4996
- oracleState: addSelfFetchFunctions(client, getOracleStateCodec2())
7494
+ oracleState: addSelfFetchFunctions(client, getOracleStateCodec3())
4997
7495
  },
4998
7496
  instructions: {
4999
7497
  finalize: (input) => addSelfPlanAndSendFunctions(client, getFinalizeInstruction(input)),
5000
7498
  initializeOracle: (input) => addSelfPlanAndSendFunctions(
5001
7499
  client,
5002
- getInitializeOracleInstruction(input)
7500
+ getInitializeOracleInstruction2(input)
5003
7501
  )
5004
7502
  }
5005
7503
  }