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