@pina-rs/amm 0.0.0 → 0.1.0
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/README.md +27 -2
- package/dist/index.cjs +1257 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1752 -0
- package/dist/index.d.ts +1752 -0
- package/dist/index.js +1078 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -8
- package/src/generated/accounts/ammConfig.ts +197 -0
- package/src/generated/accounts/index.ts +10 -0
- package/src/generated/accounts/pool.ts +218 -0
- package/src/generated/errors/index.ts +9 -0
- package/src/generated/errors/pinaAmm.ts +64 -0
- package/src/generated/events/feesCollected.ts +64 -0
- package/src/generated/events/index.ts +13 -0
- package/src/generated/events/liquidityChanged.ts +72 -0
- package/src/generated/events/logs.ts +372 -0
- package/src/generated/events/poolCreated.ts +80 -0
- package/src/generated/events/swapped.ts +100 -0
- package/src/generated/index.ts +14 -0
- package/src/generated/instructions/collectCreatorFees.ts +119 -0
- package/src/generated/instructions/collectProtocolFees.ts +123 -0
- package/src/generated/instructions/createConfig.ts +142 -0
- package/src/generated/instructions/createPool.ts +291 -0
- package/src/generated/instructions/deposit.ts +139 -0
- package/src/generated/instructions/index.ts +19 -0
- package/src/generated/instructions/migrate.ts +155 -0
- package/src/generated/instructions/setPoolCreator.ts +90 -0
- package/src/generated/instructions/swapExactIn.ts +119 -0
- package/src/generated/instructions/swapExactOut.ts +119 -0
- package/src/generated/instructions/updateConfig.ts +105 -0
- package/src/generated/instructions/withdraw.ts +139 -0
- package/src/generated/pdas/ammConfig.ts +18 -0
- package/src/generated/pdas/index.ts +12 -0
- package/src/generated/pdas/pool.ts +20 -0
- package/src/generated/pdas/poolLpMint.ts +18 -0
- package/src/generated/pdas/poolVault.ts +19 -0
- package/src/generated/pinaPodCodecs.ts +232 -0
- package/src/generated/programs/index.ts +9 -0
- package/src/generated/programs/pinaAmm.ts +115 -0
- package/src/index.ts +11 -0
- package/CHANGELOG.md +0 -5
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1257 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var kit = require('@solana/kit');
|
|
4
|
+
var programClientCore = require('@solana/program-client-core');
|
|
5
|
+
|
|
6
|
+
// src/generated/pinaPodCodecs.ts
|
|
7
|
+
function getPinaPodDiscriminatorDecoder(expected, decoder) {
|
|
8
|
+
return kit.transformDecoder(decoder, (value) => {
|
|
9
|
+
if (BigInt(value) !== BigInt(expected)) {
|
|
10
|
+
throw new RangeError(
|
|
11
|
+
`invalid discriminator: expected ${expected}, received ${value}`
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function getPinaPodMigrationVersionDecoder(expected, decoder) {
|
|
18
|
+
return kit.transformDecoder(decoder, (value) => {
|
|
19
|
+
if (BigInt(value) !== BigInt(expected)) {
|
|
20
|
+
const hint = BigInt(value) < BigInt(expected) ? "the data predates this client; migrate it by sending a transaction to the program, or decode it with a client generated from an older IDL" : "the data was written by a newer program; upgrade this client";
|
|
21
|
+
throw new RangeError(
|
|
22
|
+
`migration version mismatch: expected ${expected}, received ${value} (${hint})`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async function findAmmConfigPda(seeds, config = {}) {
|
|
29
|
+
const { programAddress = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV" } = config;
|
|
30
|
+
return await kit.getProgramDerivedAddress({ programAddress, seeds: [kit.getUtf8Encoder().encode("amm_config"), kit.getU16Encoder().encode(seeds.index)] });
|
|
31
|
+
}
|
|
32
|
+
async function findPoolPda(seeds, config = {}) {
|
|
33
|
+
const { programAddress = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV" } = config;
|
|
34
|
+
return await kit.getProgramDerivedAddress({ programAddress, seeds: [kit.getUtf8Encoder().encode("pool"), kit.getAddressEncoder().encode(seeds.ammConfig), kit.getAddressEncoder().encode(seeds.mint0), kit.getAddressEncoder().encode(seeds.mint1)] });
|
|
35
|
+
}
|
|
36
|
+
async function findPoolLpMintPda(seeds, config = {}) {
|
|
37
|
+
const { programAddress = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV" } = config;
|
|
38
|
+
return await kit.getProgramDerivedAddress({ programAddress, seeds: [kit.getUtf8Encoder().encode("pool_lp_mint"), kit.getAddressEncoder().encode(seeds.pool)] });
|
|
39
|
+
}
|
|
40
|
+
async function findPoolVaultPda(seeds, config = {}) {
|
|
41
|
+
const { programAddress = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV" } = config;
|
|
42
|
+
return await kit.getProgramDerivedAddress({ programAddress, seeds: [kit.getUtf8Encoder().encode("pool_vault"), kit.getAddressEncoder().encode(seeds.pool), kit.getAddressEncoder().encode(seeds.mint)] });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/generated/accounts/ammConfig.ts
|
|
46
|
+
var AMM_CONFIG_DISCRIMINATOR = 1;
|
|
47
|
+
function getAmmConfigDiscriminatorBytes() {
|
|
48
|
+
return kit.getU8Encoder().encode(AMM_CONFIG_DISCRIMINATOR);
|
|
49
|
+
}
|
|
50
|
+
var AMM_CONFIG_DISCRIMINATOR2 = 0;
|
|
51
|
+
function getAmmConfigDiscriminator2Bytes() {
|
|
52
|
+
return kit.getU8Encoder().encode(AMM_CONFIG_DISCRIMINATOR2);
|
|
53
|
+
}
|
|
54
|
+
function getAmmConfigEncoder() {
|
|
55
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["migrationVersion", kit.getU8Encoder()], ["authority", kit.getAddressEncoder()], ["poolCreatorAuthority", kit.getAddressEncoder()], ["tradeFeeRate", kit.getU32Encoder()], ["protocolFeeRate", kit.getU32Encoder()], ["creatorFeeRate", kit.getU32Encoder()], ["index", kit.getU16Encoder()], ["bump", kit.getU8Encoder()]]), (value) => ({ ...value, discriminator: 1, migrationVersion: 0 }));
|
|
56
|
+
}
|
|
57
|
+
function getAmmConfigDecoder() {
|
|
58
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(AMM_CONFIG_DISCRIMINATOR, kit.getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, kit.getU8Decoder())], ["authority", kit.getAddressDecoder()], ["poolCreatorAuthority", kit.getAddressDecoder()], ["tradeFeeRate", kit.getU32Decoder()], ["protocolFeeRate", kit.getU32Decoder()], ["creatorFeeRate", kit.getU32Decoder()], ["index", kit.getU16Decoder()], ["bump", kit.getU8Decoder()]]);
|
|
59
|
+
}
|
|
60
|
+
function getAmmConfigCodec() {
|
|
61
|
+
return kit.combineCodec(getAmmConfigEncoder(), getAmmConfigDecoder());
|
|
62
|
+
}
|
|
63
|
+
function decodeAmmConfig(encodedAccount) {
|
|
64
|
+
return kit.decodeAccount(encodedAccount, getAmmConfigDecoder());
|
|
65
|
+
}
|
|
66
|
+
async function fetchAmmConfig(rpc, address, config) {
|
|
67
|
+
const maybeAccount = await fetchMaybeAmmConfig(rpc, address, config);
|
|
68
|
+
kit.assertAccountExists(maybeAccount);
|
|
69
|
+
return maybeAccount;
|
|
70
|
+
}
|
|
71
|
+
async function fetchMaybeAmmConfig(rpc, address, config) {
|
|
72
|
+
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
73
|
+
return decodeAmmConfig(maybeAccount);
|
|
74
|
+
}
|
|
75
|
+
async function fetchAllAmmConfig(rpc, addresses, config) {
|
|
76
|
+
const maybeAccounts = await fetchAllMaybeAmmConfig(rpc, addresses, config);
|
|
77
|
+
kit.assertAccountsExist(maybeAccounts);
|
|
78
|
+
return maybeAccounts;
|
|
79
|
+
}
|
|
80
|
+
async function fetchAllMaybeAmmConfig(rpc, addresses, config) {
|
|
81
|
+
const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
|
|
82
|
+
return maybeAccounts.map((maybeAccount) => decodeAmmConfig(maybeAccount));
|
|
83
|
+
}
|
|
84
|
+
async function fetchAmmConfigFromSeeds(rpc, seeds, config = {}) {
|
|
85
|
+
const maybeAccount = await fetchMaybeAmmConfigFromSeeds(rpc, seeds, config);
|
|
86
|
+
kit.assertAccountExists(maybeAccount);
|
|
87
|
+
return maybeAccount;
|
|
88
|
+
}
|
|
89
|
+
async function fetchMaybeAmmConfigFromSeeds(rpc, seeds, config = {}) {
|
|
90
|
+
const { programAddress, ...fetchConfig } = config;
|
|
91
|
+
const [address] = await findAmmConfigPda(seeds, { programAddress });
|
|
92
|
+
return await fetchMaybeAmmConfig(rpc, address, fetchConfig);
|
|
93
|
+
}
|
|
94
|
+
var AMM_CONFIG_MIGRATION_VERSION = 0;
|
|
95
|
+
function ammConfigNeedsMigration(data) {
|
|
96
|
+
if (data.length < 2) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
if (data[0] !== 1) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return data[1] < 0;
|
|
103
|
+
}
|
|
104
|
+
var POOL_DISCRIMINATOR = 2;
|
|
105
|
+
function getPoolDiscriminatorBytes() {
|
|
106
|
+
return kit.getU8Encoder().encode(POOL_DISCRIMINATOR);
|
|
107
|
+
}
|
|
108
|
+
var POOL_DISCRIMINATOR2 = 0;
|
|
109
|
+
function getPoolDiscriminator2Bytes() {
|
|
110
|
+
return kit.getU8Encoder().encode(POOL_DISCRIMINATOR2);
|
|
111
|
+
}
|
|
112
|
+
function getPoolEncoder() {
|
|
113
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["migrationVersion", kit.getU8Encoder()], ["ammConfig", kit.getAddressEncoder()], ["creator", kit.getAddressEncoder()], ["mint0", kit.getAddressEncoder()], ["mint1", kit.getAddressEncoder()], ["vault0", kit.getAddressEncoder()], ["vault1", kit.getAddressEncoder()], ["lpMint", kit.getAddressEncoder()], ["lpSupply", kit.getU64Encoder()], ["protocolFees0", kit.getU64Encoder()], ["protocolFees1", kit.getU64Encoder()], ["creatorFees0", kit.getU64Encoder()], ["creatorFees1", kit.getU64Encoder()], ["tradeFeeRate", kit.getU32Encoder()], ["protocolFeeRate", kit.getU32Encoder()], ["creatorFeeRate", kit.getU32Encoder()], ["creatorFeeMode", kit.getU8Encoder()], ["bump", kit.getU8Encoder()]]), (value) => ({ ...value, discriminator: 2, migrationVersion: 0 }));
|
|
114
|
+
}
|
|
115
|
+
function getPoolDecoder() {
|
|
116
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(POOL_DISCRIMINATOR, kit.getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, kit.getU8Decoder())], ["ammConfig", kit.getAddressDecoder()], ["creator", kit.getAddressDecoder()], ["mint0", kit.getAddressDecoder()], ["mint1", kit.getAddressDecoder()], ["vault0", kit.getAddressDecoder()], ["vault1", kit.getAddressDecoder()], ["lpMint", kit.getAddressDecoder()], ["lpSupply", kit.getU64Decoder()], ["protocolFees0", kit.getU64Decoder()], ["protocolFees1", kit.getU64Decoder()], ["creatorFees0", kit.getU64Decoder()], ["creatorFees1", kit.getU64Decoder()], ["tradeFeeRate", kit.getU32Decoder()], ["protocolFeeRate", kit.getU32Decoder()], ["creatorFeeRate", kit.getU32Decoder()], ["creatorFeeMode", kit.getU8Decoder()], ["bump", kit.getU8Decoder()]]);
|
|
117
|
+
}
|
|
118
|
+
function getPoolCodec() {
|
|
119
|
+
return kit.combineCodec(getPoolEncoder(), getPoolDecoder());
|
|
120
|
+
}
|
|
121
|
+
function decodePool(encodedAccount) {
|
|
122
|
+
return kit.decodeAccount(encodedAccount, getPoolDecoder());
|
|
123
|
+
}
|
|
124
|
+
async function fetchPool(rpc, address, config) {
|
|
125
|
+
const maybeAccount = await fetchMaybePool(rpc, address, config);
|
|
126
|
+
kit.assertAccountExists(maybeAccount);
|
|
127
|
+
return maybeAccount;
|
|
128
|
+
}
|
|
129
|
+
async function fetchMaybePool(rpc, address, config) {
|
|
130
|
+
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
131
|
+
return decodePool(maybeAccount);
|
|
132
|
+
}
|
|
133
|
+
async function fetchAllPool(rpc, addresses, config) {
|
|
134
|
+
const maybeAccounts = await fetchAllMaybePool(rpc, addresses, config);
|
|
135
|
+
kit.assertAccountsExist(maybeAccounts);
|
|
136
|
+
return maybeAccounts;
|
|
137
|
+
}
|
|
138
|
+
async function fetchAllMaybePool(rpc, addresses, config) {
|
|
139
|
+
const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
|
|
140
|
+
return maybeAccounts.map((maybeAccount) => decodePool(maybeAccount));
|
|
141
|
+
}
|
|
142
|
+
async function fetchPoolFromSeeds(rpc, seeds, config = {}) {
|
|
143
|
+
const maybeAccount = await fetchMaybePoolFromSeeds(rpc, seeds, config);
|
|
144
|
+
kit.assertAccountExists(maybeAccount);
|
|
145
|
+
return maybeAccount;
|
|
146
|
+
}
|
|
147
|
+
async function fetchMaybePoolFromSeeds(rpc, seeds, config = {}) {
|
|
148
|
+
const { programAddress, ...fetchConfig } = config;
|
|
149
|
+
const [address] = await findPoolPda(seeds, { programAddress });
|
|
150
|
+
return await fetchMaybePool(rpc, address, fetchConfig);
|
|
151
|
+
}
|
|
152
|
+
var POOL_MIGRATION_VERSION = 0;
|
|
153
|
+
function poolNeedsMigration(data) {
|
|
154
|
+
if (data.length < 2) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
if (data[0] !== 2) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
return data[1] < 0;
|
|
161
|
+
}
|
|
162
|
+
var MIGRATE_DISCRIMINATOR = 255;
|
|
163
|
+
function getMigrateDiscriminatorBytes() {
|
|
164
|
+
return new Uint8Array([255]);
|
|
165
|
+
}
|
|
166
|
+
function getMigrateInstruction(input, config) {
|
|
167
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
168
|
+
const originalAccounts = {
|
|
169
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
170
|
+
systemProgram: { value: input.systemProgram ?? "11111111111111111111111111111111", isWritable: false },
|
|
171
|
+
ammConfig: { value: input.ammConfig ?? null, isWritable: true },
|
|
172
|
+
pool: { value: input.pool ?? null, isWritable: true }
|
|
173
|
+
};
|
|
174
|
+
const accounts = originalAccounts;
|
|
175
|
+
const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
|
|
176
|
+
const provided = [input.ammConfig, input.pool];
|
|
177
|
+
let lastProvided = -1;
|
|
178
|
+
for (let index = 0; index < provided.length; index += 1) {
|
|
179
|
+
if (provided[index] != null) {
|
|
180
|
+
lastProvided = index;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return Object.freeze({
|
|
184
|
+
accounts: [
|
|
185
|
+
getAccountMeta("payer", accounts.payer),
|
|
186
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
187
|
+
getAccountMeta("ammConfig", accounts.ammConfig),
|
|
188
|
+
getAccountMeta("pool", accounts.pool)
|
|
189
|
+
].slice(0, 2 + lastProvided + 1),
|
|
190
|
+
data: getMigrateDiscriminatorBytes(),
|
|
191
|
+
programAddress
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
var COLLECT_CREATOR_FEES_DISCRIMINATOR = 8;
|
|
195
|
+
function getCollectCreatorFeesDiscriminatorBytes() {
|
|
196
|
+
return kit.getU8Encoder().encode(COLLECT_CREATOR_FEES_DISCRIMINATOR);
|
|
197
|
+
}
|
|
198
|
+
function getCollectCreatorFeesInstructionDataEncoder() {
|
|
199
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["maximumAmount0", kit.getU64Encoder()], ["maximumAmount1", kit.getU64Encoder()]]), (value) => ({ ...value, discriminator: 8 }));
|
|
200
|
+
}
|
|
201
|
+
function getCollectCreatorFeesInstructionDataDecoder() {
|
|
202
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(COLLECT_CREATOR_FEES_DISCRIMINATOR, kit.getU8Decoder())], ["maximumAmount0", kit.getU64Decoder()], ["maximumAmount1", kit.getU64Decoder()]]);
|
|
203
|
+
}
|
|
204
|
+
function getCollectCreatorFeesInstructionDataCodec() {
|
|
205
|
+
return kit.combineCodec(getCollectCreatorFeesInstructionDataEncoder(), getCollectCreatorFeesInstructionDataDecoder());
|
|
206
|
+
}
|
|
207
|
+
function getCollectCreatorFeesInstruction(input, config) {
|
|
208
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
209
|
+
const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
|
|
210
|
+
const originalAccounts = { creator: { value: input.creator ?? null, isSigner: true, isWritable: false }, pool: { value: input.pool ?? null, isSigner: false, isWritable: true }, vault0: { value: input.vault0 ?? null, isSigner: false, isWritable: true }, vault1: { value: input.vault1 ?? null, isSigner: false, isWritable: true }, recipientToken0: { value: input.recipientToken0 ?? null, isSigner: false, isWritable: true }, recipientToken1: { value: input.recipientToken1 ?? null, isSigner: false, isWritable: true }, tokenProgram0: { value: input.tokenProgram0 ?? null, isSigner: false, isWritable: false }, tokenProgram1: { value: input.tokenProgram1 ?? null, isSigner: false, isWritable: false } };
|
|
211
|
+
const accounts = originalAccounts;
|
|
212
|
+
const args = { ...input };
|
|
213
|
+
return Object.freeze({ accounts: [getAccountMeta("creator", accounts.creator), getAccountMeta("pool", accounts.pool), getAccountMeta("vault0", accounts.vault0), getAccountMeta("vault1", accounts.vault1), getAccountMeta("recipientToken0", accounts.recipientToken0), getAccountMeta("recipientToken1", accounts.recipientToken1), getAccountMeta("tokenProgram0", accounts.tokenProgram0), getAccountMeta("tokenProgram1", accounts.tokenProgram1)], data: getCollectCreatorFeesInstructionDataEncoder().encode(args), programAddress });
|
|
214
|
+
}
|
|
215
|
+
function parseCollectCreatorFeesInstruction(instruction) {
|
|
216
|
+
if (instruction.accounts.length < 8) {
|
|
217
|
+
throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 8 });
|
|
218
|
+
}
|
|
219
|
+
let accountIndex = 0;
|
|
220
|
+
const getNextAccount = () => {
|
|
221
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
222
|
+
accountIndex += 1;
|
|
223
|
+
return accountMeta;
|
|
224
|
+
};
|
|
225
|
+
return { programAddress: instruction.programAddress, accounts: { creator: getNextAccount(), pool: getNextAccount(), vault0: getNextAccount(), vault1: getNextAccount(), recipientToken0: getNextAccount(), recipientToken1: getNextAccount(), tokenProgram0: getNextAccount(), tokenProgram1: getNextAccount() }, data: getCollectCreatorFeesInstructionDataDecoder().decode(instruction.data) };
|
|
226
|
+
}
|
|
227
|
+
var COLLECT_PROTOCOL_FEES_DISCRIMINATOR = 7;
|
|
228
|
+
function getCollectProtocolFeesDiscriminatorBytes() {
|
|
229
|
+
return kit.getU8Encoder().encode(COLLECT_PROTOCOL_FEES_DISCRIMINATOR);
|
|
230
|
+
}
|
|
231
|
+
function getCollectProtocolFeesInstructionDataEncoder() {
|
|
232
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["maximumAmount0", kit.getU64Encoder()], ["maximumAmount1", kit.getU64Encoder()]]), (value) => ({ ...value, discriminator: 7 }));
|
|
233
|
+
}
|
|
234
|
+
function getCollectProtocolFeesInstructionDataDecoder() {
|
|
235
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(COLLECT_PROTOCOL_FEES_DISCRIMINATOR, kit.getU8Decoder())], ["maximumAmount0", kit.getU64Decoder()], ["maximumAmount1", kit.getU64Decoder()]]);
|
|
236
|
+
}
|
|
237
|
+
function getCollectProtocolFeesInstructionDataCodec() {
|
|
238
|
+
return kit.combineCodec(getCollectProtocolFeesInstructionDataEncoder(), getCollectProtocolFeesInstructionDataDecoder());
|
|
239
|
+
}
|
|
240
|
+
function getCollectProtocolFeesInstruction(input, config) {
|
|
241
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
242
|
+
const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
|
|
243
|
+
const originalAccounts = { authority: { value: input.authority ?? null, isSigner: true, isWritable: false }, ammConfig: { value: input.ammConfig ?? null, isSigner: false, isWritable: false }, pool: { value: input.pool ?? null, isSigner: false, isWritable: true }, vault0: { value: input.vault0 ?? null, isSigner: false, isWritable: true }, vault1: { value: input.vault1 ?? null, isSigner: false, isWritable: true }, recipientToken0: { value: input.recipientToken0 ?? null, isSigner: false, isWritable: true }, recipientToken1: { value: input.recipientToken1 ?? null, isSigner: false, isWritable: true }, tokenProgram0: { value: input.tokenProgram0 ?? null, isSigner: false, isWritable: false }, tokenProgram1: { value: input.tokenProgram1 ?? null, isSigner: false, isWritable: false } };
|
|
244
|
+
const accounts = originalAccounts;
|
|
245
|
+
const args = { ...input };
|
|
246
|
+
return Object.freeze({ accounts: [getAccountMeta("authority", accounts.authority), getAccountMeta("ammConfig", accounts.ammConfig), getAccountMeta("pool", accounts.pool), getAccountMeta("vault0", accounts.vault0), getAccountMeta("vault1", accounts.vault1), getAccountMeta("recipientToken0", accounts.recipientToken0), getAccountMeta("recipientToken1", accounts.recipientToken1), getAccountMeta("tokenProgram0", accounts.tokenProgram0), getAccountMeta("tokenProgram1", accounts.tokenProgram1)], data: getCollectProtocolFeesInstructionDataEncoder().encode(args), programAddress });
|
|
247
|
+
}
|
|
248
|
+
function parseCollectProtocolFeesInstruction(instruction) {
|
|
249
|
+
if (instruction.accounts.length < 9) {
|
|
250
|
+
throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 9 });
|
|
251
|
+
}
|
|
252
|
+
let accountIndex = 0;
|
|
253
|
+
const getNextAccount = () => {
|
|
254
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
255
|
+
accountIndex += 1;
|
|
256
|
+
return accountMeta;
|
|
257
|
+
};
|
|
258
|
+
return { programAddress: instruction.programAddress, accounts: { authority: getNextAccount(), ammConfig: getNextAccount(), pool: getNextAccount(), vault0: getNextAccount(), vault1: getNextAccount(), recipientToken0: getNextAccount(), recipientToken1: getNextAccount(), tokenProgram0: getNextAccount(), tokenProgram1: getNextAccount() }, data: getCollectProtocolFeesInstructionDataDecoder().decode(instruction.data) };
|
|
259
|
+
}
|
|
260
|
+
var CREATE_CONFIG_DISCRIMINATOR = 0;
|
|
261
|
+
function getCreateConfigDiscriminatorBytes() {
|
|
262
|
+
return kit.getU8Encoder().encode(CREATE_CONFIG_DISCRIMINATOR);
|
|
263
|
+
}
|
|
264
|
+
function getCreateConfigInstructionDataEncoder() {
|
|
265
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["index", kit.getU16Encoder()], ["tradeFeeRate", kit.getU32Encoder()], ["protocolFeeRate", kit.getU32Encoder()], ["creatorFeeRate", kit.getU32Encoder()], ["authority", kit.getAddressEncoder()], ["poolCreatorAuthority", kit.getAddressEncoder()]]), (value) => ({ ...value, discriminator: 0 }));
|
|
266
|
+
}
|
|
267
|
+
function getCreateConfigInstructionDataDecoder() {
|
|
268
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(CREATE_CONFIG_DISCRIMINATOR, kit.getU8Decoder())], ["index", kit.getU16Decoder()], ["tradeFeeRate", kit.getU32Decoder()], ["protocolFeeRate", kit.getU32Decoder()], ["creatorFeeRate", kit.getU32Decoder()], ["authority", kit.getAddressDecoder()], ["poolCreatorAuthority", kit.getAddressDecoder()]]);
|
|
269
|
+
}
|
|
270
|
+
function getCreateConfigInstructionDataCodec() {
|
|
271
|
+
return kit.combineCodec(getCreateConfigInstructionDataEncoder(), getCreateConfigInstructionDataDecoder());
|
|
272
|
+
}
|
|
273
|
+
function getCreateConfigInstruction(input, config) {
|
|
274
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
275
|
+
const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
|
|
276
|
+
const originalAccounts = { payer: { value: input.payer ?? null, isSigner: true, isWritable: true }, upgradeAuthority: { value: input.upgradeAuthority ?? null, isSigner: true, isWritable: false }, programData: { value: input.programData ?? null, isSigner: false, isWritable: false }, ammConfig: { value: input.ammConfig ?? null, isSigner: false, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isSigner: false, isWritable: false } };
|
|
277
|
+
const accounts = originalAccounts;
|
|
278
|
+
const args = { ...input };
|
|
279
|
+
if (!accounts.systemProgram.value) {
|
|
280
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
281
|
+
}
|
|
282
|
+
return Object.freeze({ accounts: [getAccountMeta("payer", accounts.payer), getAccountMeta("upgradeAuthority", accounts.upgradeAuthority), getAccountMeta("programData", accounts.programData), getAccountMeta("ammConfig", accounts.ammConfig), getAccountMeta("systemProgram", accounts.systemProgram)], data: getCreateConfigInstructionDataEncoder().encode(args), programAddress });
|
|
283
|
+
}
|
|
284
|
+
function parseCreateConfigInstruction(instruction) {
|
|
285
|
+
if (instruction.accounts.length < 5) {
|
|
286
|
+
throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 5 });
|
|
287
|
+
}
|
|
288
|
+
let accountIndex = 0;
|
|
289
|
+
const getNextAccount = () => {
|
|
290
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
291
|
+
accountIndex += 1;
|
|
292
|
+
return accountMeta;
|
|
293
|
+
};
|
|
294
|
+
return { programAddress: instruction.programAddress, accounts: { payer: getNextAccount(), upgradeAuthority: getNextAccount(), programData: getNextAccount(), ammConfig: getNextAccount(), systemProgram: getNextAccount() }, data: getCreateConfigInstructionDataDecoder().decode(instruction.data) };
|
|
295
|
+
}
|
|
296
|
+
var CREATE_POOL_DISCRIMINATOR = 2;
|
|
297
|
+
function getCreatePoolDiscriminatorBytes() {
|
|
298
|
+
return kit.getU8Encoder().encode(CREATE_POOL_DISCRIMINATOR);
|
|
299
|
+
}
|
|
300
|
+
function getCreatePoolInstructionDataEncoder() {
|
|
301
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["amount0", kit.getU64Encoder()], ["amount1", kit.getU64Encoder()], ["creator", kit.getAddressEncoder()], ["creatorFeeMode", kit.getU8Encoder()]]), (value) => ({ ...value, discriminator: 2 }));
|
|
302
|
+
}
|
|
303
|
+
function getCreatePoolInstructionDataDecoder() {
|
|
304
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(CREATE_POOL_DISCRIMINATOR, kit.getU8Decoder())], ["amount0", kit.getU64Decoder()], ["amount1", kit.getU64Decoder()], ["creator", kit.getAddressDecoder()], ["creatorFeeMode", kit.getU8Decoder()]]);
|
|
305
|
+
}
|
|
306
|
+
function getCreatePoolInstructionDataCodec() {
|
|
307
|
+
return kit.combineCodec(getCreatePoolInstructionDataEncoder(), getCreatePoolInstructionDataDecoder());
|
|
308
|
+
}
|
|
309
|
+
async function getCreatePoolInstructionAsync(input, config) {
|
|
310
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
311
|
+
const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
|
|
312
|
+
const originalAccounts = { payer: { value: input.payer ?? null, isSigner: true, isWritable: true }, depositor: { value: input.depositor ?? null, isSigner: true, isWritable: false }, poolCreatorAuthority: { value: input.poolCreatorAuthority ?? null, isSigner: true, isWritable: false }, ammConfig: { value: input.ammConfig ?? null, isSigner: false, isWritable: false }, mint0: { value: input.mint0 ?? null, isSigner: false, isWritable: false }, mint1: { value: input.mint1 ?? null, isSigner: false, isWritable: false }, pool: { value: input.pool ?? null, isSigner: false, isWritable: true }, lpMint: { value: input.lpMint ?? null, isSigner: false, isWritable: true }, vault0: { value: input.vault0 ?? null, isSigner: false, isWritable: true }, vault1: { value: input.vault1 ?? null, isSigner: false, isWritable: true }, depositorToken0: { value: input.depositorToken0 ?? null, isSigner: false, isWritable: true }, depositorToken1: { value: input.depositorToken1 ?? null, isSigner: false, isWritable: true }, lpOwner: { value: input.lpOwner ?? null, isSigner: false, isWritable: false }, lpOwnerToken: { value: input.lpOwnerToken ?? null, isSigner: false, isWritable: true }, tokenProgram0: { value: input.tokenProgram0 ?? null, isSigner: false, isWritable: false }, tokenProgram1: { value: input.tokenProgram1 ?? null, isSigner: false, isWritable: false }, lpTokenProgram: { value: input.lpTokenProgram ?? null, isSigner: false, isWritable: false }, associatedTokenProgram: { value: input.associatedTokenProgram ?? null, isSigner: false, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isSigner: false, isWritable: false } };
|
|
313
|
+
const accounts = originalAccounts;
|
|
314
|
+
const args = { ...input };
|
|
315
|
+
if (!accounts.pool.value) {
|
|
316
|
+
accounts.pool.value = await findPoolPda({ ammConfig: programClientCore.getAddressFromResolvedInstructionAccount("ammConfig", accounts.ammConfig.value), mint0: programClientCore.getAddressFromResolvedInstructionAccount("mint0", accounts.mint0.value), mint1: programClientCore.getAddressFromResolvedInstructionAccount("mint1", accounts.mint1.value) }, { programAddress });
|
|
317
|
+
}
|
|
318
|
+
if (!accounts.lpTokenProgram.value) {
|
|
319
|
+
accounts.lpTokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
320
|
+
}
|
|
321
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
322
|
+
accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
323
|
+
}
|
|
324
|
+
if (!accounts.systemProgram.value) {
|
|
325
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
326
|
+
}
|
|
327
|
+
return Object.freeze({ accounts: [getAccountMeta("payer", accounts.payer), getAccountMeta("depositor", accounts.depositor), getAccountMeta("poolCreatorAuthority", accounts.poolCreatorAuthority), getAccountMeta("ammConfig", accounts.ammConfig), getAccountMeta("mint0", accounts.mint0), getAccountMeta("mint1", accounts.mint1), getAccountMeta("pool", accounts.pool), getAccountMeta("lpMint", accounts.lpMint), getAccountMeta("vault0", accounts.vault0), getAccountMeta("vault1", accounts.vault1), getAccountMeta("depositorToken0", accounts.depositorToken0), getAccountMeta("depositorToken1", accounts.depositorToken1), getAccountMeta("lpOwner", accounts.lpOwner), getAccountMeta("lpOwnerToken", accounts.lpOwnerToken), getAccountMeta("tokenProgram0", accounts.tokenProgram0), getAccountMeta("tokenProgram1", accounts.tokenProgram1), getAccountMeta("lpTokenProgram", accounts.lpTokenProgram), getAccountMeta("associatedTokenProgram", accounts.associatedTokenProgram), getAccountMeta("systemProgram", accounts.systemProgram)], data: getCreatePoolInstructionDataEncoder().encode(args), programAddress });
|
|
328
|
+
}
|
|
329
|
+
function getCreatePoolInstruction(input, config) {
|
|
330
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
331
|
+
const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
|
|
332
|
+
const originalAccounts = { payer: { value: input.payer ?? null, isSigner: true, isWritable: true }, depositor: { value: input.depositor ?? null, isSigner: true, isWritable: false }, poolCreatorAuthority: { value: input.poolCreatorAuthority ?? null, isSigner: true, isWritable: false }, ammConfig: { value: input.ammConfig ?? null, isSigner: false, isWritable: false }, mint0: { value: input.mint0 ?? null, isSigner: false, isWritable: false }, mint1: { value: input.mint1 ?? null, isSigner: false, isWritable: false }, pool: { value: input.pool ?? null, isSigner: false, isWritable: true }, lpMint: { value: input.lpMint ?? null, isSigner: false, isWritable: true }, vault0: { value: input.vault0 ?? null, isSigner: false, isWritable: true }, vault1: { value: input.vault1 ?? null, isSigner: false, isWritable: true }, depositorToken0: { value: input.depositorToken0 ?? null, isSigner: false, isWritable: true }, depositorToken1: { value: input.depositorToken1 ?? null, isSigner: false, isWritable: true }, lpOwner: { value: input.lpOwner ?? null, isSigner: false, isWritable: false }, lpOwnerToken: { value: input.lpOwnerToken ?? null, isSigner: false, isWritable: true }, tokenProgram0: { value: input.tokenProgram0 ?? null, isSigner: false, isWritable: false }, tokenProgram1: { value: input.tokenProgram1 ?? null, isSigner: false, isWritable: false }, lpTokenProgram: { value: input.lpTokenProgram ?? null, isSigner: false, isWritable: false }, associatedTokenProgram: { value: input.associatedTokenProgram ?? null, isSigner: false, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isSigner: false, isWritable: false } };
|
|
333
|
+
const accounts = originalAccounts;
|
|
334
|
+
const args = { ...input };
|
|
335
|
+
if (!accounts.lpTokenProgram.value) {
|
|
336
|
+
accounts.lpTokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
337
|
+
}
|
|
338
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
339
|
+
accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
340
|
+
}
|
|
341
|
+
if (!accounts.systemProgram.value) {
|
|
342
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
343
|
+
}
|
|
344
|
+
return Object.freeze({ accounts: [getAccountMeta("payer", accounts.payer), getAccountMeta("depositor", accounts.depositor), getAccountMeta("poolCreatorAuthority", accounts.poolCreatorAuthority), getAccountMeta("ammConfig", accounts.ammConfig), getAccountMeta("mint0", accounts.mint0), getAccountMeta("mint1", accounts.mint1), getAccountMeta("pool", accounts.pool), getAccountMeta("lpMint", accounts.lpMint), getAccountMeta("vault0", accounts.vault0), getAccountMeta("vault1", accounts.vault1), getAccountMeta("depositorToken0", accounts.depositorToken0), getAccountMeta("depositorToken1", accounts.depositorToken1), getAccountMeta("lpOwner", accounts.lpOwner), getAccountMeta("lpOwnerToken", accounts.lpOwnerToken), getAccountMeta("tokenProgram0", accounts.tokenProgram0), getAccountMeta("tokenProgram1", accounts.tokenProgram1), getAccountMeta("lpTokenProgram", accounts.lpTokenProgram), getAccountMeta("associatedTokenProgram", accounts.associatedTokenProgram), getAccountMeta("systemProgram", accounts.systemProgram)], data: getCreatePoolInstructionDataEncoder().encode(args), programAddress });
|
|
345
|
+
}
|
|
346
|
+
function parseCreatePoolInstruction(instruction) {
|
|
347
|
+
if (instruction.accounts.length < 19) {
|
|
348
|
+
throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 19 });
|
|
349
|
+
}
|
|
350
|
+
let accountIndex = 0;
|
|
351
|
+
const getNextAccount = () => {
|
|
352
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
353
|
+
accountIndex += 1;
|
|
354
|
+
return accountMeta;
|
|
355
|
+
};
|
|
356
|
+
return { programAddress: instruction.programAddress, accounts: { payer: getNextAccount(), depositor: getNextAccount(), poolCreatorAuthority: getNextAccount(), ammConfig: getNextAccount(), mint0: getNextAccount(), mint1: getNextAccount(), pool: getNextAccount(), lpMint: getNextAccount(), vault0: getNextAccount(), vault1: getNextAccount(), depositorToken0: getNextAccount(), depositorToken1: getNextAccount(), lpOwner: getNextAccount(), lpOwnerToken: getNextAccount(), tokenProgram0: getNextAccount(), tokenProgram1: getNextAccount(), lpTokenProgram: getNextAccount(), associatedTokenProgram: getNextAccount(), systemProgram: getNextAccount() }, data: getCreatePoolInstructionDataDecoder().decode(instruction.data) };
|
|
357
|
+
}
|
|
358
|
+
var DEPOSIT_DISCRIMINATOR = 3;
|
|
359
|
+
function getDepositDiscriminatorBytes() {
|
|
360
|
+
return kit.getU8Encoder().encode(DEPOSIT_DISCRIMINATOR);
|
|
361
|
+
}
|
|
362
|
+
function getDepositInstructionDataEncoder() {
|
|
363
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["lpAmount", kit.getU64Encoder()], ["maximumAmount0", kit.getU64Encoder()], ["maximumAmount1", kit.getU64Encoder()]]), (value) => ({ ...value, discriminator: 3 }));
|
|
364
|
+
}
|
|
365
|
+
function getDepositInstructionDataDecoder() {
|
|
366
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(DEPOSIT_DISCRIMINATOR, kit.getU8Decoder())], ["lpAmount", kit.getU64Decoder()], ["maximumAmount0", kit.getU64Decoder()], ["maximumAmount1", kit.getU64Decoder()]]);
|
|
367
|
+
}
|
|
368
|
+
function getDepositInstructionDataCodec() {
|
|
369
|
+
return kit.combineCodec(getDepositInstructionDataEncoder(), getDepositInstructionDataDecoder());
|
|
370
|
+
}
|
|
371
|
+
function getDepositInstruction(input, config) {
|
|
372
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
373
|
+
const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
|
|
374
|
+
const originalAccounts = { owner: { value: input.owner ?? null, isSigner: true, isWritable: false }, pool: { value: input.pool ?? null, isSigner: false, isWritable: true }, vault0: { value: input.vault0 ?? null, isSigner: false, isWritable: true }, vault1: { value: input.vault1 ?? null, isSigner: false, isWritable: true }, lpMint: { value: input.lpMint ?? null, isSigner: false, isWritable: true }, ownerToken0: { value: input.ownerToken0 ?? null, isSigner: false, isWritable: true }, ownerToken1: { value: input.ownerToken1 ?? null, isSigner: false, isWritable: true }, ownerLpToken: { value: input.ownerLpToken ?? null, isSigner: false, isWritable: true }, tokenProgram0: { value: input.tokenProgram0 ?? null, isSigner: false, isWritable: false }, tokenProgram1: { value: input.tokenProgram1 ?? null, isSigner: false, isWritable: false }, lpTokenProgram: { value: input.lpTokenProgram ?? null, isSigner: false, isWritable: false } };
|
|
375
|
+
const accounts = originalAccounts;
|
|
376
|
+
const args = { ...input };
|
|
377
|
+
if (!accounts.lpTokenProgram.value) {
|
|
378
|
+
accounts.lpTokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
379
|
+
}
|
|
380
|
+
return Object.freeze({ accounts: [getAccountMeta("owner", accounts.owner), getAccountMeta("pool", accounts.pool), getAccountMeta("vault0", accounts.vault0), getAccountMeta("vault1", accounts.vault1), getAccountMeta("lpMint", accounts.lpMint), getAccountMeta("ownerToken0", accounts.ownerToken0), getAccountMeta("ownerToken1", accounts.ownerToken1), getAccountMeta("ownerLpToken", accounts.ownerLpToken), getAccountMeta("tokenProgram0", accounts.tokenProgram0), getAccountMeta("tokenProgram1", accounts.tokenProgram1), getAccountMeta("lpTokenProgram", accounts.lpTokenProgram)], data: getDepositInstructionDataEncoder().encode(args), programAddress });
|
|
381
|
+
}
|
|
382
|
+
function parseDepositInstruction(instruction) {
|
|
383
|
+
if (instruction.accounts.length < 11) {
|
|
384
|
+
throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 11 });
|
|
385
|
+
}
|
|
386
|
+
let accountIndex = 0;
|
|
387
|
+
const getNextAccount = () => {
|
|
388
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
389
|
+
accountIndex += 1;
|
|
390
|
+
return accountMeta;
|
|
391
|
+
};
|
|
392
|
+
return { programAddress: instruction.programAddress, accounts: { owner: getNextAccount(), pool: getNextAccount(), vault0: getNextAccount(), vault1: getNextAccount(), lpMint: getNextAccount(), ownerToken0: getNextAccount(), ownerToken1: getNextAccount(), ownerLpToken: getNextAccount(), tokenProgram0: getNextAccount(), tokenProgram1: getNextAccount(), lpTokenProgram: getNextAccount() }, data: getDepositInstructionDataDecoder().decode(instruction.data) };
|
|
393
|
+
}
|
|
394
|
+
var SET_POOL_CREATOR_DISCRIMINATOR = 9;
|
|
395
|
+
function getSetPoolCreatorDiscriminatorBytes() {
|
|
396
|
+
return kit.getU8Encoder().encode(SET_POOL_CREATOR_DISCRIMINATOR);
|
|
397
|
+
}
|
|
398
|
+
function getSetPoolCreatorInstructionDataEncoder() {
|
|
399
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["newCreator", kit.getAddressEncoder()]]), (value) => ({ ...value, discriminator: 9 }));
|
|
400
|
+
}
|
|
401
|
+
function getSetPoolCreatorInstructionDataDecoder() {
|
|
402
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(SET_POOL_CREATOR_DISCRIMINATOR, kit.getU8Decoder())], ["newCreator", kit.getAddressDecoder()]]);
|
|
403
|
+
}
|
|
404
|
+
function getSetPoolCreatorInstructionDataCodec() {
|
|
405
|
+
return kit.combineCodec(getSetPoolCreatorInstructionDataEncoder(), getSetPoolCreatorInstructionDataDecoder());
|
|
406
|
+
}
|
|
407
|
+
function getSetPoolCreatorInstruction(input, config) {
|
|
408
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
409
|
+
const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
|
|
410
|
+
const originalAccounts = { creator: { value: input.creator ?? null, isSigner: true, isWritable: false }, pool: { value: input.pool ?? null, isSigner: false, isWritable: true } };
|
|
411
|
+
const accounts = originalAccounts;
|
|
412
|
+
const args = { ...input };
|
|
413
|
+
return Object.freeze({ accounts: [getAccountMeta("creator", accounts.creator), getAccountMeta("pool", accounts.pool)], data: getSetPoolCreatorInstructionDataEncoder().encode(args), programAddress });
|
|
414
|
+
}
|
|
415
|
+
function parseSetPoolCreatorInstruction(instruction) {
|
|
416
|
+
if (instruction.accounts.length < 2) {
|
|
417
|
+
throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 2 });
|
|
418
|
+
}
|
|
419
|
+
let accountIndex = 0;
|
|
420
|
+
const getNextAccount = () => {
|
|
421
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
422
|
+
accountIndex += 1;
|
|
423
|
+
return accountMeta;
|
|
424
|
+
};
|
|
425
|
+
return { programAddress: instruction.programAddress, accounts: { creator: getNextAccount(), pool: getNextAccount() }, data: getSetPoolCreatorInstructionDataDecoder().decode(instruction.data) };
|
|
426
|
+
}
|
|
427
|
+
var SWAP_EXACT_IN_DISCRIMINATOR = 5;
|
|
428
|
+
function getSwapExactInDiscriminatorBytes() {
|
|
429
|
+
return kit.getU8Encoder().encode(SWAP_EXACT_IN_DISCRIMINATOR);
|
|
430
|
+
}
|
|
431
|
+
function getSwapExactInInstructionDataEncoder() {
|
|
432
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["amountIn", kit.getU64Encoder()], ["minimumAmountOut", kit.getU64Encoder()]]), (value) => ({ ...value, discriminator: 5 }));
|
|
433
|
+
}
|
|
434
|
+
function getSwapExactInInstructionDataDecoder() {
|
|
435
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(SWAP_EXACT_IN_DISCRIMINATOR, kit.getU8Decoder())], ["amountIn", kit.getU64Decoder()], ["minimumAmountOut", kit.getU64Decoder()]]);
|
|
436
|
+
}
|
|
437
|
+
function getSwapExactInInstructionDataCodec() {
|
|
438
|
+
return kit.combineCodec(getSwapExactInInstructionDataEncoder(), getSwapExactInInstructionDataDecoder());
|
|
439
|
+
}
|
|
440
|
+
function getSwapExactInInstruction(input, config) {
|
|
441
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
442
|
+
const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
|
|
443
|
+
const originalAccounts = { trader: { value: input.trader ?? null, isSigner: true, isWritable: false }, pool: { value: input.pool ?? null, isSigner: false, isWritable: true }, inputToken: { value: input.inputToken ?? null, isSigner: false, isWritable: true }, outputToken: { value: input.outputToken ?? null, isSigner: false, isWritable: true }, inputVault: { value: input.inputVault ?? null, isSigner: false, isWritable: true }, outputVault: { value: input.outputVault ?? null, isSigner: false, isWritable: true }, inputTokenProgram: { value: input.inputTokenProgram ?? null, isSigner: false, isWritable: false }, outputTokenProgram: { value: input.outputTokenProgram ?? null, isSigner: false, isWritable: false } };
|
|
444
|
+
const accounts = originalAccounts;
|
|
445
|
+
const args = { ...input };
|
|
446
|
+
return Object.freeze({ accounts: [getAccountMeta("trader", accounts.trader), getAccountMeta("pool", accounts.pool), getAccountMeta("inputToken", accounts.inputToken), getAccountMeta("outputToken", accounts.outputToken), getAccountMeta("inputVault", accounts.inputVault), getAccountMeta("outputVault", accounts.outputVault), getAccountMeta("inputTokenProgram", accounts.inputTokenProgram), getAccountMeta("outputTokenProgram", accounts.outputTokenProgram)], data: getSwapExactInInstructionDataEncoder().encode(args), programAddress });
|
|
447
|
+
}
|
|
448
|
+
function parseSwapExactInInstruction(instruction) {
|
|
449
|
+
if (instruction.accounts.length < 8) {
|
|
450
|
+
throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 8 });
|
|
451
|
+
}
|
|
452
|
+
let accountIndex = 0;
|
|
453
|
+
const getNextAccount = () => {
|
|
454
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
455
|
+
accountIndex += 1;
|
|
456
|
+
return accountMeta;
|
|
457
|
+
};
|
|
458
|
+
return { programAddress: instruction.programAddress, accounts: { trader: getNextAccount(), pool: getNextAccount(), inputToken: getNextAccount(), outputToken: getNextAccount(), inputVault: getNextAccount(), outputVault: getNextAccount(), inputTokenProgram: getNextAccount(), outputTokenProgram: getNextAccount() }, data: getSwapExactInInstructionDataDecoder().decode(instruction.data) };
|
|
459
|
+
}
|
|
460
|
+
var SWAP_EXACT_OUT_DISCRIMINATOR = 6;
|
|
461
|
+
function getSwapExactOutDiscriminatorBytes() {
|
|
462
|
+
return kit.getU8Encoder().encode(SWAP_EXACT_OUT_DISCRIMINATOR);
|
|
463
|
+
}
|
|
464
|
+
function getSwapExactOutInstructionDataEncoder() {
|
|
465
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["amountOut", kit.getU64Encoder()], ["maximumAmountIn", kit.getU64Encoder()]]), (value) => ({ ...value, discriminator: 6 }));
|
|
466
|
+
}
|
|
467
|
+
function getSwapExactOutInstructionDataDecoder() {
|
|
468
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(SWAP_EXACT_OUT_DISCRIMINATOR, kit.getU8Decoder())], ["amountOut", kit.getU64Decoder()], ["maximumAmountIn", kit.getU64Decoder()]]);
|
|
469
|
+
}
|
|
470
|
+
function getSwapExactOutInstructionDataCodec() {
|
|
471
|
+
return kit.combineCodec(getSwapExactOutInstructionDataEncoder(), getSwapExactOutInstructionDataDecoder());
|
|
472
|
+
}
|
|
473
|
+
function getSwapExactOutInstruction(input, config) {
|
|
474
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
475
|
+
const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
|
|
476
|
+
const originalAccounts = { trader: { value: input.trader ?? null, isSigner: true, isWritable: false }, pool: { value: input.pool ?? null, isSigner: false, isWritable: true }, inputToken: { value: input.inputToken ?? null, isSigner: false, isWritable: true }, outputToken: { value: input.outputToken ?? null, isSigner: false, isWritable: true }, inputVault: { value: input.inputVault ?? null, isSigner: false, isWritable: true }, outputVault: { value: input.outputVault ?? null, isSigner: false, isWritable: true }, inputTokenProgram: { value: input.inputTokenProgram ?? null, isSigner: false, isWritable: false }, outputTokenProgram: { value: input.outputTokenProgram ?? null, isSigner: false, isWritable: false } };
|
|
477
|
+
const accounts = originalAccounts;
|
|
478
|
+
const args = { ...input };
|
|
479
|
+
return Object.freeze({ accounts: [getAccountMeta("trader", accounts.trader), getAccountMeta("pool", accounts.pool), getAccountMeta("inputToken", accounts.inputToken), getAccountMeta("outputToken", accounts.outputToken), getAccountMeta("inputVault", accounts.inputVault), getAccountMeta("outputVault", accounts.outputVault), getAccountMeta("inputTokenProgram", accounts.inputTokenProgram), getAccountMeta("outputTokenProgram", accounts.outputTokenProgram)], data: getSwapExactOutInstructionDataEncoder().encode(args), programAddress });
|
|
480
|
+
}
|
|
481
|
+
function parseSwapExactOutInstruction(instruction) {
|
|
482
|
+
if (instruction.accounts.length < 8) {
|
|
483
|
+
throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 8 });
|
|
484
|
+
}
|
|
485
|
+
let accountIndex = 0;
|
|
486
|
+
const getNextAccount = () => {
|
|
487
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
488
|
+
accountIndex += 1;
|
|
489
|
+
return accountMeta;
|
|
490
|
+
};
|
|
491
|
+
return { programAddress: instruction.programAddress, accounts: { trader: getNextAccount(), pool: getNextAccount(), inputToken: getNextAccount(), outputToken: getNextAccount(), inputVault: getNextAccount(), outputVault: getNextAccount(), inputTokenProgram: getNextAccount(), outputTokenProgram: getNextAccount() }, data: getSwapExactOutInstructionDataDecoder().decode(instruction.data) };
|
|
492
|
+
}
|
|
493
|
+
var UPDATE_CONFIG_DISCRIMINATOR = 1;
|
|
494
|
+
function getUpdateConfigDiscriminatorBytes() {
|
|
495
|
+
return kit.getU8Encoder().encode(UPDATE_CONFIG_DISCRIMINATOR);
|
|
496
|
+
}
|
|
497
|
+
function getUpdateConfigInstructionDataEncoder() {
|
|
498
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["newAuthority", kit.getAddressEncoder()], ["tradeFeeRate", kit.getU32Encoder()], ["protocolFeeRate", kit.getU32Encoder()], ["creatorFeeRate", kit.getU32Encoder()]]), (value) => ({ ...value, discriminator: 1 }));
|
|
499
|
+
}
|
|
500
|
+
function getUpdateConfigInstructionDataDecoder() {
|
|
501
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(UPDATE_CONFIG_DISCRIMINATOR, kit.getU8Decoder())], ["newAuthority", kit.getAddressDecoder()], ["tradeFeeRate", kit.getU32Decoder()], ["protocolFeeRate", kit.getU32Decoder()], ["creatorFeeRate", kit.getU32Decoder()]]);
|
|
502
|
+
}
|
|
503
|
+
function getUpdateConfigInstructionDataCodec() {
|
|
504
|
+
return kit.combineCodec(getUpdateConfigInstructionDataEncoder(), getUpdateConfigInstructionDataDecoder());
|
|
505
|
+
}
|
|
506
|
+
function getUpdateConfigInstruction(input, config) {
|
|
507
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
508
|
+
const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
|
|
509
|
+
const originalAccounts = { authority: { value: input.authority ?? null, isSigner: true, isWritable: false }, ammConfig: { value: input.ammConfig ?? null, isSigner: false, isWritable: true } };
|
|
510
|
+
const accounts = originalAccounts;
|
|
511
|
+
const args = { ...input };
|
|
512
|
+
return Object.freeze({ accounts: [getAccountMeta("authority", accounts.authority), getAccountMeta("ammConfig", accounts.ammConfig)], data: getUpdateConfigInstructionDataEncoder().encode(args), programAddress });
|
|
513
|
+
}
|
|
514
|
+
function parseUpdateConfigInstruction(instruction) {
|
|
515
|
+
if (instruction.accounts.length < 2) {
|
|
516
|
+
throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 2 });
|
|
517
|
+
}
|
|
518
|
+
let accountIndex = 0;
|
|
519
|
+
const getNextAccount = () => {
|
|
520
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
521
|
+
accountIndex += 1;
|
|
522
|
+
return accountMeta;
|
|
523
|
+
};
|
|
524
|
+
return { programAddress: instruction.programAddress, accounts: { authority: getNextAccount(), ammConfig: getNextAccount() }, data: getUpdateConfigInstructionDataDecoder().decode(instruction.data) };
|
|
525
|
+
}
|
|
526
|
+
var WITHDRAW_DISCRIMINATOR = 4;
|
|
527
|
+
function getWithdrawDiscriminatorBytes() {
|
|
528
|
+
return kit.getU8Encoder().encode(WITHDRAW_DISCRIMINATOR);
|
|
529
|
+
}
|
|
530
|
+
function getWithdrawInstructionDataEncoder() {
|
|
531
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["lpAmount", kit.getU64Encoder()], ["minimumAmount0", kit.getU64Encoder()], ["minimumAmount1", kit.getU64Encoder()]]), (value) => ({ ...value, discriminator: 4 }));
|
|
532
|
+
}
|
|
533
|
+
function getWithdrawInstructionDataDecoder() {
|
|
534
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(WITHDRAW_DISCRIMINATOR, kit.getU8Decoder())], ["lpAmount", kit.getU64Decoder()], ["minimumAmount0", kit.getU64Decoder()], ["minimumAmount1", kit.getU64Decoder()]]);
|
|
535
|
+
}
|
|
536
|
+
function getWithdrawInstructionDataCodec() {
|
|
537
|
+
return kit.combineCodec(getWithdrawInstructionDataEncoder(), getWithdrawInstructionDataDecoder());
|
|
538
|
+
}
|
|
539
|
+
function getWithdrawInstruction(input, config) {
|
|
540
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
541
|
+
const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
|
|
542
|
+
const originalAccounts = { owner: { value: input.owner ?? null, isSigner: true, isWritable: false }, pool: { value: input.pool ?? null, isSigner: false, isWritable: true }, vault0: { value: input.vault0 ?? null, isSigner: false, isWritable: true }, vault1: { value: input.vault1 ?? null, isSigner: false, isWritable: true }, lpMint: { value: input.lpMint ?? null, isSigner: false, isWritable: true }, ownerToken0: { value: input.ownerToken0 ?? null, isSigner: false, isWritable: true }, ownerToken1: { value: input.ownerToken1 ?? null, isSigner: false, isWritable: true }, ownerLpToken: { value: input.ownerLpToken ?? null, isSigner: false, isWritable: true }, tokenProgram0: { value: input.tokenProgram0 ?? null, isSigner: false, isWritable: false }, tokenProgram1: { value: input.tokenProgram1 ?? null, isSigner: false, isWritable: false }, lpTokenProgram: { value: input.lpTokenProgram ?? null, isSigner: false, isWritable: false } };
|
|
543
|
+
const accounts = originalAccounts;
|
|
544
|
+
const args = { ...input };
|
|
545
|
+
if (!accounts.lpTokenProgram.value) {
|
|
546
|
+
accounts.lpTokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
547
|
+
}
|
|
548
|
+
return Object.freeze({ accounts: [getAccountMeta("owner", accounts.owner), getAccountMeta("pool", accounts.pool), getAccountMeta("vault0", accounts.vault0), getAccountMeta("vault1", accounts.vault1), getAccountMeta("lpMint", accounts.lpMint), getAccountMeta("ownerToken0", accounts.ownerToken0), getAccountMeta("ownerToken1", accounts.ownerToken1), getAccountMeta("ownerLpToken", accounts.ownerLpToken), getAccountMeta("tokenProgram0", accounts.tokenProgram0), getAccountMeta("tokenProgram1", accounts.tokenProgram1), getAccountMeta("lpTokenProgram", accounts.lpTokenProgram)], data: getWithdrawInstructionDataEncoder().encode(args), programAddress });
|
|
549
|
+
}
|
|
550
|
+
function parseWithdrawInstruction(instruction) {
|
|
551
|
+
if (instruction.accounts.length < 11) {
|
|
552
|
+
throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 11 });
|
|
553
|
+
}
|
|
554
|
+
let accountIndex = 0;
|
|
555
|
+
const getNextAccount = () => {
|
|
556
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
557
|
+
accountIndex += 1;
|
|
558
|
+
return accountMeta;
|
|
559
|
+
};
|
|
560
|
+
return { programAddress: instruction.programAddress, accounts: { owner: getNextAccount(), pool: getNextAccount(), vault0: getNextAccount(), vault1: getNextAccount(), lpMint: getNextAccount(), ownerToken0: getNextAccount(), ownerToken1: getNextAccount(), ownerLpToken: getNextAccount(), tokenProgram0: getNextAccount(), tokenProgram1: getNextAccount(), lpTokenProgram: getNextAccount() }, data: getWithdrawInstructionDataDecoder().decode(instruction.data) };
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// src/generated/programs/pinaAmm.ts
|
|
564
|
+
var PINA_AMM_PROGRAM_ADDRESS = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV";
|
|
565
|
+
var PinaAmmAccount = /* @__PURE__ */ ((PinaAmmAccount2) => {
|
|
566
|
+
PinaAmmAccount2[PinaAmmAccount2["AmmConfig"] = 0] = "AmmConfig";
|
|
567
|
+
PinaAmmAccount2[PinaAmmAccount2["Pool"] = 1] = "Pool";
|
|
568
|
+
return PinaAmmAccount2;
|
|
569
|
+
})(PinaAmmAccount || {});
|
|
570
|
+
function identifyPinaAmmAccount(account) {
|
|
571
|
+
const data = "data" in account ? account.data : account;
|
|
572
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(1), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(0), 1)) {
|
|
573
|
+
return 0 /* AmmConfig */;
|
|
574
|
+
}
|
|
575
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(2), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(0), 1)) {
|
|
576
|
+
return 1 /* Pool */;
|
|
577
|
+
}
|
|
578
|
+
throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, { accountData: data, programName: "pinaAmm" });
|
|
579
|
+
}
|
|
580
|
+
var PinaAmmEvent = /* @__PURE__ */ ((PinaAmmEvent2) => {
|
|
581
|
+
PinaAmmEvent2[PinaAmmEvent2["PoolCreated"] = 0] = "PoolCreated";
|
|
582
|
+
PinaAmmEvent2[PinaAmmEvent2["Swapped"] = 1] = "Swapped";
|
|
583
|
+
PinaAmmEvent2[PinaAmmEvent2["LiquidityChanged"] = 2] = "LiquidityChanged";
|
|
584
|
+
PinaAmmEvent2[PinaAmmEvent2["FeesCollected"] = 3] = "FeesCollected";
|
|
585
|
+
return PinaAmmEvent2;
|
|
586
|
+
})(PinaAmmEvent || {});
|
|
587
|
+
function identifyPinaAmmEvent(event) {
|
|
588
|
+
const data = "data" in event ? event.data : event;
|
|
589
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(1), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(0), 1)) {
|
|
590
|
+
return 0 /* PoolCreated */;
|
|
591
|
+
}
|
|
592
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(2), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(0), 1)) {
|
|
593
|
+
return 1 /* Swapped */;
|
|
594
|
+
}
|
|
595
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(3), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(0), 1)) {
|
|
596
|
+
return 2 /* LiquidityChanged */;
|
|
597
|
+
}
|
|
598
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(4), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(0), 1)) {
|
|
599
|
+
return 3 /* FeesCollected */;
|
|
600
|
+
}
|
|
601
|
+
throw new Error("The provided event could not be identified as a pinaAmm event.");
|
|
602
|
+
}
|
|
603
|
+
var PinaAmmInstruction = /* @__PURE__ */ ((PinaAmmInstruction2) => {
|
|
604
|
+
PinaAmmInstruction2[PinaAmmInstruction2["CreateConfig"] = 0] = "CreateConfig";
|
|
605
|
+
PinaAmmInstruction2[PinaAmmInstruction2["UpdateConfig"] = 1] = "UpdateConfig";
|
|
606
|
+
PinaAmmInstruction2[PinaAmmInstruction2["CreatePool"] = 2] = "CreatePool";
|
|
607
|
+
PinaAmmInstruction2[PinaAmmInstruction2["Deposit"] = 3] = "Deposit";
|
|
608
|
+
PinaAmmInstruction2[PinaAmmInstruction2["Withdraw"] = 4] = "Withdraw";
|
|
609
|
+
PinaAmmInstruction2[PinaAmmInstruction2["SwapExactIn"] = 5] = "SwapExactIn";
|
|
610
|
+
PinaAmmInstruction2[PinaAmmInstruction2["SwapExactOut"] = 6] = "SwapExactOut";
|
|
611
|
+
PinaAmmInstruction2[PinaAmmInstruction2["CollectProtocolFees"] = 7] = "CollectProtocolFees";
|
|
612
|
+
PinaAmmInstruction2[PinaAmmInstruction2["CollectCreatorFees"] = 8] = "CollectCreatorFees";
|
|
613
|
+
PinaAmmInstruction2[PinaAmmInstruction2["SetPoolCreator"] = 9] = "SetPoolCreator";
|
|
614
|
+
return PinaAmmInstruction2;
|
|
615
|
+
})(PinaAmmInstruction || {});
|
|
616
|
+
function identifyPinaAmmInstruction(instruction) {
|
|
617
|
+
const data = "data" in instruction ? instruction.data : instruction;
|
|
618
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(0), 0)) {
|
|
619
|
+
return 0 /* CreateConfig */;
|
|
620
|
+
}
|
|
621
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(1), 0)) {
|
|
622
|
+
return 1 /* UpdateConfig */;
|
|
623
|
+
}
|
|
624
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(2), 0)) {
|
|
625
|
+
return 2 /* CreatePool */;
|
|
626
|
+
}
|
|
627
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(3), 0)) {
|
|
628
|
+
return 3 /* Deposit */;
|
|
629
|
+
}
|
|
630
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(4), 0)) {
|
|
631
|
+
return 4 /* Withdraw */;
|
|
632
|
+
}
|
|
633
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(5), 0)) {
|
|
634
|
+
return 5 /* SwapExactIn */;
|
|
635
|
+
}
|
|
636
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(6), 0)) {
|
|
637
|
+
return 6 /* SwapExactOut */;
|
|
638
|
+
}
|
|
639
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(7), 0)) {
|
|
640
|
+
return 7 /* CollectProtocolFees */;
|
|
641
|
+
}
|
|
642
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(8), 0)) {
|
|
643
|
+
return 8 /* CollectCreatorFees */;
|
|
644
|
+
}
|
|
645
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(9), 0)) {
|
|
646
|
+
return 9 /* SetPoolCreator */;
|
|
647
|
+
}
|
|
648
|
+
throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, { instructionData: data, programName: "pinaAmm" });
|
|
649
|
+
}
|
|
650
|
+
function parsePinaAmmInstruction(instruction) {
|
|
651
|
+
const instructionType = identifyPinaAmmInstruction(instruction);
|
|
652
|
+
switch (instructionType) {
|
|
653
|
+
case 0 /* CreateConfig */: {
|
|
654
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
655
|
+
return { instructionType: 0 /* CreateConfig */, ...parseCreateConfigInstruction(instruction) };
|
|
656
|
+
}
|
|
657
|
+
case 1 /* UpdateConfig */: {
|
|
658
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
659
|
+
return { instructionType: 1 /* UpdateConfig */, ...parseUpdateConfigInstruction(instruction) };
|
|
660
|
+
}
|
|
661
|
+
case 2 /* CreatePool */: {
|
|
662
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
663
|
+
return { instructionType: 2 /* CreatePool */, ...parseCreatePoolInstruction(instruction) };
|
|
664
|
+
}
|
|
665
|
+
case 3 /* Deposit */: {
|
|
666
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
667
|
+
return { instructionType: 3 /* Deposit */, ...parseDepositInstruction(instruction) };
|
|
668
|
+
}
|
|
669
|
+
case 4 /* Withdraw */: {
|
|
670
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
671
|
+
return { instructionType: 4 /* Withdraw */, ...parseWithdrawInstruction(instruction) };
|
|
672
|
+
}
|
|
673
|
+
case 5 /* SwapExactIn */: {
|
|
674
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
675
|
+
return { instructionType: 5 /* SwapExactIn */, ...parseSwapExactInInstruction(instruction) };
|
|
676
|
+
}
|
|
677
|
+
case 6 /* SwapExactOut */: {
|
|
678
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
679
|
+
return { instructionType: 6 /* SwapExactOut */, ...parseSwapExactOutInstruction(instruction) };
|
|
680
|
+
}
|
|
681
|
+
case 7 /* CollectProtocolFees */: {
|
|
682
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
683
|
+
return { instructionType: 7 /* CollectProtocolFees */, ...parseCollectProtocolFeesInstruction(instruction) };
|
|
684
|
+
}
|
|
685
|
+
case 8 /* CollectCreatorFees */: {
|
|
686
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
687
|
+
return { instructionType: 8 /* CollectCreatorFees */, ...parseCollectCreatorFeesInstruction(instruction) };
|
|
688
|
+
}
|
|
689
|
+
case 9 /* SetPoolCreator */: {
|
|
690
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
691
|
+
return { instructionType: 9 /* SetPoolCreator */, ...parseSetPoolCreatorInstruction(instruction) };
|
|
692
|
+
}
|
|
693
|
+
default:
|
|
694
|
+
throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, { instructionType, programName: "pinaAmm" });
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
function pinaAmmProgram() {
|
|
698
|
+
return (client) => {
|
|
699
|
+
return kit.extendClient(client, { pinaAmm: { accounts: { ammConfig: programClientCore.addSelfFetchFunctions(client, getAmmConfigCodec()), pool: programClientCore.addSelfFetchFunctions(client, getPoolCodec()) }, instructions: {
|
|
700
|
+
migrate: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getMigrateInstruction(input)),
|
|
701
|
+
createConfig: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getCreateConfigInstruction(input)),
|
|
702
|
+
updateConfig: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getUpdateConfigInstruction(input)),
|
|
703
|
+
createPool: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getCreatePoolInstructionAsync(input)),
|
|
704
|
+
deposit: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getDepositInstruction(input)),
|
|
705
|
+
withdraw: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getWithdrawInstruction(input)),
|
|
706
|
+
swapExactIn: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getSwapExactInInstruction(input)),
|
|
707
|
+
swapExactOut: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getSwapExactOutInstruction(input)),
|
|
708
|
+
collectProtocolFees: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getCollectProtocolFeesInstruction(input)),
|
|
709
|
+
collectCreatorFees: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getCollectCreatorFeesInstruction(input)),
|
|
710
|
+
setPoolCreator: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getSetPoolCreatorInstruction(input))
|
|
711
|
+
}, pdas: { ammConfig: findAmmConfigPda, pool: findPoolPda, poolVault: findPoolVaultPda, poolLpMint: findPoolLpMintPda }, identifyAccount: identifyPinaAmmAccount, identifyInstruction: identifyPinaAmmInstruction, parseInstruction: parsePinaAmmInstruction } });
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
// src/generated/errors/pinaAmm.ts
|
|
716
|
+
var PINA_AMM_ERROR__INVALID_FEE_RATES = 0;
|
|
717
|
+
var PINA_AMM_ERROR__UNAUTHORIZED = 1;
|
|
718
|
+
var PINA_AMM_ERROR__INVALID_PROGRAM_DATA = 2;
|
|
719
|
+
var PINA_AMM_ERROR__INVALID_MINT_ORDER = 3;
|
|
720
|
+
var PINA_AMM_ERROR__UNSUPPORTED_MINT = 4;
|
|
721
|
+
var PINA_AMM_ERROR__POOL_ACCOUNT_MISMATCH = 5;
|
|
722
|
+
var PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE = 6;
|
|
723
|
+
var PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY = 7;
|
|
724
|
+
var PINA_AMM_ERROR__ZERO_AMOUNT = 8;
|
|
725
|
+
var PINA_AMM_ERROR__SLIPPAGE_EXCEEDED = 9;
|
|
726
|
+
var PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY = 10;
|
|
727
|
+
var PINA_AMM_ERROR__MATH_OVERFLOW = 11;
|
|
728
|
+
var PINA_AMM_ERROR__INVARIANT_VIOLATION = 12;
|
|
729
|
+
var PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH = 13;
|
|
730
|
+
var PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED = 14;
|
|
731
|
+
var pinaAmmErrorMessages;
|
|
732
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
733
|
+
pinaAmmErrorMessages = { [PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY]: `The initial deposit must mint more LP than the permanently locked minimum.`, [PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY]: `The pool cannot pay this amount from its reserves.`, [PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE]: `The creator fee mode must be 0 (input token), 1 (token 0), or 2 (token 1).`, [PINA_AMM_ERROR__INVALID_FEE_RATES]: `Fee rates are out of range: trade plus creator fee above 10% or protocol share above 100%.`, [PINA_AMM_ERROR__INVALID_MINT_ORDER]: `Pool mints must be distinct and passed in ascending byte order.`, [PINA_AMM_ERROR__INVALID_PROGRAM_DATA]: `The program-data account is not this program's, or the program is not upgradeable.`, [PINA_AMM_ERROR__INVARIANT_VIOLATION]: `The trade would decrease the pool's constant product.`, [PINA_AMM_ERROR__MATH_OVERFLOW]: `An intermediate value overflowed or did not fit its type.`, [PINA_AMM_ERROR__POOL_ACCOUNT_MISMATCH]: `A vault, LP mint, or fee tier account does not belong to this pool.`, [PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED]: `This fee tier only lets its pool-creator authority create pools.`, [PINA_AMM_ERROR__SLIPPAGE_EXCEEDED]: `The result is worse than the caller's slippage limit.`, [PINA_AMM_ERROR__UNAUTHORIZED]: `The signer is not the authority this instruction requires.`, [PINA_AMM_ERROR__UNSUPPORTED_MINT]: `The mint's token program or Token-2022 extensions are not supported.`, [PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH]: `A vault holds less than the fees accrued against it.`, [PINA_AMM_ERROR__ZERO_AMOUNT]: `An amount is zero or the trade rounds down to nothing.` };
|
|
734
|
+
}
|
|
735
|
+
function getPinaAmmErrorMessage(code) {
|
|
736
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
737
|
+
return pinaAmmErrorMessages[code];
|
|
738
|
+
}
|
|
739
|
+
return "Error message not available in production bundles.";
|
|
740
|
+
}
|
|
741
|
+
function isPinaAmmError(error, transactionMessage, code) {
|
|
742
|
+
return kit.isProgramError(error, transactionMessage, PINA_AMM_PROGRAM_ADDRESS, code);
|
|
743
|
+
}
|
|
744
|
+
var POOL_CREATED_EVENT_DISCRIMINATOR = 1;
|
|
745
|
+
function getPoolCreatedEventDiscriminatorBytes() {
|
|
746
|
+
return kit.getU8Encoder().encode(POOL_CREATED_EVENT_DISCRIMINATOR);
|
|
747
|
+
}
|
|
748
|
+
var POOL_CREATED_EVENT_DISCRIMINATOR2 = 0;
|
|
749
|
+
function getPoolCreatedEventDiscriminator2Bytes() {
|
|
750
|
+
return kit.getU8Encoder().encode(POOL_CREATED_EVENT_DISCRIMINATOR2);
|
|
751
|
+
}
|
|
752
|
+
function getPoolCreatedEventEncoder() {
|
|
753
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["migrationVersion", kit.getU8Encoder()], ["pool", kit.getAddressEncoder()], ["ammConfig", kit.getAddressEncoder()], ["creator", kit.getAddressEncoder()], ["mint0", kit.getAddressEncoder()], ["mint1", kit.getAddressEncoder()], ["lpMint", kit.getAddressEncoder()], ["amount0", kit.getU64Encoder()], ["amount1", kit.getU64Encoder()], ["lpSupply", kit.getU64Encoder()]]), (value) => ({ ...value, discriminator: 1, migrationVersion: 0 }));
|
|
754
|
+
}
|
|
755
|
+
function getPoolCreatedEventDecoder() {
|
|
756
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(POOL_CREATED_EVENT_DISCRIMINATOR, kit.getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, kit.getU8Decoder())], ["pool", kit.getAddressDecoder()], ["ammConfig", kit.getAddressDecoder()], ["creator", kit.getAddressDecoder()], ["mint0", kit.getAddressDecoder()], ["mint1", kit.getAddressDecoder()], ["lpMint", kit.getAddressDecoder()], ["amount0", kit.getU64Decoder()], ["amount1", kit.getU64Decoder()], ["lpSupply", kit.getU64Decoder()]]);
|
|
757
|
+
}
|
|
758
|
+
function getPoolCreatedEventCodec() {
|
|
759
|
+
return kit.combineCodec(getPoolCreatedEventEncoder(), getPoolCreatedEventDecoder());
|
|
760
|
+
}
|
|
761
|
+
function parsePoolCreatedEvent(data) {
|
|
762
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(POOL_CREATED_EVENT_DISCRIMINATOR), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(POOL_CREATED_EVENT_DISCRIMINATOR2), 1)) {
|
|
763
|
+
return getPoolCreatedEventDecoder().decode(data);
|
|
764
|
+
}
|
|
765
|
+
throw new Error('The provided data does not match the "PoolCreatedEvent" event discriminators.');
|
|
766
|
+
}
|
|
767
|
+
var SWAPPED_EVENT_DISCRIMINATOR = 2;
|
|
768
|
+
function getSwappedEventDiscriminatorBytes() {
|
|
769
|
+
return kit.getU8Encoder().encode(SWAPPED_EVENT_DISCRIMINATOR);
|
|
770
|
+
}
|
|
771
|
+
var SWAPPED_EVENT_DISCRIMINATOR2 = 0;
|
|
772
|
+
function getSwappedEventDiscriminator2Bytes() {
|
|
773
|
+
return kit.getU8Encoder().encode(SWAPPED_EVENT_DISCRIMINATOR2);
|
|
774
|
+
}
|
|
775
|
+
function getSwappedEventEncoder() {
|
|
776
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["migrationVersion", kit.getU8Encoder()], ["pool", kit.getAddressEncoder()], ["trader", kit.getAddressEncoder()], ["zeroForOne", kit.getU8Encoder()], ["amountIn", kit.getU64Encoder()], ["amountOut", kit.getU64Encoder()], ["tradeFee", kit.getU64Encoder()], ["protocolFee", kit.getU64Encoder()], ["creatorFee", kit.getU64Encoder()], ["creatorFeeOnInput", kit.getU8Encoder()], ["reserve0", kit.getU64Encoder()], ["reserve1", kit.getU64Encoder()]]), (value) => ({ ...value, discriminator: 2, migrationVersion: 0 }));
|
|
777
|
+
}
|
|
778
|
+
function getSwappedEventDecoder() {
|
|
779
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(SWAPPED_EVENT_DISCRIMINATOR, kit.getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, kit.getU8Decoder())], ["pool", kit.getAddressDecoder()], ["trader", kit.getAddressDecoder()], ["zeroForOne", kit.getU8Decoder()], ["amountIn", kit.getU64Decoder()], ["amountOut", kit.getU64Decoder()], ["tradeFee", kit.getU64Decoder()], ["protocolFee", kit.getU64Decoder()], ["creatorFee", kit.getU64Decoder()], ["creatorFeeOnInput", kit.getU8Decoder()], ["reserve0", kit.getU64Decoder()], ["reserve1", kit.getU64Decoder()]]);
|
|
780
|
+
}
|
|
781
|
+
function getSwappedEventCodec() {
|
|
782
|
+
return kit.combineCodec(getSwappedEventEncoder(), getSwappedEventDecoder());
|
|
783
|
+
}
|
|
784
|
+
function parseSwappedEvent(data) {
|
|
785
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(SWAPPED_EVENT_DISCRIMINATOR), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(SWAPPED_EVENT_DISCRIMINATOR2), 1)) {
|
|
786
|
+
return getSwappedEventDecoder().decode(data);
|
|
787
|
+
}
|
|
788
|
+
throw new Error('The provided data does not match the "SwappedEvent" event discriminators.');
|
|
789
|
+
}
|
|
790
|
+
var LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR = 3;
|
|
791
|
+
function getLiquidityChangedEventDiscriminatorBytes() {
|
|
792
|
+
return kit.getU8Encoder().encode(LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR);
|
|
793
|
+
}
|
|
794
|
+
var LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR2 = 0;
|
|
795
|
+
function getLiquidityChangedEventDiscriminator2Bytes() {
|
|
796
|
+
return kit.getU8Encoder().encode(LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR2);
|
|
797
|
+
}
|
|
798
|
+
function getLiquidityChangedEventEncoder() {
|
|
799
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["migrationVersion", kit.getU8Encoder()], ["pool", kit.getAddressEncoder()], ["owner", kit.getAddressEncoder()], ["isDeposit", kit.getU8Encoder()], ["lpAmount", kit.getU64Encoder()], ["amount0", kit.getU64Encoder()], ["amount1", kit.getU64Encoder()], ["lpSupply", kit.getU64Encoder()]]), (value) => ({ ...value, discriminator: 3, migrationVersion: 0 }));
|
|
800
|
+
}
|
|
801
|
+
function getLiquidityChangedEventDecoder() {
|
|
802
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR, kit.getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, kit.getU8Decoder())], ["pool", kit.getAddressDecoder()], ["owner", kit.getAddressDecoder()], ["isDeposit", kit.getU8Decoder()], ["lpAmount", kit.getU64Decoder()], ["amount0", kit.getU64Decoder()], ["amount1", kit.getU64Decoder()], ["lpSupply", kit.getU64Decoder()]]);
|
|
803
|
+
}
|
|
804
|
+
function getLiquidityChangedEventCodec() {
|
|
805
|
+
return kit.combineCodec(getLiquidityChangedEventEncoder(), getLiquidityChangedEventDecoder());
|
|
806
|
+
}
|
|
807
|
+
function parseLiquidityChangedEvent(data) {
|
|
808
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR2), 1)) {
|
|
809
|
+
return getLiquidityChangedEventDecoder().decode(data);
|
|
810
|
+
}
|
|
811
|
+
throw new Error('The provided data does not match the "LiquidityChangedEvent" event discriminators.');
|
|
812
|
+
}
|
|
813
|
+
var FEES_COLLECTED_EVENT_DISCRIMINATOR = 4;
|
|
814
|
+
function getFeesCollectedEventDiscriminatorBytes() {
|
|
815
|
+
return kit.getU8Encoder().encode(FEES_COLLECTED_EVENT_DISCRIMINATOR);
|
|
816
|
+
}
|
|
817
|
+
var FEES_COLLECTED_EVENT_DISCRIMINATOR2 = 0;
|
|
818
|
+
function getFeesCollectedEventDiscriminator2Bytes() {
|
|
819
|
+
return kit.getU8Encoder().encode(FEES_COLLECTED_EVENT_DISCRIMINATOR2);
|
|
820
|
+
}
|
|
821
|
+
function getFeesCollectedEventEncoder() {
|
|
822
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["migrationVersion", kit.getU8Encoder()], ["pool", kit.getAddressEncoder()], ["collector", kit.getAddressEncoder()], ["isProtocol", kit.getU8Encoder()], ["amount0", kit.getU64Encoder()], ["amount1", kit.getU64Encoder()]]), (value) => ({ ...value, discriminator: 4, migrationVersion: 0 }));
|
|
823
|
+
}
|
|
824
|
+
function getFeesCollectedEventDecoder() {
|
|
825
|
+
return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(FEES_COLLECTED_EVENT_DISCRIMINATOR, kit.getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, kit.getU8Decoder())], ["pool", kit.getAddressDecoder()], ["collector", kit.getAddressDecoder()], ["isProtocol", kit.getU8Decoder()], ["amount0", kit.getU64Decoder()], ["amount1", kit.getU64Decoder()]]);
|
|
826
|
+
}
|
|
827
|
+
function getFeesCollectedEventCodec() {
|
|
828
|
+
return kit.combineCodec(getFeesCollectedEventEncoder(), getFeesCollectedEventDecoder());
|
|
829
|
+
}
|
|
830
|
+
function parseFeesCollectedEvent(data) {
|
|
831
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(FEES_COLLECTED_EVENT_DISCRIMINATOR), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(FEES_COLLECTED_EVENT_DISCRIMINATOR2), 1)) {
|
|
832
|
+
return getFeesCollectedEventDecoder().decode(data);
|
|
833
|
+
}
|
|
834
|
+
throw new Error('The provided data does not match the "FeesCollectedEvent" event discriminators.');
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
// src/generated/events/logs.ts
|
|
838
|
+
function decodePoolCreatedEvent(data) {
|
|
839
|
+
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
840
|
+
const discriminatorBytes = getPoolCreatedEventDiscriminatorBytes();
|
|
841
|
+
if (bytes.length < 2) {
|
|
842
|
+
throw new RangeError(
|
|
843
|
+
`the provided data is too short for the "PoolCreatedEvent" event envelope`
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
for (let index = 0; index < 1; index += 1) {
|
|
847
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
848
|
+
throw new RangeError(
|
|
849
|
+
'the provided data does not match the "PoolCreatedEvent" event discriminator.'
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
const sourceVersion = bytes[1];
|
|
854
|
+
if (sourceVersion !== 0) {
|
|
855
|
+
throw new RangeError(
|
|
856
|
+
`event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
return { name: "poolCreated", data: getPoolCreatedEventDecoder().decode(bytes) };
|
|
860
|
+
}
|
|
861
|
+
function parsePoolCreatedEventFromLog(log) {
|
|
862
|
+
const prefix = "Program data: ";
|
|
863
|
+
if (!log.startsWith(prefix)) {
|
|
864
|
+
return null;
|
|
865
|
+
}
|
|
866
|
+
const bytes = kit.getBase64Encoder().encode(log.slice(prefix.length));
|
|
867
|
+
if (bytes.length < 2) {
|
|
868
|
+
return null;
|
|
869
|
+
}
|
|
870
|
+
const discriminatorBytes = getPoolCreatedEventDiscriminatorBytes();
|
|
871
|
+
for (let index = 0; index < 1; index += 1) {
|
|
872
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
873
|
+
return null;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
if (bytes[1] !== 0) {
|
|
877
|
+
return null;
|
|
878
|
+
}
|
|
879
|
+
return decodePoolCreatedEvent(bytes);
|
|
880
|
+
}
|
|
881
|
+
function decodeSwappedEvent(data) {
|
|
882
|
+
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
883
|
+
const discriminatorBytes = getSwappedEventDiscriminatorBytes();
|
|
884
|
+
if (bytes.length < 2) {
|
|
885
|
+
throw new RangeError(
|
|
886
|
+
`the provided data is too short for the "SwappedEvent" event envelope`
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
for (let index = 0; index < 1; index += 1) {
|
|
890
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
891
|
+
throw new RangeError(
|
|
892
|
+
'the provided data does not match the "SwappedEvent" event discriminator.'
|
|
893
|
+
);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
const sourceVersion = bytes[1];
|
|
897
|
+
if (sourceVersion !== 0) {
|
|
898
|
+
throw new RangeError(
|
|
899
|
+
`event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
return { name: "swapped", data: getSwappedEventDecoder().decode(bytes) };
|
|
903
|
+
}
|
|
904
|
+
function parseSwappedEventFromLog(log) {
|
|
905
|
+
const prefix = "Program data: ";
|
|
906
|
+
if (!log.startsWith(prefix)) {
|
|
907
|
+
return null;
|
|
908
|
+
}
|
|
909
|
+
const bytes = kit.getBase64Encoder().encode(log.slice(prefix.length));
|
|
910
|
+
if (bytes.length < 2) {
|
|
911
|
+
return null;
|
|
912
|
+
}
|
|
913
|
+
const discriminatorBytes = getSwappedEventDiscriminatorBytes();
|
|
914
|
+
for (let index = 0; index < 1; index += 1) {
|
|
915
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
916
|
+
return null;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
if (bytes[1] !== 0) {
|
|
920
|
+
return null;
|
|
921
|
+
}
|
|
922
|
+
return decodeSwappedEvent(bytes);
|
|
923
|
+
}
|
|
924
|
+
function decodeLiquidityChangedEvent(data) {
|
|
925
|
+
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
926
|
+
const discriminatorBytes = getLiquidityChangedEventDiscriminatorBytes();
|
|
927
|
+
if (bytes.length < 2) {
|
|
928
|
+
throw new RangeError(
|
|
929
|
+
`the provided data is too short for the "LiquidityChangedEvent" event envelope`
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
for (let index = 0; index < 1; index += 1) {
|
|
933
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
934
|
+
throw new RangeError(
|
|
935
|
+
'the provided data does not match the "LiquidityChangedEvent" event discriminator.'
|
|
936
|
+
);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
const sourceVersion = bytes[1];
|
|
940
|
+
if (sourceVersion !== 0) {
|
|
941
|
+
throw new RangeError(
|
|
942
|
+
`event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
|
|
943
|
+
);
|
|
944
|
+
}
|
|
945
|
+
return { name: "liquidityChanged", data: getLiquidityChangedEventDecoder().decode(bytes) };
|
|
946
|
+
}
|
|
947
|
+
function parseLiquidityChangedEventFromLog(log) {
|
|
948
|
+
const prefix = "Program data: ";
|
|
949
|
+
if (!log.startsWith(prefix)) {
|
|
950
|
+
return null;
|
|
951
|
+
}
|
|
952
|
+
const bytes = kit.getBase64Encoder().encode(log.slice(prefix.length));
|
|
953
|
+
if (bytes.length < 2) {
|
|
954
|
+
return null;
|
|
955
|
+
}
|
|
956
|
+
const discriminatorBytes = getLiquidityChangedEventDiscriminatorBytes();
|
|
957
|
+
for (let index = 0; index < 1; index += 1) {
|
|
958
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
959
|
+
return null;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
if (bytes[1] !== 0) {
|
|
963
|
+
return null;
|
|
964
|
+
}
|
|
965
|
+
return decodeLiquidityChangedEvent(bytes);
|
|
966
|
+
}
|
|
967
|
+
function decodeFeesCollectedEvent(data) {
|
|
968
|
+
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
969
|
+
const discriminatorBytes = getFeesCollectedEventDiscriminatorBytes();
|
|
970
|
+
if (bytes.length < 2) {
|
|
971
|
+
throw new RangeError(
|
|
972
|
+
`the provided data is too short for the "FeesCollectedEvent" event envelope`
|
|
973
|
+
);
|
|
974
|
+
}
|
|
975
|
+
for (let index = 0; index < 1; index += 1) {
|
|
976
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
977
|
+
throw new RangeError(
|
|
978
|
+
'the provided data does not match the "FeesCollectedEvent" event discriminator.'
|
|
979
|
+
);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
const sourceVersion = bytes[1];
|
|
983
|
+
if (sourceVersion !== 0) {
|
|
984
|
+
throw new RangeError(
|
|
985
|
+
`event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
return { name: "feesCollected", data: getFeesCollectedEventDecoder().decode(bytes) };
|
|
989
|
+
}
|
|
990
|
+
function parseFeesCollectedEventFromLog(log) {
|
|
991
|
+
const prefix = "Program data: ";
|
|
992
|
+
if (!log.startsWith(prefix)) {
|
|
993
|
+
return null;
|
|
994
|
+
}
|
|
995
|
+
const bytes = kit.getBase64Encoder().encode(log.slice(prefix.length));
|
|
996
|
+
if (bytes.length < 2) {
|
|
997
|
+
return null;
|
|
998
|
+
}
|
|
999
|
+
const discriminatorBytes = getFeesCollectedEventDiscriminatorBytes();
|
|
1000
|
+
for (let index = 0; index < 1; index += 1) {
|
|
1001
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
1002
|
+
return null;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
if (bytes[1] !== 0) {
|
|
1006
|
+
return null;
|
|
1007
|
+
}
|
|
1008
|
+
return decodeFeesCollectedEvent(bytes);
|
|
1009
|
+
}
|
|
1010
|
+
function unrecognizedEventVersion(log) {
|
|
1011
|
+
const prefix = "Program data: ";
|
|
1012
|
+
if (!log.startsWith(prefix)) {
|
|
1013
|
+
return null;
|
|
1014
|
+
}
|
|
1015
|
+
const bytes = kit.getBase64Encoder().encode(log.slice(prefix.length));
|
|
1016
|
+
if (bytes.length >= 1 && bytes[0] === 1) {
|
|
1017
|
+
return bytes.length < 2 ? 'event "poolCreated" log is too short for its version envelope' : `event "poolCreated" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
|
|
1018
|
+
}
|
|
1019
|
+
if (bytes.length >= 1 && bytes[0] === 2) {
|
|
1020
|
+
return bytes.length < 2 ? 'event "swapped" log is too short for its version envelope' : `event "swapped" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
|
|
1021
|
+
}
|
|
1022
|
+
if (bytes.length >= 1 && bytes[0] === 3) {
|
|
1023
|
+
return bytes.length < 2 ? 'event "liquidityChanged" log is too short for its version envelope' : `event "liquidityChanged" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
|
|
1024
|
+
}
|
|
1025
|
+
if (bytes.length >= 1 && bytes[0] === 4) {
|
|
1026
|
+
return bytes.length < 2 ? 'event "feesCollected" log is too short for its version envelope' : `event "feesCollected" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
|
|
1027
|
+
}
|
|
1028
|
+
return null;
|
|
1029
|
+
}
|
|
1030
|
+
var PINA_AMM_EVENT_SOURCE_ADDRESS = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV";
|
|
1031
|
+
var PROGRAM_INVOKE_LOG = /^Program (\S+) invoke \[\d+\]$/;
|
|
1032
|
+
var PROGRAM_EXIT_LOG = /^Program (\S+) (?:success|failed: .*)$/;
|
|
1033
|
+
function parsePinaAmmEventsFromLogs(logs, programAddress = PINA_AMM_EVENT_SOURCE_ADDRESS) {
|
|
1034
|
+
const discovered = [];
|
|
1035
|
+
const frames = [];
|
|
1036
|
+
for (const log of logs) {
|
|
1037
|
+
const invoke = PROGRAM_INVOKE_LOG.exec(log);
|
|
1038
|
+
if (invoke !== null) {
|
|
1039
|
+
frames.push(invoke[1] ?? "");
|
|
1040
|
+
continue;
|
|
1041
|
+
}
|
|
1042
|
+
const exit = PROGRAM_EXIT_LOG.exec(log);
|
|
1043
|
+
if (exit !== null) {
|
|
1044
|
+
frames.pop();
|
|
1045
|
+
continue;
|
|
1046
|
+
}
|
|
1047
|
+
if (frames.length === 0 || frames[frames.length - 1] !== programAddress) {
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
const poolCreated = parsePoolCreatedEventFromLog(log);
|
|
1051
|
+
if (poolCreated !== null) {
|
|
1052
|
+
discovered.push(poolCreated);
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
1055
|
+
const swapped = parseSwappedEventFromLog(log);
|
|
1056
|
+
if (swapped !== null) {
|
|
1057
|
+
discovered.push(swapped);
|
|
1058
|
+
continue;
|
|
1059
|
+
}
|
|
1060
|
+
const liquidityChanged = parseLiquidityChangedEventFromLog(log);
|
|
1061
|
+
if (liquidityChanged !== null) {
|
|
1062
|
+
discovered.push(liquidityChanged);
|
|
1063
|
+
continue;
|
|
1064
|
+
}
|
|
1065
|
+
const feesCollected = parseFeesCollectedEventFromLog(log);
|
|
1066
|
+
if (feesCollected !== null) {
|
|
1067
|
+
discovered.push(feesCollected);
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
const unknownVersion = unrecognizedEventVersion(log);
|
|
1071
|
+
if (unknownVersion !== null) {
|
|
1072
|
+
throw new RangeError(unknownVersion);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
return discovered;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
exports.AMM_CONFIG_DISCRIMINATOR = AMM_CONFIG_DISCRIMINATOR;
|
|
1079
|
+
exports.AMM_CONFIG_DISCRIMINATOR2 = AMM_CONFIG_DISCRIMINATOR2;
|
|
1080
|
+
exports.AMM_CONFIG_MIGRATION_VERSION = AMM_CONFIG_MIGRATION_VERSION;
|
|
1081
|
+
exports.COLLECT_CREATOR_FEES_DISCRIMINATOR = COLLECT_CREATOR_FEES_DISCRIMINATOR;
|
|
1082
|
+
exports.COLLECT_PROTOCOL_FEES_DISCRIMINATOR = COLLECT_PROTOCOL_FEES_DISCRIMINATOR;
|
|
1083
|
+
exports.CREATE_CONFIG_DISCRIMINATOR = CREATE_CONFIG_DISCRIMINATOR;
|
|
1084
|
+
exports.CREATE_POOL_DISCRIMINATOR = CREATE_POOL_DISCRIMINATOR;
|
|
1085
|
+
exports.DEPOSIT_DISCRIMINATOR = DEPOSIT_DISCRIMINATOR;
|
|
1086
|
+
exports.FEES_COLLECTED_EVENT_DISCRIMINATOR = FEES_COLLECTED_EVENT_DISCRIMINATOR;
|
|
1087
|
+
exports.FEES_COLLECTED_EVENT_DISCRIMINATOR2 = FEES_COLLECTED_EVENT_DISCRIMINATOR2;
|
|
1088
|
+
exports.LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR = LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR;
|
|
1089
|
+
exports.LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR2 = LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR2;
|
|
1090
|
+
exports.MIGRATE_DISCRIMINATOR = MIGRATE_DISCRIMINATOR;
|
|
1091
|
+
exports.PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY = PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY;
|
|
1092
|
+
exports.PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY = PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY;
|
|
1093
|
+
exports.PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE = PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE;
|
|
1094
|
+
exports.PINA_AMM_ERROR__INVALID_FEE_RATES = PINA_AMM_ERROR__INVALID_FEE_RATES;
|
|
1095
|
+
exports.PINA_AMM_ERROR__INVALID_MINT_ORDER = PINA_AMM_ERROR__INVALID_MINT_ORDER;
|
|
1096
|
+
exports.PINA_AMM_ERROR__INVALID_PROGRAM_DATA = PINA_AMM_ERROR__INVALID_PROGRAM_DATA;
|
|
1097
|
+
exports.PINA_AMM_ERROR__INVARIANT_VIOLATION = PINA_AMM_ERROR__INVARIANT_VIOLATION;
|
|
1098
|
+
exports.PINA_AMM_ERROR__MATH_OVERFLOW = PINA_AMM_ERROR__MATH_OVERFLOW;
|
|
1099
|
+
exports.PINA_AMM_ERROR__POOL_ACCOUNT_MISMATCH = PINA_AMM_ERROR__POOL_ACCOUNT_MISMATCH;
|
|
1100
|
+
exports.PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED = PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED;
|
|
1101
|
+
exports.PINA_AMM_ERROR__SLIPPAGE_EXCEEDED = PINA_AMM_ERROR__SLIPPAGE_EXCEEDED;
|
|
1102
|
+
exports.PINA_AMM_ERROR__UNAUTHORIZED = PINA_AMM_ERROR__UNAUTHORIZED;
|
|
1103
|
+
exports.PINA_AMM_ERROR__UNSUPPORTED_MINT = PINA_AMM_ERROR__UNSUPPORTED_MINT;
|
|
1104
|
+
exports.PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH = PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH;
|
|
1105
|
+
exports.PINA_AMM_ERROR__ZERO_AMOUNT = PINA_AMM_ERROR__ZERO_AMOUNT;
|
|
1106
|
+
exports.PINA_AMM_EVENT_SOURCE_ADDRESS = PINA_AMM_EVENT_SOURCE_ADDRESS;
|
|
1107
|
+
exports.PINA_AMM_PROGRAM_ADDRESS = PINA_AMM_PROGRAM_ADDRESS;
|
|
1108
|
+
exports.POOL_CREATED_EVENT_DISCRIMINATOR = POOL_CREATED_EVENT_DISCRIMINATOR;
|
|
1109
|
+
exports.POOL_CREATED_EVENT_DISCRIMINATOR2 = POOL_CREATED_EVENT_DISCRIMINATOR2;
|
|
1110
|
+
exports.POOL_DISCRIMINATOR = POOL_DISCRIMINATOR;
|
|
1111
|
+
exports.POOL_DISCRIMINATOR2 = POOL_DISCRIMINATOR2;
|
|
1112
|
+
exports.POOL_MIGRATION_VERSION = POOL_MIGRATION_VERSION;
|
|
1113
|
+
exports.PinaAmmAccount = PinaAmmAccount;
|
|
1114
|
+
exports.PinaAmmEvent = PinaAmmEvent;
|
|
1115
|
+
exports.PinaAmmInstruction = PinaAmmInstruction;
|
|
1116
|
+
exports.SET_POOL_CREATOR_DISCRIMINATOR = SET_POOL_CREATOR_DISCRIMINATOR;
|
|
1117
|
+
exports.SWAPPED_EVENT_DISCRIMINATOR = SWAPPED_EVENT_DISCRIMINATOR;
|
|
1118
|
+
exports.SWAPPED_EVENT_DISCRIMINATOR2 = SWAPPED_EVENT_DISCRIMINATOR2;
|
|
1119
|
+
exports.SWAP_EXACT_IN_DISCRIMINATOR = SWAP_EXACT_IN_DISCRIMINATOR;
|
|
1120
|
+
exports.SWAP_EXACT_OUT_DISCRIMINATOR = SWAP_EXACT_OUT_DISCRIMINATOR;
|
|
1121
|
+
exports.UPDATE_CONFIG_DISCRIMINATOR = UPDATE_CONFIG_DISCRIMINATOR;
|
|
1122
|
+
exports.WITHDRAW_DISCRIMINATOR = WITHDRAW_DISCRIMINATOR;
|
|
1123
|
+
exports.ammConfigNeedsMigration = ammConfigNeedsMigration;
|
|
1124
|
+
exports.decodeAmmConfig = decodeAmmConfig;
|
|
1125
|
+
exports.decodeFeesCollectedEvent = decodeFeesCollectedEvent;
|
|
1126
|
+
exports.decodeLiquidityChangedEvent = decodeLiquidityChangedEvent;
|
|
1127
|
+
exports.decodePool = decodePool;
|
|
1128
|
+
exports.decodePoolCreatedEvent = decodePoolCreatedEvent;
|
|
1129
|
+
exports.decodeSwappedEvent = decodeSwappedEvent;
|
|
1130
|
+
exports.fetchAllAmmConfig = fetchAllAmmConfig;
|
|
1131
|
+
exports.fetchAllMaybeAmmConfig = fetchAllMaybeAmmConfig;
|
|
1132
|
+
exports.fetchAllMaybePool = fetchAllMaybePool;
|
|
1133
|
+
exports.fetchAllPool = fetchAllPool;
|
|
1134
|
+
exports.fetchAmmConfig = fetchAmmConfig;
|
|
1135
|
+
exports.fetchAmmConfigFromSeeds = fetchAmmConfigFromSeeds;
|
|
1136
|
+
exports.fetchMaybeAmmConfig = fetchMaybeAmmConfig;
|
|
1137
|
+
exports.fetchMaybeAmmConfigFromSeeds = fetchMaybeAmmConfigFromSeeds;
|
|
1138
|
+
exports.fetchMaybePool = fetchMaybePool;
|
|
1139
|
+
exports.fetchMaybePoolFromSeeds = fetchMaybePoolFromSeeds;
|
|
1140
|
+
exports.fetchPool = fetchPool;
|
|
1141
|
+
exports.fetchPoolFromSeeds = fetchPoolFromSeeds;
|
|
1142
|
+
exports.findAmmConfigPda = findAmmConfigPda;
|
|
1143
|
+
exports.findPoolLpMintPda = findPoolLpMintPda;
|
|
1144
|
+
exports.findPoolPda = findPoolPda;
|
|
1145
|
+
exports.findPoolVaultPda = findPoolVaultPda;
|
|
1146
|
+
exports.getAmmConfigCodec = getAmmConfigCodec;
|
|
1147
|
+
exports.getAmmConfigDecoder = getAmmConfigDecoder;
|
|
1148
|
+
exports.getAmmConfigDiscriminator2Bytes = getAmmConfigDiscriminator2Bytes;
|
|
1149
|
+
exports.getAmmConfigDiscriminatorBytes = getAmmConfigDiscriminatorBytes;
|
|
1150
|
+
exports.getAmmConfigEncoder = getAmmConfigEncoder;
|
|
1151
|
+
exports.getCollectCreatorFeesDiscriminatorBytes = getCollectCreatorFeesDiscriminatorBytes;
|
|
1152
|
+
exports.getCollectCreatorFeesInstruction = getCollectCreatorFeesInstruction;
|
|
1153
|
+
exports.getCollectCreatorFeesInstructionDataCodec = getCollectCreatorFeesInstructionDataCodec;
|
|
1154
|
+
exports.getCollectCreatorFeesInstructionDataDecoder = getCollectCreatorFeesInstructionDataDecoder;
|
|
1155
|
+
exports.getCollectCreatorFeesInstructionDataEncoder = getCollectCreatorFeesInstructionDataEncoder;
|
|
1156
|
+
exports.getCollectProtocolFeesDiscriminatorBytes = getCollectProtocolFeesDiscriminatorBytes;
|
|
1157
|
+
exports.getCollectProtocolFeesInstruction = getCollectProtocolFeesInstruction;
|
|
1158
|
+
exports.getCollectProtocolFeesInstructionDataCodec = getCollectProtocolFeesInstructionDataCodec;
|
|
1159
|
+
exports.getCollectProtocolFeesInstructionDataDecoder = getCollectProtocolFeesInstructionDataDecoder;
|
|
1160
|
+
exports.getCollectProtocolFeesInstructionDataEncoder = getCollectProtocolFeesInstructionDataEncoder;
|
|
1161
|
+
exports.getCreateConfigDiscriminatorBytes = getCreateConfigDiscriminatorBytes;
|
|
1162
|
+
exports.getCreateConfigInstruction = getCreateConfigInstruction;
|
|
1163
|
+
exports.getCreateConfigInstructionDataCodec = getCreateConfigInstructionDataCodec;
|
|
1164
|
+
exports.getCreateConfigInstructionDataDecoder = getCreateConfigInstructionDataDecoder;
|
|
1165
|
+
exports.getCreateConfigInstructionDataEncoder = getCreateConfigInstructionDataEncoder;
|
|
1166
|
+
exports.getCreatePoolDiscriminatorBytes = getCreatePoolDiscriminatorBytes;
|
|
1167
|
+
exports.getCreatePoolInstruction = getCreatePoolInstruction;
|
|
1168
|
+
exports.getCreatePoolInstructionAsync = getCreatePoolInstructionAsync;
|
|
1169
|
+
exports.getCreatePoolInstructionDataCodec = getCreatePoolInstructionDataCodec;
|
|
1170
|
+
exports.getCreatePoolInstructionDataDecoder = getCreatePoolInstructionDataDecoder;
|
|
1171
|
+
exports.getCreatePoolInstructionDataEncoder = getCreatePoolInstructionDataEncoder;
|
|
1172
|
+
exports.getDepositDiscriminatorBytes = getDepositDiscriminatorBytes;
|
|
1173
|
+
exports.getDepositInstruction = getDepositInstruction;
|
|
1174
|
+
exports.getDepositInstructionDataCodec = getDepositInstructionDataCodec;
|
|
1175
|
+
exports.getDepositInstructionDataDecoder = getDepositInstructionDataDecoder;
|
|
1176
|
+
exports.getDepositInstructionDataEncoder = getDepositInstructionDataEncoder;
|
|
1177
|
+
exports.getFeesCollectedEventCodec = getFeesCollectedEventCodec;
|
|
1178
|
+
exports.getFeesCollectedEventDecoder = getFeesCollectedEventDecoder;
|
|
1179
|
+
exports.getFeesCollectedEventDiscriminator2Bytes = getFeesCollectedEventDiscriminator2Bytes;
|
|
1180
|
+
exports.getFeesCollectedEventDiscriminatorBytes = getFeesCollectedEventDiscriminatorBytes;
|
|
1181
|
+
exports.getFeesCollectedEventEncoder = getFeesCollectedEventEncoder;
|
|
1182
|
+
exports.getLiquidityChangedEventCodec = getLiquidityChangedEventCodec;
|
|
1183
|
+
exports.getLiquidityChangedEventDecoder = getLiquidityChangedEventDecoder;
|
|
1184
|
+
exports.getLiquidityChangedEventDiscriminator2Bytes = getLiquidityChangedEventDiscriminator2Bytes;
|
|
1185
|
+
exports.getLiquidityChangedEventDiscriminatorBytes = getLiquidityChangedEventDiscriminatorBytes;
|
|
1186
|
+
exports.getLiquidityChangedEventEncoder = getLiquidityChangedEventEncoder;
|
|
1187
|
+
exports.getMigrateDiscriminatorBytes = getMigrateDiscriminatorBytes;
|
|
1188
|
+
exports.getMigrateInstruction = getMigrateInstruction;
|
|
1189
|
+
exports.getPinaAmmErrorMessage = getPinaAmmErrorMessage;
|
|
1190
|
+
exports.getPoolCodec = getPoolCodec;
|
|
1191
|
+
exports.getPoolCreatedEventCodec = getPoolCreatedEventCodec;
|
|
1192
|
+
exports.getPoolCreatedEventDecoder = getPoolCreatedEventDecoder;
|
|
1193
|
+
exports.getPoolCreatedEventDiscriminator2Bytes = getPoolCreatedEventDiscriminator2Bytes;
|
|
1194
|
+
exports.getPoolCreatedEventDiscriminatorBytes = getPoolCreatedEventDiscriminatorBytes;
|
|
1195
|
+
exports.getPoolCreatedEventEncoder = getPoolCreatedEventEncoder;
|
|
1196
|
+
exports.getPoolDecoder = getPoolDecoder;
|
|
1197
|
+
exports.getPoolDiscriminator2Bytes = getPoolDiscriminator2Bytes;
|
|
1198
|
+
exports.getPoolDiscriminatorBytes = getPoolDiscriminatorBytes;
|
|
1199
|
+
exports.getPoolEncoder = getPoolEncoder;
|
|
1200
|
+
exports.getSetPoolCreatorDiscriminatorBytes = getSetPoolCreatorDiscriminatorBytes;
|
|
1201
|
+
exports.getSetPoolCreatorInstruction = getSetPoolCreatorInstruction;
|
|
1202
|
+
exports.getSetPoolCreatorInstructionDataCodec = getSetPoolCreatorInstructionDataCodec;
|
|
1203
|
+
exports.getSetPoolCreatorInstructionDataDecoder = getSetPoolCreatorInstructionDataDecoder;
|
|
1204
|
+
exports.getSetPoolCreatorInstructionDataEncoder = getSetPoolCreatorInstructionDataEncoder;
|
|
1205
|
+
exports.getSwapExactInDiscriminatorBytes = getSwapExactInDiscriminatorBytes;
|
|
1206
|
+
exports.getSwapExactInInstruction = getSwapExactInInstruction;
|
|
1207
|
+
exports.getSwapExactInInstructionDataCodec = getSwapExactInInstructionDataCodec;
|
|
1208
|
+
exports.getSwapExactInInstructionDataDecoder = getSwapExactInInstructionDataDecoder;
|
|
1209
|
+
exports.getSwapExactInInstructionDataEncoder = getSwapExactInInstructionDataEncoder;
|
|
1210
|
+
exports.getSwapExactOutDiscriminatorBytes = getSwapExactOutDiscriminatorBytes;
|
|
1211
|
+
exports.getSwapExactOutInstruction = getSwapExactOutInstruction;
|
|
1212
|
+
exports.getSwapExactOutInstructionDataCodec = getSwapExactOutInstructionDataCodec;
|
|
1213
|
+
exports.getSwapExactOutInstructionDataDecoder = getSwapExactOutInstructionDataDecoder;
|
|
1214
|
+
exports.getSwapExactOutInstructionDataEncoder = getSwapExactOutInstructionDataEncoder;
|
|
1215
|
+
exports.getSwappedEventCodec = getSwappedEventCodec;
|
|
1216
|
+
exports.getSwappedEventDecoder = getSwappedEventDecoder;
|
|
1217
|
+
exports.getSwappedEventDiscriminator2Bytes = getSwappedEventDiscriminator2Bytes;
|
|
1218
|
+
exports.getSwappedEventDiscriminatorBytes = getSwappedEventDiscriminatorBytes;
|
|
1219
|
+
exports.getSwappedEventEncoder = getSwappedEventEncoder;
|
|
1220
|
+
exports.getUpdateConfigDiscriminatorBytes = getUpdateConfigDiscriminatorBytes;
|
|
1221
|
+
exports.getUpdateConfigInstruction = getUpdateConfigInstruction;
|
|
1222
|
+
exports.getUpdateConfigInstructionDataCodec = getUpdateConfigInstructionDataCodec;
|
|
1223
|
+
exports.getUpdateConfigInstructionDataDecoder = getUpdateConfigInstructionDataDecoder;
|
|
1224
|
+
exports.getUpdateConfigInstructionDataEncoder = getUpdateConfigInstructionDataEncoder;
|
|
1225
|
+
exports.getWithdrawDiscriminatorBytes = getWithdrawDiscriminatorBytes;
|
|
1226
|
+
exports.getWithdrawInstruction = getWithdrawInstruction;
|
|
1227
|
+
exports.getWithdrawInstructionDataCodec = getWithdrawInstructionDataCodec;
|
|
1228
|
+
exports.getWithdrawInstructionDataDecoder = getWithdrawInstructionDataDecoder;
|
|
1229
|
+
exports.getWithdrawInstructionDataEncoder = getWithdrawInstructionDataEncoder;
|
|
1230
|
+
exports.identifyPinaAmmAccount = identifyPinaAmmAccount;
|
|
1231
|
+
exports.identifyPinaAmmEvent = identifyPinaAmmEvent;
|
|
1232
|
+
exports.identifyPinaAmmInstruction = identifyPinaAmmInstruction;
|
|
1233
|
+
exports.isPinaAmmError = isPinaAmmError;
|
|
1234
|
+
exports.parseCollectCreatorFeesInstruction = parseCollectCreatorFeesInstruction;
|
|
1235
|
+
exports.parseCollectProtocolFeesInstruction = parseCollectProtocolFeesInstruction;
|
|
1236
|
+
exports.parseCreateConfigInstruction = parseCreateConfigInstruction;
|
|
1237
|
+
exports.parseCreatePoolInstruction = parseCreatePoolInstruction;
|
|
1238
|
+
exports.parseDepositInstruction = parseDepositInstruction;
|
|
1239
|
+
exports.parseFeesCollectedEvent = parseFeesCollectedEvent;
|
|
1240
|
+
exports.parseFeesCollectedEventFromLog = parseFeesCollectedEventFromLog;
|
|
1241
|
+
exports.parseLiquidityChangedEvent = parseLiquidityChangedEvent;
|
|
1242
|
+
exports.parseLiquidityChangedEventFromLog = parseLiquidityChangedEventFromLog;
|
|
1243
|
+
exports.parsePinaAmmEventsFromLogs = parsePinaAmmEventsFromLogs;
|
|
1244
|
+
exports.parsePinaAmmInstruction = parsePinaAmmInstruction;
|
|
1245
|
+
exports.parsePoolCreatedEvent = parsePoolCreatedEvent;
|
|
1246
|
+
exports.parsePoolCreatedEventFromLog = parsePoolCreatedEventFromLog;
|
|
1247
|
+
exports.parseSetPoolCreatorInstruction = parseSetPoolCreatorInstruction;
|
|
1248
|
+
exports.parseSwapExactInInstruction = parseSwapExactInInstruction;
|
|
1249
|
+
exports.parseSwapExactOutInstruction = parseSwapExactOutInstruction;
|
|
1250
|
+
exports.parseSwappedEvent = parseSwappedEvent;
|
|
1251
|
+
exports.parseSwappedEventFromLog = parseSwappedEventFromLog;
|
|
1252
|
+
exports.parseUpdateConfigInstruction = parseUpdateConfigInstruction;
|
|
1253
|
+
exports.parseWithdrawInstruction = parseWithdrawInstruction;
|
|
1254
|
+
exports.pinaAmmProgram = pinaAmmProgram;
|
|
1255
|
+
exports.poolNeedsMigration = poolNeedsMigration;
|
|
1256
|
+
//# sourceMappingURL=index.cjs.map
|
|
1257
|
+
//# sourceMappingURL=index.cjs.map
|