@whetstone-research/doppler-sdk 1.0.10 → 1.0.12

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-ZQEEGBXT.js';
2
+ import { sortMints, getSwapAddresses, getProtocolPositionAddress, getPositionAddress, getPoolVault1Address, getPoolVault0Address, getPoolInitAddresses, getPoolAuthorityAddress, getPoolAddress, getOracleAddress, getLiquidityAddresses, getConfigAddress, CPMM_PROGRAM_ID, areMintsOrdered, TOKEN_METADATA_PROGRAM_ID, SF_REQUIRE_ORACLE, SF_FORWARD_READONLY_SIGNERS, 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-2NFQKIOB.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, address, addEncoderSizePrefix, getUtf8Encoder, addDecoderSizePrefix, getUtf8Decoder, AccountRole, 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,23 @@ __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
+ SF_FORWARD_READONLY_SIGNERS: () => SF_FORWARD_READONLY_SIGNERS,
54
+ SF_REQUIRE_ORACLE: () => SF_REQUIRE_ORACLE,
55
+ SKIM_DISCRIMINATOR: () => SKIM_DISCRIMINATOR,
56
+ SWAP_EXACT_IN_DISCRIMINATOR: () => SWAP_EXACT_IN_DISCRIMINATOR,
36
57
  TOKEN_METADATA_PROGRAM_ID: () => TOKEN_METADATA_PROGRAM_ID,
58
+ TRANSFER_ADMIN_DISCRIMINATOR: () => TRANSFER_ADMIN_DISCRIMINATOR,
59
+ UNPAUSE_DISCRIMINATOR: () => UNPAUSE_DISCRIMINATOR,
60
+ UPDATE_CONFIG_DISCRIMINATOR: () => UPDATE_CONFIG_DISCRIMINATOR,
37
61
  addLiquidityArgsCodec: () => addLiquidityArgsCodec,
38
62
  ammConfigDataCodec: () => ammConfigDataCodec,
39
63
  areMintsOrdered: () => areMintsOrdered,
@@ -47,35 +71,33 @@ __export(cpmm_exports, {
47
71
  computePrice0Q64: () => computePrice0Q64,
48
72
  computePrice1Q64: () => computePrice1Q64,
49
73
  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,
74
+ createAddLiquidityInstruction: () => getAddLiquidityInstruction,
75
+ createClosePositionInstruction: () => getClosePositionInstruction,
76
+ createCollectFeesInstruction: () => getCollectFeesInstruction,
77
+ createCollectProtocolFeesInstruction: () => getCollectProtocolFeesInstruction,
78
+ createCreatePositionInstruction: () => getCreatePositionInstruction,
79
+ createInitializeConfigInstruction: () => getInitializeConfigInstruction,
80
+ createInitializeOracleInstruction: () => getInitializeOracleInstruction,
81
+ createInitializePoolInstruction: () => getInitializePoolInstruction,
82
+ createOracleConsultInstruction: () => getOracleConsultInstruction,
83
+ createOracleUpdateInstruction: () => getOracleUpdateInstruction,
84
+ createPauseInstruction: () => getPauseInstruction,
61
85
  createPositionArgsCodec: () => createPositionArgsCodec,
62
- createQuoteToNumeraireInstruction: () => createQuoteToNumeraireInstruction,
63
- createRemoveLiquidityInstruction: () => createRemoveLiquidityInstruction,
64
- createSetFeesInstruction: () => createSetFeesInstruction,
65
- createSetRouteInstruction: () => createSetRouteInstruction,
66
- createSetSentinelInstruction: () => createSetSentinelInstruction,
67
- createSkimInstruction: () => createSkimInstruction,
68
- createSwapExactInInstruction: () => createSwapExactInInstruction,
86
+ createQuoteToNumeraireInstruction: () => getQuoteToNumeraireInstruction,
87
+ createRemoveLiquidityInstruction: () => getRemoveLiquidityInstruction,
88
+ createSetFeesInstruction: () => getSetFeesInstruction,
89
+ createSetRouteInstruction: () => getSetRouteInstruction,
90
+ createSetSentinelInstruction: () => getSetSentinelInstruction,
91
+ createSkimInstruction: () => getSkimInstruction,
92
+ createSwapExactInInstruction: () => getSwapExactInInstruction,
69
93
  createSwapInstruction: () => createSwapInstruction,
70
- createTransferAdminInstruction: () => createTransferAdminInstruction,
71
- createUnpauseInstruction: () => createUnpauseInstruction,
94
+ createTransferAdminInstruction: () => getTransferAdminInstruction,
95
+ createUnpauseInstruction: () => getUnpauseInstruction,
72
96
  curveParamsToMarketCap: () => curveParamsToMarketCap,
73
97
  decodeAmmConfig: () => decodeAmmConfig,
74
- decodeOracleConsultResult: () => decodeOracleConsultResult,
75
98
  decodeOracleState: () => decodeOracleState,
76
99
  decodePool: () => decodePool,
77
100
  decodePosition: () => decodePosition,
78
- decodeQuoteToNumeraireResult: () => decodeQuoteToNumeraireResult,
79
101
  encodeAddLiquidityArgs: () => encodeAddLiquidityArgs,
80
102
  encodeCollectFeesArgs: () => encodeCollectFeesArgs,
81
103
  encodeCollectProtocolFeesArgs: () => encodeCollectProtocolFeesArgs,
@@ -106,9 +128,56 @@ __export(cpmm_exports, {
106
128
  fetchUserPositions: () => fetchUserPositions,
107
129
  filterActivePositions: () => filterActivePositions,
108
130
  filterPoolsByMint: () => filterPoolsByMint,
131
+ getAddLiquidityDiscriminatorBytes: () => getAddLiquidityDiscriminatorBytes,
132
+ getAddLiquidityInstruction: () => getAddLiquidityInstruction,
133
+ getAddLiquidityInstructionAsync: () => getAddLiquidityInstructionAsync,
134
+ getAddLiquidityInstructionDataCodec: () => getAddLiquidityInstructionDataCodec,
135
+ getAddLiquidityInstructionDataDecoder: () => getAddLiquidityInstructionDataDecoder,
136
+ getAddLiquidityInstructionDataEncoder: () => getAddLiquidityInstructionDataEncoder,
109
137
  getAddLiquidityQuote: () => getAddLiquidityQuote,
138
+ getClosePositionDiscriminatorBytes: () => getClosePositionDiscriminatorBytes,
139
+ getClosePositionInstruction: () => getClosePositionInstruction,
140
+ getClosePositionInstructionDataCodec: () => getClosePositionInstructionDataCodec,
141
+ getClosePositionInstructionDataDecoder: () => getClosePositionInstructionDataDecoder,
142
+ getClosePositionInstructionDataEncoder: () => getClosePositionInstructionDataEncoder,
143
+ getCollectFeesDiscriminatorBytes: () => getCollectFeesDiscriminatorBytes,
144
+ getCollectFeesInstruction: () => getCollectFeesInstruction,
145
+ getCollectFeesInstructionAsync: () => getCollectFeesInstructionAsync,
146
+ getCollectFeesInstructionDataCodec: () => getCollectFeesInstructionDataCodec,
147
+ getCollectFeesInstructionDataDecoder: () => getCollectFeesInstructionDataDecoder,
148
+ getCollectFeesInstructionDataEncoder: () => getCollectFeesInstructionDataEncoder,
149
+ getCollectProtocolFeesDiscriminatorBytes: () => getCollectProtocolFeesDiscriminatorBytes,
150
+ getCollectProtocolFeesInstruction: () => getCollectProtocolFeesInstruction,
151
+ getCollectProtocolFeesInstructionAsync: () => getCollectProtocolFeesInstructionAsync,
152
+ getCollectProtocolFeesInstructionDataCodec: () => getCollectProtocolFeesInstructionDataCodec,
153
+ getCollectProtocolFeesInstructionDataDecoder: () => getCollectProtocolFeesInstructionDataDecoder,
154
+ getCollectProtocolFeesInstructionDataEncoder: () => getCollectProtocolFeesInstructionDataEncoder,
110
155
  getConfigAddress: () => getConfigAddress,
156
+ getCreatePositionDiscriminatorBytes: () => getCreatePositionDiscriminatorBytes,
157
+ getCreatePositionInstruction: () => getCreatePositionInstruction,
158
+ getCreatePositionInstructionAsync: () => getCreatePositionInstructionAsync,
159
+ getCreatePositionInstructionDataCodec: () => getCreatePositionInstructionDataCodec,
160
+ getCreatePositionInstructionDataDecoder: () => getCreatePositionInstructionDataDecoder,
161
+ getCreatePositionInstructionDataEncoder: () => getCreatePositionInstructionDataEncoder,
111
162
  getErrorMessage: () => getErrorMessage,
163
+ getInitializeConfigDiscriminatorBytes: () => getInitializeConfigDiscriminatorBytes,
164
+ getInitializeConfigInstruction: () => getInitializeConfigInstruction,
165
+ getInitializeConfigInstructionAsync: () => getInitializeConfigInstructionAsync,
166
+ getInitializeConfigInstructionDataCodec: () => getInitializeConfigInstructionDataCodec,
167
+ getInitializeConfigInstructionDataDecoder: () => getInitializeConfigInstructionDataDecoder,
168
+ getInitializeConfigInstructionDataEncoder: () => getInitializeConfigInstructionDataEncoder,
169
+ getInitializeOracleDiscriminatorBytes: () => getInitializeOracleDiscriminatorBytes,
170
+ getInitializeOracleInstruction: () => getInitializeOracleInstruction,
171
+ getInitializeOracleInstructionAsync: () => getInitializeOracleInstructionAsync,
172
+ getInitializeOracleInstructionDataCodec: () => getInitializeOracleInstructionDataCodec,
173
+ getInitializeOracleInstructionDataDecoder: () => getInitializeOracleInstructionDataDecoder,
174
+ getInitializeOracleInstructionDataEncoder: () => getInitializeOracleInstructionDataEncoder,
175
+ getInitializePoolDiscriminatorBytes: () => getInitializePoolDiscriminatorBytes,
176
+ getInitializePoolInstruction: () => getInitializePoolInstruction,
177
+ getInitializePoolInstructionAsync: () => getInitializePoolInstructionAsync,
178
+ getInitializePoolInstructionDataCodec: () => getInitializePoolInstructionDataCodec,
179
+ getInitializePoolInstructionDataDecoder: () => getInitializePoolInstructionDataDecoder,
180
+ getInitializePoolInstructionDataEncoder: () => getInitializePoolInstructionDataEncoder,
112
181
  getK: () => getK,
113
182
  getLiquidityAddresses: () => getLiquidityAddresses,
114
183
  getMetadataAddress: () => getMetadataAddress,
@@ -116,9 +185,26 @@ __export(cpmm_exports, {
116
185
  getOracleAddressFromPool: () => getOracleAddressFromPool,
117
186
  getOracleAge: () => getOracleAge,
118
187
  getOracleBufferStats: () => getOracleBufferStats,
188
+ getOracleConsultDiscriminatorBytes: () => getOracleConsultDiscriminatorBytes,
189
+ getOracleConsultInstruction: () => getOracleConsultInstruction,
190
+ getOracleConsultInstructionAsync: () => getOracleConsultInstructionAsync,
191
+ getOracleConsultInstructionDataCodec: () => getOracleConsultInstructionDataCodec,
192
+ getOracleConsultInstructionDataDecoder: () => getOracleConsultInstructionDataDecoder,
193
+ getOracleConsultInstructionDataEncoder: () => getOracleConsultInstructionDataEncoder,
119
194
  getOracleDeviation: () => getOracleDeviation,
120
195
  getOracleForPool: () => getOracleForPool,
121
196
  getOracleSpotPrices: () => getOracleSpotPrices,
197
+ getOracleUpdateDiscriminatorBytes: () => getOracleUpdateDiscriminatorBytes,
198
+ getOracleUpdateInstruction: () => getOracleUpdateInstruction,
199
+ getOracleUpdateInstructionAsync: () => getOracleUpdateInstructionAsync,
200
+ getOracleUpdateInstructionDataCodec: () => getOracleUpdateInstructionDataCodec,
201
+ getOracleUpdateInstructionDataDecoder: () => getOracleUpdateInstructionDataDecoder,
202
+ getOracleUpdateInstructionDataEncoder: () => getOracleUpdateInstructionDataEncoder,
203
+ getPauseDiscriminatorBytes: () => getPauseDiscriminatorBytes,
204
+ getPauseInstruction: () => getPauseInstruction,
205
+ getPauseInstructionDataCodec: () => getPauseInstructionDataCodec,
206
+ getPauseInstructionDataDecoder: () => getPauseInstructionDataDecoder,
207
+ getPauseInstructionDataEncoder: () => getPauseInstructionDataEncoder,
122
208
  getPendingFees: () => getPendingFees,
123
209
  getPoolAddress: () => getPoolAddress,
124
210
  getPoolAddressFromMints: () => getPoolAddressFromMints,
@@ -130,14 +216,72 @@ __export(cpmm_exports, {
130
216
  getPositionAddress: () => getPositionAddress,
131
217
  getPositionAddressFromParams: () => getPositionAddressFromParams,
132
218
  getPositionValue: () => getPositionValue,
219
+ getPreviewSwapExactInDiscriminatorBytes: () => getPreviewSwapExactInDiscriminatorBytes,
220
+ getPreviewSwapExactInInstruction: () => getPreviewSwapExactInInstruction,
221
+ getPreviewSwapExactInInstructionDataCodec: () => getPreviewSwapExactInInstructionDataCodec,
222
+ getPreviewSwapExactInInstructionDataDecoder: () => getPreviewSwapExactInInstructionDataDecoder,
223
+ getPreviewSwapExactInInstructionDataEncoder: () => getPreviewSwapExactInInstructionDataEncoder,
133
224
  getProtocolPositionAddress: () => getProtocolPositionAddress,
225
+ getQuoteToNumeraireDiscriminatorBytes: () => getQuoteToNumeraireDiscriminatorBytes,
226
+ getQuoteToNumeraireInstruction: () => getQuoteToNumeraireInstruction,
227
+ getQuoteToNumeraireInstructionDataCodec: () => getQuoteToNumeraireInstructionDataCodec,
228
+ getQuoteToNumeraireInstructionDataDecoder: () => getQuoteToNumeraireInstructionDataDecoder,
229
+ getQuoteToNumeraireInstructionDataEncoder: () => getQuoteToNumeraireInstructionDataEncoder,
230
+ getRemoveLiquidityDiscriminatorBytes: () => getRemoveLiquidityDiscriminatorBytes,
231
+ getRemoveLiquidityInstruction: () => getRemoveLiquidityInstruction,
232
+ getRemoveLiquidityInstructionAsync: () => getRemoveLiquidityInstructionAsync,
233
+ getRemoveLiquidityInstructionDataCodec: () => getRemoveLiquidityInstructionDataCodec,
234
+ getRemoveLiquidityInstructionDataDecoder: () => getRemoveLiquidityInstructionDataDecoder,
235
+ getRemoveLiquidityInstructionDataEncoder: () => getRemoveLiquidityInstructionDataEncoder,
134
236
  getRemoveLiquidityQuote: () => getRemoveLiquidityQuote,
237
+ getSetFeesDiscriminatorBytes: () => getSetFeesDiscriminatorBytes,
238
+ getSetFeesInstruction: () => getSetFeesInstruction,
239
+ getSetFeesInstructionDataCodec: () => getSetFeesInstructionDataCodec,
240
+ getSetFeesInstructionDataDecoder: () => getSetFeesInstructionDataDecoder,
241
+ getSetFeesInstructionDataEncoder: () => getSetFeesInstructionDataEncoder,
242
+ getSetRouteDiscriminatorBytes: () => getSetRouteDiscriminatorBytes,
243
+ getSetRouteInstruction: () => getSetRouteInstruction,
244
+ getSetRouteInstructionDataCodec: () => getSetRouteInstructionDataCodec,
245
+ getSetRouteInstructionDataDecoder: () => getSetRouteInstructionDataDecoder,
246
+ getSetRouteInstructionDataEncoder: () => getSetRouteInstructionDataEncoder,
247
+ getSetSentinelDiscriminatorBytes: () => getSetSentinelDiscriminatorBytes,
248
+ getSetSentinelInstruction: () => getSetSentinelInstruction,
249
+ getSetSentinelInstructionDataCodec: () => getSetSentinelInstructionDataCodec,
250
+ getSetSentinelInstructionDataDecoder: () => getSetSentinelInstructionDataDecoder,
251
+ getSetSentinelInstructionDataEncoder: () => getSetSentinelInstructionDataEncoder,
252
+ getSkimDiscriminatorBytes: () => getSkimDiscriminatorBytes,
253
+ getSkimInstruction: () => getSkimInstruction,
254
+ getSkimInstructionAsync: () => getSkimInstructionAsync,
255
+ getSkimInstructionDataCodec: () => getSkimInstructionDataCodec,
256
+ getSkimInstructionDataDecoder: () => getSkimInstructionDataDecoder,
257
+ getSkimInstructionDataEncoder: () => getSkimInstructionDataEncoder,
135
258
  getSpotPrice0: () => getSpotPrice0,
136
259
  getSpotPrice1: () => getSpotPrice1,
137
260
  getSwapAddresses: () => getSwapAddresses,
261
+ getSwapExactInDiscriminatorBytes: () => getSwapExactInDiscriminatorBytes,
262
+ getSwapExactInInstruction: () => getSwapExactInInstruction,
263
+ getSwapExactInInstructionAsync: () => getSwapExactInInstructionAsync,
264
+ getSwapExactInInstructionDataCodec: () => getSwapExactInInstructionDataCodec,
265
+ getSwapExactInInstructionDataDecoder: () => getSwapExactInInstructionDataDecoder,
266
+ getSwapExactInInstructionDataEncoder: () => getSwapExactInInstructionDataEncoder,
138
267
  getSwapQuote: () => getSwapQuote,
139
268
  getSwapQuoteExactOut: () => getSwapQuoteExactOut,
269
+ getTransferAdminDiscriminatorBytes: () => getTransferAdminDiscriminatorBytes,
270
+ getTransferAdminInstruction: () => getTransferAdminInstruction,
271
+ getTransferAdminInstructionDataCodec: () => getTransferAdminInstructionDataCodec,
272
+ getTransferAdminInstructionDataDecoder: () => getTransferAdminInstructionDataDecoder,
273
+ getTransferAdminInstructionDataEncoder: () => getTransferAdminInstructionDataEncoder,
140
274
  getTvl: () => getTvl,
275
+ getUnpauseDiscriminatorBytes: () => getUnpauseDiscriminatorBytes,
276
+ getUnpauseInstruction: () => getUnpauseInstruction,
277
+ getUnpauseInstructionDataCodec: () => getUnpauseInstructionDataCodec,
278
+ getUnpauseInstructionDataDecoder: () => getUnpauseInstructionDataDecoder,
279
+ getUnpauseInstructionDataEncoder: () => getUnpauseInstructionDataEncoder,
280
+ getUpdateConfigDiscriminatorBytes: () => getUpdateConfigDiscriminatorBytes,
281
+ getUpdateConfigInstruction: () => getUpdateConfigInstruction,
282
+ getUpdateConfigInstructionDataCodec: () => getUpdateConfigInstructionDataCodec,
283
+ getUpdateConfigInstructionDataDecoder: () => getUpdateConfigInstructionDataDecoder,
284
+ getUpdateConfigInstructionDataEncoder: () => getUpdateConfigInstructionDataEncoder,
141
285
  initializeConfigArgsCodec: () => initializeConfigArgsCodec,
142
286
  initializeOracleArgsCodec: () => initializeOracleArgsCodec,
143
287
  initializePoolArgsCodec: () => initializePoolArgsCodec,
@@ -153,7 +297,29 @@ __export(cpmm_exports, {
153
297
  observationCodec: () => observationCodec,
154
298
  oracleConsultArgsCodec: () => oracleConsultArgsCodec,
155
299
  oracleStateDataCodec: () => oracleStateDataCodec,
300
+ parseAddLiquidityInstruction: () => parseAddLiquidityInstruction,
301
+ parseClosePositionInstruction: () => parseClosePositionInstruction,
302
+ parseCollectFeesInstruction: () => parseCollectFeesInstruction,
303
+ parseCollectProtocolFeesInstruction: () => parseCollectProtocolFeesInstruction,
304
+ parseCreatePositionInstruction: () => parseCreatePositionInstruction,
156
305
  parseErrorFromLogs: () => parseErrorFromLogs,
306
+ parseInitializeConfigInstruction: () => parseInitializeConfigInstruction,
307
+ parseInitializeOracleInstruction: () => parseInitializeOracleInstruction,
308
+ parseInitializePoolInstruction: () => parseInitializePoolInstruction,
309
+ parseOracleConsultInstruction: () => parseOracleConsultInstruction,
310
+ parseOracleUpdateInstruction: () => parseOracleUpdateInstruction,
311
+ parsePauseInstruction: () => parsePauseInstruction,
312
+ parsePreviewSwapExactInInstruction: () => parsePreviewSwapExactInInstruction,
313
+ parseQuoteToNumeraireInstruction: () => parseQuoteToNumeraireInstruction,
314
+ parseRemoveLiquidityInstruction: () => parseRemoveLiquidityInstruction,
315
+ parseSetFeesInstruction: () => parseSetFeesInstruction,
316
+ parseSetRouteInstruction: () => parseSetRouteInstruction,
317
+ parseSetSentinelInstruction: () => parseSetSentinelInstruction,
318
+ parseSkimInstruction: () => parseSkimInstruction,
319
+ parseSwapExactInInstruction: () => parseSwapExactInInstruction,
320
+ parseTransferAdminInstruction: () => parseTransferAdminInstruction,
321
+ parseUnpauseInstruction: () => parseUnpauseInstruction,
322
+ parseUpdateConfigInstruction: () => parseUpdateConfigInstruction,
157
323
  poolDataCodec: () => poolDataCodec,
158
324
  poolExists: () => poolExists,
159
325
  positionDataCodec: () => positionDataCodec,
@@ -468,605 +634,2933 @@ function getErrorMessage(code) {
468
634
  }
469
635
  return `Unknown error code: ${code}`;
470
636
  }
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
637
+
638
+ // src/solana/generated/cpmm/programs/cpmm.ts
639
+ var CPMM_PROGRAM_ADDRESS = "9PSxVPoPfnbZ8Q1uQhgS6ZxvBjFboZtebNsu34umxkgQ";
640
+
641
+ // src/solana/generated/cpmm/instructions/addLiquidity.ts
642
+ var ADD_LIQUIDITY_DISCRIMINATOR = new Uint8Array([
643
+ 181,
644
+ 157,
645
+ 89,
646
+ 67,
647
+ 143,
648
+ 182,
649
+ 52,
650
+ 72
651
+ ]);
652
+ function getAddLiquidityDiscriminatorBytes() {
653
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
654
+ ADD_LIQUIDITY_DISCRIMINATOR
482
655
  );
483
- return {
484
- programAddress: programId,
485
- accounts: keys,
486
- data
487
- };
488
656
  }
489
- function isTransactionSigner(value) {
490
- return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
657
+ function getAddLiquidityInstructionDataEncoder() {
658
+ return transformEncoder(
659
+ getStructEncoder([
660
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
661
+ ["amount0Max", getU64Encoder()],
662
+ ["amount1Max", getU64Encoder()],
663
+ ["minSharesOut", getU128Encoder()],
664
+ ["updateOracle", getBooleanEncoder()]
665
+ ]),
666
+ (value) => ({ ...value, discriminator: ADD_LIQUIDITY_DISCRIMINATOR })
667
+ );
491
668
  }
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 };
669
+ function getAddLiquidityInstructionDataDecoder() {
670
+ return getStructDecoder([
671
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
672
+ ["amount0Max", getU64Decoder()],
673
+ ["amount1Max", getU64Decoder()],
674
+ ["minSharesOut", getU128Decoder()],
675
+ ["updateOracle", getBooleanDecoder()]
676
+ ]);
501
677
  }
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
678
+ function getAddLiquidityInstructionDataCodec() {
679
+ return combineCodec(
680
+ getAddLiquidityInstructionDataEncoder(),
681
+ getAddLiquidityInstructionDataDecoder()
542
682
  );
543
- return {
544
- programAddress: programId,
545
- accounts: keys,
546
- data
683
+ }
684
+ async function getAddLiquidityInstructionAsync(input, config) {
685
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
686
+ const originalAccounts = {
687
+ config: { value: input.config ?? null, isWritable: false },
688
+ pool: { value: input.pool ?? null, isWritable: true },
689
+ position: { value: input.position ?? null, isWritable: true },
690
+ protocolPosition: {
691
+ value: input.protocolPosition ?? null,
692
+ isWritable: true
693
+ },
694
+ owner: { value: input.owner ?? null, isWritable: false },
695
+ authority: { value: input.authority ?? null, isWritable: false },
696
+ vault0: { value: input.vault0 ?? null, isWritable: true },
697
+ vault1: { value: input.vault1 ?? null, isWritable: true },
698
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
699
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
700
+ user0: { value: input.user0 ?? null, isWritable: true },
701
+ user1: { value: input.user1 ?? null, isWritable: true },
702
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
703
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
704
+ oracle: { value: input.oracle ?? null, isWritable: true }
547
705
  };
706
+ const accounts = originalAccounts;
707
+ const args = { ...input };
708
+ if (!accounts.authority.value) {
709
+ accounts.authority.value = await getProgramDerivedAddress({
710
+ programAddress,
711
+ seeds: [
712
+ getBytesEncoder().encode(
713
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
714
+ ),
715
+ getAddressEncoder().encode(
716
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
717
+ )
718
+ ]
719
+ });
720
+ }
721
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
722
+ return Object.freeze({
723
+ accounts: [
724
+ getAccountMeta("config", accounts.config),
725
+ getAccountMeta("pool", accounts.pool),
726
+ getAccountMeta("position", accounts.position),
727
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
728
+ getAccountMeta("owner", accounts.owner),
729
+ getAccountMeta("authority", accounts.authority),
730
+ getAccountMeta("vault0", accounts.vault0),
731
+ getAccountMeta("vault1", accounts.vault1),
732
+ getAccountMeta("token0Mint", accounts.token0Mint),
733
+ getAccountMeta("token1Mint", accounts.token1Mint),
734
+ getAccountMeta("user0", accounts.user0),
735
+ getAccountMeta("user1", accounts.user1),
736
+ getAccountMeta("token0Program", accounts.token0Program),
737
+ getAccountMeta("token1Program", accounts.token1Program),
738
+ getAccountMeta("oracle", accounts.oracle)
739
+ ],
740
+ data: getAddLiquidityInstructionDataEncoder().encode(
741
+ args
742
+ ),
743
+ programAddress
744
+ });
548
745
  }
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
746
+ function getAddLiquidityInstruction(input, config) {
747
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
748
+ const originalAccounts = {
749
+ config: { value: input.config ?? null, isWritable: false },
750
+ pool: { value: input.pool ?? null, isWritable: true },
751
+ position: { value: input.position ?? null, isWritable: true },
752
+ protocolPosition: {
753
+ value: input.protocolPosition ?? null,
754
+ isWritable: true
755
+ },
756
+ owner: { value: input.owner ?? null, isWritable: false },
757
+ authority: { value: input.authority ?? null, isWritable: false },
758
+ vault0: { value: input.vault0 ?? null, isWritable: true },
759
+ vault1: { value: input.vault1 ?? null, isWritable: true },
760
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
761
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
762
+ user0: { value: input.user0 ?? null, isWritable: true },
763
+ user1: { value: input.user1 ?? null, isWritable: true },
764
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
765
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
766
+ oracle: { value: input.oracle ?? null, isWritable: true }
575
767
  };
768
+ const accounts = originalAccounts;
769
+ const args = { ...input };
770
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
771
+ return Object.freeze({
772
+ accounts: [
773
+ getAccountMeta("config", accounts.config),
774
+ getAccountMeta("pool", accounts.pool),
775
+ getAccountMeta("position", accounts.position),
776
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
777
+ getAccountMeta("owner", accounts.owner),
778
+ getAccountMeta("authority", accounts.authority),
779
+ getAccountMeta("vault0", accounts.vault0),
780
+ getAccountMeta("vault1", accounts.vault1),
781
+ getAccountMeta("token0Mint", accounts.token0Mint),
782
+ getAccountMeta("token1Mint", accounts.token1Mint),
783
+ getAccountMeta("user0", accounts.user0),
784
+ getAccountMeta("user1", accounts.user1),
785
+ getAccountMeta("token0Program", accounts.token0Program),
786
+ getAccountMeta("token1Program", accounts.token1Program),
787
+ getAccountMeta("oracle", accounts.oracle)
788
+ ],
789
+ data: getAddLiquidityInstructionDataEncoder().encode(
790
+ args
791
+ ),
792
+ programAddress
793
+ });
576
794
  }
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
- );
795
+ function parseAddLiquidityInstruction(instruction) {
796
+ if (instruction.accounts.length < 15) {
797
+ throw new SolanaError(
798
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
799
+ {
800
+ actualAccountMetas: instruction.accounts.length,
801
+ expectedAccountMetas: 15
802
+ }
803
+ );
804
+ }
805
+ let accountIndex = 0;
806
+ const getNextAccount = () => {
807
+ const accountMeta = instruction.accounts[accountIndex];
808
+ accountIndex += 1;
809
+ return accountMeta;
810
+ };
811
+ const getNextOptionalAccount = () => {
812
+ const accountMeta = getNextAccount();
813
+ return accountMeta.address === CPMM_PROGRAM_ADDRESS ? void 0 : accountMeta;
814
+ };
589
815
  return {
590
- programAddress: programId,
591
- accounts: keys,
592
- data
816
+ programAddress: instruction.programAddress,
817
+ accounts: {
818
+ config: getNextAccount(),
819
+ pool: getNextAccount(),
820
+ position: getNextAccount(),
821
+ protocolPosition: getNextAccount(),
822
+ owner: getNextAccount(),
823
+ authority: getNextAccount(),
824
+ vault0: getNextAccount(),
825
+ vault1: getNextAccount(),
826
+ token0Mint: getNextAccount(),
827
+ token1Mint: getNextAccount(),
828
+ user0: getNextAccount(),
829
+ user1: getNextAccount(),
830
+ token0Program: getNextAccount(),
831
+ token1Program: getNextAccount(),
832
+ oracle: getNextOptionalAccount()
833
+ },
834
+ data: getAddLiquidityInstructionDataDecoder().decode(instruction.data)
593
835
  };
594
836
  }
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
837
+ var CLOSE_POSITION_DISCRIMINATOR = new Uint8Array([
838
+ 123,
839
+ 134,
840
+ 81,
841
+ 0,
842
+ 49,
843
+ 68,
844
+ 98,
845
+ 98
846
+ ]);
847
+ function getClosePositionDiscriminatorBytes() {
848
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
849
+ CLOSE_POSITION_DISCRIMINATOR
606
850
  );
607
- return {
608
- programAddress: programId,
609
- accounts: keys,
610
- data
611
- };
612
851
  }
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
852
+ function getClosePositionInstructionDataEncoder() {
853
+ return transformEncoder(
854
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
855
+ (value) => ({ ...value, discriminator: CLOSE_POSITION_DISCRIMINATOR })
627
856
  );
628
- return {
629
- programAddress: programId,
630
- accounts: keys,
631
- data
632
- };
633
857
  }
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
858
+ function getClosePositionInstructionDataDecoder() {
859
+ return getStructDecoder([
860
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)]
861
+ ]);
862
+ }
863
+ function getClosePositionInstructionDataCodec() {
864
+ return combineCodec(
865
+ getClosePositionInstructionDataEncoder(),
866
+ getClosePositionInstructionDataDecoder()
867
+ );
868
+ }
869
+ function getClosePositionInstruction(input, config) {
870
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
871
+ const originalAccounts = {
872
+ pool: { value: input.pool ?? null, isWritable: false },
873
+ position: { value: input.position ?? null, isWritable: true },
874
+ owner: { value: input.owner ?? null, isWritable: false },
875
+ rentRecipient: { value: input.rentRecipient ?? null, isWritable: true }
645
876
  };
877
+ const accounts = originalAccounts;
878
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
879
+ return Object.freeze({
880
+ accounts: [
881
+ getAccountMeta("pool", accounts.pool),
882
+ getAccountMeta("position", accounts.position),
883
+ getAccountMeta("owner", accounts.owner),
884
+ getAccountMeta("rentRecipient", accounts.rentRecipient)
885
+ ],
886
+ data: getClosePositionInstructionDataEncoder().encode({}),
887
+ programAddress
888
+ });
646
889
  }
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;
890
+ function parseClosePositionInstruction(instruction) {
891
+ if (instruction.accounts.length < 4) {
892
+ throw new SolanaError(
893
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
894
+ {
895
+ actualAccountMetas: instruction.accounts.length,
896
+ expectedAccountMetas: 4
897
+ }
898
+ );
899
+ }
900
+ let accountIndex = 0;
901
+ const getNextAccount = () => {
902
+ const accountMeta = instruction.accounts[accountIndex];
903
+ accountIndex += 1;
904
+ return accountMeta;
905
+ };
654
906
  return {
655
- programAddress: programId,
656
- accounts: keys,
657
- data
907
+ programAddress: instruction.programAddress,
908
+ accounts: {
909
+ pool: getNextAccount(),
910
+ position: getNextAccount(),
911
+ owner: getNextAccount(),
912
+ rentRecipient: getNextAccount()
913
+ },
914
+ data: getClosePositionInstructionDataDecoder().decode(instruction.data)
658
915
  };
659
916
  }
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
917
+ var COLLECT_FEES_DISCRIMINATOR = new Uint8Array([
918
+ 164,
919
+ 152,
920
+ 207,
921
+ 99,
922
+ 30,
923
+ 186,
924
+ 19,
925
+ 182
926
+ ]);
927
+ function getCollectFeesDiscriminatorBytes() {
928
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
929
+ COLLECT_FEES_DISCRIMINATOR
670
930
  );
671
- return {
672
- programAddress: programId,
673
- accounts: keys,
674
- data
675
- };
676
931
  }
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
- };
932
+ function getCollectFeesInstructionDataEncoder() {
933
+ return transformEncoder(
934
+ getStructEncoder([
935
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
936
+ ["max0", getU64Encoder()],
937
+ ["max1", getU64Encoder()]
938
+ ]),
939
+ (value) => ({ ...value, discriminator: COLLECT_FEES_DISCRIMINATOR })
940
+ );
710
941
  }
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 });
752
- }
753
- const data = encodeInstructionData(
754
- INSTRUCTION_DISCRIMINATORS.swapExactIn,
755
- swapExactInArgsCodec,
756
- args
942
+ function getCollectFeesInstructionDataDecoder() {
943
+ return getStructDecoder([
944
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
945
+ ["max0", getU64Decoder()],
946
+ ["max1", getU64Decoder()]
947
+ ]);
948
+ }
949
+ function getCollectFeesInstructionDataCodec() {
950
+ return combineCodec(
951
+ getCollectFeesInstructionDataEncoder(),
952
+ getCollectFeesInstructionDataDecoder()
757
953
  );
758
- return {
759
- programAddress: programId,
760
- accounts: keys,
761
- data
762
- };
763
954
  }
764
- function createSwapInstruction(params) {
765
- const {
766
- config,
767
- pool,
768
- authority,
769
- vault0,
770
- vault1,
771
- token0Mint,
772
- token1Mint,
773
- userToken0,
774
- userToken1,
775
- user,
776
- amountIn,
777
- minAmountOut,
778
- direction,
779
- oracle,
780
- remainingAccounts,
781
- updateOracle = false,
782
- token0Program,
783
- token1Program,
784
- tokenProgram,
785
- instructionsSysvar,
786
- programId = CPMM_PROGRAM_ID
787
- } = params;
788
- const [vaultIn, vaultOut] = direction === 0 ? [vault0, vault1] : [vault1, vault0];
789
- const [userIn, userOut] = direction === 0 ? [userToken0, userToken1] : [userToken1, userToken0];
790
- return createSwapExactInInstruction(
791
- {
792
- config,
793
- pool,
794
- authority,
795
- vaultIn,
796
- vaultOut,
797
- token0Mint,
798
- token1Mint,
799
- userIn,
800
- userOut,
801
- user,
802
- token0Program,
803
- token1Program,
804
- tokenProgram,
805
- instructionsSysvar,
806
- oracle,
807
- remainingAccounts
955
+ async function getCollectFeesInstructionAsync(input, config) {
956
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
957
+ const originalAccounts = {
958
+ pool: { value: input.pool ?? null, isWritable: true },
959
+ position: { value: input.position ?? null, isWritable: true },
960
+ owner: { value: input.owner ?? null, isWritable: false },
961
+ authority: { value: input.authority ?? null, isWritable: false },
962
+ vault0: { value: input.vault0 ?? null, isWritable: true },
963
+ vault1: { value: input.vault1 ?? null, isWritable: true },
964
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
965
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
966
+ user0: { value: input.user0 ?? null, isWritable: true },
967
+ user1: { value: input.user1 ?? null, isWritable: true },
968
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
969
+ token1Program: { value: input.token1Program ?? null, isWritable: false }
970
+ };
971
+ const accounts = originalAccounts;
972
+ const args = { ...input };
973
+ if (!accounts.authority.value) {
974
+ accounts.authority.value = await getProgramDerivedAddress({
975
+ programAddress,
976
+ seeds: [
977
+ getBytesEncoder().encode(
978
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
979
+ ),
980
+ getAddressEncoder().encode(
981
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
982
+ )
983
+ ]
984
+ });
985
+ }
986
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
987
+ return Object.freeze({
988
+ accounts: [
989
+ getAccountMeta("pool", accounts.pool),
990
+ getAccountMeta("position", accounts.position),
991
+ getAccountMeta("owner", accounts.owner),
992
+ getAccountMeta("authority", accounts.authority),
993
+ getAccountMeta("vault0", accounts.vault0),
994
+ getAccountMeta("vault1", accounts.vault1),
995
+ getAccountMeta("token0Mint", accounts.token0Mint),
996
+ getAccountMeta("token1Mint", accounts.token1Mint),
997
+ getAccountMeta("user0", accounts.user0),
998
+ getAccountMeta("user1", accounts.user1),
999
+ getAccountMeta("token0Program", accounts.token0Program),
1000
+ getAccountMeta("token1Program", accounts.token1Program)
1001
+ ],
1002
+ data: getCollectFeesInstructionDataEncoder().encode(
1003
+ args
1004
+ ),
1005
+ programAddress
1006
+ });
1007
+ }
1008
+ function getCollectFeesInstruction(input, config) {
1009
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1010
+ const originalAccounts = {
1011
+ pool: { value: input.pool ?? null, isWritable: true },
1012
+ position: { value: input.position ?? null, isWritable: true },
1013
+ owner: { value: input.owner ?? null, isWritable: false },
1014
+ authority: { value: input.authority ?? null, isWritable: false },
1015
+ vault0: { value: input.vault0 ?? null, isWritable: true },
1016
+ vault1: { value: input.vault1 ?? null, isWritable: true },
1017
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
1018
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
1019
+ user0: { value: input.user0 ?? null, isWritable: true },
1020
+ user1: { value: input.user1 ?? null, isWritable: true },
1021
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
1022
+ token1Program: { value: input.token1Program ?? null, isWritable: false }
1023
+ };
1024
+ const accounts = originalAccounts;
1025
+ const args = { ...input };
1026
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1027
+ return Object.freeze({
1028
+ accounts: [
1029
+ getAccountMeta("pool", accounts.pool),
1030
+ getAccountMeta("position", accounts.position),
1031
+ getAccountMeta("owner", accounts.owner),
1032
+ getAccountMeta("authority", accounts.authority),
1033
+ getAccountMeta("vault0", accounts.vault0),
1034
+ getAccountMeta("vault1", accounts.vault1),
1035
+ getAccountMeta("token0Mint", accounts.token0Mint),
1036
+ getAccountMeta("token1Mint", accounts.token1Mint),
1037
+ getAccountMeta("user0", accounts.user0),
1038
+ getAccountMeta("user1", accounts.user1),
1039
+ getAccountMeta("token0Program", accounts.token0Program),
1040
+ getAccountMeta("token1Program", accounts.token1Program)
1041
+ ],
1042
+ data: getCollectFeesInstructionDataEncoder().encode(
1043
+ args
1044
+ ),
1045
+ programAddress
1046
+ });
1047
+ }
1048
+ function parseCollectFeesInstruction(instruction) {
1049
+ if (instruction.accounts.length < 12) {
1050
+ throw new SolanaError(
1051
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
1052
+ {
1053
+ actualAccountMetas: instruction.accounts.length,
1054
+ expectedAccountMetas: 12
1055
+ }
1056
+ );
1057
+ }
1058
+ let accountIndex = 0;
1059
+ const getNextAccount = () => {
1060
+ const accountMeta = instruction.accounts[accountIndex];
1061
+ accountIndex += 1;
1062
+ return accountMeta;
1063
+ };
1064
+ return {
1065
+ programAddress: instruction.programAddress,
1066
+ accounts: {
1067
+ pool: getNextAccount(),
1068
+ position: getNextAccount(),
1069
+ owner: getNextAccount(),
1070
+ authority: getNextAccount(),
1071
+ vault0: getNextAccount(),
1072
+ vault1: getNextAccount(),
1073
+ token0Mint: getNextAccount(),
1074
+ token1Mint: getNextAccount(),
1075
+ user0: getNextAccount(),
1076
+ user1: getNextAccount(),
1077
+ token0Program: getNextAccount(),
1078
+ token1Program: getNextAccount()
1079
+ },
1080
+ data: getCollectFeesInstructionDataDecoder().decode(instruction.data)
1081
+ };
1082
+ }
1083
+ var COLLECT_PROTOCOL_FEES_DISCRIMINATOR = new Uint8Array([
1084
+ 22,
1085
+ 67,
1086
+ 23,
1087
+ 98,
1088
+ 150,
1089
+ 178,
1090
+ 70,
1091
+ 220
1092
+ ]);
1093
+ function getCollectProtocolFeesDiscriminatorBytes() {
1094
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
1095
+ COLLECT_PROTOCOL_FEES_DISCRIMINATOR
1096
+ );
1097
+ }
1098
+ function getCollectProtocolFeesInstructionDataEncoder() {
1099
+ return transformEncoder(
1100
+ getStructEncoder([
1101
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1102
+ ["max0", getU64Encoder()],
1103
+ ["max1", getU64Encoder()]
1104
+ ]),
1105
+ (value) => ({
1106
+ ...value,
1107
+ discriminator: COLLECT_PROTOCOL_FEES_DISCRIMINATOR
1108
+ })
1109
+ );
1110
+ }
1111
+ function getCollectProtocolFeesInstructionDataDecoder() {
1112
+ return getStructDecoder([
1113
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
1114
+ ["max0", getU64Decoder()],
1115
+ ["max1", getU64Decoder()]
1116
+ ]);
1117
+ }
1118
+ function getCollectProtocolFeesInstructionDataCodec() {
1119
+ return combineCodec(
1120
+ getCollectProtocolFeesInstructionDataEncoder(),
1121
+ getCollectProtocolFeesInstructionDataDecoder()
1122
+ );
1123
+ }
1124
+ async function getCollectProtocolFeesInstructionAsync(input, config) {
1125
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1126
+ const originalAccounts = {
1127
+ config: { value: input.config ?? null, isWritable: false },
1128
+ pool: { value: input.pool ?? null, isWritable: true },
1129
+ protocolPosition: {
1130
+ value: input.protocolPosition ?? null,
1131
+ isWritable: true
1132
+ },
1133
+ admin: { value: input.admin ?? null, isWritable: false },
1134
+ authority: { value: input.authority ?? null, isWritable: false },
1135
+ vault0: { value: input.vault0 ?? null, isWritable: true },
1136
+ vault1: { value: input.vault1 ?? null, isWritable: true },
1137
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
1138
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
1139
+ recipient0: { value: input.recipient0 ?? null, isWritable: true },
1140
+ recipient1: { value: input.recipient1 ?? null, isWritable: true },
1141
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
1142
+ token1Program: { value: input.token1Program ?? null, isWritable: false }
1143
+ };
1144
+ const accounts = originalAccounts;
1145
+ const args = { ...input };
1146
+ if (!accounts.authority.value) {
1147
+ accounts.authority.value = await getProgramDerivedAddress({
1148
+ programAddress,
1149
+ seeds: [
1150
+ getBytesEncoder().encode(
1151
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
1152
+ ),
1153
+ getAddressEncoder().encode(
1154
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1155
+ )
1156
+ ]
1157
+ });
1158
+ }
1159
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1160
+ return Object.freeze({
1161
+ accounts: [
1162
+ getAccountMeta("config", accounts.config),
1163
+ getAccountMeta("pool", accounts.pool),
1164
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
1165
+ getAccountMeta("admin", accounts.admin),
1166
+ getAccountMeta("authority", accounts.authority),
1167
+ getAccountMeta("vault0", accounts.vault0),
1168
+ getAccountMeta("vault1", accounts.vault1),
1169
+ getAccountMeta("token0Mint", accounts.token0Mint),
1170
+ getAccountMeta("token1Mint", accounts.token1Mint),
1171
+ getAccountMeta("recipient0", accounts.recipient0),
1172
+ getAccountMeta("recipient1", accounts.recipient1),
1173
+ getAccountMeta("token0Program", accounts.token0Program),
1174
+ getAccountMeta("token1Program", accounts.token1Program)
1175
+ ],
1176
+ data: getCollectProtocolFeesInstructionDataEncoder().encode(
1177
+ args
1178
+ ),
1179
+ programAddress
1180
+ });
1181
+ }
1182
+ function getCollectProtocolFeesInstruction(input, config) {
1183
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1184
+ const originalAccounts = {
1185
+ config: { value: input.config ?? null, isWritable: false },
1186
+ pool: { value: input.pool ?? null, isWritable: true },
1187
+ protocolPosition: {
1188
+ value: input.protocolPosition ?? null,
1189
+ isWritable: true
1190
+ },
1191
+ admin: { value: input.admin ?? null, isWritable: false },
1192
+ authority: { value: input.authority ?? null, isWritable: false },
1193
+ vault0: { value: input.vault0 ?? null, isWritable: true },
1194
+ vault1: { value: input.vault1 ?? null, isWritable: true },
1195
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
1196
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
1197
+ recipient0: { value: input.recipient0 ?? null, isWritable: true },
1198
+ recipient1: { value: input.recipient1 ?? null, isWritable: true },
1199
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
1200
+ token1Program: { value: input.token1Program ?? null, isWritable: false }
1201
+ };
1202
+ const accounts = originalAccounts;
1203
+ const args = { ...input };
1204
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1205
+ return Object.freeze({
1206
+ accounts: [
1207
+ getAccountMeta("config", accounts.config),
1208
+ getAccountMeta("pool", accounts.pool),
1209
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
1210
+ getAccountMeta("admin", accounts.admin),
1211
+ getAccountMeta("authority", accounts.authority),
1212
+ getAccountMeta("vault0", accounts.vault0),
1213
+ getAccountMeta("vault1", accounts.vault1),
1214
+ getAccountMeta("token0Mint", accounts.token0Mint),
1215
+ getAccountMeta("token1Mint", accounts.token1Mint),
1216
+ getAccountMeta("recipient0", accounts.recipient0),
1217
+ getAccountMeta("recipient1", accounts.recipient1),
1218
+ getAccountMeta("token0Program", accounts.token0Program),
1219
+ getAccountMeta("token1Program", accounts.token1Program)
1220
+ ],
1221
+ data: getCollectProtocolFeesInstructionDataEncoder().encode(
1222
+ args
1223
+ ),
1224
+ programAddress
1225
+ });
1226
+ }
1227
+ function parseCollectProtocolFeesInstruction(instruction) {
1228
+ if (instruction.accounts.length < 13) {
1229
+ throw new SolanaError(
1230
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
1231
+ {
1232
+ actualAccountMetas: instruction.accounts.length,
1233
+ expectedAccountMetas: 13
1234
+ }
1235
+ );
1236
+ }
1237
+ let accountIndex = 0;
1238
+ const getNextAccount = () => {
1239
+ const accountMeta = instruction.accounts[accountIndex];
1240
+ accountIndex += 1;
1241
+ return accountMeta;
1242
+ };
1243
+ return {
1244
+ programAddress: instruction.programAddress,
1245
+ accounts: {
1246
+ config: getNextAccount(),
1247
+ pool: getNextAccount(),
1248
+ protocolPosition: getNextAccount(),
1249
+ admin: getNextAccount(),
1250
+ authority: getNextAccount(),
1251
+ vault0: getNextAccount(),
1252
+ vault1: getNextAccount(),
1253
+ token0Mint: getNextAccount(),
1254
+ token1Mint: getNextAccount(),
1255
+ recipient0: getNextAccount(),
1256
+ recipient1: getNextAccount(),
1257
+ token0Program: getNextAccount(),
1258
+ token1Program: getNextAccount()
1259
+ },
1260
+ data: getCollectProtocolFeesInstructionDataDecoder().decode(
1261
+ instruction.data
1262
+ )
1263
+ };
1264
+ }
1265
+ var CREATE_POSITION_DISCRIMINATOR = new Uint8Array([
1266
+ 48,
1267
+ 215,
1268
+ 197,
1269
+ 153,
1270
+ 96,
1271
+ 203,
1272
+ 180,
1273
+ 133
1274
+ ]);
1275
+ function getCreatePositionDiscriminatorBytes() {
1276
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
1277
+ CREATE_POSITION_DISCRIMINATOR
1278
+ );
1279
+ }
1280
+ function getCreatePositionInstructionDataEncoder() {
1281
+ return transformEncoder(
1282
+ getStructEncoder([
1283
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1284
+ ["positionId", getU64Encoder()]
1285
+ ]),
1286
+ (value) => ({ ...value, discriminator: CREATE_POSITION_DISCRIMINATOR })
1287
+ );
1288
+ }
1289
+ function getCreatePositionInstructionDataDecoder() {
1290
+ return getStructDecoder([
1291
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
1292
+ ["positionId", getU64Decoder()]
1293
+ ]);
1294
+ }
1295
+ function getCreatePositionInstructionDataCodec() {
1296
+ return combineCodec(
1297
+ getCreatePositionInstructionDataEncoder(),
1298
+ getCreatePositionInstructionDataDecoder()
1299
+ );
1300
+ }
1301
+ async function getCreatePositionInstructionAsync(input, config) {
1302
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1303
+ const originalAccounts = {
1304
+ pool: { value: input.pool ?? null, isWritable: false },
1305
+ position: { value: input.position ?? null, isWritable: true },
1306
+ owner: { value: input.owner ?? null, isWritable: false },
1307
+ payer: { value: input.payer ?? null, isWritable: true },
1308
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1309
+ };
1310
+ const accounts = originalAccounts;
1311
+ const args = { ...input };
1312
+ if (!accounts.position.value) {
1313
+ accounts.position.value = await getProgramDerivedAddress({
1314
+ programAddress,
1315
+ seeds: [
1316
+ getBytesEncoder().encode(
1317
+ new Uint8Array([112, 111, 115, 105, 116, 105, 111, 110])
1318
+ ),
1319
+ getAddressEncoder().encode(
1320
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1321
+ ),
1322
+ getAddressEncoder().encode(
1323
+ getAddressFromResolvedInstructionAccount(
1324
+ "owner",
1325
+ accounts.owner.value
1326
+ )
1327
+ ),
1328
+ getU64Encoder().encode(
1329
+ getNonNullResolvedInstructionInput("positionId", args.positionId)
1330
+ )
1331
+ ]
1332
+ });
1333
+ }
1334
+ if (!accounts.systemProgram.value) {
1335
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1336
+ }
1337
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1338
+ return Object.freeze({
1339
+ accounts: [
1340
+ getAccountMeta("pool", accounts.pool),
1341
+ getAccountMeta("position", accounts.position),
1342
+ getAccountMeta("owner", accounts.owner),
1343
+ getAccountMeta("payer", accounts.payer),
1344
+ getAccountMeta("systemProgram", accounts.systemProgram)
1345
+ ],
1346
+ data: getCreatePositionInstructionDataEncoder().encode(
1347
+ args
1348
+ ),
1349
+ programAddress
1350
+ });
1351
+ }
1352
+ function getCreatePositionInstruction(input, config) {
1353
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1354
+ const originalAccounts = {
1355
+ pool: { value: input.pool ?? null, isWritable: false },
1356
+ position: { value: input.position ?? null, isWritable: true },
1357
+ owner: { value: input.owner ?? null, isWritable: false },
1358
+ payer: { value: input.payer ?? null, isWritable: true },
1359
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1360
+ };
1361
+ const accounts = originalAccounts;
1362
+ const args = { ...input };
1363
+ if (!accounts.systemProgram.value) {
1364
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1365
+ }
1366
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1367
+ return Object.freeze({
1368
+ accounts: [
1369
+ getAccountMeta("pool", accounts.pool),
1370
+ getAccountMeta("position", accounts.position),
1371
+ getAccountMeta("owner", accounts.owner),
1372
+ getAccountMeta("payer", accounts.payer),
1373
+ getAccountMeta("systemProgram", accounts.systemProgram)
1374
+ ],
1375
+ data: getCreatePositionInstructionDataEncoder().encode(
1376
+ args
1377
+ ),
1378
+ programAddress
1379
+ });
1380
+ }
1381
+ function parseCreatePositionInstruction(instruction) {
1382
+ if (instruction.accounts.length < 5) {
1383
+ throw new SolanaError(
1384
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
1385
+ {
1386
+ actualAccountMetas: instruction.accounts.length,
1387
+ expectedAccountMetas: 5
1388
+ }
1389
+ );
1390
+ }
1391
+ let accountIndex = 0;
1392
+ const getNextAccount = () => {
1393
+ const accountMeta = instruction.accounts[accountIndex];
1394
+ accountIndex += 1;
1395
+ return accountMeta;
1396
+ };
1397
+ return {
1398
+ programAddress: instruction.programAddress,
1399
+ accounts: {
1400
+ pool: getNextAccount(),
1401
+ position: getNextAccount(),
1402
+ owner: getNextAccount(),
1403
+ payer: getNextAccount(),
1404
+ systemProgram: getNextAccount()
1405
+ },
1406
+ data: getCreatePositionInstructionDataDecoder().decode(instruction.data)
1407
+ };
1408
+ }
1409
+ var INITIALIZE_CONFIG_DISCRIMINATOR = new Uint8Array([
1410
+ 208,
1411
+ 127,
1412
+ 21,
1413
+ 1,
1414
+ 194,
1415
+ 190,
1416
+ 196,
1417
+ 70
1418
+ ]);
1419
+ function getInitializeConfigDiscriminatorBytes() {
1420
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
1421
+ INITIALIZE_CONFIG_DISCRIMINATOR
1422
+ );
1423
+ }
1424
+ function getInitializeConfigInstructionDataEncoder() {
1425
+ return transformEncoder(
1426
+ getStructEncoder([
1427
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1428
+ ["admin", getAddressEncoder()],
1429
+ ["numeraireMint", getAddressEncoder()],
1430
+ ["maxSwapFeeBps", getU16Encoder()],
1431
+ ["maxFeeSplitBps", getU16Encoder()],
1432
+ ["maxRouteHops", getU8Encoder()],
1433
+ ["protocolFeeEnabled", getBooleanEncoder()],
1434
+ ["protocolFeeBps", getU16Encoder()],
1435
+ ["sentinelAllowlist", getArrayEncoder(getAddressEncoder())]
1436
+ ]),
1437
+ (value) => ({ ...value, discriminator: INITIALIZE_CONFIG_DISCRIMINATOR })
1438
+ );
1439
+ }
1440
+ function getInitializeConfigInstructionDataDecoder() {
1441
+ return getStructDecoder([
1442
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
1443
+ ["admin", getAddressDecoder()],
1444
+ ["numeraireMint", getAddressDecoder()],
1445
+ ["maxSwapFeeBps", getU16Decoder()],
1446
+ ["maxFeeSplitBps", getU16Decoder()],
1447
+ ["maxRouteHops", getU8Decoder()],
1448
+ ["protocolFeeEnabled", getBooleanDecoder()],
1449
+ ["protocolFeeBps", getU16Decoder()],
1450
+ ["sentinelAllowlist", getArrayDecoder(getAddressDecoder())]
1451
+ ]);
1452
+ }
1453
+ function getInitializeConfigInstructionDataCodec() {
1454
+ return combineCodec(
1455
+ getInitializeConfigInstructionDataEncoder(),
1456
+ getInitializeConfigInstructionDataDecoder()
1457
+ );
1458
+ }
1459
+ async function getInitializeConfigInstructionAsync(input, config) {
1460
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1461
+ const originalAccounts = {
1462
+ config: { value: input.config ?? null, isWritable: true },
1463
+ programData: { value: input.programData ?? null, isWritable: false },
1464
+ payer: { value: input.payer ?? null, isWritable: true },
1465
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1466
+ };
1467
+ const accounts = originalAccounts;
1468
+ const args = { ...input };
1469
+ if (!accounts.config.value) {
1470
+ accounts.config.value = await getProgramDerivedAddress({
1471
+ programAddress,
1472
+ seeds: [
1473
+ getBytesEncoder().encode(new Uint8Array([99, 111, 110, 102, 105, 103]))
1474
+ ]
1475
+ });
1476
+ }
1477
+ if (!accounts.systemProgram.value) {
1478
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1479
+ }
1480
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1481
+ return Object.freeze({
1482
+ accounts: [
1483
+ getAccountMeta("config", accounts.config),
1484
+ getAccountMeta("programData", accounts.programData),
1485
+ getAccountMeta("payer", accounts.payer),
1486
+ getAccountMeta("systemProgram", accounts.systemProgram)
1487
+ ],
1488
+ data: getInitializeConfigInstructionDataEncoder().encode(
1489
+ args
1490
+ ),
1491
+ programAddress
1492
+ });
1493
+ }
1494
+ function getInitializeConfigInstruction(input, config) {
1495
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1496
+ const originalAccounts = {
1497
+ config: { value: input.config ?? null, isWritable: true },
1498
+ programData: { value: input.programData ?? null, isWritable: false },
1499
+ payer: { value: input.payer ?? null, isWritable: true },
1500
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1501
+ };
1502
+ const accounts = originalAccounts;
1503
+ const args = { ...input };
1504
+ if (!accounts.systemProgram.value) {
1505
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1506
+ }
1507
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1508
+ return Object.freeze({
1509
+ accounts: [
1510
+ getAccountMeta("config", accounts.config),
1511
+ getAccountMeta("programData", accounts.programData),
1512
+ getAccountMeta("payer", accounts.payer),
1513
+ getAccountMeta("systemProgram", accounts.systemProgram)
1514
+ ],
1515
+ data: getInitializeConfigInstructionDataEncoder().encode(
1516
+ args
1517
+ ),
1518
+ programAddress
1519
+ });
1520
+ }
1521
+ function parseInitializeConfigInstruction(instruction) {
1522
+ if (instruction.accounts.length < 4) {
1523
+ throw new SolanaError(
1524
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
1525
+ {
1526
+ actualAccountMetas: instruction.accounts.length,
1527
+ expectedAccountMetas: 4
1528
+ }
1529
+ );
1530
+ }
1531
+ let accountIndex = 0;
1532
+ const getNextAccount = () => {
1533
+ const accountMeta = instruction.accounts[accountIndex];
1534
+ accountIndex += 1;
1535
+ return accountMeta;
1536
+ };
1537
+ return {
1538
+ programAddress: instruction.programAddress,
1539
+ accounts: {
1540
+ config: getNextAccount(),
1541
+ programData: getNextAccount(),
1542
+ payer: getNextAccount(),
1543
+ systemProgram: getNextAccount()
1544
+ },
1545
+ data: getInitializeConfigInstructionDataDecoder().decode(instruction.data)
1546
+ };
1547
+ }
1548
+ var INITIALIZE_ORACLE_DISCRIMINATOR = new Uint8Array([
1549
+ 144,
1550
+ 223,
1551
+ 131,
1552
+ 120,
1553
+ 196,
1554
+ 253,
1555
+ 181,
1556
+ 99
1557
+ ]);
1558
+ function getInitializeOracleDiscriminatorBytes() {
1559
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
1560
+ INITIALIZE_ORACLE_DISCRIMINATOR
1561
+ );
1562
+ }
1563
+ function getInitializeOracleInstructionDataEncoder() {
1564
+ return transformEncoder(
1565
+ getStructEncoder([
1566
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1567
+ ["maxPriceChangeRatioQ64", getU128Encoder()],
1568
+ ["observationIntervalSec", getU32Encoder()]
1569
+ ]),
1570
+ (value) => ({ ...value, discriminator: INITIALIZE_ORACLE_DISCRIMINATOR })
1571
+ );
1572
+ }
1573
+ function getInitializeOracleInstructionDataDecoder() {
1574
+ return getStructDecoder([
1575
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
1576
+ ["maxPriceChangeRatioQ64", getU128Decoder()],
1577
+ ["observationIntervalSec", getU32Decoder()]
1578
+ ]);
1579
+ }
1580
+ function getInitializeOracleInstructionDataCodec() {
1581
+ return combineCodec(
1582
+ getInitializeOracleInstructionDataEncoder(),
1583
+ getInitializeOracleInstructionDataDecoder()
1584
+ );
1585
+ }
1586
+ async function getInitializeOracleInstructionAsync(input, config) {
1587
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1588
+ const originalAccounts = {
1589
+ config: { value: input.config ?? null, isWritable: false },
1590
+ pool: { value: input.pool ?? null, isWritable: false },
1591
+ oracle: { value: input.oracle ?? null, isWritable: true },
1592
+ admin: { value: input.admin ?? null, isWritable: false },
1593
+ payer: { value: input.payer ?? null, isWritable: true },
1594
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1595
+ };
1596
+ const accounts = originalAccounts;
1597
+ const args = { ...input };
1598
+ if (!accounts.oracle.value) {
1599
+ accounts.oracle.value = await getProgramDerivedAddress({
1600
+ programAddress,
1601
+ seeds: [
1602
+ getBytesEncoder().encode(new Uint8Array([111, 114, 97, 99, 108, 101])),
1603
+ getAddressEncoder().encode(
1604
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1605
+ )
1606
+ ]
1607
+ });
1608
+ }
1609
+ if (!accounts.systemProgram.value) {
1610
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1611
+ }
1612
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1613
+ return Object.freeze({
1614
+ accounts: [
1615
+ getAccountMeta("config", accounts.config),
1616
+ getAccountMeta("pool", accounts.pool),
1617
+ getAccountMeta("oracle", accounts.oracle),
1618
+ getAccountMeta("admin", accounts.admin),
1619
+ getAccountMeta("payer", accounts.payer),
1620
+ getAccountMeta("systemProgram", accounts.systemProgram)
1621
+ ],
1622
+ data: getInitializeOracleInstructionDataEncoder().encode(
1623
+ args
1624
+ ),
1625
+ programAddress
1626
+ });
1627
+ }
1628
+ function getInitializeOracleInstruction(input, config) {
1629
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1630
+ const originalAccounts = {
1631
+ config: { value: input.config ?? null, isWritable: false },
1632
+ pool: { value: input.pool ?? null, isWritable: false },
1633
+ oracle: { value: input.oracle ?? null, isWritable: true },
1634
+ admin: { value: input.admin ?? null, isWritable: false },
1635
+ payer: { value: input.payer ?? null, isWritable: true },
1636
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1637
+ };
1638
+ const accounts = originalAccounts;
1639
+ const args = { ...input };
1640
+ if (!accounts.systemProgram.value) {
1641
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1642
+ }
1643
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1644
+ return Object.freeze({
1645
+ accounts: [
1646
+ getAccountMeta("config", accounts.config),
1647
+ getAccountMeta("pool", accounts.pool),
1648
+ getAccountMeta("oracle", accounts.oracle),
1649
+ getAccountMeta("admin", accounts.admin),
1650
+ getAccountMeta("payer", accounts.payer),
1651
+ getAccountMeta("systemProgram", accounts.systemProgram)
1652
+ ],
1653
+ data: getInitializeOracleInstructionDataEncoder().encode(
1654
+ args
1655
+ ),
1656
+ programAddress
1657
+ });
1658
+ }
1659
+ function parseInitializeOracleInstruction(instruction) {
1660
+ if (instruction.accounts.length < 6) {
1661
+ throw new SolanaError(
1662
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
1663
+ {
1664
+ actualAccountMetas: instruction.accounts.length,
1665
+ expectedAccountMetas: 6
1666
+ }
1667
+ );
1668
+ }
1669
+ let accountIndex = 0;
1670
+ const getNextAccount = () => {
1671
+ const accountMeta = instruction.accounts[accountIndex];
1672
+ accountIndex += 1;
1673
+ return accountMeta;
1674
+ };
1675
+ return {
1676
+ programAddress: instruction.programAddress,
1677
+ accounts: {
1678
+ config: getNextAccount(),
1679
+ pool: getNextAccount(),
1680
+ oracle: getNextAccount(),
1681
+ admin: getNextAccount(),
1682
+ payer: getNextAccount(),
1683
+ systemProgram: getNextAccount()
1684
+ },
1685
+ data: getInitializeOracleInstructionDataDecoder().decode(instruction.data)
1686
+ };
1687
+ }
1688
+ var INITIALIZE_POOL_DISCRIMINATOR = new Uint8Array([
1689
+ 95,
1690
+ 180,
1691
+ 10,
1692
+ 172,
1693
+ 84,
1694
+ 174,
1695
+ 232,
1696
+ 40
1697
+ ]);
1698
+ function getInitializePoolDiscriminatorBytes() {
1699
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
1700
+ INITIALIZE_POOL_DISCRIMINATOR
1701
+ );
1702
+ }
1703
+ function getInitializePoolInstructionDataEncoder() {
1704
+ return transformEncoder(
1705
+ getStructEncoder([
1706
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1707
+ ["mintA", getAddressEncoder()],
1708
+ ["mintB", getAddressEncoder()],
1709
+ ["initialSwapFeeBps", getU16Encoder()],
1710
+ ["initialFeeSplitBps", getU16Encoder()],
1711
+ ["liquidityMeasureSide", getU8Encoder()],
1712
+ ["numeraireMintOverride", getOptionEncoder(getAddressEncoder())]
1713
+ ]),
1714
+ (value) => ({ ...value, discriminator: INITIALIZE_POOL_DISCRIMINATOR })
1715
+ );
1716
+ }
1717
+ function getInitializePoolInstructionDataDecoder() {
1718
+ return getStructDecoder([
1719
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
1720
+ ["mintA", getAddressDecoder()],
1721
+ ["mintB", getAddressDecoder()],
1722
+ ["initialSwapFeeBps", getU16Decoder()],
1723
+ ["initialFeeSplitBps", getU16Decoder()],
1724
+ ["liquidityMeasureSide", getU8Decoder()],
1725
+ ["numeraireMintOverride", getOptionDecoder(getAddressDecoder())]
1726
+ ]);
1727
+ }
1728
+ function getInitializePoolInstructionDataCodec() {
1729
+ return combineCodec(
1730
+ getInitializePoolInstructionDataEncoder(),
1731
+ getInitializePoolInstructionDataDecoder()
1732
+ );
1733
+ }
1734
+ async function getInitializePoolInstructionAsync(input, config) {
1735
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1736
+ const originalAccounts = {
1737
+ config: { value: input.config ?? null, isWritable: false },
1738
+ pool: { value: input.pool ?? null, isWritable: true },
1739
+ protocolPosition: {
1740
+ value: input.protocolPosition ?? null,
1741
+ isWritable: true
1742
+ },
1743
+ authority: { value: input.authority ?? null, isWritable: false },
1744
+ vault0: { value: input.vault0 ?? null, isWritable: true },
1745
+ vault1: { value: input.vault1 ?? null, isWritable: true },
1746
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
1747
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
1748
+ payer: { value: input.payer ?? null, isWritable: true },
1749
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
1750
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
1751
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1752
+ rent: { value: input.rent ?? null, isWritable: false },
1753
+ migrationAuthority: {
1754
+ value: input.migrationAuthority ?? null,
1755
+ isWritable: false
1756
+ }
1757
+ };
1758
+ const accounts = originalAccounts;
1759
+ const args = { ...input };
1760
+ if (!accounts.pool.value) {
1761
+ accounts.pool.value = await getProgramDerivedAddress({
1762
+ programAddress,
1763
+ seeds: [
1764
+ getBytesEncoder().encode(new Uint8Array([112, 111, 111, 108])),
1765
+ getAddressEncoder().encode(
1766
+ getAddressFromResolvedInstructionAccount(
1767
+ "token0Mint",
1768
+ accounts.token0Mint.value
1769
+ )
1770
+ ),
1771
+ getAddressEncoder().encode(
1772
+ getAddressFromResolvedInstructionAccount(
1773
+ "token1Mint",
1774
+ accounts.token1Mint.value
1775
+ )
1776
+ )
1777
+ ]
1778
+ });
1779
+ }
1780
+ if (!accounts.protocolPosition.value) {
1781
+ accounts.protocolPosition.value = await getProgramDerivedAddress({
1782
+ programAddress,
1783
+ seeds: [
1784
+ getBytesEncoder().encode(
1785
+ new Uint8Array([
1786
+ 112,
1787
+ 114,
1788
+ 111,
1789
+ 116,
1790
+ 111,
1791
+ 99,
1792
+ 111,
1793
+ 108,
1794
+ 95,
1795
+ 112,
1796
+ 111,
1797
+ 115,
1798
+ 105,
1799
+ 116,
1800
+ 105,
1801
+ 111,
1802
+ 110
1803
+ ])
1804
+ ),
1805
+ getAddressEncoder().encode(
1806
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1807
+ )
1808
+ ]
1809
+ });
1810
+ }
1811
+ if (!accounts.authority.value) {
1812
+ accounts.authority.value = await getProgramDerivedAddress({
1813
+ programAddress,
1814
+ seeds: [
1815
+ getBytesEncoder().encode(
1816
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
1817
+ ),
1818
+ getAddressEncoder().encode(
1819
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1820
+ )
1821
+ ]
1822
+ });
1823
+ }
1824
+ if (!accounts.vault0.value) {
1825
+ accounts.vault0.value = await getProgramDerivedAddress({
1826
+ programAddress,
1827
+ seeds: [
1828
+ getBytesEncoder().encode(new Uint8Array([118, 97, 117, 108, 116, 48])),
1829
+ getAddressEncoder().encode(
1830
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1831
+ )
1832
+ ]
1833
+ });
1834
+ }
1835
+ if (!accounts.vault1.value) {
1836
+ accounts.vault1.value = await getProgramDerivedAddress({
1837
+ programAddress,
1838
+ seeds: [
1839
+ getBytesEncoder().encode(new Uint8Array([118, 97, 117, 108, 116, 49])),
1840
+ getAddressEncoder().encode(
1841
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
1842
+ )
1843
+ ]
1844
+ });
1845
+ }
1846
+ if (!accounts.systemProgram.value) {
1847
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1848
+ }
1849
+ if (!accounts.rent.value) {
1850
+ accounts.rent.value = "SysvarRent111111111111111111111111111111111";
1851
+ }
1852
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1853
+ return Object.freeze({
1854
+ accounts: [
1855
+ getAccountMeta("config", accounts.config),
1856
+ getAccountMeta("pool", accounts.pool),
1857
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
1858
+ getAccountMeta("authority", accounts.authority),
1859
+ getAccountMeta("vault0", accounts.vault0),
1860
+ getAccountMeta("vault1", accounts.vault1),
1861
+ getAccountMeta("token0Mint", accounts.token0Mint),
1862
+ getAccountMeta("token1Mint", accounts.token1Mint),
1863
+ getAccountMeta("payer", accounts.payer),
1864
+ getAccountMeta("token0Program", accounts.token0Program),
1865
+ getAccountMeta("token1Program", accounts.token1Program),
1866
+ getAccountMeta("systemProgram", accounts.systemProgram),
1867
+ getAccountMeta("rent", accounts.rent),
1868
+ getAccountMeta("migrationAuthority", accounts.migrationAuthority)
1869
+ ],
1870
+ data: getInitializePoolInstructionDataEncoder().encode(
1871
+ args
1872
+ ),
1873
+ programAddress
1874
+ });
1875
+ }
1876
+ function getInitializePoolInstruction(input, config) {
1877
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
1878
+ const originalAccounts = {
1879
+ config: { value: input.config ?? null, isWritable: false },
1880
+ pool: { value: input.pool ?? null, isWritable: true },
1881
+ protocolPosition: {
1882
+ value: input.protocolPosition ?? null,
1883
+ isWritable: true
1884
+ },
1885
+ authority: { value: input.authority ?? null, isWritable: false },
1886
+ vault0: { value: input.vault0 ?? null, isWritable: true },
1887
+ vault1: { value: input.vault1 ?? null, isWritable: true },
1888
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
1889
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
1890
+ payer: { value: input.payer ?? null, isWritable: true },
1891
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
1892
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
1893
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1894
+ rent: { value: input.rent ?? null, isWritable: false },
1895
+ migrationAuthority: {
1896
+ value: input.migrationAuthority ?? null,
1897
+ isWritable: false
1898
+ }
1899
+ };
1900
+ const accounts = originalAccounts;
1901
+ const args = { ...input };
1902
+ if (!accounts.systemProgram.value) {
1903
+ accounts.systemProgram.value = "11111111111111111111111111111111";
1904
+ }
1905
+ if (!accounts.rent.value) {
1906
+ accounts.rent.value = "SysvarRent111111111111111111111111111111111";
1907
+ }
1908
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1909
+ return Object.freeze({
1910
+ accounts: [
1911
+ getAccountMeta("config", accounts.config),
1912
+ getAccountMeta("pool", accounts.pool),
1913
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
1914
+ getAccountMeta("authority", accounts.authority),
1915
+ getAccountMeta("vault0", accounts.vault0),
1916
+ getAccountMeta("vault1", accounts.vault1),
1917
+ getAccountMeta("token0Mint", accounts.token0Mint),
1918
+ getAccountMeta("token1Mint", accounts.token1Mint),
1919
+ getAccountMeta("payer", accounts.payer),
1920
+ getAccountMeta("token0Program", accounts.token0Program),
1921
+ getAccountMeta("token1Program", accounts.token1Program),
1922
+ getAccountMeta("systemProgram", accounts.systemProgram),
1923
+ getAccountMeta("rent", accounts.rent),
1924
+ getAccountMeta("migrationAuthority", accounts.migrationAuthority)
1925
+ ],
1926
+ data: getInitializePoolInstructionDataEncoder().encode(
1927
+ args
1928
+ ),
1929
+ programAddress
1930
+ });
1931
+ }
1932
+ function parseInitializePoolInstruction(instruction) {
1933
+ if (instruction.accounts.length < 14) {
1934
+ throw new SolanaError(
1935
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
1936
+ {
1937
+ actualAccountMetas: instruction.accounts.length,
1938
+ expectedAccountMetas: 14
1939
+ }
1940
+ );
1941
+ }
1942
+ let accountIndex = 0;
1943
+ const getNextAccount = () => {
1944
+ const accountMeta = instruction.accounts[accountIndex];
1945
+ accountIndex += 1;
1946
+ return accountMeta;
1947
+ };
1948
+ return {
1949
+ programAddress: instruction.programAddress,
1950
+ accounts: {
1951
+ config: getNextAccount(),
1952
+ pool: getNextAccount(),
1953
+ protocolPosition: getNextAccount(),
1954
+ authority: getNextAccount(),
1955
+ vault0: getNextAccount(),
1956
+ vault1: getNextAccount(),
1957
+ token0Mint: getNextAccount(),
1958
+ token1Mint: getNextAccount(),
1959
+ payer: getNextAccount(),
1960
+ token0Program: getNextAccount(),
1961
+ token1Program: getNextAccount(),
1962
+ systemProgram: getNextAccount(),
1963
+ rent: getNextAccount(),
1964
+ migrationAuthority: getNextAccount()
1965
+ },
1966
+ data: getInitializePoolInstructionDataDecoder().decode(instruction.data)
1967
+ };
1968
+ }
1969
+ var ORACLE_CONSULT_DISCRIMINATOR = new Uint8Array([
1970
+ 239,
1971
+ 237,
1972
+ 255,
1973
+ 177,
1974
+ 142,
1975
+ 72,
1976
+ 96,
1977
+ 175
1978
+ ]);
1979
+ function getOracleConsultDiscriminatorBytes() {
1980
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
1981
+ ORACLE_CONSULT_DISCRIMINATOR
1982
+ );
1983
+ }
1984
+ function getOracleConsultInstructionDataEncoder() {
1985
+ return transformEncoder(
1986
+ getStructEncoder([
1987
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1988
+ ["windowSeconds", getU32Encoder()]
1989
+ ]),
1990
+ (value) => ({ ...value, discriminator: ORACLE_CONSULT_DISCRIMINATOR })
1991
+ );
1992
+ }
1993
+ function getOracleConsultInstructionDataDecoder() {
1994
+ return getStructDecoder([
1995
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
1996
+ ["windowSeconds", getU32Decoder()]
1997
+ ]);
1998
+ }
1999
+ function getOracleConsultInstructionDataCodec() {
2000
+ return combineCodec(
2001
+ getOracleConsultInstructionDataEncoder(),
2002
+ getOracleConsultInstructionDataDecoder()
2003
+ );
2004
+ }
2005
+ async function getOracleConsultInstructionAsync(input, config) {
2006
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2007
+ const originalAccounts = {
2008
+ pool: { value: input.pool ?? null, isWritable: false },
2009
+ oracle: { value: input.oracle ?? null, isWritable: false }
2010
+ };
2011
+ const accounts = originalAccounts;
2012
+ const args = { ...input };
2013
+ if (!accounts.oracle.value) {
2014
+ accounts.oracle.value = await getProgramDerivedAddress({
2015
+ programAddress,
2016
+ seeds: [
2017
+ getBytesEncoder().encode(new Uint8Array([111, 114, 97, 99, 108, 101])),
2018
+ getAddressEncoder().encode(
2019
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
2020
+ )
2021
+ ]
2022
+ });
2023
+ }
2024
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2025
+ return Object.freeze({
2026
+ accounts: [
2027
+ getAccountMeta("pool", accounts.pool),
2028
+ getAccountMeta("oracle", accounts.oracle)
2029
+ ],
2030
+ data: getOracleConsultInstructionDataEncoder().encode(
2031
+ args
2032
+ ),
2033
+ programAddress
2034
+ });
2035
+ }
2036
+ function getOracleConsultInstruction(input, config) {
2037
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2038
+ const originalAccounts = {
2039
+ pool: { value: input.pool ?? null, isWritable: false },
2040
+ oracle: { value: input.oracle ?? null, isWritable: false }
2041
+ };
2042
+ const accounts = originalAccounts;
2043
+ const args = { ...input };
2044
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2045
+ return Object.freeze({
2046
+ accounts: [
2047
+ getAccountMeta("pool", accounts.pool),
2048
+ getAccountMeta("oracle", accounts.oracle)
2049
+ ],
2050
+ data: getOracleConsultInstructionDataEncoder().encode(
2051
+ args
2052
+ ),
2053
+ programAddress
2054
+ });
2055
+ }
2056
+ function parseOracleConsultInstruction(instruction) {
2057
+ if (instruction.accounts.length < 2) {
2058
+ throw new SolanaError(
2059
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2060
+ {
2061
+ actualAccountMetas: instruction.accounts.length,
2062
+ expectedAccountMetas: 2
2063
+ }
2064
+ );
2065
+ }
2066
+ let accountIndex = 0;
2067
+ const getNextAccount = () => {
2068
+ const accountMeta = instruction.accounts[accountIndex];
2069
+ accountIndex += 1;
2070
+ return accountMeta;
2071
+ };
2072
+ return {
2073
+ programAddress: instruction.programAddress,
2074
+ accounts: { pool: getNextAccount(), oracle: getNextAccount() },
2075
+ data: getOracleConsultInstructionDataDecoder().decode(instruction.data)
2076
+ };
2077
+ }
2078
+ var ORACLE_UPDATE_DISCRIMINATOR = new Uint8Array([
2079
+ 85,
2080
+ 209,
2081
+ 248,
2082
+ 142,
2083
+ 186,
2084
+ 249,
2085
+ 120,
2086
+ 239
2087
+ ]);
2088
+ function getOracleUpdateDiscriminatorBytes() {
2089
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
2090
+ ORACLE_UPDATE_DISCRIMINATOR
2091
+ );
2092
+ }
2093
+ function getOracleUpdateInstructionDataEncoder() {
2094
+ return transformEncoder(
2095
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
2096
+ (value) => ({ ...value, discriminator: ORACLE_UPDATE_DISCRIMINATOR })
2097
+ );
2098
+ }
2099
+ function getOracleUpdateInstructionDataDecoder() {
2100
+ return getStructDecoder([
2101
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)]
2102
+ ]);
2103
+ }
2104
+ function getOracleUpdateInstructionDataCodec() {
2105
+ return combineCodec(
2106
+ getOracleUpdateInstructionDataEncoder(),
2107
+ getOracleUpdateInstructionDataDecoder()
2108
+ );
2109
+ }
2110
+ async function getOracleUpdateInstructionAsync(input, config) {
2111
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2112
+ const originalAccounts = {
2113
+ pool: { value: input.pool ?? null, isWritable: false },
2114
+ oracle: { value: input.oracle ?? null, isWritable: true }
2115
+ };
2116
+ const accounts = originalAccounts;
2117
+ if (!accounts.oracle.value) {
2118
+ accounts.oracle.value = await getProgramDerivedAddress({
2119
+ programAddress,
2120
+ seeds: [
2121
+ getBytesEncoder().encode(new Uint8Array([111, 114, 97, 99, 108, 101])),
2122
+ getAddressEncoder().encode(
2123
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
2124
+ )
2125
+ ]
2126
+ });
2127
+ }
2128
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2129
+ return Object.freeze({
2130
+ accounts: [
2131
+ getAccountMeta("pool", accounts.pool),
2132
+ getAccountMeta("oracle", accounts.oracle)
2133
+ ],
2134
+ data: getOracleUpdateInstructionDataEncoder().encode({}),
2135
+ programAddress
2136
+ });
2137
+ }
2138
+ function getOracleUpdateInstruction(input, config) {
2139
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2140
+ const originalAccounts = {
2141
+ pool: { value: input.pool ?? null, isWritable: false },
2142
+ oracle: { value: input.oracle ?? null, isWritable: true }
2143
+ };
2144
+ const accounts = originalAccounts;
2145
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2146
+ return Object.freeze({
2147
+ accounts: [
2148
+ getAccountMeta("pool", accounts.pool),
2149
+ getAccountMeta("oracle", accounts.oracle)
2150
+ ],
2151
+ data: getOracleUpdateInstructionDataEncoder().encode({}),
2152
+ programAddress
2153
+ });
2154
+ }
2155
+ function parseOracleUpdateInstruction(instruction) {
2156
+ if (instruction.accounts.length < 2) {
2157
+ throw new SolanaError(
2158
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2159
+ {
2160
+ actualAccountMetas: instruction.accounts.length,
2161
+ expectedAccountMetas: 2
2162
+ }
2163
+ );
2164
+ }
2165
+ let accountIndex = 0;
2166
+ const getNextAccount = () => {
2167
+ const accountMeta = instruction.accounts[accountIndex];
2168
+ accountIndex += 1;
2169
+ return accountMeta;
2170
+ };
2171
+ return {
2172
+ programAddress: instruction.programAddress,
2173
+ accounts: { pool: getNextAccount(), oracle: getNextAccount() },
2174
+ data: getOracleUpdateInstructionDataDecoder().decode(instruction.data)
2175
+ };
2176
+ }
2177
+ var PAUSE_DISCRIMINATOR = new Uint8Array([
2178
+ 211,
2179
+ 22,
2180
+ 221,
2181
+ 251,
2182
+ 74,
2183
+ 121,
2184
+ 193,
2185
+ 47
2186
+ ]);
2187
+ function getPauseDiscriminatorBytes() {
2188
+ return fixEncoderSize(getBytesEncoder(), 8).encode(PAUSE_DISCRIMINATOR);
2189
+ }
2190
+ function getPauseInstructionDataEncoder() {
2191
+ return transformEncoder(
2192
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
2193
+ (value) => ({ ...value, discriminator: PAUSE_DISCRIMINATOR })
2194
+ );
2195
+ }
2196
+ function getPauseInstructionDataDecoder() {
2197
+ return getStructDecoder([
2198
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)]
2199
+ ]);
2200
+ }
2201
+ function getPauseInstructionDataCodec() {
2202
+ return combineCodec(
2203
+ getPauseInstructionDataEncoder(),
2204
+ getPauseInstructionDataDecoder()
2205
+ );
2206
+ }
2207
+ function getPauseInstruction(input, config) {
2208
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2209
+ const originalAccounts = {
2210
+ config: { value: input.config ?? null, isWritable: true },
2211
+ admin: { value: input.admin ?? null, isWritable: false }
2212
+ };
2213
+ const accounts = originalAccounts;
2214
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2215
+ return Object.freeze({
2216
+ accounts: [
2217
+ getAccountMeta("config", accounts.config),
2218
+ getAccountMeta("admin", accounts.admin)
2219
+ ],
2220
+ data: getPauseInstructionDataEncoder().encode({}),
2221
+ programAddress
2222
+ });
2223
+ }
2224
+ function parsePauseInstruction(instruction) {
2225
+ if (instruction.accounts.length < 2) {
2226
+ throw new SolanaError(
2227
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2228
+ {
2229
+ actualAccountMetas: instruction.accounts.length,
2230
+ expectedAccountMetas: 2
2231
+ }
2232
+ );
2233
+ }
2234
+ let accountIndex = 0;
2235
+ const getNextAccount = () => {
2236
+ const accountMeta = instruction.accounts[accountIndex];
2237
+ accountIndex += 1;
2238
+ return accountMeta;
2239
+ };
2240
+ return {
2241
+ programAddress: instruction.programAddress,
2242
+ accounts: { config: getNextAccount(), admin: getNextAccount() },
2243
+ data: getPauseInstructionDataDecoder().decode(instruction.data)
2244
+ };
2245
+ }
2246
+ var PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR = new Uint8Array([
2247
+ 50,
2248
+ 130,
2249
+ 31,
2250
+ 69,
2251
+ 147,
2252
+ 58,
2253
+ 222,
2254
+ 178
2255
+ ]);
2256
+ function getPreviewSwapExactInDiscriminatorBytes() {
2257
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
2258
+ PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR
2259
+ );
2260
+ }
2261
+ function getPreviewSwapExactInInstructionDataEncoder() {
2262
+ return transformEncoder(
2263
+ getStructEncoder([
2264
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
2265
+ ["amountIn", getU64Encoder()],
2266
+ ["direction", getU8Encoder()]
2267
+ ]),
2268
+ (value) => ({
2269
+ ...value,
2270
+ discriminator: PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR
2271
+ })
2272
+ );
2273
+ }
2274
+ function getPreviewSwapExactInInstructionDataDecoder() {
2275
+ return getStructDecoder([
2276
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
2277
+ ["amountIn", getU64Decoder()],
2278
+ ["direction", getU8Decoder()]
2279
+ ]);
2280
+ }
2281
+ function getPreviewSwapExactInInstructionDataCodec() {
2282
+ return combineCodec(
2283
+ getPreviewSwapExactInInstructionDataEncoder(),
2284
+ getPreviewSwapExactInInstructionDataDecoder()
2285
+ );
2286
+ }
2287
+ function getPreviewSwapExactInInstruction(input, config) {
2288
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2289
+ const originalAccounts = {
2290
+ config: { value: input.config ?? null, isWritable: false },
2291
+ pool: { value: input.pool ?? null, isWritable: false }
2292
+ };
2293
+ const accounts = originalAccounts;
2294
+ const args = { ...input };
2295
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2296
+ return Object.freeze({
2297
+ accounts: [
2298
+ getAccountMeta("config", accounts.config),
2299
+ getAccountMeta("pool", accounts.pool)
2300
+ ],
2301
+ data: getPreviewSwapExactInInstructionDataEncoder().encode(
2302
+ args
2303
+ ),
2304
+ programAddress
2305
+ });
2306
+ }
2307
+ function parsePreviewSwapExactInInstruction(instruction) {
2308
+ if (instruction.accounts.length < 2) {
2309
+ throw new SolanaError(
2310
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2311
+ {
2312
+ actualAccountMetas: instruction.accounts.length,
2313
+ expectedAccountMetas: 2
2314
+ }
2315
+ );
2316
+ }
2317
+ let accountIndex = 0;
2318
+ const getNextAccount = () => {
2319
+ const accountMeta = instruction.accounts[accountIndex];
2320
+ accountIndex += 1;
2321
+ return accountMeta;
2322
+ };
2323
+ return {
2324
+ programAddress: instruction.programAddress,
2325
+ accounts: { config: getNextAccount(), pool: getNextAccount() },
2326
+ data: getPreviewSwapExactInInstructionDataDecoder().decode(
2327
+ instruction.data
2328
+ )
2329
+ };
2330
+ }
2331
+ var QUOTE_TO_NUMERAIRE_DISCRIMINATOR = new Uint8Array([
2332
+ 4,
2333
+ 142,
2334
+ 249,
2335
+ 240,
2336
+ 129,
2337
+ 15,
2338
+ 143,
2339
+ 57
2340
+ ]);
2341
+ function getQuoteToNumeraireDiscriminatorBytes() {
2342
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
2343
+ QUOTE_TO_NUMERAIRE_DISCRIMINATOR
2344
+ );
2345
+ }
2346
+ function getQuoteToNumeraireInstructionDataEncoder() {
2347
+ return transformEncoder(
2348
+ getStructEncoder([
2349
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
2350
+ ["amount", getU128Encoder()],
2351
+ ["side", getU8Encoder()],
2352
+ ["maxHops", getU8Encoder()],
2353
+ ["useTwap", getBooleanEncoder()],
2354
+ ["windowSeconds", getU32Encoder()]
2355
+ ]),
2356
+ (value) => ({ ...value, discriminator: QUOTE_TO_NUMERAIRE_DISCRIMINATOR })
2357
+ );
2358
+ }
2359
+ function getQuoteToNumeraireInstructionDataDecoder() {
2360
+ return getStructDecoder([
2361
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
2362
+ ["amount", getU128Decoder()],
2363
+ ["side", getU8Decoder()],
2364
+ ["maxHops", getU8Decoder()],
2365
+ ["useTwap", getBooleanDecoder()],
2366
+ ["windowSeconds", getU32Decoder()]
2367
+ ]);
2368
+ }
2369
+ function getQuoteToNumeraireInstructionDataCodec() {
2370
+ return combineCodec(
2371
+ getQuoteToNumeraireInstructionDataEncoder(),
2372
+ getQuoteToNumeraireInstructionDataDecoder()
2373
+ );
2374
+ }
2375
+ function getQuoteToNumeraireInstruction(input, config) {
2376
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2377
+ const originalAccounts = {
2378
+ config: { value: input.config ?? null, isWritable: false },
2379
+ startPool: { value: input.startPool ?? null, isWritable: false }
2380
+ };
2381
+ const accounts = originalAccounts;
2382
+ const args = { ...input };
2383
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2384
+ return Object.freeze({
2385
+ accounts: [
2386
+ getAccountMeta("config", accounts.config),
2387
+ getAccountMeta("startPool", accounts.startPool)
2388
+ ],
2389
+ data: getQuoteToNumeraireInstructionDataEncoder().encode(
2390
+ args
2391
+ ),
2392
+ programAddress
2393
+ });
2394
+ }
2395
+ function parseQuoteToNumeraireInstruction(instruction) {
2396
+ if (instruction.accounts.length < 2) {
2397
+ throw new SolanaError(
2398
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2399
+ {
2400
+ actualAccountMetas: instruction.accounts.length,
2401
+ expectedAccountMetas: 2
2402
+ }
2403
+ );
2404
+ }
2405
+ let accountIndex = 0;
2406
+ const getNextAccount = () => {
2407
+ const accountMeta = instruction.accounts[accountIndex];
2408
+ accountIndex += 1;
2409
+ return accountMeta;
2410
+ };
2411
+ return {
2412
+ programAddress: instruction.programAddress,
2413
+ accounts: { config: getNextAccount(), startPool: getNextAccount() },
2414
+ data: getQuoteToNumeraireInstructionDataDecoder().decode(instruction.data)
2415
+ };
2416
+ }
2417
+ var REMOVE_LIQUIDITY_DISCRIMINATOR = new Uint8Array([
2418
+ 80,
2419
+ 85,
2420
+ 209,
2421
+ 72,
2422
+ 24,
2423
+ 206,
2424
+ 177,
2425
+ 108
2426
+ ]);
2427
+ function getRemoveLiquidityDiscriminatorBytes() {
2428
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
2429
+ REMOVE_LIQUIDITY_DISCRIMINATOR
2430
+ );
2431
+ }
2432
+ function getRemoveLiquidityInstructionDataEncoder() {
2433
+ return transformEncoder(
2434
+ getStructEncoder([
2435
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
2436
+ ["sharesIn", getU128Encoder()],
2437
+ ["minAmount0Out", getU64Encoder()],
2438
+ ["minAmount1Out", getU64Encoder()],
2439
+ ["updateOracle", getBooleanEncoder()]
2440
+ ]),
2441
+ (value) => ({ ...value, discriminator: REMOVE_LIQUIDITY_DISCRIMINATOR })
2442
+ );
2443
+ }
2444
+ function getRemoveLiquidityInstructionDataDecoder() {
2445
+ return getStructDecoder([
2446
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
2447
+ ["sharesIn", getU128Decoder()],
2448
+ ["minAmount0Out", getU64Decoder()],
2449
+ ["minAmount1Out", getU64Decoder()],
2450
+ ["updateOracle", getBooleanDecoder()]
2451
+ ]);
2452
+ }
2453
+ function getRemoveLiquidityInstructionDataCodec() {
2454
+ return combineCodec(
2455
+ getRemoveLiquidityInstructionDataEncoder(),
2456
+ getRemoveLiquidityInstructionDataDecoder()
2457
+ );
2458
+ }
2459
+ async function getRemoveLiquidityInstructionAsync(input, config) {
2460
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2461
+ const originalAccounts = {
2462
+ config: { value: input.config ?? null, isWritable: false },
2463
+ pool: { value: input.pool ?? null, isWritable: true },
2464
+ position: { value: input.position ?? null, isWritable: true },
2465
+ protocolPosition: {
2466
+ value: input.protocolPosition ?? null,
2467
+ isWritable: true
2468
+ },
2469
+ owner: { value: input.owner ?? null, isWritable: false },
2470
+ authority: { value: input.authority ?? null, isWritable: false },
2471
+ vault0: { value: input.vault0 ?? null, isWritable: true },
2472
+ vault1: { value: input.vault1 ?? null, isWritable: true },
2473
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
2474
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
2475
+ user0: { value: input.user0 ?? null, isWritable: true },
2476
+ user1: { value: input.user1 ?? null, isWritable: true },
2477
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
2478
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
2479
+ oracle: { value: input.oracle ?? null, isWritable: true }
2480
+ };
2481
+ const accounts = originalAccounts;
2482
+ const args = { ...input };
2483
+ if (!accounts.authority.value) {
2484
+ accounts.authority.value = await getProgramDerivedAddress({
2485
+ programAddress,
2486
+ seeds: [
2487
+ getBytesEncoder().encode(
2488
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
2489
+ ),
2490
+ getAddressEncoder().encode(
2491
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
2492
+ )
2493
+ ]
2494
+ });
2495
+ }
2496
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2497
+ return Object.freeze({
2498
+ accounts: [
2499
+ getAccountMeta("config", accounts.config),
2500
+ getAccountMeta("pool", accounts.pool),
2501
+ getAccountMeta("position", accounts.position),
2502
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
2503
+ getAccountMeta("owner", accounts.owner),
2504
+ getAccountMeta("authority", accounts.authority),
2505
+ getAccountMeta("vault0", accounts.vault0),
2506
+ getAccountMeta("vault1", accounts.vault1),
2507
+ getAccountMeta("token0Mint", accounts.token0Mint),
2508
+ getAccountMeta("token1Mint", accounts.token1Mint),
2509
+ getAccountMeta("user0", accounts.user0),
2510
+ getAccountMeta("user1", accounts.user1),
2511
+ getAccountMeta("token0Program", accounts.token0Program),
2512
+ getAccountMeta("token1Program", accounts.token1Program),
2513
+ getAccountMeta("oracle", accounts.oracle)
2514
+ ],
2515
+ data: getRemoveLiquidityInstructionDataEncoder().encode(
2516
+ args
2517
+ ),
2518
+ programAddress
2519
+ });
2520
+ }
2521
+ function getRemoveLiquidityInstruction(input, config) {
2522
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2523
+ const originalAccounts = {
2524
+ config: { value: input.config ?? null, isWritable: false },
2525
+ pool: { value: input.pool ?? null, isWritable: true },
2526
+ position: { value: input.position ?? null, isWritable: true },
2527
+ protocolPosition: {
2528
+ value: input.protocolPosition ?? null,
2529
+ isWritable: true
2530
+ },
2531
+ owner: { value: input.owner ?? null, isWritable: false },
2532
+ authority: { value: input.authority ?? null, isWritable: false },
2533
+ vault0: { value: input.vault0 ?? null, isWritable: true },
2534
+ vault1: { value: input.vault1 ?? null, isWritable: true },
2535
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
2536
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
2537
+ user0: { value: input.user0 ?? null, isWritable: true },
2538
+ user1: { value: input.user1 ?? null, isWritable: true },
2539
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
2540
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
2541
+ oracle: { value: input.oracle ?? null, isWritable: true }
2542
+ };
2543
+ const accounts = originalAccounts;
2544
+ const args = { ...input };
2545
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2546
+ return Object.freeze({
2547
+ accounts: [
2548
+ getAccountMeta("config", accounts.config),
2549
+ getAccountMeta("pool", accounts.pool),
2550
+ getAccountMeta("position", accounts.position),
2551
+ getAccountMeta("protocolPosition", accounts.protocolPosition),
2552
+ getAccountMeta("owner", accounts.owner),
2553
+ getAccountMeta("authority", accounts.authority),
2554
+ getAccountMeta("vault0", accounts.vault0),
2555
+ getAccountMeta("vault1", accounts.vault1),
2556
+ getAccountMeta("token0Mint", accounts.token0Mint),
2557
+ getAccountMeta("token1Mint", accounts.token1Mint),
2558
+ getAccountMeta("user0", accounts.user0),
2559
+ getAccountMeta("user1", accounts.user1),
2560
+ getAccountMeta("token0Program", accounts.token0Program),
2561
+ getAccountMeta("token1Program", accounts.token1Program),
2562
+ getAccountMeta("oracle", accounts.oracle)
2563
+ ],
2564
+ data: getRemoveLiquidityInstructionDataEncoder().encode(
2565
+ args
2566
+ ),
2567
+ programAddress
2568
+ });
2569
+ }
2570
+ function parseRemoveLiquidityInstruction(instruction) {
2571
+ if (instruction.accounts.length < 15) {
2572
+ throw new SolanaError(
2573
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2574
+ {
2575
+ actualAccountMetas: instruction.accounts.length,
2576
+ expectedAccountMetas: 15
2577
+ }
2578
+ );
2579
+ }
2580
+ let accountIndex = 0;
2581
+ const getNextAccount = () => {
2582
+ const accountMeta = instruction.accounts[accountIndex];
2583
+ accountIndex += 1;
2584
+ return accountMeta;
2585
+ };
2586
+ const getNextOptionalAccount = () => {
2587
+ const accountMeta = getNextAccount();
2588
+ return accountMeta.address === CPMM_PROGRAM_ADDRESS ? void 0 : accountMeta;
2589
+ };
2590
+ return {
2591
+ programAddress: instruction.programAddress,
2592
+ accounts: {
2593
+ config: getNextAccount(),
2594
+ pool: getNextAccount(),
2595
+ position: getNextAccount(),
2596
+ protocolPosition: getNextAccount(),
2597
+ owner: getNextAccount(),
2598
+ authority: getNextAccount(),
2599
+ vault0: getNextAccount(),
2600
+ vault1: getNextAccount(),
2601
+ token0Mint: getNextAccount(),
2602
+ token1Mint: getNextAccount(),
2603
+ user0: getNextAccount(),
2604
+ user1: getNextAccount(),
2605
+ token0Program: getNextAccount(),
2606
+ token1Program: getNextAccount(),
2607
+ oracle: getNextOptionalAccount()
808
2608
  },
809
- {
810
- amountIn,
811
- minAmountOut,
812
- direction,
813
- updateOracle
2609
+ data: getRemoveLiquidityInstructionDataDecoder().decode(instruction.data)
2610
+ };
2611
+ }
2612
+ var SET_FEES_DISCRIMINATOR = new Uint8Array([
2613
+ 137,
2614
+ 178,
2615
+ 49,
2616
+ 58,
2617
+ 0,
2618
+ 245,
2619
+ 242,
2620
+ 190
2621
+ ]);
2622
+ function getSetFeesDiscriminatorBytes() {
2623
+ return fixEncoderSize(getBytesEncoder(), 8).encode(SET_FEES_DISCRIMINATOR);
2624
+ }
2625
+ function getSetFeesInstructionDataEncoder() {
2626
+ return transformEncoder(
2627
+ getStructEncoder([
2628
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
2629
+ ["swapFeeBps", getU16Encoder()],
2630
+ ["feeSplitBps", getU16Encoder()]
2631
+ ]),
2632
+ (value) => ({ ...value, discriminator: SET_FEES_DISCRIMINATOR })
2633
+ );
2634
+ }
2635
+ function getSetFeesInstructionDataDecoder() {
2636
+ return getStructDecoder([
2637
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
2638
+ ["swapFeeBps", getU16Decoder()],
2639
+ ["feeSplitBps", getU16Decoder()]
2640
+ ]);
2641
+ }
2642
+ function getSetFeesInstructionDataCodec() {
2643
+ return combineCodec(
2644
+ getSetFeesInstructionDataEncoder(),
2645
+ getSetFeesInstructionDataDecoder()
2646
+ );
2647
+ }
2648
+ function getSetFeesInstruction(input, config) {
2649
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2650
+ const originalAccounts = {
2651
+ config: { value: input.config ?? null, isWritable: false },
2652
+ pool: { value: input.pool ?? null, isWritable: true },
2653
+ admin: { value: input.admin ?? null, isWritable: false }
2654
+ };
2655
+ const accounts = originalAccounts;
2656
+ const args = { ...input };
2657
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2658
+ return Object.freeze({
2659
+ accounts: [
2660
+ getAccountMeta("config", accounts.config),
2661
+ getAccountMeta("pool", accounts.pool),
2662
+ getAccountMeta("admin", accounts.admin)
2663
+ ],
2664
+ data: getSetFeesInstructionDataEncoder().encode(
2665
+ args
2666
+ ),
2667
+ programAddress
2668
+ });
2669
+ }
2670
+ function parseSetFeesInstruction(instruction) {
2671
+ if (instruction.accounts.length < 3) {
2672
+ throw new SolanaError(
2673
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2674
+ {
2675
+ actualAccountMetas: instruction.accounts.length,
2676
+ expectedAccountMetas: 3
2677
+ }
2678
+ );
2679
+ }
2680
+ let accountIndex = 0;
2681
+ const getNextAccount = () => {
2682
+ const accountMeta = instruction.accounts[accountIndex];
2683
+ accountIndex += 1;
2684
+ return accountMeta;
2685
+ };
2686
+ return {
2687
+ programAddress: instruction.programAddress,
2688
+ accounts: {
2689
+ config: getNextAccount(),
2690
+ pool: getNextAccount(),
2691
+ admin: getNextAccount()
2692
+ },
2693
+ data: getSetFeesInstructionDataDecoder().decode(instruction.data)
2694
+ };
2695
+ }
2696
+ var SET_ROUTE_DISCRIMINATOR = new Uint8Array([
2697
+ 244,
2698
+ 231,
2699
+ 3,
2700
+ 84,
2701
+ 233,
2702
+ 61,
2703
+ 146,
2704
+ 149
2705
+ ]);
2706
+ function getSetRouteDiscriminatorBytes() {
2707
+ return fixEncoderSize(getBytesEncoder(), 8).encode(SET_ROUTE_DISCRIMINATOR);
2708
+ }
2709
+ function getSetRouteInstructionDataEncoder() {
2710
+ return transformEncoder(
2711
+ getStructEncoder([
2712
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
2713
+ ["routeNextPool", getAddressEncoder()],
2714
+ ["routeBridgeMint", getAddressEncoder()]
2715
+ ]),
2716
+ (value) => ({ ...value, discriminator: SET_ROUTE_DISCRIMINATOR })
2717
+ );
2718
+ }
2719
+ function getSetRouteInstructionDataDecoder() {
2720
+ return getStructDecoder([
2721
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
2722
+ ["routeNextPool", getAddressDecoder()],
2723
+ ["routeBridgeMint", getAddressDecoder()]
2724
+ ]);
2725
+ }
2726
+ function getSetRouteInstructionDataCodec() {
2727
+ return combineCodec(
2728
+ getSetRouteInstructionDataEncoder(),
2729
+ getSetRouteInstructionDataDecoder()
2730
+ );
2731
+ }
2732
+ function getSetRouteInstruction(input, config) {
2733
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2734
+ const originalAccounts = {
2735
+ config: { value: input.config ?? null, isWritable: false },
2736
+ pool: { value: input.pool ?? null, isWritable: true },
2737
+ nextPool: { value: input.nextPool ?? null, isWritable: false },
2738
+ admin: { value: input.admin ?? null, isWritable: false }
2739
+ };
2740
+ const accounts = originalAccounts;
2741
+ const args = { ...input };
2742
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2743
+ return Object.freeze({
2744
+ accounts: [
2745
+ getAccountMeta("config", accounts.config),
2746
+ getAccountMeta("pool", accounts.pool),
2747
+ getAccountMeta("nextPool", accounts.nextPool),
2748
+ getAccountMeta("admin", accounts.admin)
2749
+ ],
2750
+ data: getSetRouteInstructionDataEncoder().encode(
2751
+ args
2752
+ ),
2753
+ programAddress
2754
+ });
2755
+ }
2756
+ function parseSetRouteInstruction(instruction) {
2757
+ if (instruction.accounts.length < 4) {
2758
+ throw new SolanaError(
2759
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2760
+ {
2761
+ actualAccountMetas: instruction.accounts.length,
2762
+ expectedAccountMetas: 4
2763
+ }
2764
+ );
2765
+ }
2766
+ let accountIndex = 0;
2767
+ const getNextAccount = () => {
2768
+ const accountMeta = instruction.accounts[accountIndex];
2769
+ accountIndex += 1;
2770
+ return accountMeta;
2771
+ };
2772
+ const getNextOptionalAccount = () => {
2773
+ const accountMeta = getNextAccount();
2774
+ return accountMeta.address === CPMM_PROGRAM_ADDRESS ? void 0 : accountMeta;
2775
+ };
2776
+ return {
2777
+ programAddress: instruction.programAddress,
2778
+ accounts: {
2779
+ config: getNextAccount(),
2780
+ pool: getNextAccount(),
2781
+ nextPool: getNextOptionalAccount(),
2782
+ admin: getNextAccount()
2783
+ },
2784
+ data: getSetRouteInstructionDataDecoder().decode(instruction.data)
2785
+ };
2786
+ }
2787
+ var SET_SENTINEL_DISCRIMINATOR = new Uint8Array([
2788
+ 94,
2789
+ 200,
2790
+ 82,
2791
+ 129,
2792
+ 53,
2793
+ 149,
2794
+ 232,
2795
+ 113
2796
+ ]);
2797
+ function getSetSentinelDiscriminatorBytes() {
2798
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
2799
+ SET_SENTINEL_DISCRIMINATOR
2800
+ );
2801
+ }
2802
+ function getSetSentinelInstructionDataEncoder() {
2803
+ return transformEncoder(
2804
+ getStructEncoder([
2805
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
2806
+ ["sentinelProgram", getAddressEncoder()],
2807
+ ["sentinelFlags", getU32Encoder()]
2808
+ ]),
2809
+ (value) => ({ ...value, discriminator: SET_SENTINEL_DISCRIMINATOR })
2810
+ );
2811
+ }
2812
+ function getSetSentinelInstructionDataDecoder() {
2813
+ return getStructDecoder([
2814
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
2815
+ ["sentinelProgram", getAddressDecoder()],
2816
+ ["sentinelFlags", getU32Decoder()]
2817
+ ]);
2818
+ }
2819
+ function getSetSentinelInstructionDataCodec() {
2820
+ return combineCodec(
2821
+ getSetSentinelInstructionDataEncoder(),
2822
+ getSetSentinelInstructionDataDecoder()
2823
+ );
2824
+ }
2825
+ function getSetSentinelInstruction(input, config) {
2826
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2827
+ const originalAccounts = {
2828
+ config: { value: input.config ?? null, isWritable: false },
2829
+ pool: { value: input.pool ?? null, isWritable: true },
2830
+ admin: { value: input.admin ?? null, isWritable: false }
2831
+ };
2832
+ const accounts = originalAccounts;
2833
+ const args = { ...input };
2834
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2835
+ return Object.freeze({
2836
+ accounts: [
2837
+ getAccountMeta("config", accounts.config),
2838
+ getAccountMeta("pool", accounts.pool),
2839
+ getAccountMeta("admin", accounts.admin)
2840
+ ],
2841
+ data: getSetSentinelInstructionDataEncoder().encode(
2842
+ args
2843
+ ),
2844
+ programAddress
2845
+ });
2846
+ }
2847
+ function parseSetSentinelInstruction(instruction) {
2848
+ if (instruction.accounts.length < 3) {
2849
+ throw new SolanaError(
2850
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2851
+ {
2852
+ actualAccountMetas: instruction.accounts.length,
2853
+ expectedAccountMetas: 3
2854
+ }
2855
+ );
2856
+ }
2857
+ let accountIndex = 0;
2858
+ const getNextAccount = () => {
2859
+ const accountMeta = instruction.accounts[accountIndex];
2860
+ accountIndex += 1;
2861
+ return accountMeta;
2862
+ };
2863
+ return {
2864
+ programAddress: instruction.programAddress,
2865
+ accounts: {
2866
+ config: getNextAccount(),
2867
+ pool: getNextAccount(),
2868
+ admin: getNextAccount()
2869
+ },
2870
+ data: getSetSentinelInstructionDataDecoder().decode(instruction.data)
2871
+ };
2872
+ }
2873
+ var SKIM_DISCRIMINATOR = new Uint8Array([
2874
+ 238,
2875
+ 120,
2876
+ 221,
2877
+ 138,
2878
+ 82,
2879
+ 60,
2880
+ 100,
2881
+ 218
2882
+ ]);
2883
+ function getSkimDiscriminatorBytes() {
2884
+ return fixEncoderSize(getBytesEncoder(), 8).encode(SKIM_DISCRIMINATOR);
2885
+ }
2886
+ function getSkimInstructionDataEncoder() {
2887
+ return transformEncoder(
2888
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
2889
+ (value) => ({ ...value, discriminator: SKIM_DISCRIMINATOR })
2890
+ );
2891
+ }
2892
+ function getSkimInstructionDataDecoder() {
2893
+ return getStructDecoder([
2894
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)]
2895
+ ]);
2896
+ }
2897
+ function getSkimInstructionDataCodec() {
2898
+ return combineCodec(
2899
+ getSkimInstructionDataEncoder(),
2900
+ getSkimInstructionDataDecoder()
2901
+ );
2902
+ }
2903
+ async function getSkimInstructionAsync(input, config) {
2904
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
2905
+ const originalAccounts = {
2906
+ config: { value: input.config ?? null, isWritable: false },
2907
+ pool: { value: input.pool ?? null, isWritable: false },
2908
+ admin: { value: input.admin ?? null, isWritable: false },
2909
+ authority: { value: input.authority ?? null, isWritable: false },
2910
+ vault0: { value: input.vault0 ?? null, isWritable: true },
2911
+ vault1: { value: input.vault1 ?? null, isWritable: true },
2912
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
2913
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
2914
+ adminAta0: { value: input.adminAta0 ?? null, isWritable: true },
2915
+ adminAta1: { value: input.adminAta1 ?? null, isWritable: true },
2916
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
2917
+ token1Program: { value: input.token1Program ?? null, isWritable: false }
2918
+ };
2919
+ const accounts = originalAccounts;
2920
+ if (!accounts.authority.value) {
2921
+ accounts.authority.value = await getProgramDerivedAddress({
2922
+ programAddress,
2923
+ seeds: [
2924
+ getBytesEncoder().encode(
2925
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
2926
+ ),
2927
+ getAddressEncoder().encode(
2928
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
2929
+ )
2930
+ ]
2931
+ });
2932
+ }
2933
+ if (!accounts.adminAta0.value) {
2934
+ accounts.adminAta0.value = await getProgramDerivedAddress({
2935
+ programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
2936
+ seeds: [
2937
+ getAddressEncoder().encode(
2938
+ getAddressFromResolvedInstructionAccount(
2939
+ "admin",
2940
+ accounts.admin.value
2941
+ )
2942
+ ),
2943
+ getAddressEncoder().encode(
2944
+ getAddressFromResolvedInstructionAccount(
2945
+ "token0Program",
2946
+ accounts.token0Program.value
2947
+ )
2948
+ ),
2949
+ getAddressEncoder().encode(
2950
+ getAddressFromResolvedInstructionAccount(
2951
+ "token0Mint",
2952
+ accounts.token0Mint.value
2953
+ )
2954
+ )
2955
+ ]
2956
+ });
2957
+ }
2958
+ if (!accounts.adminAta1.value) {
2959
+ accounts.adminAta1.value = await getProgramDerivedAddress({
2960
+ programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
2961
+ seeds: [
2962
+ getAddressEncoder().encode(
2963
+ getAddressFromResolvedInstructionAccount(
2964
+ "admin",
2965
+ accounts.admin.value
2966
+ )
2967
+ ),
2968
+ getAddressEncoder().encode(
2969
+ getAddressFromResolvedInstructionAccount(
2970
+ "token1Program",
2971
+ accounts.token1Program.value
2972
+ )
2973
+ ),
2974
+ getAddressEncoder().encode(
2975
+ getAddressFromResolvedInstructionAccount(
2976
+ "token1Mint",
2977
+ accounts.token1Mint.value
2978
+ )
2979
+ )
2980
+ ]
2981
+ });
2982
+ }
2983
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2984
+ return Object.freeze({
2985
+ accounts: [
2986
+ getAccountMeta("config", accounts.config),
2987
+ getAccountMeta("pool", accounts.pool),
2988
+ getAccountMeta("admin", accounts.admin),
2989
+ getAccountMeta("authority", accounts.authority),
2990
+ getAccountMeta("vault0", accounts.vault0),
2991
+ getAccountMeta("vault1", accounts.vault1),
2992
+ getAccountMeta("token0Mint", accounts.token0Mint),
2993
+ getAccountMeta("token1Mint", accounts.token1Mint),
2994
+ getAccountMeta("adminAta0", accounts.adminAta0),
2995
+ getAccountMeta("adminAta1", accounts.adminAta1),
2996
+ getAccountMeta("token0Program", accounts.token0Program),
2997
+ getAccountMeta("token1Program", accounts.token1Program)
2998
+ ],
2999
+ data: getSkimInstructionDataEncoder().encode({}),
3000
+ programAddress
3001
+ });
3002
+ }
3003
+ function getSkimInstruction(input, config) {
3004
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
3005
+ const originalAccounts = {
3006
+ config: { value: input.config ?? null, isWritable: false },
3007
+ pool: { value: input.pool ?? null, isWritable: false },
3008
+ admin: { value: input.admin ?? null, isWritable: false },
3009
+ authority: { value: input.authority ?? null, isWritable: false },
3010
+ vault0: { value: input.vault0 ?? null, isWritable: true },
3011
+ vault1: { value: input.vault1 ?? null, isWritable: true },
3012
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
3013
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
3014
+ adminAta0: { value: input.adminAta0 ?? null, isWritable: true },
3015
+ adminAta1: { value: input.adminAta1 ?? null, isWritable: true },
3016
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
3017
+ token1Program: { value: input.token1Program ?? null, isWritable: false }
3018
+ };
3019
+ const accounts = originalAccounts;
3020
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3021
+ return Object.freeze({
3022
+ accounts: [
3023
+ getAccountMeta("config", accounts.config),
3024
+ getAccountMeta("pool", accounts.pool),
3025
+ getAccountMeta("admin", accounts.admin),
3026
+ getAccountMeta("authority", accounts.authority),
3027
+ getAccountMeta("vault0", accounts.vault0),
3028
+ getAccountMeta("vault1", accounts.vault1),
3029
+ getAccountMeta("token0Mint", accounts.token0Mint),
3030
+ getAccountMeta("token1Mint", accounts.token1Mint),
3031
+ getAccountMeta("adminAta0", accounts.adminAta0),
3032
+ getAccountMeta("adminAta1", accounts.adminAta1),
3033
+ getAccountMeta("token0Program", accounts.token0Program),
3034
+ getAccountMeta("token1Program", accounts.token1Program)
3035
+ ],
3036
+ data: getSkimInstructionDataEncoder().encode({}),
3037
+ programAddress
3038
+ });
3039
+ }
3040
+ function parseSkimInstruction(instruction) {
3041
+ if (instruction.accounts.length < 12) {
3042
+ throw new SolanaError(
3043
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3044
+ {
3045
+ actualAccountMetas: instruction.accounts.length,
3046
+ expectedAccountMetas: 12
3047
+ }
3048
+ );
3049
+ }
3050
+ let accountIndex = 0;
3051
+ const getNextAccount = () => {
3052
+ const accountMeta = instruction.accounts[accountIndex];
3053
+ accountIndex += 1;
3054
+ return accountMeta;
3055
+ };
3056
+ return {
3057
+ programAddress: instruction.programAddress,
3058
+ accounts: {
3059
+ config: getNextAccount(),
3060
+ pool: getNextAccount(),
3061
+ admin: getNextAccount(),
3062
+ authority: getNextAccount(),
3063
+ vault0: getNextAccount(),
3064
+ vault1: getNextAccount(),
3065
+ token0Mint: getNextAccount(),
3066
+ token1Mint: getNextAccount(),
3067
+ adminAta0: getNextAccount(),
3068
+ adminAta1: getNextAccount(),
3069
+ token0Program: getNextAccount(),
3070
+ token1Program: getNextAccount()
814
3071
  },
815
- programId
3072
+ data: getSkimInstructionDataDecoder().decode(instruction.data)
3073
+ };
3074
+ }
3075
+ var SWAP_EXACT_IN_DISCRIMINATOR = new Uint8Array([
3076
+ 104,
3077
+ 104,
3078
+ 131,
3079
+ 86,
3080
+ 161,
3081
+ 189,
3082
+ 180,
3083
+ 216
3084
+ ]);
3085
+ function getSwapExactInDiscriminatorBytes() {
3086
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
3087
+ SWAP_EXACT_IN_DISCRIMINATOR
816
3088
  );
817
3089
  }
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
3090
+ function getSwapExactInInstructionDataEncoder() {
3091
+ return transformEncoder(
3092
+ getStructEncoder([
3093
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
3094
+ ["amountIn", getU64Encoder()],
3095
+ ["minAmountOut", getU64Encoder()],
3096
+ ["direction", getU8Encoder()],
3097
+ ["updateOracle", getBooleanEncoder()]
3098
+ ]),
3099
+ (value) => ({ ...value, discriminator: SWAP_EXACT_IN_DISCRIMINATOR })
3100
+ );
3101
+ }
3102
+ function getSwapExactInInstructionDataDecoder() {
3103
+ return getStructDecoder([
3104
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
3105
+ ["amountIn", getU64Decoder()],
3106
+ ["minAmountOut", getU64Decoder()],
3107
+ ["direction", getU8Decoder()],
3108
+ ["updateOracle", getBooleanDecoder()]
3109
+ ]);
3110
+ }
3111
+ function getSwapExactInInstructionDataCodec() {
3112
+ return combineCodec(
3113
+ getSwapExactInInstructionDataEncoder(),
3114
+ getSwapExactInInstructionDataDecoder()
837
3115
  );
3116
+ }
3117
+ async function getSwapExactInInstructionAsync(input, config) {
3118
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
3119
+ const originalAccounts = {
3120
+ config: { value: input.config ?? null, isWritable: false },
3121
+ pool: { value: input.pool ?? null, isWritable: true },
3122
+ authority: { value: input.authority ?? null, isWritable: false },
3123
+ vaultIn: { value: input.vaultIn ?? null, isWritable: true },
3124
+ vaultOut: { value: input.vaultOut ?? null, isWritable: true },
3125
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
3126
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
3127
+ userIn: { value: input.userIn ?? null, isWritable: true },
3128
+ userOut: { value: input.userOut ?? null, isWritable: true },
3129
+ trader: { value: input.trader ?? null, isWritable: false },
3130
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
3131
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
3132
+ oracle: { value: input.oracle ?? null, isWritable: true }
3133
+ };
3134
+ const accounts = originalAccounts;
3135
+ const args = { ...input };
3136
+ if (!accounts.authority.value) {
3137
+ accounts.authority.value = await getProgramDerivedAddress({
3138
+ programAddress,
3139
+ seeds: [
3140
+ getBytesEncoder().encode(
3141
+ new Uint8Array([97, 117, 116, 104, 111, 114, 105, 116, 121])
3142
+ ),
3143
+ getAddressEncoder().encode(
3144
+ getAddressFromResolvedInstructionAccount("pool", accounts.pool.value)
3145
+ )
3146
+ ]
3147
+ });
3148
+ }
3149
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3150
+ return Object.freeze({
3151
+ accounts: [
3152
+ getAccountMeta("config", accounts.config),
3153
+ getAccountMeta("pool", accounts.pool),
3154
+ getAccountMeta("authority", accounts.authority),
3155
+ getAccountMeta("vaultIn", accounts.vaultIn),
3156
+ getAccountMeta("vaultOut", accounts.vaultOut),
3157
+ getAccountMeta("token0Mint", accounts.token0Mint),
3158
+ getAccountMeta("token1Mint", accounts.token1Mint),
3159
+ getAccountMeta("userIn", accounts.userIn),
3160
+ getAccountMeta("userOut", accounts.userOut),
3161
+ getAccountMeta("trader", accounts.trader),
3162
+ getAccountMeta("token0Program", accounts.token0Program),
3163
+ getAccountMeta("token1Program", accounts.token1Program),
3164
+ getAccountMeta("oracle", accounts.oracle)
3165
+ ],
3166
+ data: getSwapExactInInstructionDataEncoder().encode(
3167
+ args
3168
+ ),
3169
+ programAddress
3170
+ });
3171
+ }
3172
+ function getSwapExactInInstruction(input, config) {
3173
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
3174
+ const originalAccounts = {
3175
+ config: { value: input.config ?? null, isWritable: false },
3176
+ pool: { value: input.pool ?? null, isWritable: true },
3177
+ authority: { value: input.authority ?? null, isWritable: false },
3178
+ vaultIn: { value: input.vaultIn ?? null, isWritable: true },
3179
+ vaultOut: { value: input.vaultOut ?? null, isWritable: true },
3180
+ token0Mint: { value: input.token0Mint ?? null, isWritable: false },
3181
+ token1Mint: { value: input.token1Mint ?? null, isWritable: false },
3182
+ userIn: { value: input.userIn ?? null, isWritable: true },
3183
+ userOut: { value: input.userOut ?? null, isWritable: true },
3184
+ trader: { value: input.trader ?? null, isWritable: false },
3185
+ token0Program: { value: input.token0Program ?? null, isWritable: false },
3186
+ token1Program: { value: input.token1Program ?? null, isWritable: false },
3187
+ oracle: { value: input.oracle ?? null, isWritable: true }
3188
+ };
3189
+ const accounts = originalAccounts;
3190
+ const args = { ...input };
3191
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3192
+ return Object.freeze({
3193
+ accounts: [
3194
+ getAccountMeta("config", accounts.config),
3195
+ getAccountMeta("pool", accounts.pool),
3196
+ getAccountMeta("authority", accounts.authority),
3197
+ getAccountMeta("vaultIn", accounts.vaultIn),
3198
+ getAccountMeta("vaultOut", accounts.vaultOut),
3199
+ getAccountMeta("token0Mint", accounts.token0Mint),
3200
+ getAccountMeta("token1Mint", accounts.token1Mint),
3201
+ getAccountMeta("userIn", accounts.userIn),
3202
+ getAccountMeta("userOut", accounts.userOut),
3203
+ getAccountMeta("trader", accounts.trader),
3204
+ getAccountMeta("token0Program", accounts.token0Program),
3205
+ getAccountMeta("token1Program", accounts.token1Program),
3206
+ getAccountMeta("oracle", accounts.oracle)
3207
+ ],
3208
+ data: getSwapExactInInstructionDataEncoder().encode(
3209
+ args
3210
+ ),
3211
+ programAddress
3212
+ });
3213
+ }
3214
+ function parseSwapExactInInstruction(instruction) {
3215
+ if (instruction.accounts.length < 13) {
3216
+ throw new SolanaError(
3217
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3218
+ {
3219
+ actualAccountMetas: instruction.accounts.length,
3220
+ expectedAccountMetas: 13
3221
+ }
3222
+ );
3223
+ }
3224
+ let accountIndex = 0;
3225
+ const getNextAccount = () => {
3226
+ const accountMeta = instruction.accounts[accountIndex];
3227
+ accountIndex += 1;
3228
+ return accountMeta;
3229
+ };
3230
+ const getNextOptionalAccount = () => {
3231
+ const accountMeta = getNextAccount();
3232
+ return accountMeta.address === CPMM_PROGRAM_ADDRESS ? void 0 : accountMeta;
3233
+ };
838
3234
  return {
839
- programAddress: programId,
840
- accounts: keys,
841
- data
3235
+ programAddress: instruction.programAddress,
3236
+ accounts: {
3237
+ config: getNextAccount(),
3238
+ pool: getNextAccount(),
3239
+ authority: getNextAccount(),
3240
+ vaultIn: getNextAccount(),
3241
+ vaultOut: getNextAccount(),
3242
+ token0Mint: getNextAccount(),
3243
+ token1Mint: getNextAccount(),
3244
+ userIn: getNextAccount(),
3245
+ userOut: getNextAccount(),
3246
+ trader: getNextAccount(),
3247
+ token0Program: getNextAccount(),
3248
+ token1Program: getNextAccount(),
3249
+ oracle: getNextOptionalAccount()
3250
+ },
3251
+ data: getSwapExactInInstructionDataDecoder().decode(instruction.data)
842
3252
  };
843
3253
  }
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;
3254
+ var TRANSFER_ADMIN_DISCRIMINATOR = new Uint8Array([
3255
+ 42,
3256
+ 242,
3257
+ 66,
3258
+ 106,
3259
+ 228,
3260
+ 10,
3261
+ 111,
3262
+ 156
3263
+ ]);
3264
+ function getTransferAdminDiscriminatorBytes() {
3265
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
3266
+ TRANSFER_ADMIN_DISCRIMINATOR
3267
+ );
3268
+ }
3269
+ function getTransferAdminInstructionDataEncoder() {
3270
+ return transformEncoder(
3271
+ getStructEncoder([
3272
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
3273
+ ["newAdmin", getAddressEncoder()]
3274
+ ]),
3275
+ (value) => ({ ...value, discriminator: TRANSFER_ADMIN_DISCRIMINATOR })
3276
+ );
3277
+ }
3278
+ function getTransferAdminInstructionDataDecoder() {
3279
+ return getStructDecoder([
3280
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
3281
+ ["newAdmin", getAddressDecoder()]
3282
+ ]);
3283
+ }
3284
+ function getTransferAdminInstructionDataCodec() {
3285
+ return combineCodec(
3286
+ getTransferAdminInstructionDataEncoder(),
3287
+ getTransferAdminInstructionDataDecoder()
3288
+ );
3289
+ }
3290
+ function getTransferAdminInstruction(input, config) {
3291
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
3292
+ const originalAccounts = {
3293
+ config: { value: input.config ?? null, isWritable: true },
3294
+ admin: { value: input.admin ?? null, isWritable: false }
3295
+ };
3296
+ const accounts = originalAccounts;
3297
+ const args = { ...input };
3298
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3299
+ return Object.freeze({
3300
+ accounts: [
3301
+ getAccountMeta("config", accounts.config),
3302
+ getAccountMeta("admin", accounts.admin)
3303
+ ],
3304
+ data: getTransferAdminInstructionDataEncoder().encode(
3305
+ args
3306
+ ),
3307
+ programAddress
3308
+ });
3309
+ }
3310
+ function parseTransferAdminInstruction(instruction) {
3311
+ if (instruction.accounts.length < 2) {
3312
+ throw new SolanaError(
3313
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3314
+ {
3315
+ actualAccountMetas: instruction.accounts.length,
3316
+ expectedAccountMetas: 2
3317
+ }
3318
+ );
3319
+ }
3320
+ let accountIndex = 0;
3321
+ const getNextAccount = () => {
3322
+ const accountMeta = instruction.accounts[accountIndex];
3323
+ accountIndex += 1;
3324
+ return accountMeta;
3325
+ };
853
3326
  return {
854
- programAddress: programId,
855
- accounts: keys,
856
- data
3327
+ programAddress: instruction.programAddress,
3328
+ accounts: { config: getNextAccount(), admin: getNextAccount() },
3329
+ data: getTransferAdminInstructionDataDecoder().decode(instruction.data)
857
3330
  };
858
3331
  }
859
- var addLiquidityArgsWithOracleCodec = getStructCodec([
860
- ["amount0Max", getU64Codec()],
861
- ["amount1Max", getU64Codec()],
862
- ["minSharesOut", getU128Codec()],
863
- ["updateOracle", getBooleanCodec()]
3332
+ var UNPAUSE_DISCRIMINATOR = new Uint8Array([
3333
+ 169,
3334
+ 144,
3335
+ 4,
3336
+ 38,
3337
+ 10,
3338
+ 141,
3339
+ 188,
3340
+ 255
864
3341
  ]);
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 });
3342
+ function getUnpauseDiscriminatorBytes() {
3343
+ return fixEncoderSize(getBytesEncoder(), 8).encode(UNPAUSE_DISCRIMINATOR);
3344
+ }
3345
+ function getUnpauseInstructionDataEncoder() {
3346
+ return transformEncoder(
3347
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
3348
+ (value) => ({ ...value, discriminator: UNPAUSE_DISCRIMINATOR })
3349
+ );
3350
+ }
3351
+ function getUnpauseInstructionDataDecoder() {
3352
+ return getStructDecoder([
3353
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)]
3354
+ ]);
3355
+ }
3356
+ function getUnpauseInstructionDataCodec() {
3357
+ return combineCodec(
3358
+ getUnpauseInstructionDataEncoder(),
3359
+ getUnpauseInstructionDataDecoder()
3360
+ );
3361
+ }
3362
+ function getUnpauseInstruction(input, config) {
3363
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
3364
+ const originalAccounts = {
3365
+ config: { value: input.config ?? null, isWritable: true },
3366
+ admin: { value: input.admin ?? null, isWritable: false }
3367
+ };
3368
+ const accounts = originalAccounts;
3369
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3370
+ return Object.freeze({
3371
+ accounts: [
3372
+ getAccountMeta("config", accounts.config),
3373
+ getAccountMeta("admin", accounts.admin)
3374
+ ],
3375
+ data: getUnpauseInstructionDataEncoder().encode({}),
3376
+ programAddress
3377
+ });
3378
+ }
3379
+ function parseUnpauseInstruction(instruction) {
3380
+ if (instruction.accounts.length < 2) {
3381
+ throw new SolanaError(
3382
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3383
+ {
3384
+ actualAccountMetas: instruction.accounts.length,
3385
+ expectedAccountMetas: 2
3386
+ }
3387
+ );
900
3388
  }
901
- for (const account of remainingAccounts) {
902
- keys.push({ address: account, role: AccountRole.READONLY });
3389
+ let accountIndex = 0;
3390
+ const getNextAccount = () => {
3391
+ const accountMeta = instruction.accounts[accountIndex];
3392
+ accountIndex += 1;
3393
+ return accountMeta;
3394
+ };
3395
+ return {
3396
+ programAddress: instruction.programAddress,
3397
+ accounts: { config: getNextAccount(), admin: getNextAccount() },
3398
+ data: getUnpauseInstructionDataDecoder().decode(instruction.data)
3399
+ };
3400
+ }
3401
+ var UPDATE_CONFIG_DISCRIMINATOR = new Uint8Array([
3402
+ 29,
3403
+ 158,
3404
+ 252,
3405
+ 191,
3406
+ 10,
3407
+ 83,
3408
+ 219,
3409
+ 99
3410
+ ]);
3411
+ function getUpdateConfigDiscriminatorBytes() {
3412
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
3413
+ UPDATE_CONFIG_DISCRIMINATOR
3414
+ );
3415
+ }
3416
+ function getUpdateConfigInstructionDataEncoder() {
3417
+ return transformEncoder(
3418
+ getStructEncoder([
3419
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
3420
+ ["numeraireMint", getAddressEncoder()],
3421
+ ["maxSwapFeeBps", getU16Encoder()],
3422
+ ["maxFeeSplitBps", getU16Encoder()],
3423
+ ["maxRouteHops", getU8Encoder()],
3424
+ ["protocolFeeEnabled", getBooleanEncoder()],
3425
+ ["protocolFeeBps", getU16Encoder()],
3426
+ ["sentinelAllowlist", getArrayEncoder(getAddressEncoder())]
3427
+ ]),
3428
+ (value) => ({ ...value, discriminator: UPDATE_CONFIG_DISCRIMINATOR })
3429
+ );
3430
+ }
3431
+ function getUpdateConfigInstructionDataDecoder() {
3432
+ return getStructDecoder([
3433
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
3434
+ ["numeraireMint", getAddressDecoder()],
3435
+ ["maxSwapFeeBps", getU16Decoder()],
3436
+ ["maxFeeSplitBps", getU16Decoder()],
3437
+ ["maxRouteHops", getU8Decoder()],
3438
+ ["protocolFeeEnabled", getBooleanDecoder()],
3439
+ ["protocolFeeBps", getU16Decoder()],
3440
+ ["sentinelAllowlist", getArrayDecoder(getAddressDecoder())]
3441
+ ]);
3442
+ }
3443
+ function getUpdateConfigInstructionDataCodec() {
3444
+ return combineCodec(
3445
+ getUpdateConfigInstructionDataEncoder(),
3446
+ getUpdateConfigInstructionDataDecoder()
3447
+ );
3448
+ }
3449
+ function getUpdateConfigInstruction(input, config) {
3450
+ const programAddress = config?.programAddress ?? CPMM_PROGRAM_ADDRESS;
3451
+ const originalAccounts = {
3452
+ config: { value: input.config ?? null, isWritable: true },
3453
+ admin: { value: input.admin ?? null, isWritable: false }
3454
+ };
3455
+ const accounts = originalAccounts;
3456
+ const args = { ...input };
3457
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3458
+ return Object.freeze({
3459
+ accounts: [
3460
+ getAccountMeta("config", accounts.config),
3461
+ getAccountMeta("admin", accounts.admin)
3462
+ ],
3463
+ data: getUpdateConfigInstructionDataEncoder().encode(
3464
+ args
3465
+ ),
3466
+ programAddress
3467
+ });
3468
+ }
3469
+ function parseUpdateConfigInstruction(instruction) {
3470
+ if (instruction.accounts.length < 2) {
3471
+ throw new SolanaError(
3472
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3473
+ {
3474
+ actualAccountMetas: instruction.accounts.length,
3475
+ expectedAccountMetas: 2
3476
+ }
3477
+ );
903
3478
  }
904
- const data = encodeInstructionData(
905
- INSTRUCTION_DISCRIMINATORS.addLiquidity,
906
- addLiquidityArgsWithOracleCodec,
907
- args
908
- );
3479
+ let accountIndex = 0;
3480
+ const getNextAccount = () => {
3481
+ const accountMeta = instruction.accounts[accountIndex];
3482
+ accountIndex += 1;
3483
+ return accountMeta;
3484
+ };
909
3485
  return {
910
- programAddress: programId,
911
- accounts: keys,
912
- data
3486
+ programAddress: instruction.programAddress,
3487
+ accounts: { config: getNextAccount(), admin: getNextAccount() },
3488
+ data: getUpdateConfigInstructionDataDecoder().decode(instruction.data)
913
3489
  };
914
3490
  }
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 });
3491
+ function isTransactionSigner(value) {
3492
+ return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
3493
+ }
3494
+ function toRemainingAccountMeta(account) {
3495
+ if (typeof account === "string") {
3496
+ return { address: account, role: AccountRole.READONLY };
950
3497
  }
951
- for (const account of remainingAccounts) {
952
- keys.push({ address: account, role: AccountRole.READONLY });
3498
+ if (isTransactionSigner(account)) {
3499
+ return {
3500
+ address: account.address,
3501
+ role: AccountRole.READONLY_SIGNER,
3502
+ signer: account
3503
+ };
953
3504
  }
954
- const data = encodeInstructionData(
955
- INSTRUCTION_DISCRIMINATORS.removeLiquidity,
956
- removeLiquidityArgsCodec,
957
- args
958
- );
959
- return {
960
- programAddress: programId,
961
- accounts: keys,
962
- data
963
- };
3505
+ return account;
964
3506
  }
965
- function createCollectProtocolFeesInstruction(accounts, args, programId = CPMM_PROGRAM_ID) {
3507
+ function createSwapInstruction(params) {
966
3508
  const {
967
3509
  config,
968
3510
  pool,
969
- protocolPosition,
970
- admin,
971
3511
  authority,
972
3512
  vault0,
973
3513
  vault1,
974
3514
  token0Mint,
975
3515
  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
3516
+ userToken0,
3517
+ userToken1,
3518
+ user,
3519
+ amountIn,
3520
+ minAmountOut,
3521
+ direction,
3522
+ oracle,
3523
+ remainingAccounts = [],
3524
+ updateOracle = false,
3525
+ token0Program,
3526
+ token1Program,
3527
+ tokenProgram,
3528
+ programId = CPMM_PROGRAM_ADDRESS
3529
+ } = params;
3530
+ const trader = typeof user === "string" ? createNoopSigner(user) : user;
3531
+ const [vaultIn, vaultOut] = direction === 0 ? [vault0, vault1] : [vault1, vault0];
3532
+ const [userIn, userOut] = direction === 0 ? [userToken0, userToken1] : [userToken1, userToken0];
3533
+ const instruction = getSwapExactInInstruction(
3534
+ {
3535
+ config,
3536
+ pool,
3537
+ authority,
3538
+ vaultIn,
3539
+ vaultOut,
3540
+ token0Mint,
3541
+ token1Mint,
3542
+ userIn,
3543
+ userOut,
3544
+ trader,
3545
+ token0Program: token0Program ?? tokenProgram ?? TOKEN_PROGRAM_ADDRESS,
3546
+ token1Program: token1Program ?? tokenProgram ?? TOKEN_PROGRAM_ADDRESS,
3547
+ oracle,
3548
+ amountIn,
3549
+ minAmountOut,
3550
+ direction,
3551
+ updateOracle
3552
+ },
3553
+ { programAddress: programId }
1063
3554
  );
1064
3555
  return {
1065
- programAddress: programId,
1066
- accounts: keys,
1067
- data
3556
+ ...instruction,
3557
+ accounts: [
3558
+ ...instruction.accounts ?? [],
3559
+ ...remainingAccounts.map(toRemainingAccountMeta)
3560
+ ]
1068
3561
  };
1069
3562
  }
3563
+ var MAX_FEE_AMOUNT = BigInt("18446744073709551615");
1070
3564
 
1071
3565
  // src/solana/client/config.ts
1072
3566
  function base64ToBytes(base64) {
@@ -1122,11 +3616,15 @@ __export(initializer_exports, {
1122
3616
  SEED_LAUNCH: () => SEED_LAUNCH,
1123
3617
  SEED_LAUNCH_AUTHORITY: () => SEED_LAUNCH_AUTHORITY,
1124
3618
  SENTINEL_NO_CHANGE: () => SENTINEL_NO_CHANGE2,
3619
+ SF_AFTER_CREATE: () => SF_AFTER_CREATE,
3620
+ SF_AFTER_MIGRATE: () => SF_AFTER_MIGRATE,
1125
3621
  SF_AFTER_SWAP: () => SF_AFTER_SWAP2,
3622
+ SF_BEFORE_CREATE: () => SF_BEFORE_CREATE,
3623
+ SF_BEFORE_MIGRATE: () => SF_BEFORE_MIGRATE,
1126
3624
  SF_BEFORE_SWAP: () => SF_BEFORE_SWAP2,
1127
3625
  computeRemainingAccountsHash: () => computeRemainingAccountsHash,
1128
3626
  createCurveSwapExactInInstruction: () => createCurveSwapExactInInstruction,
1129
- createInitializeConfigInstruction: () => createInitializeConfigInstruction2,
3627
+ createInitializeConfigInstruction: () => createInitializeConfigInstruction,
1130
3628
  createInitializeLaunchInstruction: () => createInitializeLaunchInstruction,
1131
3629
  createMigrateLaunchInstruction: () => createMigrateLaunchInstruction,
1132
3630
  createPreviewMigrationInstruction: () => createPreviewMigrationInstruction,
@@ -1224,6 +3722,10 @@ var CURVE_KIND_XYK = 0;
1224
3722
  var CURVE_PARAMS_FORMAT_XYK_V0 = 0;
1225
3723
  var SF_BEFORE_SWAP2 = 1 << 0;
1226
3724
  var SF_AFTER_SWAP2 = 1 << 1;
3725
+ var SF_BEFORE_CREATE = 1 << 2;
3726
+ var SF_AFTER_CREATE = 1 << 3;
3727
+ var SF_BEFORE_MIGRATE = 1 << 4;
3728
+ var SF_AFTER_MIGRATE = 1 << 5;
1227
3729
  var SENTINEL_NO_CHANGE2 = 65535;
1228
3730
  var INITIALIZER_INSTRUCTION_DISCRIMINATORS = {
1229
3731
  // SHA256("global:initialize_config")[0:8]
@@ -1414,6 +3916,7 @@ function getInitializeLaunchArgsEncoder() {
1414
3916
  "sentinelCalldata",
1415
3917
  addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())
1416
3918
  ],
3919
+ ["sentinelCreateRemainingAccountsLen", getU32Encoder()],
1417
3920
  ["migratorProgram", getAddressEncoder()],
1418
3921
  [
1419
3922
  "migratorInitCalldata",
@@ -1423,7 +3926,15 @@ function getInitializeLaunchArgsEncoder() {
1423
3926
  "migratorMigrateCalldata",
1424
3927
  addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())
1425
3928
  ],
3929
+ [
3930
+ "sentinelCreateRemainingAccountsHash",
3931
+ fixEncoderSize(getBytesEncoder(), 32)
3932
+ ],
1426
3933
  ["sentinelRemainingAccountsHash", fixEncoderSize(getBytesEncoder(), 32)],
3934
+ [
3935
+ "migratorInitRemainingAccountsHash",
3936
+ fixEncoderSize(getBytesEncoder(), 32)
3937
+ ],
1427
3938
  ["migratorRemainingAccountsHash", fixEncoderSize(getBytesEncoder(), 32)],
1428
3939
  ["metadataName", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
1429
3940
  ["metadataSymbol", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
@@ -1451,6 +3962,7 @@ function getInitializeLaunchArgsDecoder() {
1451
3962
  "sentinelCalldata",
1452
3963
  addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())
1453
3964
  ],
3965
+ ["sentinelCreateRemainingAccountsLen", getU32Decoder()],
1454
3966
  ["migratorProgram", getAddressDecoder()],
1455
3967
  [
1456
3968
  "migratorInitCalldata",
@@ -1460,7 +3972,15 @@ function getInitializeLaunchArgsDecoder() {
1460
3972
  "migratorMigrateCalldata",
1461
3973
  addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())
1462
3974
  ],
3975
+ [
3976
+ "sentinelCreateRemainingAccountsHash",
3977
+ fixDecoderSize(getBytesDecoder(), 32)
3978
+ ],
1463
3979
  ["sentinelRemainingAccountsHash", fixDecoderSize(getBytesDecoder(), 32)],
3980
+ [
3981
+ "migratorInitRemainingAccountsHash",
3982
+ fixDecoderSize(getBytesDecoder(), 32)
3983
+ ],
1464
3984
  ["migratorRemainingAccountsHash", fixDecoderSize(getBytesDecoder(), 32)],
1465
3985
  ["metadataName", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
1466
3986
  ["metadataSymbol", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
@@ -1592,7 +4112,7 @@ function getCurveSwapExactInInstructionDataEncoder() {
1592
4112
  (value) => ({ ...value, discriminator: CURVE_SWAP_EXACT_IN_DISCRIMINATOR })
1593
4113
  );
1594
4114
  }
1595
- var INITIALIZE_CONFIG_DISCRIMINATOR = new Uint8Array([
4115
+ var INITIALIZE_CONFIG_DISCRIMINATOR2 = new Uint8Array([
1596
4116
  208,
1597
4117
  127,
1598
4118
  21,
@@ -1602,14 +4122,14 @@ var INITIALIZE_CONFIG_DISCRIMINATOR = new Uint8Array([
1602
4122
  196,
1603
4123
  70
1604
4124
  ]);
1605
- function getInitializeConfigInstructionDataEncoder() {
4125
+ function getInitializeConfigInstructionDataEncoder2() {
1606
4126
  return transformEncoder(
1607
4127
  getStructEncoder([
1608
4128
  ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
1609
4129
  ["migratorAllowlist", getArrayEncoder(getAddressEncoder())],
1610
4130
  ["sentinelAllowlist", getArrayEncoder(getAddressEncoder())]
1611
4131
  ]),
1612
- (value) => ({ ...value, discriminator: INITIALIZE_CONFIG_DISCRIMINATOR })
4132
+ (value) => ({ ...value, discriminator: INITIALIZE_CONFIG_DISCRIMINATOR2 })
1613
4133
  );
1614
4134
  }
1615
4135
  var INITIALIZE_LAUNCH_DISCRIMINATOR = new Uint8Array([
@@ -1645,6 +4165,7 @@ function getInitializeLaunchInstructionDataEncoder() {
1645
4165
  "sentinelCalldata",
1646
4166
  addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())
1647
4167
  ],
4168
+ ["sentinelCreateRemainingAccountsLen", getU32Encoder()],
1648
4169
  ["migratorProgram", getAddressEncoder()],
1649
4170
  [
1650
4171
  "migratorInitCalldata",
@@ -1654,7 +4175,15 @@ function getInitializeLaunchInstructionDataEncoder() {
1654
4175
  "migratorMigrateCalldata",
1655
4176
  addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())
1656
4177
  ],
4178
+ [
4179
+ "sentinelCreateRemainingAccountsHash",
4180
+ fixEncoderSize(getBytesEncoder(), 32)
4181
+ ],
1657
4182
  ["sentinelRemainingAccountsHash", fixEncoderSize(getBytesEncoder(), 32)],
4183
+ [
4184
+ "migratorInitRemainingAccountsHash",
4185
+ fixEncoderSize(getBytesEncoder(), 32)
4186
+ ],
1658
4187
  ["migratorRemainingAccountsHash", fixEncoderSize(getBytesEncoder(), 32)],
1659
4188
  ["metadataName", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
1660
4189
  [
@@ -1666,7 +4195,7 @@ function getInitializeLaunchInstructionDataEncoder() {
1666
4195
  (value) => ({ ...value, discriminator: INITIALIZE_LAUNCH_DISCRIMINATOR })
1667
4196
  );
1668
4197
  }
1669
- var PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR = new Uint8Array([
4198
+ var PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR2 = new Uint8Array([
1670
4199
  50,
1671
4200
  130,
1672
4201
  31,
@@ -1676,7 +4205,7 @@ var PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR = new Uint8Array([
1676
4205
  222,
1677
4206
  178
1678
4207
  ]);
1679
- function getPreviewSwapExactInInstructionDataEncoder() {
4208
+ function getPreviewSwapExactInInstructionDataEncoder2() {
1680
4209
  return transformEncoder(
1681
4210
  getStructEncoder([
1682
4211
  ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
@@ -1685,7 +4214,7 @@ function getPreviewSwapExactInInstructionDataEncoder() {
1685
4214
  ]),
1686
4215
  (value) => ({
1687
4216
  ...value,
1688
- discriminator: PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR
4217
+ discriminator: PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR2
1689
4218
  })
1690
4219
  );
1691
4220
  }
@@ -1784,36 +4313,34 @@ function launchIdFromU64(launchId) {
1784
4313
  function isTransactionSigner2(value) {
1785
4314
  return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
1786
4315
  }
1787
- function createSignerAccountMeta2(value, role) {
4316
+ function createSignerAccountMeta(value, role) {
1788
4317
  if (isTransactionSigner2(value)) {
1789
4318
  return { address: value.address, role, signer: value };
1790
4319
  }
1791
4320
  return { address: value, role };
1792
4321
  }
1793
- function createInitializeConfigInstruction2(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
4322
+ function createInitializeConfigInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
1794
4323
  const {
1795
4324
  admin,
1796
4325
  config,
1797
4326
  programData,
1798
- systemProgram = SYSTEM_PROGRAM_ADDRESS,
1799
- instructionsSysvar = SYSVAR_INSTRUCTIONS_ADDRESS
4327
+ systemProgram = SYSTEM_PROGRAM_ADDRESS
1800
4328
  } = accounts;
1801
4329
  const keys = [
1802
- createSignerAccountMeta2(admin, AccountRole.WRITABLE_SIGNER),
4330
+ createSignerAccountMeta(admin, AccountRole.WRITABLE_SIGNER),
1803
4331
  { address: config, role: AccountRole.WRITABLE },
1804
4332
  { address: programData, role: AccountRole.READONLY },
1805
- { address: systemProgram, role: AccountRole.READONLY },
1806
- { address: instructionsSysvar, role: AccountRole.READONLY }
4333
+ { address: systemProgram, role: AccountRole.READONLY }
1807
4334
  ];
1808
4335
  const data = new Uint8Array(
1809
- getInitializeConfigInstructionDataEncoder().encode(args)
4336
+ getInitializeConfigInstructionDataEncoder2().encode(args)
1810
4337
  );
1811
4338
  return { programAddress: programId, accounts: keys, data };
1812
4339
  }
1813
4340
  function isTransactionSigner3(value) {
1814
4341
  return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
1815
4342
  }
1816
- function createSignerAccountMeta3(value, role) {
4343
+ function createSignerAccountMeta2(value, role) {
1817
4344
  if (isTransactionSigner3(value)) {
1818
4345
  return { address: value.address, role, signer: value };
1819
4346
  }
@@ -1822,7 +4349,7 @@ function createSignerAccountMeta3(value, role) {
1822
4349
  function createSetMigratorAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
1823
4350
  const { admin, config } = accounts;
1824
4351
  const keys = [
1825
- createSignerAccountMeta3(admin, AccountRole.WRITABLE_SIGNER),
4352
+ createSignerAccountMeta2(admin, AccountRole.WRITABLE_SIGNER),
1826
4353
  { address: config, role: AccountRole.WRITABLE }
1827
4354
  ];
1828
4355
  const data = new Uint8Array(
@@ -1833,7 +4360,7 @@ function createSetMigratorAllowlistInstruction(accounts, allowlist, programId =
1833
4360
  function isTransactionSigner4(value) {
1834
4361
  return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
1835
4362
  }
1836
- function createSignerAccountMeta4(value, role) {
4363
+ function createSignerAccountMeta3(value, role) {
1837
4364
  if (isTransactionSigner4(value)) {
1838
4365
  return { address: value.address, role, signer: value };
1839
4366
  }
@@ -1842,7 +4369,7 @@ function createSignerAccountMeta4(value, role) {
1842
4369
  function createSetSentinelAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
1843
4370
  const { admin, config } = accounts;
1844
4371
  const keys = [
1845
- createSignerAccountMeta4(admin, AccountRole.WRITABLE_SIGNER),
4372
+ createSignerAccountMeta3(admin, AccountRole.WRITABLE_SIGNER),
1846
4373
  { address: config, role: AccountRole.WRITABLE }
1847
4374
  ];
1848
4375
  const data = new Uint8Array(
@@ -1850,6 +4377,27 @@ function createSetSentinelAllowlistInstruction(accounts, allowlist, programId =
1850
4377
  );
1851
4378
  return { programAddress: programId, accounts: keys, data };
1852
4379
  }
4380
+ function computeRemainingAccountsHash(addresses) {
4381
+ const addressEncoder = getAddressEncoder();
4382
+ const buf = new Uint8Array(4 + addresses.length * 32);
4383
+ new DataView(buf.buffer).setUint32(0, addresses.length, true);
4384
+ for (let i = 0; i < addresses.length; i++) {
4385
+ buf.set(addressEncoder.encode(addresses[i]), 4 + i * 32);
4386
+ }
4387
+ return keccak_256(buf);
4388
+ }
4389
+ function phaseLabel(phase) {
4390
+ switch (phase) {
4391
+ case PHASE_TRADING:
4392
+ return "TRADING";
4393
+ case PHASE_MIGRATED:
4394
+ return "MIGRATED";
4395
+ case PHASE_ABORTED:
4396
+ return "ABORTED";
4397
+ default:
4398
+ return String(phase);
4399
+ }
4400
+ }
1853
4401
  var CPMM_MIGRATOR_PROGRAM_ID = address(
1854
4402
  "7WMUTNC41eMCo6eGH5Sy2xbgE3AycvLbFPo95AU9CSUd"
1855
4403
  );
@@ -2492,7 +5040,7 @@ async function fetchAllMaybeMarket(rpc, addresses, config) {
2492
5040
  function getMarketSize() {
2493
5041
  return 208;
2494
5042
  }
2495
- var ORACLE_STATE_DISCRIMINATOR = new Uint8Array([
5043
+ var ORACLE_STATE_DISCRIMINATOR2 = new Uint8Array([
2496
5044
  97,
2497
5045
  156,
2498
5046
  157,
@@ -2504,7 +5052,7 @@ var ORACLE_STATE_DISCRIMINATOR = new Uint8Array([
2504
5052
  ]);
2505
5053
  function getOracleStateDiscriminatorBytes() {
2506
5054
  return fixEncoderSize(getBytesEncoder(), 8).encode(
2507
- ORACLE_STATE_DISCRIMINATOR
5055
+ ORACLE_STATE_DISCRIMINATOR2
2508
5056
  );
2509
5057
  }
2510
5058
  function getOracleStateEncoder() {
@@ -2519,7 +5067,7 @@ function getOracleStateEncoder() {
2519
5067
  ["bump", getU8Encoder()],
2520
5068
  ["reserved", fixEncoderSize(getBytesEncoder(), 31)]
2521
5069
  ]),
2522
- (value) => ({ ...value, discriminator: ORACLE_STATE_DISCRIMINATOR })
5070
+ (value) => ({ ...value, discriminator: ORACLE_STATE_DISCRIMINATOR2 })
2523
5071
  );
2524
5072
  }
2525
5073
  function getOracleStateDecoder() {
@@ -2534,7 +5082,7 @@ function getOracleStateDecoder() {
2534
5082
  ["reserved", fixDecoderSize(getBytesDecoder(), 31)]
2535
5083
  ]);
2536
5084
  }
2537
- function getOracleStateCodec() {
5085
+ function getOracleStateCodec2() {
2538
5086
  return combineCodec(getOracleStateEncoder(), getOracleStateDecoder());
2539
5087
  }
2540
5088
  function decodeOracleState2(encodedAccount) {
@@ -2608,6 +5156,7 @@ async function getClaimInstructionAsync(input, config) {
2608
5156
  },
2609
5157
  potVault: { value: input.potVault ?? null, isWritable: true },
2610
5158
  winnerMint: { value: input.winnerMint ?? null, isWritable: true },
5159
+ quoteMint: { value: input.quoteMint ?? null, isWritable: false },
2611
5160
  entryByMint: { value: input.entryByMint ?? null, isWritable: false },
2612
5161
  claimerWinnerAta: {
2613
5162
  value: input.claimerWinnerAta ?? null,
@@ -2617,7 +5166,14 @@ async function getClaimInstructionAsync(input, config) {
2617
5166
  claimer: { value: input.claimer ?? null, isWritable: false },
2618
5167
  receipt: { value: input.receipt ?? null, isWritable: true },
2619
5168
  payer: { value: input.payer ?? null, isWritable: true },
2620
- tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
5169
+ baseTokenProgram: {
5170
+ value: input.baseTokenProgram ?? null,
5171
+ isWritable: false
5172
+ },
5173
+ quoteTokenProgram: {
5174
+ value: input.quoteTokenProgram ?? null,
5175
+ isWritable: false
5176
+ },
2621
5177
  systemProgram: { value: input.systemProgram ?? null, isWritable: false }
2622
5178
  };
2623
5179
  const accounts = originalAccounts;
@@ -2713,9 +5269,6 @@ async function getClaimInstructionAsync(input, config) {
2713
5269
  ]
2714
5270
  });
2715
5271
  }
2716
- if (!accounts.tokenProgram.value) {
2717
- accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2718
- }
2719
5272
  if (!accounts.systemProgram.value) {
2720
5273
  accounts.systemProgram.value = "11111111111111111111111111111111";
2721
5274
  }
@@ -2726,13 +5279,15 @@ async function getClaimInstructionAsync(input, config) {
2726
5279
  getAccountMeta("marketAuthority", accounts.marketAuthority),
2727
5280
  getAccountMeta("potVault", accounts.potVault),
2728
5281
  getAccountMeta("winnerMint", accounts.winnerMint),
5282
+ getAccountMeta("quoteMint", accounts.quoteMint),
2729
5283
  getAccountMeta("entryByMint", accounts.entryByMint),
2730
5284
  getAccountMeta("claimerWinnerAta", accounts.claimerWinnerAta),
2731
5285
  getAccountMeta("claimerQuoteAta", accounts.claimerQuoteAta),
2732
5286
  getAccountMeta("claimer", accounts.claimer),
2733
5287
  getAccountMeta("receipt", accounts.receipt),
2734
5288
  getAccountMeta("payer", accounts.payer),
2735
- getAccountMeta("tokenProgram", accounts.tokenProgram),
5289
+ getAccountMeta("baseTokenProgram", accounts.baseTokenProgram),
5290
+ getAccountMeta("quoteTokenProgram", accounts.quoteTokenProgram),
2736
5291
  getAccountMeta("systemProgram", accounts.systemProgram)
2737
5292
  ],
2738
5293
  data: getClaimInstructionDataEncoder().encode(
@@ -2751,6 +5306,7 @@ function getClaimInstruction(input, config) {
2751
5306
  },
2752
5307
  potVault: { value: input.potVault ?? null, isWritable: true },
2753
5308
  winnerMint: { value: input.winnerMint ?? null, isWritable: true },
5309
+ quoteMint: { value: input.quoteMint ?? null, isWritable: false },
2754
5310
  entryByMint: { value: input.entryByMint ?? null, isWritable: false },
2755
5311
  claimerWinnerAta: {
2756
5312
  value: input.claimerWinnerAta ?? null,
@@ -2760,14 +5316,18 @@ function getClaimInstruction(input, config) {
2760
5316
  claimer: { value: input.claimer ?? null, isWritable: false },
2761
5317
  receipt: { value: input.receipt ?? null, isWritable: true },
2762
5318
  payer: { value: input.payer ?? null, isWritable: true },
2763
- tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
5319
+ baseTokenProgram: {
5320
+ value: input.baseTokenProgram ?? null,
5321
+ isWritable: false
5322
+ },
5323
+ quoteTokenProgram: {
5324
+ value: input.quoteTokenProgram ?? null,
5325
+ isWritable: false
5326
+ },
2764
5327
  systemProgram: { value: input.systemProgram ?? null, isWritable: false }
2765
5328
  };
2766
5329
  const accounts = originalAccounts;
2767
5330
  const args = { ...input };
2768
- if (!accounts.tokenProgram.value) {
2769
- accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2770
- }
2771
5331
  if (!accounts.systemProgram.value) {
2772
5332
  accounts.systemProgram.value = "11111111111111111111111111111111";
2773
5333
  }
@@ -2778,13 +5338,15 @@ function getClaimInstruction(input, config) {
2778
5338
  getAccountMeta("marketAuthority", accounts.marketAuthority),
2779
5339
  getAccountMeta("potVault", accounts.potVault),
2780
5340
  getAccountMeta("winnerMint", accounts.winnerMint),
5341
+ getAccountMeta("quoteMint", accounts.quoteMint),
2781
5342
  getAccountMeta("entryByMint", accounts.entryByMint),
2782
5343
  getAccountMeta("claimerWinnerAta", accounts.claimerWinnerAta),
2783
5344
  getAccountMeta("claimerQuoteAta", accounts.claimerQuoteAta),
2784
5345
  getAccountMeta("claimer", accounts.claimer),
2785
5346
  getAccountMeta("receipt", accounts.receipt),
2786
5347
  getAccountMeta("payer", accounts.payer),
2787
- getAccountMeta("tokenProgram", accounts.tokenProgram),
5348
+ getAccountMeta("baseTokenProgram", accounts.baseTokenProgram),
5349
+ getAccountMeta("quoteTokenProgram", accounts.quoteTokenProgram),
2788
5350
  getAccountMeta("systemProgram", accounts.systemProgram)
2789
5351
  ],
2790
5352
  data: getClaimInstructionDataEncoder().encode(
@@ -2794,12 +5356,12 @@ function getClaimInstruction(input, config) {
2794
5356
  });
2795
5357
  }
2796
5358
  function parseClaimInstruction(instruction) {
2797
- if (instruction.accounts.length < 12) {
5359
+ if (instruction.accounts.length < 14) {
2798
5360
  throw new SolanaError(
2799
5361
  SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
2800
5362
  {
2801
5363
  actualAccountMetas: instruction.accounts.length,
2802
- expectedAccountMetas: 12
5364
+ expectedAccountMetas: 14
2803
5365
  }
2804
5366
  );
2805
5367
  }
@@ -2816,13 +5378,15 @@ function parseClaimInstruction(instruction) {
2816
5378
  marketAuthority: getNextAccount(),
2817
5379
  potVault: getNextAccount(),
2818
5380
  winnerMint: getNextAccount(),
5381
+ quoteMint: getNextAccount(),
2819
5382
  entryByMint: getNextAccount(),
2820
5383
  claimerWinnerAta: getNextAccount(),
2821
5384
  claimerQuoteAta: getNextAccount(),
2822
5385
  claimer: getNextAccount(),
2823
5386
  receipt: getNextAccount(),
2824
5387
  payer: getNextAccount(),
2825
- tokenProgram: getNextAccount(),
5388
+ baseTokenProgram: getNextAccount(),
5389
+ quoteTokenProgram: getNextAccount(),
2826
5390
  systemProgram: getNextAccount()
2827
5391
  },
2828
5392
  data: getClaimInstructionDataDecoder().decode(instruction.data)
@@ -3728,7 +6292,7 @@ function predictionMigratorProgram() {
3728
6292
  entryByMint: addSelfFetchFunctions(client, getEntryByMintCodec()),
3729
6293
  launch: addSelfFetchFunctions(client, getLaunchCodec2()),
3730
6294
  market: addSelfFetchFunctions(client, getMarketCodec()),
3731
- oracleState: addSelfFetchFunctions(client, getOracleStateCodec())
6295
+ oracleState: addSelfFetchFunctions(client, getOracleStateCodec2())
3732
6296
  },
3733
6297
  instructions: {
3734
6298
  claim: (input) => addSelfPlanAndSendFunctions(
@@ -3835,7 +6399,8 @@ var ALT_INDEX = {
3835
6399
  [TOKEN_METADATA_PROGRAM_ID]: 4,
3836
6400
  [CPMM_MIGRATOR_PROGRAM_ID]: 5,
3837
6401
  So11111111111111111111111111111111111111112: 6,
3838
- [PREDICTION_MIGRATOR_PROGRAM_ADDRESS]: 8
6402
+ [PREDICTION_MIGRATOR_PROGRAM_ADDRESS]: 8,
6403
+ A9DojSvj32PMTTGctEcWZu9GSKuQVEhPkBXxDxmYu34o: 10
3839
6404
  };
3840
6405
  function validateInitializeLaunchCurveParams(args) {
3841
6406
  if (args.curveKind !== CURVE_KIND_XYK) {
@@ -3859,6 +6424,7 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
3859
6424
  quoteVault,
3860
6425
  payer,
3861
6426
  authority,
6427
+ sentinelProgram,
3862
6428
  migratorProgram,
3863
6429
  baseTokenProgram = TOKEN_PROGRAM_ADDRESS,
3864
6430
  quoteTokenProgram = TOKEN_PROGRAM_ADDRESS,
@@ -3866,7 +6432,7 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
3866
6432
  rent,
3867
6433
  metadataAccount,
3868
6434
  metadataProgram = TOKEN_METADATA_PROGRAM_ID,
3869
- instructionsSysvar = SYSVAR_INSTRUCTIONS_ADDRESS,
6435
+ sentinelCreateRemainingAccounts = [],
3870
6436
  addressLookupTable: alt
3871
6437
  } = accounts;
3872
6438
  const withMetadata = Boolean(
@@ -3877,6 +6443,10 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
3877
6443
  "metadataName is set but metadataAccount was not provided. Derive it with await initializer.getTokenMetadataAddress(baseMintAddress)."
3878
6444
  );
3879
6445
  }
6446
+ const createHooksEnabled = (args.sentinelFlags & (SF_BEFORE_CREATE | SF_AFTER_CREATE)) !== 0;
6447
+ const sentinelCreateRemainingAccountAddresses = sentinelCreateRemainingAccounts.map(
6448
+ (account) => isTransactionSigner5(account) ? account.address : account
6449
+ );
3880
6450
  const altIndexMap = alt ? ALT_INDEX : {};
3881
6451
  function staticOrLookup(addr, role) {
3882
6452
  if (alt && altIndexMap[addr] !== void 0) {
@@ -3899,12 +6469,15 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
3899
6469
  createAccountMeta(quoteVault, AccountRole.WRITABLE_SIGNER),
3900
6470
  createAccountMeta(payer, AccountRole.WRITABLE_SIGNER)
3901
6471
  ];
3902
- if (authority) {
3903
- keys.push(createAccountMeta(authority, AccountRole.READONLY_SIGNER));
3904
- }
3905
- if (migratorProgram) {
3906
- keys.push(staticOrLookup(migratorProgram, AccountRole.READONLY));
3907
- }
6472
+ keys.push(
6473
+ authority ? createAccountMeta(authority, AccountRole.READONLY_SIGNER) : staticOrLookup(programId, AccountRole.READONLY)
6474
+ );
6475
+ keys.push(
6476
+ sentinelProgram ? staticOrLookup(sentinelProgram, AccountRole.READONLY) : staticOrLookup(programId, AccountRole.READONLY)
6477
+ );
6478
+ keys.push(
6479
+ migratorProgram ? staticOrLookup(migratorProgram, AccountRole.READONLY) : staticOrLookup(programId, AccountRole.READONLY)
6480
+ );
3908
6481
  keys.push(staticOrLookup(baseTokenProgram, AccountRole.READONLY));
3909
6482
  keys.push(staticOrLookup(quoteTokenProgram, AccountRole.READONLY));
3910
6483
  keys.push(staticOrLookup(systemProgram, AccountRole.READONLY));
@@ -3913,19 +6486,29 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
3913
6486
  keys.push({ address: metadataAccount, role: AccountRole.WRITABLE });
3914
6487
  keys.push(staticOrLookup(metadataProgram, AccountRole.READONLY));
3915
6488
  } else {
3916
- keys.push({ address: programId, role: AccountRole.READONLY });
3917
- keys.push({ address: programId, role: AccountRole.READONLY });
6489
+ keys.push(staticOrLookup(programId, AccountRole.READONLY));
6490
+ keys.push(staticOrLookup(programId, AccountRole.READONLY));
3918
6491
  }
3919
- keys.push({ address: instructionsSysvar, role: AccountRole.READONLY });
3920
6492
  const encoderArgs = {
3921
6493
  ...args,
3922
6494
  allowBuy: args.allowBuy ? 1 : 0,
3923
6495
  allowSell: args.allowSell ? 1 : 0,
3924
- migratorProgram: migratorProgram ?? SYSTEM_PROGRAM_ADDRESS
6496
+ sentinelProgram: args.sentinelProgram ?? sentinelProgram ?? SYSTEM_PROGRAM_ADDRESS,
6497
+ sentinelCreateRemainingAccountsLen: args.sentinelCreateRemainingAccountsLen ?? sentinelCreateRemainingAccounts.length,
6498
+ migratorProgram: migratorProgram ?? SYSTEM_PROGRAM_ADDRESS,
6499
+ sentinelCreateRemainingAccountsHash: args.sentinelCreateRemainingAccountsHash ?? (createHooksEnabled ? computeRemainingAccountsHash(sentinelCreateRemainingAccountAddresses) : new Uint8Array(32))
3925
6500
  };
3926
6501
  const data = new Uint8Array(
3927
6502
  getInitializeLaunchInstructionDataEncoder().encode(encoderArgs)
3928
6503
  );
6504
+ keys.push(
6505
+ ...sentinelCreateRemainingAccounts.map(
6506
+ (account) => createAccountMeta(
6507
+ account,
6508
+ isTransactionSigner5(account) ? AccountRole.READONLY_SIGNER : AccountRole.READONLY
6509
+ )
6510
+ )
6511
+ );
3929
6512
  if (migratorProgram === CPMM_MIGRATOR_PROGRAM_ID) {
3930
6513
  if (!accounts.cpmmConfig) {
3931
6514
  throw new Error(
@@ -3980,8 +6563,7 @@ function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZ
3980
6563
  user,
3981
6564
  sentinelProgram = SYSTEM_PROGRAM_ADDRESS,
3982
6565
  baseTokenProgram = TOKEN_PROGRAM_ADDRESS,
3983
- quoteTokenProgram = TOKEN_PROGRAM_ADDRESS,
3984
- instructionsSysvar = SYSVAR_INSTRUCTIONS_ADDRESS
6566
+ quoteTokenProgram = TOKEN_PROGRAM_ADDRESS
3985
6567
  } = accounts;
3986
6568
  const keys = [
3987
6569
  { address: config, role: AccountRole.READONLY },
@@ -3999,8 +6581,7 @@ function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZ
3999
6581
  // no-op placeholder when no real sentinel is configured.
4000
6582
  { address: sentinelProgram, role: AccountRole.READONLY },
4001
6583
  { address: baseTokenProgram, role: AccountRole.READONLY },
4002
- { address: quoteTokenProgram, role: AccountRole.READONLY },
4003
- { address: instructionsSysvar, role: AccountRole.READONLY }
6584
+ { address: quoteTokenProgram, role: AccountRole.READONLY }
4004
6585
  ];
4005
6586
  const data = new Uint8Array(
4006
6587
  getCurveSwapExactInInstructionDataEncoder().encode(args)
@@ -4010,7 +6591,7 @@ function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZ
4010
6591
  function isTransactionSigner7(value) {
4011
6592
  return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
4012
6593
  }
4013
- function createSignerAccountMeta5(value, role) {
6594
+ function createSignerAccountMeta4(value, role) {
4014
6595
  if (isTransactionSigner7(value)) {
4015
6596
  return { address: value.address, role, signer: value };
4016
6597
  }
@@ -4030,8 +6611,7 @@ function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRA
4030
6611
  baseTokenProgram = TOKEN_PROGRAM_ADDRESS,
4031
6612
  quoteTokenProgram = TOKEN_PROGRAM_ADDRESS,
4032
6613
  systemProgram = SYSTEM_PROGRAM_ADDRESS,
4033
- rent,
4034
- instructionsSysvar = SYSVAR_INSTRUCTIONS_ADDRESS
6614
+ rent
4035
6615
  } = accounts;
4036
6616
  const keys = [
4037
6617
  { address: config, role: AccountRole.READONLY },
@@ -4042,12 +6622,11 @@ function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRA
4042
6622
  { address: baseVault, role: AccountRole.WRITABLE },
4043
6623
  { address: quoteVault, role: AccountRole.WRITABLE },
4044
6624
  { address: migratorProgram, role: AccountRole.READONLY },
4045
- createSignerAccountMeta5(payer, AccountRole.WRITABLE_SIGNER),
6625
+ createSignerAccountMeta4(payer, AccountRole.WRITABLE_SIGNER),
4046
6626
  { address: baseTokenProgram, role: AccountRole.READONLY },
4047
6627
  { address: quoteTokenProgram, role: AccountRole.READONLY },
4048
6628
  { address: systemProgram, role: AccountRole.READONLY },
4049
- { address: rent, role: AccountRole.READONLY },
4050
- { address: instructionsSysvar, role: AccountRole.READONLY }
6629
+ { address: rent, role: AccountRole.READONLY }
4051
6630
  ];
4052
6631
  const data = encodeInstructionData(
4053
6632
  INITIALIZER_INSTRUCTION_DISCRIMINATORS.migrateLaunch
@@ -4067,7 +6646,7 @@ function createPreviewSwapExactInInstruction(accounts, args, programId = INITIAL
4067
6646
  ];
4068
6647
  const accountsList = sentinelProgram ? [...keys, { address: sentinelProgram, role: AccountRole.READONLY }] : keys;
4069
6648
  const data = new Uint8Array(
4070
- getPreviewSwapExactInInstructionDataEncoder().encode(args)
6649
+ getPreviewSwapExactInInstructionDataEncoder2().encode(args)
4071
6650
  );
4072
6651
  return { programAddress: programId, accounts: accountsList, data };
4073
6652
  }
@@ -4095,27 +6674,6 @@ function createPreviewMigrationInstruction(accounts, programId = INITIALIZER_PRO
4095
6674
  function decodePreviewMigrationResult(data) {
4096
6675
  return previewMigrationResultCodec.decode(data);
4097
6676
  }
4098
- function computeRemainingAccountsHash(addresses) {
4099
- const addressEncoder = getAddressEncoder();
4100
- const buf = new Uint8Array(4 + addresses.length * 32);
4101
- new DataView(buf.buffer).setUint32(0, addresses.length, true);
4102
- for (let i = 0; i < addresses.length; i++) {
4103
- buf.set(addressEncoder.encode(addresses[i]), 4 + i * 32);
4104
- }
4105
- return keccak_256(buf);
4106
- }
4107
- function phaseLabel(phase) {
4108
- switch (phase) {
4109
- case PHASE_TRADING:
4110
- return "TRADING";
4111
- case PHASE_MIGRATED:
4112
- return "MIGRATED";
4113
- case PHASE_ABORTED:
4114
- return "ABORTED";
4115
- default:
4116
- return String(phase);
4117
- }
4118
- }
4119
6677
  var addressCodec5 = getAddressCodec();
4120
6678
  function bytesToBase64(bytes) {
4121
6679
  let binary = "";
@@ -4403,7 +6961,7 @@ __export(predictionMigrator_exports, {
4403
6961
  LAUNCH_DISCRIMINATOR: () => LAUNCH_DISCRIMINATOR2,
4404
6962
  MARKET_DISCRIMINATOR: () => MARKET_DISCRIMINATOR,
4405
6963
  MIGRATE_ENTRY_DISCRIMINATOR: () => MIGRATE_ENTRY_DISCRIMINATOR,
4406
- ORACLE_STATE_DISCRIMINATOR: () => ORACLE_STATE_DISCRIMINATOR,
6964
+ ORACLE_STATE_DISCRIMINATOR: () => ORACLE_STATE_DISCRIMINATOR2,
4407
6965
  PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_MIGRATED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_MIGRATED,
4408
6966
  PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_REGISTERED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_ALREADY_REGISTERED,
4409
6967
  PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_MIGRATED: () => PREDICTION_MIGRATOR_ERROR__ENTRY_NOT_MIGRATED,
@@ -4517,7 +7075,7 @@ __export(predictionMigrator_exports, {
4517
7075
  getMigrateEntryInstructionDataCodec: () => getMigrateEntryInstructionDataCodec,
4518
7076
  getMigrateEntryInstructionDataDecoder: () => getMigrateEntryInstructionDataDecoder,
4519
7077
  getMigrateEntryInstructionDataEncoder: () => getMigrateEntryInstructionDataEncoder,
4520
- getOracleStateCodec: () => getOracleStateCodec,
7078
+ getOracleStateCodec: () => getOracleStateCodec2,
4521
7079
  getOracleStateDecoder: () => getOracleStateDecoder,
4522
7080
  getOracleStateDiscriminatorBytes: () => getOracleStateDiscriminatorBytes,
4523
7081
  getOracleStateEncoder: () => getOracleStateEncoder,
@@ -4622,8 +7180,8 @@ function isPredictionMigratorError(error, transactionMessage, code) {
4622
7180
  var trustedOracle_exports = {};
4623
7181
  __export(trustedOracle_exports, {
4624
7182
  FINALIZE_DISCRIMINATOR: () => FINALIZE_DISCRIMINATOR,
4625
- INITIALIZE_ORACLE_DISCRIMINATOR: () => INITIALIZE_ORACLE_DISCRIMINATOR,
4626
- ORACLE_STATE_DISCRIMINATOR: () => ORACLE_STATE_DISCRIMINATOR2,
7183
+ INITIALIZE_ORACLE_DISCRIMINATOR: () => INITIALIZE_ORACLE_DISCRIMINATOR2,
7184
+ ORACLE_STATE_DISCRIMINATOR: () => ORACLE_STATE_DISCRIMINATOR3,
4627
7185
  TRUSTED_ORACLE_ERROR__ALREADY_FINALIZED: () => TRUSTED_ORACLE_ERROR__ALREADY_FINALIZED,
4628
7186
  TRUSTED_ORACLE_ERROR__INVALID_WINNING_MINT: () => TRUSTED_ORACLE_ERROR__INVALID_WINNING_MINT,
4629
7187
  TRUSTED_ORACLE_ERROR__NOT_FINALIZED: () => TRUSTED_ORACLE_ERROR__NOT_FINALIZED,
@@ -4644,13 +7202,13 @@ __export(trustedOracle_exports, {
4644
7202
  getInitializeOracleArgsCodec: () => getInitializeOracleArgsCodec,
4645
7203
  getInitializeOracleArgsDecoder: () => getInitializeOracleArgsDecoder,
4646
7204
  getInitializeOracleArgsEncoder: () => getInitializeOracleArgsEncoder,
4647
- getInitializeOracleDiscriminatorBytes: () => getInitializeOracleDiscriminatorBytes,
4648
- getInitializeOracleInstruction: () => getInitializeOracleInstruction,
4649
- getInitializeOracleInstructionDataCodec: () => getInitializeOracleInstructionDataCodec,
4650
- getInitializeOracleInstructionDataDecoder: () => getInitializeOracleInstructionDataDecoder,
4651
- getInitializeOracleInstructionDataEncoder: () => getInitializeOracleInstructionDataEncoder,
7205
+ getInitializeOracleDiscriminatorBytes: () => getInitializeOracleDiscriminatorBytes2,
7206
+ getInitializeOracleInstruction: () => getInitializeOracleInstruction2,
7207
+ getInitializeOracleInstructionDataCodec: () => getInitializeOracleInstructionDataCodec2,
7208
+ getInitializeOracleInstructionDataDecoder: () => getInitializeOracleInstructionDataDecoder2,
7209
+ getInitializeOracleInstructionDataEncoder: () => getInitializeOracleInstructionDataEncoder2,
4652
7210
  getOracleStateAddress: () => getOracleStateAddress,
4653
- getOracleStateCodec: () => getOracleStateCodec2,
7211
+ getOracleStateCodec: () => getOracleStateCodec3,
4654
7212
  getOracleStateDecoder: () => getOracleStateDecoder2,
4655
7213
  getOracleStateDiscriminatorBytes: () => getOracleStateDiscriminatorBytes2,
4656
7214
  getOracleStateEncoder: () => getOracleStateEncoder2,
@@ -4660,11 +7218,11 @@ __export(trustedOracle_exports, {
4660
7218
  identifyTrustedOracleInstruction: () => identifyTrustedOracleInstruction,
4661
7219
  isTrustedOracleError: () => isTrustedOracleError,
4662
7220
  parseFinalizeInstruction: () => parseFinalizeInstruction,
4663
- parseInitializeOracleInstruction: () => parseInitializeOracleInstruction,
7221
+ parseInitializeOracleInstruction: () => parseInitializeOracleInstruction2,
4664
7222
  parseTrustedOracleInstruction: () => parseTrustedOracleInstruction,
4665
7223
  trustedOracleProgram: () => trustedOracleProgram
4666
7224
  });
4667
- var ORACLE_STATE_DISCRIMINATOR2 = new Uint8Array([
7225
+ var ORACLE_STATE_DISCRIMINATOR3 = new Uint8Array([
4668
7226
  97,
4669
7227
  156,
4670
7228
  157,
@@ -4676,7 +7234,7 @@ var ORACLE_STATE_DISCRIMINATOR2 = new Uint8Array([
4676
7234
  ]);
4677
7235
  function getOracleStateDiscriminatorBytes2() {
4678
7236
  return fixEncoderSize(getBytesEncoder(), 8).encode(
4679
- ORACLE_STATE_DISCRIMINATOR2
7237
+ ORACLE_STATE_DISCRIMINATOR3
4680
7238
  );
4681
7239
  }
4682
7240
  function getOracleStateEncoder2() {
@@ -4691,7 +7249,7 @@ function getOracleStateEncoder2() {
4691
7249
  ["bump", getU8Encoder()],
4692
7250
  ["reserved", fixEncoderSize(getBytesEncoder(), 31)]
4693
7251
  ]),
4694
- (value) => ({ ...value, discriminator: ORACLE_STATE_DISCRIMINATOR2 })
7252
+ (value) => ({ ...value, discriminator: ORACLE_STATE_DISCRIMINATOR3 })
4695
7253
  );
4696
7254
  }
4697
7255
  function getOracleStateDecoder2() {
@@ -4706,7 +7264,7 @@ function getOracleStateDecoder2() {
4706
7264
  ["reserved", fixDecoderSize(getBytesDecoder(), 31)]
4707
7265
  ]);
4708
7266
  }
4709
- function getOracleStateCodec2() {
7267
+ function getOracleStateCodec3() {
4710
7268
  return combineCodec(getOracleStateEncoder2(), getOracleStateDecoder2());
4711
7269
  }
4712
7270
  function decodeOracleState3(encodedAccount) {
@@ -4818,7 +7376,7 @@ function parseFinalizeInstruction(instruction) {
4818
7376
  data: getFinalizeInstructionDataDecoder().decode(instruction.data)
4819
7377
  };
4820
7378
  }
4821
- var INITIALIZE_ORACLE_DISCRIMINATOR = new Uint8Array([
7379
+ var INITIALIZE_ORACLE_DISCRIMINATOR2 = new Uint8Array([
4822
7380
  144,
4823
7381
  223,
4824
7382
  131,
@@ -4828,35 +7386,35 @@ var INITIALIZE_ORACLE_DISCRIMINATOR = new Uint8Array([
4828
7386
  181,
4829
7387
  99
4830
7388
  ]);
4831
- function getInitializeOracleDiscriminatorBytes() {
7389
+ function getInitializeOracleDiscriminatorBytes2() {
4832
7390
  return fixEncoderSize(getBytesEncoder(), 8).encode(
4833
- INITIALIZE_ORACLE_DISCRIMINATOR
7391
+ INITIALIZE_ORACLE_DISCRIMINATOR2
4834
7392
  );
4835
7393
  }
4836
- function getInitializeOracleInstructionDataEncoder() {
7394
+ function getInitializeOracleInstructionDataEncoder2() {
4837
7395
  return transformEncoder(
4838
7396
  getStructEncoder([
4839
7397
  ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
4840
7398
  ["nonce", getU64Encoder()],
4841
7399
  ["quoteMint", getAddressEncoder()]
4842
7400
  ]),
4843
- (value) => ({ ...value, discriminator: INITIALIZE_ORACLE_DISCRIMINATOR })
7401
+ (value) => ({ ...value, discriminator: INITIALIZE_ORACLE_DISCRIMINATOR2 })
4844
7402
  );
4845
7403
  }
4846
- function getInitializeOracleInstructionDataDecoder() {
7404
+ function getInitializeOracleInstructionDataDecoder2() {
4847
7405
  return getStructDecoder([
4848
7406
  ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
4849
7407
  ["nonce", getU64Decoder()],
4850
7408
  ["quoteMint", getAddressDecoder()]
4851
7409
  ]);
4852
7410
  }
4853
- function getInitializeOracleInstructionDataCodec() {
7411
+ function getInitializeOracleInstructionDataCodec2() {
4854
7412
  return combineCodec(
4855
- getInitializeOracleInstructionDataEncoder(),
4856
- getInitializeOracleInstructionDataDecoder()
7413
+ getInitializeOracleInstructionDataEncoder2(),
7414
+ getInitializeOracleInstructionDataDecoder2()
4857
7415
  );
4858
7416
  }
4859
- function getInitializeOracleInstruction(input, config) {
7417
+ function getInitializeOracleInstruction2(input, config) {
4860
7418
  const programAddress = config?.programAddress ?? TRUSTED_ORACLE_PROGRAM_ADDRESS;
4861
7419
  const originalAccounts = {
4862
7420
  oracleAuthority: { value: input.oracleAuthority ?? null, isWritable: true },
@@ -4875,13 +7433,13 @@ function getInitializeOracleInstruction(input, config) {
4875
7433
  getAccountMeta("oracleState", accounts.oracleState),
4876
7434
  getAccountMeta("systemProgram", accounts.systemProgram)
4877
7435
  ],
4878
- data: getInitializeOracleInstructionDataEncoder().encode(
7436
+ data: getInitializeOracleInstructionDataEncoder2().encode(
4879
7437
  args
4880
7438
  ),
4881
7439
  programAddress
4882
7440
  });
4883
7441
  }
4884
- function parseInitializeOracleInstruction(instruction) {
7442
+ function parseInitializeOracleInstruction2(instruction) {
4885
7443
  if (instruction.accounts.length < 3) {
4886
7444
  throw new SolanaError(
4887
7445
  SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
@@ -4904,7 +7462,7 @@ function parseInitializeOracleInstruction(instruction) {
4904
7462
  oracleState: getNextAccount(),
4905
7463
  systemProgram: getNextAccount()
4906
7464
  },
4907
- data: getInitializeOracleInstructionDataDecoder().decode(instruction.data)
7465
+ data: getInitializeOracleInstructionDataDecoder2().decode(instruction.data)
4908
7466
  };
4909
7467
  }
4910
7468
 
@@ -4974,7 +7532,7 @@ function parseTrustedOracleInstruction(instruction) {
4974
7532
  assertIsInstructionWithAccounts(instruction);
4975
7533
  return {
4976
7534
  instructionType: 1 /* InitializeOracle */,
4977
- ...parseInitializeOracleInstruction(instruction)
7535
+ ...parseInitializeOracleInstruction2(instruction)
4978
7536
  };
4979
7537
  }
4980
7538
  default:
@@ -4993,13 +7551,13 @@ function trustedOracleProgram() {
4993
7551
  ...client,
4994
7552
  trustedOracle: {
4995
7553
  accounts: {
4996
- oracleState: addSelfFetchFunctions(client, getOracleStateCodec2())
7554
+ oracleState: addSelfFetchFunctions(client, getOracleStateCodec3())
4997
7555
  },
4998
7556
  instructions: {
4999
7557
  finalize: (input) => addSelfPlanAndSendFunctions(client, getFinalizeInstruction(input)),
5000
7558
  initializeOracle: (input) => addSelfPlanAndSendFunctions(
5001
7559
  client,
5002
- getInitializeOracleInstruction(input)
7560
+ getInitializeOracleInstruction2(input)
5003
7561
  )
5004
7562
  }
5005
7563
  }