@lightprotocol/compressed-token 0.20.9 → 0.22.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.
@@ -1,824 +1,696 @@
1
- import { PackedMerkleContext, CompressedProof, ParsedTokenAccount, InputTokenDataWithContext as InputTokenDataWithContext$1, Rpc } from '@lightprotocol/stateless.js';
2
- import { PublicKey, AccountMeta, TransactionInstruction, Connection, Signer, ConfirmOptions, TransactionSignature, Keypair } from '@solana/web3.js';
1
+ import { Signer, PublicKey, ConfirmOptions, TransactionSignature, Commitment, Keypair, AccountMeta, TransactionInstruction, Connection } from '@solana/web3.js';
2
+ import { Rpc, TreeInfo, ParsedTokenAccount, PackedMerkleContextLegacy, CompressedCpiContext, ValidityProof, InputTokenDataWithContext as InputTokenDataWithContext$1, CompressedProof } from '@lightprotocol/stateless.js';
3
3
  import BN from 'bn.js';
4
+ import { Buffer } from 'buffer';
4
5
  import * as buffer_layout from 'buffer-layout';
5
- import { Buffer as Buffer$1 } from 'buffer';
6
6
 
7
- type CompressedCpiContext = {
8
- setContext: boolean;
9
- firstSetContext: boolean;
10
- cpiContextAccountIndex: number;
11
- };
12
- type TokenTransferOutputData = {
13
- /**
14
- * The owner of the output token account
15
- */
16
- owner: PublicKey;
17
- /**
18
- * The amount of tokens of the output token account
19
- */
20
- amount: BN;
21
- /**
22
- * lamports associated with the output token account
23
- */
24
- lamports: BN | null;
25
- /**
26
- * TokenExtension tlv
27
- */
28
- tlv: Buffer | null;
29
- };
30
- type PackedTokenTransferOutputData = {
31
- /**
32
- * The owner of the output token account
33
- */
34
- owner: PublicKey;
35
- /**
36
- * The amount of tokens of the output token account
37
- */
38
- amount: BN;
39
- /**
40
- * lamports associated with the output token account
41
- */
42
- lamports: BN | null;
43
- /**
44
- * Merkle tree pubkey index in remaining accounts
45
- */
46
- merkleTreeIndex: number;
47
- /**
48
- * TokenExtension tlv
49
- */
50
- tlv: Buffer | null;
51
- };
52
- type InputTokenDataWithContext = {
7
+ /**
8
+ * Approve a delegate to spend tokens
9
+ *
10
+ * @param rpc Rpc to use
11
+ * @param payer Fee payer
12
+ * @param mint SPL Mint address
13
+ * @param amount Number of tokens to delegate
14
+ * @param owner Owner of the SPL token account.
15
+ * @param delegate Address of the delegate
16
+ * @param confirmOptions Options for confirming the transaction
17
+ *
18
+ * @return Signature of the confirmed transaction
19
+ */
20
+ declare function approve(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, delegate: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
21
+
22
+ /**
23
+ * Check if the token pool info is initialized and has a balance.
24
+ * @param mint The mint of the token pool
25
+ * @param tokenPoolInfo The token pool info
26
+ * @returns True if the token pool info is initialized and has a balance
27
+ */
28
+ declare function checkTokenPoolInfo(tokenPoolInfo: TokenPoolInfo, mint: PublicKey): boolean;
29
+ /**
30
+ * Get the token pool infos for a given mint.
31
+ * @param rpc The RPC client
32
+ * @param mint The mint of the token pool
33
+ * @param commitment The commitment to use
34
+ *
35
+ * @returns The token pool infos
36
+ */
37
+ declare function getTokenPoolInfos(rpc: Rpc, mint: PublicKey, commitment?: Commitment): Promise<TokenPoolInfo[]>;
38
+ type TokenPoolActivity = {
39
+ signature: string;
53
40
  amount: BN;
54
- delegateIndex: number | null;
55
- merkleContext: PackedMerkleContext;
56
- rootIndex: number;
57
- lamports: BN | null;
58
- tlv: Buffer | null;
59
- };
60
- type DelegatedTransfer = {
61
- owner: PublicKey;
62
- delegateChangeAccountIndex: number | null;
63
- };
64
- type MintToInstructionData = {
65
- recipients: PublicKey[];
66
- amounts: BN[];
67
- lamports: BN | null;
68
- };
69
- type CompressSplTokenAccountInstructionData = {
70
- owner: PublicKey;
71
- remainingAmount: BN | null;
72
- cpiContext: CompressedCpiContext | null;
41
+ action: Action;
73
42
  };
74
- type CompressedTokenInstructionDataTransfer = {
75
- /**
76
- * Validity proof
77
- */
78
- proof: CompressedProof | null;
43
+ /**
44
+ * Token pool pda info.
45
+ */
46
+ type TokenPoolInfo = {
79
47
  /**
80
- * The mint of the transfer
48
+ * The mint of the token pool
81
49
  */
82
50
  mint: PublicKey;
83
51
  /**
84
- * Whether the signer is a delegate
85
- * TODO: implement delegated transfer struct
86
- */
87
- delegatedTransfer: DelegatedTransfer | null;
88
- /**
89
- * Input token data with packed merkle context
90
- */
91
- inputTokenDataWithContext: InputTokenDataWithContext[];
92
- /**
93
- * Data of the output token accounts
94
- */
95
- outputCompressedAccounts: PackedTokenTransferOutputData[];
96
- /**
97
- * Whether it's a compress or decompress action if compressOrDecompressAmount is non-null
98
- */
99
- isCompress: boolean;
100
- /**
101
- * If null, it's a transfer.
102
- * If some, the amount that is being deposited into (compress) or withdrawn from (decompress) the token escrow
103
- */
104
- compressOrDecompressAmount: BN | null;
105
- /**
106
- * CPI context if
107
- */
108
- cpiContext: CompressedCpiContext | null;
109
- /**
110
- * The index of the Merkle tree for a lamport change account.
52
+ * The token pool address
111
53
  */
112
- lamportsChangeAccountMerkleTreeIndex: number | null;
113
- };
114
- type TokenData = {
54
+ tokenPoolPda: PublicKey;
115
55
  /**
116
- * The mint associated with this account
56
+ * The token program of the token pool
117
57
  */
118
- mint: PublicKey;
58
+ tokenProgram: PublicKey;
119
59
  /**
120
- * The owner of this account
60
+ * count of txs and volume in the past 60 seconds.
121
61
  */
122
- owner: PublicKey;
62
+ activity?: {
63
+ txs: number;
64
+ amountAdded: BN;
65
+ amountRemoved: BN;
66
+ };
123
67
  /**
124
- * The amount of tokens this account holds
68
+ * Whether the token pool is initialized
125
69
  */
126
- amount: BN;
70
+ isInitialized: boolean;
127
71
  /**
128
- * If `delegate` is `Some` then `delegated_amount` represents the amount
129
- * authorized by the delegate
72
+ * The balance of the token pool
130
73
  */
131
- delegate: PublicKey | null;
74
+ balance: BN;
132
75
  /**
133
- * The account's state
76
+ * The index of the token pool
134
77
  */
135
- state: number;
78
+ poolIndex: number;
136
79
  /**
137
- * TokenExtension tlv
80
+ * The bump used to derive the token pool pda
138
81
  */
139
- tlv: Buffer | null;
82
+ bump: number;
140
83
  };
84
+ /**
85
+ * @internal
86
+ */
87
+ declare enum Action {
88
+ Compress = 1,
89
+ Decompress = 2,
90
+ Transfer = 3
91
+ }
92
+ /**
93
+ * For `compress` and `mintTo` instructions only.
94
+ * Select a random token pool info from the token pool infos.
95
+ *
96
+ * For `decompress`, use {@link selectTokenPoolInfosForDecompression} instead.
97
+ *
98
+ * @param infos The token pool infos
99
+ *
100
+ * @returns A random token pool info
101
+ */
102
+ declare function selectTokenPoolInfo(infos: TokenPoolInfo[]): TokenPoolInfo;
103
+ /**
104
+ * Select one or multiple token pool infos from the token pool infos.
105
+ *
106
+ * Use this function for `decompress`.
107
+ *
108
+ * For `compress`, `mintTo` use {@link selectTokenPoolInfo} instead.
109
+ *
110
+ * @param infos The token pool infos
111
+ * @param decompressAmount The amount of tokens to withdraw
112
+ *
113
+ * @returns Array with one or more token pool infos.
114
+ */
115
+ declare function selectTokenPoolInfosForDecompression(infos: TokenPoolInfo[], decompressAmount: number | BN): TokenPoolInfo[];
141
116
 
142
- type PackCompressedTokenAccountsParams = {
143
- /** Input state to be consumed */
144
- inputCompressedTokenAccounts: ParsedTokenAccount[];
145
- /**
146
- * State trees that the output should be inserted into. Defaults to the 0th
147
- * state tree of the input state. Gets padded to the length of
148
- * outputCompressedAccounts.
149
- */
150
- outputStateTrees?: PublicKey[] | PublicKey;
151
- /** Optional remaining accounts to append to */
152
- remainingAccounts?: PublicKey[];
153
- /**
154
- * Root indices that are used on-chain to fetch the correct root
155
- * from the state Merkle tree account for validity proof verification.
156
- */
157
- rootIndices: number[];
158
- tokenTransferOutputs: TokenTransferOutputData[];
159
- };
160
117
  /**
161
- * Packs Compressed Token Accounts.
118
+ * Mint compressed tokens to a solana address from an external mint authority
119
+ *
120
+ * @param rpc Rpc to use
121
+ * @param payer Fee payer
122
+ * @param mint SPL Mint address
123
+ * @param toPubkey Address of the account to mint to
124
+ * @param authority Minting authority
125
+ * @param amount Amount to mint
126
+ * @param outputStateTreeInfo Optional: State tree account that the compressed
127
+ * tokens should be inserted into. Defaults to a
128
+ * shared state tree account.
129
+ * @param tokenPoolInfo Optional: Token pool info.
130
+ * @param confirmOptions Options for confirming the transaction
131
+ *
132
+ * @return Signature of the confirmed transaction
162
133
  */
163
- declare function packCompressedTokenAccounts(params: PackCompressedTokenAccountsParams): {
164
- inputTokenDataWithContext: InputTokenDataWithContext$1[];
165
- remainingAccountMetas: AccountMeta[];
166
- packedOutputTokenData: PackedTokenTransferOutputData[];
167
- };
134
+ declare function approveAndMintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: PublicKey, authority: Signer, amount: number | BN, outputStateTreeInfo?: TreeInfo, tokenPoolInfo?: TokenPoolInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
168
135
 
169
- declare const POOL_SEED: Buffer;
170
- declare const CPI_AUTHORITY_SEED: Buffer;
171
- declare const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;
172
- declare const CREATE_TOKEN_POOL_DISCRIMINATOR: Buffer;
173
- declare const MINT_TO_DISCRIMINATOR: Buffer;
174
- declare const TRANSFER_DISCRIMINATOR: Buffer;
175
- declare const COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR: Buffer;
136
+ /**
137
+ * Compress SPL tokens
138
+ *
139
+ * @param rpc Rpc connection to use
140
+ * @param payer Fee payer
141
+ * @param mint SPL Mint address
142
+ * @param amount Number of tokens to compress.
143
+ * @param owner Owner of the SPL token account.
144
+ * @param sourceTokenAccount Source SPL token account. (ATA)
145
+ * @param toAddress Recipient owner address.
146
+ * @param outputStateTreeInfo Optional: State tree account that the compressed
147
+ * tokens should be inserted into. Defaults to a
148
+ * shared state tree account.
149
+ * @param tokenPoolInfo Optional: Token pool info.
150
+ * @param confirmOptions Options for confirming the transaction
151
+ *
152
+ * @return Signature of the confirmed transaction
153
+ */
154
+ declare function compress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN | number[] | BN[], owner: Signer, sourceTokenAccount: PublicKey, toAddress: PublicKey | Array<PublicKey>, outputStateTreeInfo?: TreeInfo, tokenPoolInfo?: TokenPoolInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
176
155
 
177
- type CompressParams = {
178
- /**
179
- * The payer of the transaction.
180
- */
181
- payer: PublicKey;
182
- /**
183
- * owner of the *uncompressed* token account.
184
- */
185
- owner: PublicKey;
186
- /**
187
- * source (associated) token account address.
188
- */
189
- source: PublicKey;
190
- /**
191
- * owner of the compressed token account.
192
- * To compress to a batch of recipients, pass an array of PublicKeys.
193
- */
194
- toAddress: PublicKey | PublicKey[];
195
- /**
196
- * Mint address of the token to compress.
197
- */
198
- mint: PublicKey;
199
- /**
200
- * amount of tokens to compress.
201
- */
202
- amount: number | BN | number[] | BN[];
203
- /**
204
- * The state tree that the tx output should be inserted into. Defaults to a
205
- * public state tree if unspecified.
206
- */
207
- outputStateTree?: PublicKey;
208
- /**
209
- * Optional: The token program ID. Default: SPL Token Program ID
210
- */
211
- tokenProgramId?: PublicKey;
212
- };
213
- type CompressSplTokenAccountParams = {
214
- /**
215
- * Tx feepayer
216
- */
217
- feePayer: PublicKey;
218
- /**
219
- * Authority that owns the token account
220
- */
221
- authority: PublicKey;
222
- /**
223
- * Token account to compress
224
- */
225
- tokenAccount: PublicKey;
226
- /**
227
- * Mint public key
228
- */
156
+ /**
157
+ * Compress SPL tokens into compressed token format
158
+ *
159
+ * @param rpc Rpc connection to use
160
+ * @param payer Fee payer
161
+ * @param mint SPL Mint address
162
+ * @param owner Owner of the token account
163
+ * @param tokenAccount Token account to compress
164
+ * @param remainingAmount Optional: amount to leave in token account.
165
+ * Default: 0
166
+ * @param outputStateTreeInfo Optional: State tree account that the compressed
167
+ * account into
168
+ * @param tokenPoolInfo Optional: Token pool info.
169
+ * @param confirmOptions Options for confirming the transaction
170
+
171
+ *
172
+ * @return Signature of the confirmed transaction
173
+ */
174
+ declare function compressSplTokenAccount(rpc: Rpc, payer: Signer, mint: PublicKey, owner: Signer, tokenAccount: PublicKey, remainingAmount?: BN, outputStateTreeInfo?: TreeInfo, tokenPoolInfo?: TokenPoolInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
175
+
176
+ /**
177
+ * Create and initialize a new compressed token mint
178
+ *
179
+ * @param rpc RPC connection to use
180
+ * @param payer Fee payer
181
+ * @param mintAuthority Account that will control minting
182
+ * @param decimals Location of the decimal place
183
+ * @param keypair Optional: Mint keypair. Defaults to a random
184
+ * keypair.
185
+ * @param confirmOptions Options for confirming the transaction
186
+ * @param tokenProgramId Optional: Program ID for the token. Defaults to
187
+ * TOKEN_PROGRAM_ID.
188
+ * @param freezeAuthority Optional: Account that will control freeze and thaw.
189
+ * Defaults to none.
190
+ *
191
+ * @return Object with mint address and transaction signature
192
+ */
193
+ declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: PublicKey | Signer, decimals: number, keypair?: Keypair, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey | boolean, freezeAuthority?: PublicKey | Signer): Promise<{
229
194
  mint: PublicKey;
230
- /**
231
- * Optional: remaining amount to leave in token account. Default: 0
232
- */
233
- remainingAmount?: BN;
234
- /**
235
- * The state tree that the compressed token account should be inserted into.
236
- */
237
- outputStateTree: PublicKey;
238
- /**
239
- * Optional: The token program ID. Default: SPL Token Program ID
240
- */
241
- tokenProgramId?: PublicKey;
242
- };
243
- type DecompressParams = {
244
- /**
245
- * The payer of the transaction.
246
- */
247
- payer: PublicKey;
248
- /**
249
- * input state to be consumed
250
- */
251
- inputCompressedTokenAccounts: ParsedTokenAccount[];
252
- /**
253
- * address of **uncompressed** destination token account.
254
- */
255
- toAddress: PublicKey;
256
- /**
257
- * amount of tokens to decompress.
258
- */
259
- amount: number | BN;
260
- /**
261
- * The recent state root indices of the input state. The expiry is tied to
262
- * the proof.
263
- */
264
- recentInputStateRootIndices: number[];
265
- /**
266
- * The recent validity proof for state inclusion of the input state. It
267
- * expires after n slots.
268
- */
269
- recentValidityProof: CompressedProof;
270
- /**
271
- * The state tree that the change tx output should be inserted into.
272
- * Defaults to a public state tree if unspecified.
273
- */
274
- outputStateTree?: PublicKey;
275
- /**
276
- * Optional: The token program ID. Default: SPL Token Program ID
277
- */
278
- tokenProgramId?: PublicKey;
279
- };
280
- type TransferParams = {
281
- /**
282
- * The payer of the transaction
283
- */
284
- payer: PublicKey;
285
- /**
286
- * The input state to be consumed
287
- */
288
- inputCompressedTokenAccounts: ParsedTokenAccount[];
289
- /**
290
- * Recipient address
291
- */
292
- toAddress: PublicKey;
293
- /**
294
- * Amount of tokens to transfer
295
- */
296
- amount: BN | number;
297
- /**
298
- * The recent state root indices of the input state. The expiry is tied to
299
- * the proof.
195
+ transactionSignature: TransactionSignature;
196
+ }>;
300
197
 
301
- */
302
- recentInputStateRootIndices: number[];
303
- /**
304
- * The recent validity proof for state inclusion of the input state. It
305
- * expires after n slots.
306
- */
307
- recentValidityProof: CompressedProof;
308
- /**
309
- * The state trees that the tx output should be inserted into. This can be a
310
- * single PublicKey or an array of PublicKey. Defaults to the 0th state tree
311
- * of input state.
312
- */
313
- outputStateTrees?: PublicKey[] | PublicKey;
314
- };
315
198
  /**
316
- * Create Mint account for compressed Tokens
199
+ * Register an existing mint with the CompressedToken program
200
+ *
201
+ * @param rpc RPC connection to use
202
+ * @param payer Fee payer
203
+ * @param mint SPL Mint address
204
+ * @param confirmOptions Options for confirming the transaction
205
+ * @param tokenProgramId Optional: Address of the token program. Default:
206
+ * TOKEN_PROGRAM_ID
207
+ *
208
+ * @return transaction signature
317
209
  */
318
- type CreateMintParams = {
319
- /**
320
- * Tx feepayer
321
- */
322
- feePayer: PublicKey;
323
- /**
324
- * Mint authority
325
- */
326
- authority: PublicKey;
327
- /**
328
- * Mint public key
329
- */
330
- mint: PublicKey;
331
- /**
332
- * Mint decimals
333
- */
334
- decimals: number;
335
- /**
336
- * Optional: freeze authority
337
- */
338
- freezeAuthority: PublicKey | null;
339
- /**
340
- * lamport amount for mint account rent exemption
341
- */
342
- rentExemptBalance: number;
343
- /**
344
- * Optional: The token program ID. Default: SPL Token Program ID
345
- */
346
- tokenProgramId?: PublicKey;
347
- /**
348
- * Optional: Mint size to use, defaults to MINT_SIZE
349
- */
350
- mintSize?: number;
351
- };
210
+ declare function createTokenPool(rpc: Rpc, payer: Signer, mint: PublicKey, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
352
211
  /**
353
- * Parameters for merging compressed token accounts
212
+ * Create additional token pools for an existing mint
213
+ *
214
+ * @param rpc RPC connection to use
215
+ * @param payer Fee payer
216
+ * @param mint SPL Mint address
217
+ * @param numMaxAdditionalPools Number of additional token pools to create. Max
218
+ * 3.
219
+ * @param confirmOptions Optional: Options for confirming the transaction
220
+ * @param tokenProgramId Optional: Address of the token program. Default:
221
+ * TOKEN_PROGRAM_ID
222
+ *
223
+ * @return transaction signature
354
224
  */
355
- type MergeTokenAccountsParams = {
356
- /**
357
- * Tx feepayer
358
- */
359
- payer: PublicKey;
360
- /**
361
- * Owner of the token accounts to be merged
362
- */
363
- owner: PublicKey;
364
- /**
365
- * Mint public key
366
- */
367
- mint: PublicKey;
368
- /**
369
- * Array of compressed token accounts to merge
370
- */
371
- inputCompressedTokenAccounts: ParsedTokenAccount[];
372
- /**
373
- * Optional: Public key of the state tree to merge into
374
- */
375
- outputStateTree: PublicKey;
376
- /**
377
- * Optional: Recent validity proof for state inclusion
378
- */
379
- recentValidityProof: CompressedProof;
380
- /**
381
- * Optional: Recent state root indices of the input state
382
- */
383
- recentInputStateRootIndices: number[];
384
- };
225
+ declare function addTokenPools(rpc: Rpc, payer: Signer, mint: PublicKey, numMaxAdditionalPools: number, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<string>;
226
+
385
227
  /**
386
- * Create compressed token accounts
228
+ * Create a lookup table for the token program's default accounts
229
+ *
230
+ * @param rpc Rpc connection to use
231
+ * @param payer Fee payer
232
+ * @param authority Authority of the lookup table
233
+ * @param mints Optional array of mint public keys to include in
234
+ * the lookup table
235
+ * @param additionalAccounts Optional array of additional account public keys
236
+ * to include in the lookup table
237
+ *
238
+ * @return Object with transaction signatures and the address of the created
239
+ * lookup table
387
240
  */
388
- type MintToParams = {
389
- /**
390
- * Tx feepayer
391
- */
392
- feePayer: PublicKey;
393
- /**
394
- * Mint authority
395
- */
396
- authority: PublicKey;
397
- /**
398
- * Mint public key
399
- */
400
- mint: PublicKey;
401
- /**
402
- * The Solana Public Keys to mint to.
403
- */
404
- toPubkey: PublicKey[] | PublicKey;
405
- /**
406
- * The amount of compressed tokens to mint.
407
- */
408
- amount: BN | BN[] | number | number[];
409
- /**
410
- * Public key of the state tree to mint into. Defaults to a public state
411
- * tree if unspecified.
412
- */
413
- merkleTree?: PublicKey;
414
- /**
415
- * Optional: The token program ID. Default: SPL Token Program ID
416
- */
417
- tokenProgramId?: PublicKey;
418
- };
241
+ declare function createTokenProgramLookupTable(rpc: Rpc, payer: Signer, authority: Signer, mints?: PublicKey[], additionalAccounts?: PublicKey[]): Promise<{
242
+ txIds: TransactionSignature[];
243
+ address: PublicKey;
244
+ }>;
245
+
419
246
  /**
420
- * Register an existing SPL mint account to the compressed token program
421
- * Creates an omnibus account for the mint
247
+ * Decompress compressed tokens
248
+ *
249
+ * @param rpc Rpc connection to use
250
+ * @param payer Fee payer
251
+ * @param mint SPL Mint address
252
+ * @param amount Number of tokens to transfer
253
+ * @param owner Owner of the compressed tokens
254
+ * @param toAddress Destination **uncompressed** token account
255
+ * address. (ATA)
256
+ * @param tokenPoolInfos Optional: Token pool infos.
257
+ * @param confirmOptions Options for confirming the transaction
258
+ *
259
+ * @return confirmed transaction signature
422
260
  */
423
- type RegisterMintParams = {
424
- /** Tx feepayer */
425
- feePayer: PublicKey;
426
- /** Mint public key */
427
- mint: PublicKey;
428
- /**
429
- * Optional: The token program ID. Default: SPL Token Program ID
430
- */
431
- tokenProgramId?: PublicKey;
432
- };
261
+ declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, tokenPoolInfos?: TokenPoolInfo[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
262
+
433
263
  /**
434
- * Mint from existing SPL mint to compressed token accounts
264
+ * Merge multiple compressed token accounts for a given mint into a single
265
+ * account
266
+ *
267
+ * @param rpc RPC connection to use
268
+ * @param payer Fee payer
269
+ * @param mint SPL Mint address
270
+ * @param owner Owner of the token accounts to be merged
271
+ * @param confirmOptions Options for confirming the transaction
272
+ *
273
+ * @return confirmed transaction signature
435
274
  */
436
- type ApproveAndMintToParams = {
437
- /**
438
- * Tx feepayer
439
- */
440
- feePayer: PublicKey;
441
- /**
442
- * Mint authority
443
- */
444
- authority: PublicKey;
445
- /**
446
- * Mint authority (associated) token account
447
- */
448
- authorityTokenAccount: PublicKey;
449
- /**
450
- * Mint public key
451
- */
452
- mint: PublicKey;
453
- /**
454
- * The Solana Public Key to mint to.
455
- */
456
- toPubkey: PublicKey;
457
- /**
458
- * The amount of compressed tokens to mint.
459
- */
460
- amount: BN | number;
461
- /**
462
- * Public key of the state tree to mint into. Defaults to a public state
463
- * tree if unspecified.
464
- */
465
- merkleTree?: PublicKey;
466
- /**
467
- * Optional: The token program ID. Default: SPL Token Program ID
468
- */
469
- tokenProgramId?: PublicKey;
470
- };
471
- type CreateTokenProgramLookupTableParams = {
472
- /**
473
- * The payer of the transaction.
474
- */
475
- payer: PublicKey;
476
- /**
477
- * The authority of the transaction.
478
- */
479
- authority: PublicKey;
480
- /**
481
- * Recently finalized Solana slot.
482
- */
483
- recentSlot: number;
484
- /**
485
- * Optional Mint addresses to store in the lookup table.
486
- */
487
- mints?: PublicKey[];
488
- /**
489
- * Optional additional addresses to store in the lookup table.
490
- */
491
- remainingAccounts?: PublicKey[];
492
- };
275
+ declare function mergeTokenAccounts(rpc: Rpc, payer: Signer, mint: PublicKey, owner: Signer, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
276
+
493
277
  /**
494
- * Sum up the token amounts of the compressed token accounts
278
+ * Mint compressed tokens to a solana address
279
+ *
280
+ * @param rpc Rpc connection to use
281
+ * @param payer Fee payer
282
+ * @param mint SPL Mint address
283
+ * @param toPubkey Address of the account to mint to. Can be an
284
+ * array of addresses if the amount is an array of
285
+ * amounts.
286
+ * @param authority Mint authority
287
+ * @param amount Amount to mint. Pass an array of amounts if the
288
+ * toPubkey is an array of addresses.
289
+ * @param outputStateTreeInfo Optional: State tree account that the compressed
290
+ * tokens should be part of. Defaults to the
291
+ * default state tree account.
292
+ * @param tokenPoolInfo Optional: Token pool information
293
+ * @param confirmOptions Options for confirming the transaction
294
+ *
295
+ * @return Signature of the confirmed transaction
495
296
  */
496
- declare const sumUpTokenAmount: (accounts: ParsedTokenAccount[]) => BN;
297
+ declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: PublicKey | PublicKey[], authority: Signer, amount: number | BN | number[] | BN[], outputStateTreeInfo?: TreeInfo, tokenPoolInfo?: TokenPoolInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
298
+
497
299
  /**
498
- * Validate that all the compressed token accounts are owned by the same owner.
300
+ * Revoke one or more delegated token accounts
301
+ *
302
+ * @param rpc Rpc connection to use
303
+ * @param payer Fee payer
304
+ * @param accounts Delegated compressed token accounts to revoke
305
+ * @param owner Owner of the compressed tokens
306
+ * @param confirmOptions Options for confirming the transaction
307
+ *
308
+ * @return Signature of the confirmed transaction
499
309
  */
500
- declare const validateSameTokenOwner: (accounts: ParsedTokenAccount[]) => void;
310
+ declare function revoke(rpc: Rpc, payer: Signer, accounts: ParsedTokenAccount[], owner: Signer, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
311
+
501
312
  /**
502
- * Parse compressed token accounts to get the mint, current owner and delegate.
313
+ * Transfer compressed tokens from one owner to another
314
+ *
315
+ * @param rpc Rpc connection to use
316
+ * @param payer Fee payer
317
+ * @param mint SPL Mint address
318
+ * @param amount Number of tokens to transfer
319
+ * @param owner Owner of the compressed tokens
320
+ * @param toAddress Destination address of the recipient
321
+ * @param confirmOptions Options for confirming the transaction
322
+ *
323
+ * @return confirmed transaction signature
503
324
  */
504
- declare const parseTokenData: (compressedTokenAccounts: ParsedTokenAccount[]) => {
505
- mint: PublicKey;
506
- currentOwner: PublicKey;
507
- delegate: PublicKey | null;
508
- };
325
+ declare function transfer(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
326
+
509
327
  /**
510
- * Create the output state for a transfer transaction.
511
- * @param inputCompressedTokenAccounts Input state
512
- * @param toAddress Recipient address
513
- * @param amount Amount of tokens to transfer
514
- * @returns Output token data for the transfer
515
- * instruction
328
+ * Transfer delegated compressed tokens to another owner
329
+ *
330
+ * @param rpc Rpc connection to use
331
+ * @param payer Fee payer
332
+ * @param mint SPL Mint address
333
+ * @param amount Number of tokens to transfer
334
+ * @param owner Owner of the compressed tokens
335
+ * @param toAddress Destination address of the recipient
336
+ * @param confirmOptions Options for confirming the transaction
337
+ *
338
+ * @return confirmed transaction signature
516
339
  */
517
- declare function createTransferOutputState(inputCompressedTokenAccounts: ParsedTokenAccount[], toAddress: PublicKey, amount: number | BN): TokenTransferOutputData[];
340
+ declare function transferDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
341
+
518
342
  /**
519
- * Create the output state for a compress transaction.
520
- * @param inputCompressedTokenAccounts Input state
521
- * @param amount Amount of tokens to compress
522
- * @returns Output token data for the compress
523
- * instruction
524
- */
525
- declare function createDecompressOutputState(inputCompressedTokenAccounts: ParsedTokenAccount[], amount: number | BN): TokenTransferOutputData[];
526
- declare class CompressedTokenProgram {
527
- /**
528
- * @internal
529
- */
530
- constructor();
531
- /**
532
- * Public key that identifies the CompressedPda program
533
- */
534
- static programId: PublicKey;
535
- /**
536
- * Set a custom programId via PublicKey or base58 encoded string.
537
- * This method is not required for regular usage.
538
- *
539
- * Use this only if you know what you are doing.
540
- */
541
- static setProgramId(programId: PublicKey | string): void;
542
- /** @internal */
543
- static deriveTokenPoolPda(mint: PublicKey): PublicKey;
544
- /** @internal */
545
- static get deriveCpiAuthorityPda(): PublicKey;
546
- /**
547
- * Construct createMint instruction for compressed tokens.
548
- * @returns [createMintAccountInstruction, initializeMintInstruction, createTokenPoolInstruction]
549
- *
550
- * Note that `createTokenPoolInstruction` must be executed after `initializeMintInstruction`.
551
- */
552
- static createMint(params: CreateMintParams): Promise<TransactionInstruction[]>;
553
- /**
554
- * Enable compression for an existing SPL mint, creating an omnibus account.
555
- * For new mints, use `CompressedTokenProgram.createMint`.
556
- */
557
- static createTokenPool(params: RegisterMintParams): Promise<TransactionInstruction>;
558
- /**
559
- * Construct mintTo instruction for compressed tokens
560
- */
561
- static mintTo(params: MintToParams): Promise<TransactionInstruction>;
562
- /**
563
- * Mint tokens from registered SPL mint account to a compressed account
564
- */
565
- static approveAndMintTo(params: ApproveAndMintToParams): Promise<TransactionInstruction[]>;
566
- /**
567
- * Construct transfer instruction for compressed tokens
568
- */
569
- static transfer(params: TransferParams): Promise<TransactionInstruction>;
570
- /**
571
- * Create lookup table instructions for the token program's default accounts.
572
- */
573
- static createTokenProgramLookupTable(params: CreateTokenProgramLookupTableParams): Promise<{
574
- instructions: TransactionInstruction[];
575
- address: PublicKey;
576
- }>;
577
- /**
578
- * Create compress instruction
579
- * @returns compressInstruction
580
- */
581
- static compress(params: CompressParams): Promise<TransactionInstruction>;
582
- /**
583
- * Construct decompress instruction
584
- */
585
- static decompress(params: DecompressParams): Promise<TransactionInstruction>;
586
- static mergeTokenAccounts(params: MergeTokenAccountsParams): Promise<TransactionInstruction[]>;
587
- static compressSplTokenAccount(params: CompressSplTokenAccountParams): Promise<TransactionInstruction>;
588
- static get_mint_program_id(mint: PublicKey, connection: Connection): Promise<PublicKey | undefined>;
589
- }
590
-
591
- /**
592
- * Mint compressed tokens to a solana address from an external mint authority
593
- *
594
- * @param rpc Rpc to use
595
- * @param payer Payer of the transaction fees
596
- * @param mint Mint for the account
597
- * @param destination Address of the account to mint to
598
- * @param authority Minting authority
599
- * @param amount Amount to mint
600
- * @param merkleTree State tree account that the compressed tokens should be
601
- * part of. Defaults to random public state tree account.
602
- * @param confirmOptions Options for confirming the transaction
603
- *
604
- * @return Signature of the confirmed transaction
605
- */
606
- declare function approveAndMintTo(rpc: Rpc, payer: Signer, mint: PublicKey, destination: PublicKey, authority: Signer, amount: number | BN, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
607
-
608
- /**
609
- * Compress SPL tokens
343
+ * Decompress delegated compressed tokens. Remaining compressed tokens are
344
+ * returned to the owner without delegation.
610
345
  *
611
346
  * @param rpc Rpc connection to use
612
- * @param payer Payer of the transaction fees
613
- * @param mint Mint of the compressed token
614
- * @param amount Number of tokens to transfer
615
- * @param owner Owner of the compressed tokens.
616
- * @param sourceTokenAccount Source (associated) token account
617
- * @param toAddress Destination address of the recipient
618
- * @param merkleTree State tree account that the compressed tokens
619
- * should be inserted into. Defaults to a default
620
- * state tree account.
347
+ * @param payer Fee payer
348
+ * @param mint SPL Mint address
349
+ * @param amount Number of tokens to decompress
350
+ * @param owner Owner of the compressed tokens
351
+ * @param toAddress Destination **uncompressed** token account
352
+ * address. (ATA)
353
+ * @param tokenPoolInfos Optional: Token pool infos.
621
354
  * @param confirmOptions Options for confirming the transaction
622
355
  *
623
- *
624
- * @return Signature of the confirmed transaction
625
- */
626
- declare function compress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN | number[] | BN[], owner: Signer, sourceTokenAccount: PublicKey, toAddress: PublicKey | Array<PublicKey>, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
627
-
628
- /**
629
- * Decompress compressed tokens
630
- *
631
- * @param rpc Rpc to use
632
- * @param payer Payer of the transaction fees
633
- * @param mint Mint of the compressed token
634
- * @param amount Number of tokens to transfer
635
- * @param owner Owner of the compressed tokens
636
- * @param toAddress Destination **uncompressed** (associated) token account
637
- * address.
638
- * @param merkleTree State tree account that any change compressed tokens should be
639
- * inserted into. Defaults to a default state tree
640
- * account.
641
- * @param confirmOptions Options for confirming the transaction
642
- *
643
- *
644
356
  * @return Signature of the confirmed transaction
645
357
  */
646
- declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
358
+ declare function decompressDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, tokenPoolInfos?: TokenPoolInfo[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
647
359
 
360
+ declare const ERROR_NO_ACCOUNTS_FOUND = "Could not find accounts to select for transfer.";
648
361
  /**
649
- * Create and initialize a new compressed token mint
650
- *
651
- * @param rpc RPC to use
652
- * @param payer Payer of the transaction and initialization fees
653
- * @param mintAuthority Account or multisig that will control minting
654
- * @param decimals Location of the decimal place
655
- * @param keypair Optional keypair, defaulting to a new random one
656
- * @param confirmOptions Options for confirming the transaction
657
- * @param tokenProgramId Program ID for the token. Defaults to
658
- * TOKEN_PROGRAM_ID. You can pass in a boolean to
659
- * automatically resolve to TOKEN_2022_PROGRAM_ID if
660
- * true, or TOKEN_PROGRAM_ID if false.
661
- * @param freezeAuthority Account that will control freeze and thaw. Defaults to null.
362
+ * Selects token accounts for approval, first trying to find an exact match, then falling back to minimum selection.
662
363
  *
663
- * @return Address of the new mint and the transaction signature
364
+ * @param {ParsedTokenAccount[]} accounts - Token accounts to choose from.
365
+ * @param {BN} approveAmount - Amount to approve.
366
+ * @param {number} [maxInputs=4] - Max accounts to select when falling back to minimum selection.
367
+ * @returns {[
368
+ * selectedAccounts: ParsedTokenAccount[],
369
+ * total: BN,
370
+ * totalLamports: BN | null,
371
+ * maxPossibleAmount: BN
372
+ * ]} - Returns:
373
+ * - selectedAccounts: Accounts chosen for approval.
374
+ * - total: Total amount from selected accounts.
375
+ * - totalLamports: Total lamports from selected accounts.
376
+ * - maxPossibleAmount: Max approvable amount given maxInputs.
664
377
  */
665
- declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: PublicKey, decimals: number, keypair?: Keypair, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey | boolean, freezeAuthority?: PublicKey): Promise<{
666
- mint: PublicKey;
667
- transactionSignature: TransactionSignature;
668
- }>;
669
-
378
+ declare function selectTokenAccountsForApprove(accounts: ParsedTokenAccount[], approveAmount: BN, maxInputs?: number): [
379
+ selectedAccounts: ParsedTokenAccount[],
380
+ total: BN,
381
+ totalLamports: BN | null,
382
+ maxPossibleAmount: BN
383
+ ];
670
384
  /**
671
- * Mint compressed tokens to a solana address
385
+ * Selects the minimum number of compressed token accounts required for a
386
+ * decompress instruction, up to a specified maximum.
672
387
  *
673
- * @param rpc Rpc to use
674
- * @param payer Payer of the transaction fees
675
- * @param mint Mint for the account
676
- * @param destination Address of the account to mint to. Can be an array of
677
- * addresses if the amount is an array of amounts.
678
- * @param authority Minting authority
679
- * @param amount Amount to mint. Can be an array of amounts if the
680
- * destination is an array of addresses.
681
- * @param merkleTree State tree account that the compressed tokens should be
682
- * part of. Defaults to the default state tree account.
683
- * @param confirmOptions Options for confirming the transaction
388
+ * @param {ParsedTokenAccount[]} accounts Token accounts to choose from.
389
+ * @param {BN} amount Amount to decompress.
390
+ * @param {number} [maxInputs=4] Max accounts to select. Default
391
+ * is 4.
684
392
  *
685
- * @return Signature of the confirmed transaction
393
+ * @returns Returns selected accounts and their totals.
686
394
  */
687
- declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, destination: PublicKey | PublicKey[], authority: Signer, amount: number | BN | number[] | BN[], merkleTree?: PublicKey, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
688
-
395
+ declare function selectMinCompressedTokenAccountsForDecompression(accounts: ParsedTokenAccount[], amount: BN, maxInputs?: number): {
396
+ selectedAccounts: ParsedTokenAccount[];
397
+ total: BN;
398
+ totalLamports: BN | null;
399
+ maxPossibleAmount: BN;
400
+ };
689
401
  /**
690
- * Merge multiple compressed token accounts for a given mint into a single
691
- * account
402
+ * Selects the minimum number of compressed token accounts required for a
403
+ * transfer or decompression instruction, up to a specified maximum.
692
404
  *
693
- * @param rpc RPC to use
694
- * @param payer Payer of the transaction fees
695
- * @param mint Public key of the token's mint
696
- * @param owner Owner of the token accounts to be merged
697
- * @param merkleTree Optional merkle tree for compressed tokens
698
- * @param confirmOptions Options for confirming the transaction
405
+ * @param {ParsedTokenAccount[]} accounts Token accounts to choose from.
406
+ * @param {BN} transferAmount Amount to transfer or decompress.
407
+ * @param {number} [maxInputs=4] Max accounts to select. Default
408
+ * is 4.
699
409
  *
700
- * @return Array of transaction signatures
410
+ * @returns Returns selected accounts and their totals. [
411
+ * selectedAccounts: ParsedTokenAccount[],
412
+ * total: BN,
413
+ * totalLamports: BN | null,
414
+ * maxPossibleAmount: BN
415
+ * ]
701
416
  */
702
- declare function mergeTokenAccounts(rpc: Rpc, payer: Signer, mint: PublicKey, owner: Signer, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
703
-
417
+ declare function selectMinCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
418
+ selectedAccounts: ParsedTokenAccount[],
419
+ total: BN,
420
+ totalLamports: BN | null,
421
+ maxPossibleAmount: BN
422
+ ];
704
423
  /**
705
- * Register an existing mint with the CompressedToken program
706
- *
707
- * @param rpc RPC to use
708
- * @param payer Payer of the transaction and initialization fees
709
- * @param mintAuthority Account or multisig that will control minting. Is signer.
710
- * @param mintAddress Address of the existing mint
711
- * @param confirmOptions Options for confirming the transaction
712
- *
713
- * @return transaction signature
424
+ * Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,
425
+ * returns partial amounts if insufficient accounts are found instead of
426
+ * throwing an error.
714
427
  */
715
- declare function createTokenPool(rpc: Rpc, payer: Signer, mint: PublicKey, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
716
-
428
+ declare function selectMinCompressedTokenAccountsForTransferOrPartial(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
429
+ selectedAccounts: ParsedTokenAccount[],
430
+ total: BN,
431
+ totalLamports: BN | null,
432
+ maxPossibleAmount: BN
433
+ ];
717
434
  /**
718
- * Transfer compressed tokens from one owner to another
435
+ * Selects compressed token accounts for a transfer, ensuring one extra account
436
+ * if possible, up to maxInputs.
719
437
  *
720
- * @param rpc Rpc to use
721
- * @param payer Payer of the transaction fees
722
- * @param mint Mint of the compressed token
723
- * @param amount Number of tokens to transfer
724
- * @param owner Owner of the compressed tokens
725
- * @param toAddress Destination address of the recipient
726
- * @param merkleTree State tree account that the compressed tokens should be
727
- * inserted into. Defaults to the default state tree
728
- * account.
729
- * @param confirmOptions Options for confirming the transaction
438
+ * 1. Sorts accounts by amount (desc)
439
+ * 2. Selects accounts until transfer amount is met or maxInputs is reached,
440
+ * attempting to add one extra account if possible.
730
441
  *
442
+ * @param {ParsedTokenAccount[]} accounts - The list of token accounts to select from.
443
+ * @param {BN} transferAmount - The token amount to be transferred.
444
+ * @param {number} [maxInputs=4] - The maximum number of accounts to select. Default: 4.
445
+ * @returns {[
446
+ * selectedAccounts: ParsedTokenAccount[],
447
+ * total: BN,
448
+ * totalLamports: BN | null,
449
+ * maxPossibleAmount: BN
450
+ * ]} - An array containing:
451
+ * - selectedAccounts: The accounts selected for the transfer.
452
+ * - total: The total amount accumulated from the selected accounts.
453
+ * - totalLamports: The total lamports accumulated from the selected accounts.
454
+ * - maxPossibleAmount: The maximum possible amount that can be transferred considering maxInputs.
731
455
  *
732
- * @return Signature of the confirmed transaction
733
- */
734
- declare function transfer(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
735
-
736
- /**
737
- * Create a lookup table for the token program's default accounts
456
+ * @example
457
+ * const accounts = [
458
+ * { parsed: { amount: new BN(100) }, compressedAccount: { lamports: new BN(10) } },
459
+ * { parsed: { amount: new BN(50) }, compressedAccount: { lamports: new BN(5) } },
460
+ * { parsed: { amount: new BN(25) }, compressedAccount: { lamports: new BN(2) } },
461
+ * ];
462
+ * const transferAmount = new BN(75);
463
+ * const maxInputs = 2;
738
464
  *
739
- * @param rpc Rpc connection to use
740
- * @param payer Payer of the transaction fees
741
- * @param authority Authority of the lookup table
742
- * @param mints Optional array of mint public keys to include in
743
- * the lookup table
744
- * @param additionalAccounts Optional array of additional account public keys
745
- * to include in the lookup table
465
+ * const [selectedAccounts, total, totalLamports, maxPossibleAmount] =
466
+ * selectSmartCompressedTokenAccountsForTransfer(accounts, transferAmount, maxInputs);
746
467
  *
747
- * @return Transaction signatures and the address of the created lookup table
468
+ * console.log(selectedAccounts.length); // 2
469
+ * console.log(total.toString()); // '150'
470
+ * console.log(totalLamports!.toString()); // '15'
471
+ * console.log(maxPossibleAmount.toString()); // '150'
748
472
  */
749
- declare function createTokenProgramLookupTable(rpc: Rpc, payer: Signer, authority: Signer, mints?: PublicKey[], additionalAccounts?: PublicKey[]): Promise<{
750
- txIds: TransactionSignature[];
751
- address: PublicKey;
752
- }>;
753
-
473
+ declare function selectSmartCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
474
+ selectedAccounts: ParsedTokenAccount[],
475
+ total: BN,
476
+ totalLamports: BN | null,
477
+ maxPossibleAmount: BN
478
+ ];
754
479
  /**
755
- * Compress SPL tokens into compressed token format
756
- *
757
- * @param rpc Rpc connection to use
758
- * @param payer Payer of the transaction fees
759
- * @param mint Mint of the token to compress
760
- * @param owner Owner of the token account
761
- * @param tokenAccount Token account to compress
762
- * @param outputStateTree State tree to insert the compressed token account into
763
- * @param remainingAmount Optional: amount to leave in token account. Default: 0
764
- * @param confirmOptions Options for confirming the transaction
765
- *
766
- * @return Signature of the confirmed transaction
480
+ * Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,
481
+ * returns partial amounts if insufficient accounts are found instead of
482
+ * throwing an error.
767
483
  */
768
- declare function compressSplTokenAccount(rpc: Rpc, payer: Signer, mint: PublicKey, owner: Signer, tokenAccount: PublicKey, outputStateTree: PublicKey, remainingAmount?: BN, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
484
+ declare function selectSmartCompressedTokenAccountsForTransferOrPartial(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
485
+ selectedAccounts: ParsedTokenAccount[],
486
+ total: BN,
487
+ totalLamports: BN | null,
488
+ maxPossibleAmount: BN
489
+ ];
769
490
 
770
- declare const DelegatedTransferLayout: buffer_layout.Layout<unknown>;
771
- declare const CpiContextLayout: buffer_layout.Layout<unknown>;
772
- declare const CompressedTokenInstructionDataTransferLayout: buffer_layout.Layout<unknown>;
773
- declare const mintToLayout: buffer_layout.Layout<unknown>;
774
- declare const compressSplTokenAccountInstructionDataLayout: buffer_layout.Layout<unknown>;
775
- declare function encodeMintToInstructionData(data: MintToInstructionData): Buffer$1;
776
- declare function decodeMintToInstructionData(buffer: Buffer$1): MintToInstructionData;
777
- declare function encodeCompressSplTokenAccountInstructionData(data: CompressSplTokenAccountInstructionData): Buffer$1;
778
- declare function decodeCompressSplTokenAccountInstructionData(buffer: Buffer$1): CompressSplTokenAccountInstructionData;
779
- declare function encodeTransferInstructionData(data: CompressedTokenInstructionDataTransfer): Buffer$1;
780
- declare function decodeTransferInstructionData(buffer: Buffer$1): CompressedTokenInstructionDataTransfer;
781
- interface BaseAccountsLayoutParams {
782
- feePayer: PublicKey;
783
- authority: PublicKey;
784
- cpiAuthorityPda: PublicKey;
785
- lightSystemProgram: PublicKey;
786
- registeredProgramPda: PublicKey;
787
- noopProgram: PublicKey;
788
- accountCompressionAuthority: PublicKey;
789
- accountCompressionProgram: PublicKey;
790
- selfProgram: PublicKey;
791
- systemProgram: PublicKey;
792
- }
793
- type createTokenPoolAccountsLayoutParams = {
794
- feePayer: PublicKey;
795
- tokenPoolPda: PublicKey;
796
- systemProgram: PublicKey;
797
- mint: PublicKey;
798
- tokenProgram: PublicKey;
799
- cpiAuthorityPda: PublicKey;
800
- };
801
- type mintToAccountsLayoutParams = BaseAccountsLayoutParams & {
802
- mint: PublicKey;
803
- tokenPoolPda: PublicKey;
804
- tokenProgram: PublicKey;
805
- merkleTree: PublicKey;
806
- solPoolPda: PublicKey | null;
807
- };
808
- type transferAccountsLayoutParams = BaseAccountsLayoutParams & {
809
- tokenPoolPda?: PublicKey;
810
- compressOrDecompressTokenAccount?: PublicKey;
811
- tokenProgram?: PublicKey;
491
+ type TokenTransferOutputData = {
492
+ /**
493
+ * The owner of the output token account
494
+ */
495
+ owner: PublicKey;
496
+ /**
497
+ * The amount of tokens of the output token account
498
+ */
499
+ amount: BN;
500
+ /**
501
+ * lamports associated with the output token account
502
+ */
503
+ lamports: BN | null;
504
+ /**
505
+ * TokenExtension tlv
506
+ */
507
+ tlv: Buffer | null;
812
508
  };
813
- type approveAccountsLayoutParams = BaseAccountsLayoutParams;
814
- type revokeAccountsLayoutParams = approveAccountsLayoutParams;
815
- type freezeAccountsLayoutParams = BaseAccountsLayoutParams & {
509
+ type PackedTokenTransferOutputData = {
510
+ /**
511
+ * The owner of the output token account
512
+ */
513
+ owner: PublicKey;
514
+ /**
515
+ * The amount of tokens of the output token account
516
+ */
517
+ amount: BN;
518
+ /**
519
+ * lamports associated with the output token account
520
+ */
521
+ lamports: BN | null;
522
+ /**
523
+ * Merkle tree pubkey index in remaining accounts
524
+ */
525
+ merkleTreeIndex: number;
526
+ /**
527
+ * TokenExtension tlv
528
+ */
529
+ tlv: Buffer | null;
530
+ };
531
+ type InputTokenDataWithContext = {
532
+ amount: BN;
533
+ delegateIndex: number | null;
534
+ merkleContext: PackedMerkleContextLegacy;
535
+ rootIndex: number;
536
+ lamports: BN | null;
537
+ tlv: Buffer | null;
538
+ };
539
+ type DelegatedTransfer = {
540
+ owner: PublicKey;
541
+ delegateChangeAccountIndex: number | null;
542
+ };
543
+ type BatchCompressInstructionData = {
544
+ pubkeys: PublicKey[];
545
+ amounts: BN[] | null;
546
+ lamports: BN | null;
547
+ amount: BN | null;
548
+ index: number;
549
+ bump: number;
550
+ };
551
+ type MintToInstructionData = {
552
+ recipients: PublicKey[];
553
+ amounts: BN[];
554
+ lamports: BN | null;
555
+ };
556
+ type CompressSplTokenAccountInstructionData = {
557
+ owner: PublicKey;
558
+ remainingAmount: BN | null;
559
+ cpiContext: CompressedCpiContext | null;
560
+ };
561
+ declare function isSingleTokenPoolInfo(tokenPoolInfos: TokenPoolInfo | TokenPoolInfo[]): tokenPoolInfos is TokenPoolInfo;
562
+ type CompressedTokenInstructionDataTransfer = {
563
+ /**
564
+ * Validity proof
565
+ */
566
+ proof: ValidityProof | null;
567
+ /**
568
+ * The mint of the transfer
569
+ */
570
+ mint: PublicKey;
571
+ /**
572
+ * Whether the signer is a delegate
573
+ */
574
+ delegatedTransfer: DelegatedTransfer | null;
575
+ /**
576
+ * Input token data with packed merkle context
577
+ */
578
+ inputTokenDataWithContext: InputTokenDataWithContext[];
579
+ /**
580
+ * Data of the output token accounts
581
+ */
582
+ outputCompressedAccounts: PackedTokenTransferOutputData[];
583
+ /**
584
+ * Whether it's a compress or decompress action if compressOrDecompressAmount is non-null
585
+ */
586
+ isCompress: boolean;
587
+ /**
588
+ * If null, it's a transfer.
589
+ * If some, the amount that is being deposited into (compress) or withdrawn from (decompress) the token escrow
590
+ */
591
+ compressOrDecompressAmount: BN | null;
592
+ /**
593
+ * CPI context if
594
+ */
595
+ cpiContext: CompressedCpiContext | null;
596
+ /**
597
+ * The index of the Merkle tree for a lamport change account.
598
+ */
599
+ lamportsChangeAccountMerkleTreeIndex: number | null;
600
+ };
601
+ type TokenData = {
602
+ /**
603
+ * The mint associated with this account
604
+ */
605
+ mint: PublicKey;
606
+ /**
607
+ * The owner of this account
608
+ */
609
+ owner: PublicKey;
610
+ /**
611
+ * The amount of tokens this account holds
612
+ */
613
+ amount: BN;
614
+ /**
615
+ * If `delegate` is `Some` then `delegated_amount` represents the amount
616
+ * authorized by the delegate
617
+ */
618
+ delegate: PublicKey | null;
619
+ /**
620
+ * The account's state
621
+ */
622
+ state: number;
623
+ /**
624
+ * TokenExtension tlv
625
+ */
626
+ tlv: Buffer | null;
627
+ };
628
+ type CompressedTokenInstructionDataApprove = {
629
+ proof: ValidityProof | null;
816
630
  mint: PublicKey;
631
+ inputTokenDataWithContext: InputTokenDataWithContext[];
632
+ cpiContext: CompressedCpiContext | null;
633
+ delegate: PublicKey;
634
+ delegatedAmount: BN;
635
+ delegateMerkleTreeIndex: number;
636
+ changeAccountMerkleTreeIndex: number;
637
+ delegateLamports: BN | null;
817
638
  };
818
- type thawAccountsLayoutParams = freezeAccountsLayoutParams;
819
- declare const createTokenPoolAccountsLayout: (accounts: createTokenPoolAccountsLayoutParams) => AccountMeta[];
820
- declare const mintToAccountsLayout: (accounts: mintToAccountsLayoutParams) => AccountMeta[];
821
- declare const transferAccountsLayout: (accounts: transferAccountsLayoutParams) => AccountMeta[];
639
+ type CompressedTokenInstructionDataRevoke = {
640
+ proof: ValidityProof | null;
641
+ mint: PublicKey;
642
+ inputTokenDataWithContext: InputTokenDataWithContext[];
643
+ cpiContext: CompressedCpiContext | null;
644
+ outputAccountMerkleTreeIndex: number;
645
+ };
646
+
647
+ type PackCompressedTokenAccountsParams = {
648
+ /** Input state to be consumed */
649
+ inputCompressedTokenAccounts: ParsedTokenAccount[];
650
+ /**
651
+ * State trees that the output should be inserted into. Defaults to the 0th
652
+ * state tree of the input state. Gets padded to the length of
653
+ * outputCompressedAccounts.
654
+ */
655
+ outputStateTreeInfo?: TreeInfo;
656
+ /** Optional remaining accounts to append to */
657
+ remainingAccounts?: PublicKey[];
658
+ /**
659
+ * Root indices that are used on-chain to fetch the correct root
660
+ * from the state Merkle tree account for validity proof verification.
661
+ */
662
+ rootIndices: number[];
663
+ tokenTransferOutputs: TokenTransferOutputData[];
664
+ };
665
+ /**
666
+ * Packs Compressed Token Accounts.
667
+ */
668
+ declare function packCompressedTokenAccounts(params: PackCompressedTokenAccountsParams): {
669
+ inputTokenDataWithContext: InputTokenDataWithContext$1[];
670
+ remainingAccountMetas: AccountMeta[];
671
+ packedOutputTokenData: PackedTokenTransferOutputData[];
672
+ };
673
+
674
+ /**
675
+ * Check if all input accounts belong to the same mint.
676
+ *
677
+ * @param compressedTokenAccounts The compressed token accounts
678
+ * @param mint The mint of the token pool
679
+ * @returns True if all input accounts belong to the same mint
680
+ */
681
+ declare function checkMint(compressedTokenAccounts: ParsedTokenAccount[], mint: PublicKey): boolean;
682
+
683
+ declare const POOL_SEED: Buffer;
684
+ declare const CPI_AUTHORITY_SEED: Buffer;
685
+ declare const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;
686
+ declare const CREATE_TOKEN_POOL_DISCRIMINATOR: Buffer;
687
+ declare const MINT_TO_DISCRIMINATOR: Buffer;
688
+ declare const BATCH_COMPRESS_DISCRIMINATOR: Buffer;
689
+ declare const TRANSFER_DISCRIMINATOR: Buffer;
690
+ declare const COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR: Buffer;
691
+ declare const APPROVE_DISCRIMINATOR: Buffer;
692
+ declare const REVOKE_DISCRIMINATOR: Buffer;
693
+ declare const ADD_TOKEN_POOL_DISCRIMINATOR: Buffer;
822
694
 
823
695
  type LightCompressedToken = {
824
696
  version: '1.2.0';
@@ -1911,6 +1783,104 @@ type LightCompressedToken = {
1911
1783
  ];
1912
1784
  };
1913
1785
  },
1786
+ {
1787
+ name: 'CompressedTokenInstructionDataRevoke';
1788
+ type: {
1789
+ kind: 'struct';
1790
+ fields: [
1791
+ {
1792
+ name: 'proof';
1793
+ type: {
1794
+ option: {
1795
+ defined: 'CompressedProof';
1796
+ };
1797
+ };
1798
+ },
1799
+ {
1800
+ name: 'mint';
1801
+ type: 'publicKey';
1802
+ },
1803
+ {
1804
+ name: 'inputTokenDataWithContext';
1805
+ type: {
1806
+ vec: {
1807
+ defined: 'InputTokenDataWithContext';
1808
+ };
1809
+ };
1810
+ },
1811
+ {
1812
+ name: 'cpiContext';
1813
+ type: {
1814
+ option: {
1815
+ defined: 'CompressedCpiContext';
1816
+ };
1817
+ };
1818
+ },
1819
+ {
1820
+ name: 'outputAccountMerkleTreeIndex';
1821
+ type: 'u8';
1822
+ }
1823
+ ];
1824
+ };
1825
+ },
1826
+ {
1827
+ name: 'CompressedTokenInstructionDataApprove';
1828
+ type: {
1829
+ kind: 'struct';
1830
+ fields: [
1831
+ {
1832
+ name: 'proof';
1833
+ type: {
1834
+ option: {
1835
+ defined: 'CompressedProof';
1836
+ };
1837
+ };
1838
+ },
1839
+ {
1840
+ name: 'mint';
1841
+ type: 'publicKey';
1842
+ },
1843
+ {
1844
+ name: 'inputTokenDataWithContext';
1845
+ type: {
1846
+ vec: {
1847
+ defined: 'InputTokenDataWithContext';
1848
+ };
1849
+ };
1850
+ },
1851
+ {
1852
+ name: 'cpiContext';
1853
+ type: {
1854
+ option: {
1855
+ defined: 'CompressedCpiContext';
1856
+ };
1857
+ };
1858
+ },
1859
+ {
1860
+ name: 'delegate';
1861
+ type: 'publicKey';
1862
+ },
1863
+ {
1864
+ name: 'delegatedAmount';
1865
+ type: 'u64';
1866
+ },
1867
+ {
1868
+ name: 'delegateMerkleTreeIndex';
1869
+ type: 'u8';
1870
+ },
1871
+ {
1872
+ name: 'changeAccountMerkleTreeIndex';
1873
+ type: 'u8';
1874
+ },
1875
+ {
1876
+ name: 'delegateLamports';
1877
+ type: {
1878
+ option: 'u64';
1879
+ };
1880
+ }
1881
+ ];
1882
+ };
1883
+ },
1914
1884
  {
1915
1885
  name: 'DelegatedTransfer';
1916
1886
  docs: [
@@ -2205,7 +2175,7 @@ type LightCompressedToken = {
2205
2175
  type: 'u8';
2206
2176
  },
2207
2177
  {
2208
- name: 'nullifierQueuePubkeyIndex';
2178
+ name: 'queuePubkeyIndex';
2209
2179
  type: 'u8';
2210
2180
  },
2211
2181
  {
@@ -2213,12 +2183,8 @@ type LightCompressedToken = {
2213
2183
  type: 'u32';
2214
2184
  },
2215
2185
  {
2216
- name: 'queueIndex';
2217
- type: {
2218
- option: {
2219
- defined: 'QueueIndex';
2220
- };
2221
- };
2186
+ name: 'proveByIndex';
2187
+ type: 'bool';
2222
2188
  }
2223
2189
  ];
2224
2190
  };
@@ -2560,112 +2526,711 @@ type LightCompressedToken = {
2560
2526
  };
2561
2527
  declare const IDL: LightCompressedToken;
2562
2528
 
2563
- declare const ERROR_NO_ACCOUNTS_FOUND = "Could not find accounts to select for transfer.";
2529
+ declare const DelegatedTransferLayout: buffer_layout.Layout<unknown>;
2530
+ declare const CpiContextLayout: buffer_layout.Layout<unknown>;
2531
+ declare const CompressedTokenInstructionDataTransferLayout: buffer_layout.Layout<unknown>;
2532
+ declare const mintToLayout: buffer_layout.Layout<unknown>;
2533
+ declare const batchCompressLayout: buffer_layout.Layout<unknown>;
2534
+ declare const compressSplTokenAccountInstructionDataLayout: buffer_layout.Layout<unknown>;
2535
+ declare function encodeMintToInstructionData(data: MintToInstructionData): Buffer;
2536
+ declare function decodeMintToInstructionData(buffer: Buffer): MintToInstructionData;
2537
+ declare function encodeBatchCompressInstructionData(data: BatchCompressInstructionData): Buffer;
2538
+ declare function decodeBatchCompressInstructionData(buffer: Buffer): BatchCompressInstructionData;
2539
+ declare function encodeCompressSplTokenAccountInstructionData(data: CompressSplTokenAccountInstructionData): Buffer;
2540
+ declare function decodeCompressSplTokenAccountInstructionData(buffer: Buffer): CompressSplTokenAccountInstructionData;
2541
+ declare function encodeTransferInstructionData(data: CompressedTokenInstructionDataTransfer): Buffer;
2542
+ declare function decodeTransferInstructionData(buffer: Buffer): CompressedTokenInstructionDataTransfer;
2543
+ interface BaseAccountsLayoutParams {
2544
+ feePayer: PublicKey;
2545
+ authority: PublicKey;
2546
+ cpiAuthorityPda: PublicKey;
2547
+ lightSystemProgram: PublicKey;
2548
+ registeredProgramPda: PublicKey;
2549
+ noopProgram: PublicKey;
2550
+ accountCompressionAuthority: PublicKey;
2551
+ accountCompressionProgram: PublicKey;
2552
+ selfProgram: PublicKey;
2553
+ systemProgram: PublicKey;
2554
+ }
2555
+ type createTokenPoolAccountsLayoutParams = {
2556
+ feePayer: PublicKey;
2557
+ tokenPoolPda: PublicKey;
2558
+ systemProgram: PublicKey;
2559
+ mint: PublicKey;
2560
+ tokenProgram: PublicKey;
2561
+ cpiAuthorityPda: PublicKey;
2562
+ };
2563
+ type addTokenPoolAccountsLayoutParams = createTokenPoolAccountsLayoutParams & {
2564
+ existingTokenPoolPda: PublicKey;
2565
+ };
2566
+ type mintToAccountsLayoutParams = BaseAccountsLayoutParams & {
2567
+ mint: PublicKey;
2568
+ tokenPoolPda: PublicKey;
2569
+ tokenProgram: PublicKey;
2570
+ merkleTree: PublicKey;
2571
+ solPoolPda: PublicKey | null;
2572
+ };
2573
+ type transferAccountsLayoutParams = BaseAccountsLayoutParams & {
2574
+ tokenPoolPda?: PublicKey;
2575
+ compressOrDecompressTokenAccount?: PublicKey;
2576
+ tokenProgram?: PublicKey;
2577
+ };
2578
+ type approveAccountsLayoutParams = BaseAccountsLayoutParams;
2579
+ type revokeAccountsLayoutParams = approveAccountsLayoutParams;
2580
+ type freezeAccountsLayoutParams = BaseAccountsLayoutParams & {
2581
+ mint: PublicKey;
2582
+ };
2583
+ type thawAccountsLayoutParams = freezeAccountsLayoutParams;
2584
+ declare const createTokenPoolAccountsLayout: (accounts: createTokenPoolAccountsLayoutParams) => AccountMeta[];
2585
+ declare const addTokenPoolAccountsLayout: (accounts: addTokenPoolAccountsLayoutParams) => AccountMeta[];
2586
+ declare const mintToAccountsLayout: (accounts: mintToAccountsLayoutParams) => AccountMeta[];
2587
+ declare const transferAccountsLayout: (accounts: transferAccountsLayoutParams) => AccountMeta[];
2588
+ declare const approveAccountsLayout: (accounts: approveAccountsLayoutParams) => AccountMeta[];
2589
+ declare const revokeAccountsLayout: (accounts: approveAccountsLayoutParams) => AccountMeta[];
2590
+ declare const freezeAccountsLayout: (accounts: freezeAccountsLayoutParams) => AccountMeta[];
2591
+ declare const thawAccountsLayout: (accounts: freezeAccountsLayoutParams) => AccountMeta[];
2592
+ declare const CompressedTokenInstructionDataApproveLayout: buffer_layout.Layout<unknown>;
2593
+ declare const CompressedTokenInstructionDataRevokeLayout: buffer_layout.Layout<unknown>;
2594
+ declare function encodeApproveInstructionData(data: CompressedTokenInstructionDataApprove): Buffer;
2595
+ declare function decodeApproveInstructionData(buffer: Buffer): CompressedTokenInstructionDataApprove;
2596
+ declare function encodeRevokeInstructionData(data: CompressedTokenInstructionDataRevoke): Buffer;
2597
+ declare function decodeRevokeInstructionData(buffer: Buffer): CompressedTokenInstructionDataRevoke;
2598
+
2599
+ type CompressParams = {
2600
+ /**
2601
+ * Fee payer
2602
+ */
2603
+ payer: PublicKey;
2604
+ /**
2605
+ * Owner of uncompressed token account
2606
+ */
2607
+ owner: PublicKey;
2608
+ /**
2609
+ * Source SPL Token account address
2610
+ */
2611
+ source: PublicKey;
2612
+ /**
2613
+ * Recipient address(es)
2614
+ */
2615
+ toAddress: PublicKey | PublicKey[];
2616
+ /**
2617
+ * Token amount(s) to compress
2618
+ */
2619
+ amount: number | BN | number[] | BN[];
2620
+ /**
2621
+ * SPL Token mint address
2622
+ */
2623
+ mint: PublicKey;
2624
+ /**
2625
+ * State tree to write to
2626
+ */
2627
+ outputStateTreeInfo: TreeInfo;
2628
+ /**
2629
+ * Token pool
2630
+ */
2631
+ tokenPoolInfo: TokenPoolInfo;
2632
+ };
2633
+ type CompressSplTokenAccountParams = {
2634
+ /**
2635
+ * Fee payer
2636
+ */
2637
+ feePayer: PublicKey;
2638
+ /**
2639
+ * SPL Token account owner
2640
+ */
2641
+ authority: PublicKey;
2642
+ /**
2643
+ * SPL Token account to compress
2644
+ */
2645
+ tokenAccount: PublicKey;
2646
+ /**
2647
+ * SPL Token mint address
2648
+ */
2649
+ mint: PublicKey;
2650
+ /**
2651
+ * Amount to leave in token account
2652
+ */
2653
+ remainingAmount?: BN;
2654
+ /**
2655
+ * State tree to write to
2656
+ */
2657
+ outputStateTreeInfo: TreeInfo;
2658
+ /**
2659
+ * Token pool
2660
+ */
2661
+ tokenPoolInfo: TokenPoolInfo;
2662
+ };
2663
+ type DecompressParams = {
2664
+ /**
2665
+ * Fee payer
2666
+ */
2667
+ payer: PublicKey;
2668
+ /**
2669
+ * Source compressed token accounts
2670
+ */
2671
+ inputCompressedTokenAccounts: ParsedTokenAccount[];
2672
+ /**
2673
+ * Destination uncompressed token account
2674
+ */
2675
+ toAddress: PublicKey;
2676
+ /**
2677
+ * Token amount to decompress
2678
+ */
2679
+ amount: number | BN;
2680
+ /**
2681
+ * Validity proof for input state
2682
+ */
2683
+ recentValidityProof: ValidityProof | CompressedProof | null;
2684
+ /**
2685
+ * Recent state root indices
2686
+ */
2687
+ recentInputStateRootIndices: number[];
2688
+ /**
2689
+ * Token pool(s)
2690
+ */
2691
+ tokenPoolInfos: TokenPoolInfo | TokenPoolInfo[];
2692
+ };
2693
+ type TransferParams = {
2694
+ /**
2695
+ * Fee payer
2696
+ */
2697
+ payer: PublicKey;
2698
+ /**
2699
+ * Source compressed token accounts
2700
+ */
2701
+ inputCompressedTokenAccounts: ParsedTokenAccount[];
2702
+ /**
2703
+ * Recipient address
2704
+ */
2705
+ toAddress: PublicKey;
2706
+ /**
2707
+ * Token amount to transfer
2708
+ */
2709
+ amount: BN | number;
2710
+ /**
2711
+ * Validity proof for input state
2712
+ */
2713
+ recentValidityProof: ValidityProof | CompressedProof | null;
2714
+ /**
2715
+ * Recent state root indices
2716
+ */
2717
+ recentInputStateRootIndices: number[];
2718
+ };
2719
+ type ApproveParams = {
2720
+ /**
2721
+ * Fee payer
2722
+ */
2723
+ payer: PublicKey;
2724
+ /**
2725
+ * Source compressed token accounts
2726
+ */
2727
+ inputCompressedTokenAccounts: ParsedTokenAccount[];
2728
+ /**
2729
+ * Recipient address
2730
+ */
2731
+ toAddress: PublicKey;
2732
+ /**
2733
+ * Token amount to approve
2734
+ */
2735
+ amount: BN | number;
2736
+ /**
2737
+ * Validity proof for input state
2738
+ */
2739
+ recentValidityProof: ValidityProof | CompressedProof | null;
2740
+ /**
2741
+ * Recent state root indices
2742
+ */
2743
+ recentInputStateRootIndices: number[];
2744
+ };
2745
+ type RevokeParams = {
2746
+ /**
2747
+ * Fee payer
2748
+ */
2749
+ payer: PublicKey;
2750
+ /**
2751
+ * Input compressed token accounts
2752
+ */
2753
+ inputCompressedTokenAccounts: ParsedTokenAccount[];
2754
+ /**
2755
+ * Validity proof for input state
2756
+ */
2757
+ recentValidityProof: ValidityProof | CompressedProof | null;
2758
+ /**
2759
+ * Recent state root indices
2760
+ */
2761
+ recentInputStateRootIndices: number[];
2762
+ };
2763
+ /**
2764
+ * Create Mint account for compressed Tokens
2765
+ */
2766
+ type CreateMintParams = {
2767
+ /**
2768
+ * Fee payer
2769
+ */
2770
+ feePayer: PublicKey;
2771
+ /**
2772
+ * SPL Mint address
2773
+ */
2774
+ mint: PublicKey;
2775
+ /**
2776
+ * Mint authority
2777
+ */
2778
+ authority: PublicKey;
2779
+ /**
2780
+ * Optional: freeze authority
2781
+ */
2782
+ freezeAuthority: PublicKey | null;
2783
+ /**
2784
+ * Mint decimals
2785
+ */
2786
+ decimals: number;
2787
+ /**
2788
+ * lamport amount for mint account rent exemption
2789
+ */
2790
+ rentExemptBalance: number;
2791
+ /**
2792
+ * Optional: The token program ID. Default: SPL Token Program ID
2793
+ */
2794
+ tokenProgramId?: PublicKey;
2795
+ /**
2796
+ * Optional: Mint size to use, defaults to MINT_SIZE
2797
+ */
2798
+ mintSize?: number;
2799
+ };
2800
+ /**
2801
+ * Parameters for merging compressed token accounts
2802
+ */
2803
+ type MergeTokenAccountsParams = {
2804
+ /**
2805
+ * Fee payer
2806
+ */
2807
+ payer: PublicKey;
2808
+ /**
2809
+ * Owner of the compressed token accounts to be merged
2810
+ */
2811
+ owner: PublicKey;
2812
+ /**
2813
+ * SPL Token mint address
2814
+ */
2815
+ mint: PublicKey;
2816
+ /**
2817
+ * Array of compressed token accounts to merge
2818
+ */
2819
+ inputCompressedTokenAccounts: ParsedTokenAccount[];
2820
+ /**
2821
+ * Validity proof for state inclusion
2822
+ */
2823
+ recentValidityProof: ValidityProof | CompressedProof | null;
2824
+ /**
2825
+ * State root indices of the input state
2826
+ */
2827
+ recentInputStateRootIndices: number[];
2828
+ };
2829
+ /**
2830
+ * Create compressed token accounts
2831
+ */
2832
+ type MintToParams = {
2833
+ /**
2834
+ * Fee payer
2835
+ */
2836
+ feePayer: PublicKey;
2837
+ /**
2838
+ * Token mint address
2839
+ */
2840
+ mint: PublicKey;
2841
+ /**
2842
+ * Mint authority
2843
+ */
2844
+ authority: PublicKey;
2845
+ /**
2846
+ * Recipient address(es)
2847
+ */
2848
+ toPubkey: PublicKey[] | PublicKey;
2849
+ /**
2850
+ * Token amount(s) to mint
2851
+ */
2852
+ amount: BN | BN[] | number | number[];
2853
+ /**
2854
+ * State tree for minted tokens
2855
+ */
2856
+ outputStateTreeInfo: TreeInfo;
2857
+ /**
2858
+ * Token pool
2859
+ */
2860
+ tokenPoolInfo: TokenPoolInfo;
2861
+ };
2862
+ /**
2863
+ * Register an existing SPL mint account to the compressed token program
2864
+ * Creates an omnibus account for the mint
2865
+ */
2866
+ type CreateTokenPoolParams = {
2867
+ /**
2868
+ * Fee payer
2869
+ */
2870
+ feePayer: PublicKey;
2871
+ /**
2872
+ * SPL Mint address
2873
+ */
2874
+ mint: PublicKey;
2875
+ /**
2876
+ * Optional: The token program ID. Default: SPL Token Program ID
2877
+ */
2878
+ tokenProgramId?: PublicKey;
2879
+ };
2880
+ type AddTokenPoolParams = {
2881
+ /**
2882
+ * Fee payer
2883
+ */
2884
+ feePayer: PublicKey;
2885
+ /**
2886
+ * Token mint address
2887
+ */
2888
+ mint: PublicKey;
2889
+ /**
2890
+ * Token pool index
2891
+ */
2892
+ poolIndex: number;
2893
+ /**
2894
+ * Optional: Token program ID. Default: SPL Token Program ID
2895
+ */
2896
+ tokenProgramId?: PublicKey;
2897
+ };
2898
+ /**
2899
+ * Mint from existing SPL mint to compressed token accounts
2900
+ */
2901
+ type ApproveAndMintToParams = {
2902
+ /**
2903
+ * Fee payer
2904
+ */
2905
+ feePayer: PublicKey;
2906
+ /**
2907
+ * SPL Mint address
2908
+ */
2909
+ mint: PublicKey;
2910
+ /**
2911
+ * Mint authority
2912
+ */
2913
+ authority: PublicKey;
2914
+ /**
2915
+ * Mint authority (associated) token account
2916
+ */
2917
+ authorityTokenAccount: PublicKey;
2918
+ /**
2919
+ * Recipient address
2920
+ */
2921
+ toPubkey: PublicKey;
2922
+ /**
2923
+ * Token amount to mint
2924
+ */
2925
+ amount: BN | number;
2926
+ /**
2927
+ * State tree to write to
2928
+ */
2929
+ outputStateTreeInfo: TreeInfo;
2930
+ /**
2931
+ * Token pool
2932
+ */
2933
+ tokenPoolInfo: TokenPoolInfo;
2934
+ };
2935
+ type CreateTokenProgramLookupTableParams = {
2936
+ /**
2937
+ * Fee payer
2938
+ */
2939
+ payer: PublicKey;
2940
+ /**
2941
+ * Authority of the transaction
2942
+ */
2943
+ authority: PublicKey;
2944
+ /**
2945
+ * Optional Mint addresses to store in the lookup table
2946
+ */
2947
+ mints?: PublicKey[];
2948
+ /**
2949
+ * Recently finalized Solana slot
2950
+ */
2951
+ recentSlot: number;
2952
+ /**
2953
+ * Optional additional addresses to store in the lookup table
2954
+ */
2955
+ remainingAccounts?: PublicKey[];
2956
+ };
2564
2957
  /**
2565
- * Selects the minimum number of compressed token accounts required for a transfer, up to a specified maximum.
2566
- *
2567
- * @param {ParsedTokenAccount[]} accounts - Token accounts to choose from.
2568
- * @param {BN} transferAmount - Amount to transfer.
2569
- * @param {number} [maxInputs=4] - Max accounts to select. Default is 4.
2570
- * @returns {[
2571
- * selectedAccounts: ParsedTokenAccount[],
2572
- * total: BN,
2573
- * totalLamports: BN | null,
2574
- * maxPossibleAmount: BN
2575
- * ]} - Returns:
2576
- * - selectedAccounts: Accounts chosen for transfer.
2577
- * - total: Total amount from selected accounts.
2578
- * - totalLamports: Total lamports from selected accounts.
2579
- * - maxPossibleAmount: Max transferable amount given maxInputs.
2580
- *
2581
- * @example
2582
- * const accounts = [
2583
- * { parsed: { amount: new BN(100) }, compressedAccount: { lamports: new BN(10) } },
2584
- * { parsed: { amount: new BN(50) }, compressedAccount: { lamports: new BN(5) } },
2585
- * { parsed: { amount: new BN(25) }, compressedAccount: { lamports: new BN(2) } },
2586
- * ];
2587
- * const transferAmount = new BN(75);
2588
- * const maxInputs = 2;
2589
- *
2590
- * const [selectedAccounts, total, totalLamports, maxPossibleAmount] =
2591
- * selectMinCompressedTokenAccountsForTransfer(accounts, transferAmount, maxInputs);
2592
- *
2593
- * console.log(selectedAccounts.length); // 2
2594
- * console.log(total.toString()); // '150'
2595
- * console.log(totalLamports!.toString()); // '15'
2958
+ * Sum up the token amounts of the compressed token accounts
2596
2959
  */
2597
- declare function selectMinCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
2598
- selectedAccounts: ParsedTokenAccount[],
2599
- total: BN,
2600
- totalLamports: BN | null,
2601
- maxPossibleAmount: BN
2602
- ];
2960
+ declare const sumUpTokenAmount: (accounts: ParsedTokenAccount[]) => BN;
2603
2961
  /**
2604
- * Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,
2605
- * returns partial amounts if insufficient accounts are found instead of
2606
- * throwing an error.
2962
+ * Validate that all the compressed token accounts are owned by the same owner.
2607
2963
  */
2608
- declare function selectMinCompressedTokenAccountsForTransferOrPartial(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
2609
- selectedAccounts: ParsedTokenAccount[],
2610
- total: BN,
2611
- totalLamports: BN | null,
2612
- maxPossibleAmount: BN
2613
- ];
2964
+ declare const validateSameTokenOwner: (accounts: ParsedTokenAccount[]) => void;
2614
2965
  /**
2615
- * Selects compressed token accounts for a transfer, ensuring one extra account
2616
- * if possible, up to maxInputs.
2617
- *
2618
- * 1. Sorts accounts by amount (desc)
2619
- * 2. Selects accounts until transfer amount is met or maxInputs is reached,
2620
- * attempting to add one extra account if possible.
2621
- *
2622
- * @param {ParsedTokenAccount[]} accounts - The list of token accounts to select from.
2623
- * @param {BN} transferAmount - The token amount to be transferred.
2624
- * @param {number} [maxInputs=4] - The maximum number of accounts to select. Default: 4.
2625
- * @returns {[
2626
- * selectedAccounts: ParsedTokenAccount[],
2627
- * total: BN,
2628
- * totalLamports: BN | null,
2629
- * maxPossibleAmount: BN
2630
- * ]} - An array containing:
2631
- * - selectedAccounts: The accounts selected for the transfer.
2632
- * - total: The total amount accumulated from the selected accounts.
2633
- * - totalLamports: The total lamports accumulated from the selected accounts.
2634
- * - maxPossibleAmount: The maximum possible amount that can be transferred considering maxInputs.
2635
- *
2636
- * @example
2637
- * const accounts = [
2638
- * { parsed: { amount: new BN(100) }, compressedAccount: { lamports: new BN(10) } },
2639
- * { parsed: { amount: new BN(50) }, compressedAccount: { lamports: new BN(5) } },
2640
- * { parsed: { amount: new BN(25) }, compressedAccount: { lamports: new BN(2) } },
2641
- * ];
2642
- * const transferAmount = new BN(75);
2643
- * const maxInputs = 2;
2644
- *
2645
- * const [selectedAccounts, total, totalLamports, maxPossibleAmount] =
2646
- * selectSmartCompressedTokenAccountsForTransfer(accounts, transferAmount, maxInputs);
2647
- *
2648
- * console.log(selectedAccounts.length); // 2
2649
- * console.log(total.toString()); // '150'
2650
- * console.log(totalLamports!.toString()); // '15'
2651
- * console.log(maxPossibleAmount.toString()); // '150'
2966
+ * Parse compressed token accounts to get the mint, current owner and delegate.
2652
2967
  */
2653
- declare function selectSmartCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
2654
- selectedAccounts: ParsedTokenAccount[],
2655
- total: BN,
2656
- totalLamports: BN | null,
2657
- maxPossibleAmount: BN
2658
- ];
2968
+ declare const parseTokenData: (compressedTokenAccounts: ParsedTokenAccount[]) => {
2969
+ mint: PublicKey;
2970
+ currentOwner: PublicKey;
2971
+ delegate: PublicKey | null;
2972
+ };
2973
+ declare const parseMaybeDelegatedTransfer: (inputs: ParsedTokenAccount[], outputs: TokenTransferOutputData[]) => {
2974
+ delegatedTransfer: DelegatedTransfer | null;
2975
+ authority: PublicKey;
2976
+ };
2659
2977
  /**
2660
- * Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,
2661
- * returns partial amounts if insufficient accounts are found instead of
2662
- * throwing an error.
2978
+ * Create the output state for a transfer transaction.
2979
+ * @param inputCompressedTokenAccounts Input state
2980
+ * @param toAddress Recipient address
2981
+ * @param amount Amount of tokens to transfer
2982
+ * @returns Output token data for the transfer
2983
+ * instruction
2663
2984
  */
2664
- declare function selectSmartCompressedTokenAccountsForTransferOrPartial(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
2665
- selectedAccounts: ParsedTokenAccount[],
2666
- total: BN,
2667
- totalLamports: BN | null,
2668
- maxPossibleAmount: BN
2669
- ];
2985
+ declare function createTransferOutputState(inputCompressedTokenAccounts: ParsedTokenAccount[], toAddress: PublicKey, amount: number | BN): TokenTransferOutputData[];
2986
+ /**
2987
+ * Create the output state for a compress transaction.
2988
+ * @param inputCompressedTokenAccounts Input state
2989
+ * @param amount Amount of tokens to compress
2990
+ * @returns Output token data for the compress
2991
+ * instruction
2992
+ */
2993
+ declare function createDecompressOutputState(inputCompressedTokenAccounts: ParsedTokenAccount[], amount: number | BN): TokenTransferOutputData[];
2994
+ declare class CompressedTokenProgram {
2995
+ /**
2996
+ * @internal
2997
+ */
2998
+ constructor();
2999
+ /**
3000
+ * Public key that identifies the CompressedPda program
3001
+ */
3002
+ static programId: PublicKey;
3003
+ /**
3004
+ * Set a custom programId via PublicKey or base58 encoded string.
3005
+ * This method is not required for regular usage.
3006
+ *
3007
+ * Use this only if you know what you are doing.
3008
+ */
3009
+ static setProgramId(programId: PublicKey | string): void;
3010
+ /**
3011
+ * Derive the token pool pda.
3012
+ * To derive the token pool pda with bump, use {@link deriveTokenPoolPdaWithIndex}.
3013
+ *
3014
+ * @param mint The mint of the token pool
3015
+ *
3016
+ * @returns The token pool pda
3017
+ */
3018
+ static deriveTokenPoolPda(mint: PublicKey): PublicKey;
3019
+ /**
3020
+ * Find the index and bump for a given token pool pda and mint.
3021
+ *
3022
+ * @param poolPda The token pool pda to find the index and bump for
3023
+ * @param mint The mint of the token pool
3024
+ *
3025
+ * @returns The index and bump number.
3026
+ */
3027
+ static findTokenPoolIndexAndBump(poolPda: PublicKey, mint: PublicKey): [number, number];
3028
+ /**
3029
+ * Derive the token pool pda with index.
3030
+ *
3031
+ * @param mint The mint of the token pool
3032
+ * @param index Index. starts at 0. The Protocol supports 4 indexes aka token pools
3033
+ * per mint.
3034
+ *
3035
+ * @returns The token pool pda and bump.
3036
+ */
3037
+ static deriveTokenPoolPdaWithIndex(mint: PublicKey, index: number): [PublicKey, number];
3038
+ /** @internal */
3039
+ static get deriveCpiAuthorityPda(): PublicKey;
3040
+ /**
3041
+ * Construct createMint instruction for compressed tokens.
3042
+ *
3043
+ * @param feePayer Fee payer.
3044
+ * @param mint SPL Mint address.
3045
+ * @param authority Mint authority.
3046
+ * @param freezeAuthority Optional: freeze authority.
3047
+ * @param decimals Decimals.
3048
+ * @param rentExemptBalance Lamport amount for mint account rent exemption.
3049
+ * @param tokenProgramId Optional: Token program ID. Default: SPL Token Program ID
3050
+ * @param mintSize Optional: mint size. Default: MINT_SIZE
3051
+ *
3052
+ * @returns [createMintAccountInstruction, initializeMintInstruction,
3053
+ * createTokenPoolInstruction]
3054
+ *
3055
+ * Note that `createTokenPoolInstruction` must be executed after
3056
+ * `initializeMintInstruction`.
3057
+ */
3058
+ static createMint({ feePayer, mint, authority, freezeAuthority, decimals, rentExemptBalance, tokenProgramId, mintSize, }: CreateMintParams): Promise<TransactionInstruction[]>;
3059
+ /**
3060
+ * Enable compression for an existing SPL mint, creating an omnibus account.
3061
+ * For new mints, use `CompressedTokenProgram.createMint`.
3062
+ *
3063
+ * @param feePayer Fee payer.
3064
+ * @param mint SPL Mint address.
3065
+ * @param tokenProgramId Optional: Token program ID. Default: SPL
3066
+ * Token Program ID
3067
+ *
3068
+ * @returns The createTokenPool instruction
3069
+ */
3070
+ static createTokenPool({ feePayer, mint, tokenProgramId, }: CreateTokenPoolParams): Promise<TransactionInstruction>;
3071
+ /**
3072
+ * Add a token pool to an existing SPL mint. For new mints, use
3073
+ * {@link createTokenPool}.
3074
+ *
3075
+ * @param feePayer Fee payer.
3076
+ * @param mint SPL Mint address.
3077
+ * @param poolIndex Pool index.
3078
+ * @param tokenProgramId Optional: Token program ID. Default: SPL
3079
+ * Token Program ID
3080
+ *
3081
+ * @returns The addTokenPool instruction
3082
+ */
3083
+ static addTokenPool({ feePayer, mint, poolIndex, tokenProgramId, }: AddTokenPoolParams): Promise<TransactionInstruction>;
3084
+ /**
3085
+ * Construct mintTo instruction for compressed tokens
3086
+ *
3087
+ * @param feePayer Fee payer.
3088
+ * @param mint SPL Mint address.
3089
+ * @param authority Mint authority.
3090
+ * @param toPubkey Recipient owner address.
3091
+ * @param amount Amount of tokens to mint.
3092
+ * @param outputStateTreeInfo State tree to write to.
3093
+ * @param tokenPoolInfo Token pool info.
3094
+ *
3095
+ * @returns The mintTo instruction
3096
+ */
3097
+ static mintTo({ feePayer, mint, authority, toPubkey, amount, outputStateTreeInfo, tokenPoolInfo, }: MintToParams): Promise<TransactionInstruction>;
3098
+ /**
3099
+ * Mint tokens from registered SPL mint account to a compressed account
3100
+ *
3101
+ * @param feePayer Fee payer.
3102
+ * @param mint SPL Mint address.
3103
+ * @param authority Mint authority.
3104
+ * @param authorityTokenAccount The mint authority's associated token
3105
+ * account (ATA).
3106
+ * @param toPubkey Recipient owner address.
3107
+ * @param amount Amount of tokens to mint.
3108
+ * @param outputStateTreeInfo State tree to write to.
3109
+ * @param tokenPoolInfo Token pool info.
3110
+ *
3111
+ * @returns The mintTo instruction
3112
+ */
3113
+ static approveAndMintTo({ feePayer, mint, authority, authorityTokenAccount, toPubkey, amount, outputStateTreeInfo, tokenPoolInfo, }: ApproveAndMintToParams): Promise<TransactionInstruction[]>;
3114
+ /**
3115
+ * Construct transfer instruction for compressed tokens
3116
+ *
3117
+ * @param payer Fee payer.
3118
+ * @param inputCompressedTokenAccounts Source compressed token accounts.
3119
+ * @param toAddress Recipient owner address.
3120
+ * @param amount Amount of tokens to transfer.
3121
+ * @param recentValidityProof Recent validity proof.
3122
+ * @param recentInputStateRootIndices Recent state root indices.
3123
+ *
3124
+ * @returns The transfer instruction
3125
+ */
3126
+ static transfer({ payer, inputCompressedTokenAccounts, toAddress, amount, recentValidityProof, recentInputStateRootIndices, }: TransferParams): Promise<TransactionInstruction>;
3127
+ /**
3128
+ * Create lookup table instructions for the token program's default
3129
+ * accounts.
3130
+ *
3131
+ * @param payer Fee payer.
3132
+ * @param authority Authority.
3133
+ * @param mints Mints.
3134
+ * @param recentSlot Recent slot.
3135
+ * @param remainingAccounts Remaining accounts.
3136
+ *
3137
+ * @returns [createInstruction, extendInstruction, option(extendInstruction2)]
3138
+ */
3139
+ static createTokenProgramLookupTable({ payer, authority, mints, recentSlot, remainingAccounts, }: CreateTokenProgramLookupTableParams): Promise<{
3140
+ instructions: TransactionInstruction[];
3141
+ address: PublicKey;
3142
+ }>;
3143
+ /**
3144
+ * Create compress instruction
3145
+ *
3146
+ * @param payer Fee payer.
3147
+ * @param owner Owner of uncompressed token account.
3148
+ * @param source Source SPL Token account address.
3149
+ * @param toAddress Recipient owner address(es).
3150
+ * @param amount Amount of tokens to compress.
3151
+ * @param mint SPL Token mint address.
3152
+ * @param outputStateTreeInfo State tree to write to.
3153
+ * @param tokenPoolInfo Token pool info.
3154
+ *
3155
+ * @returns The compress instruction
3156
+ */
3157
+ static compress({ payer, owner, source, toAddress, amount, mint, outputStateTreeInfo, tokenPoolInfo, }: CompressParams): Promise<TransactionInstruction>;
3158
+ /**
3159
+ * Construct decompress instruction
3160
+ *
3161
+ * @param payer Fee payer.
3162
+ * @param inputCompressedTokenAccounts Source compressed token accounts.
3163
+ * @param toAddress Destination **uncompressed** token
3164
+ * account address. (ATA)
3165
+ * @param amount Amount of tokens to decompress.
3166
+ * @param recentValidityProof Recent validity proof.
3167
+ * @param recentInputStateRootIndices Recent state root indices.
3168
+ * @param tokenPoolInfos Token pool info.
3169
+ *
3170
+ * @returns The decompress instruction
3171
+ */
3172
+ static decompress({ payer, inputCompressedTokenAccounts, toAddress, amount, recentValidityProof, recentInputStateRootIndices, tokenPoolInfos, }: DecompressParams): Promise<TransactionInstruction>;
3173
+ /**
3174
+ * Create `mergeTokenAccounts` instruction
3175
+ *
3176
+ * @param payer Fee payer.
3177
+ * @param owner Owner of the compressed token
3178
+ * accounts to be merged.
3179
+ * @param inputCompressedTokenAccounts Source compressed token accounts.
3180
+ * @param mint SPL Token mint address.
3181
+ * @param recentValidityProof Recent validity proof.
3182
+ * @param recentInputStateRootIndices Recent state root indices.
3183
+ *
3184
+ * @returns instruction
3185
+ */
3186
+ static mergeTokenAccounts({ payer, owner, inputCompressedTokenAccounts, mint, recentValidityProof, recentInputStateRootIndices, }: MergeTokenAccountsParams): Promise<TransactionInstruction[]>;
3187
+ /**
3188
+ * Create `compressSplTokenAccount` instruction
3189
+ *
3190
+ * @param feePayer Fee payer.
3191
+ * @param authority SPL Token account owner.
3192
+ * @param tokenAccount SPL Token account to compress.
3193
+ * @param mint SPL Token mint address.
3194
+ * @param remainingAmount Optional: Amount to leave in token account.
3195
+ * @param outputStateTreeInfo State tree to write to.
3196
+ * @param tokenPoolInfo Token pool info.
3197
+ *
3198
+ * @returns instruction
3199
+ */
3200
+ static compressSplTokenAccount({ feePayer, authority, tokenAccount, mint, remainingAmount, outputStateTreeInfo, tokenPoolInfo, }: CompressSplTokenAccountParams): Promise<TransactionInstruction>;
3201
+ /**
3202
+ * Get the program ID for a mint
3203
+ *
3204
+ * @param mint SPL Token mint address.
3205
+ * @param connection Connection.
3206
+ *
3207
+ * @returns program ID
3208
+ */
3209
+ static getMintProgramId(mint: PublicKey, connection: Connection): Promise<PublicKey | undefined>;
3210
+ /**
3211
+ * Create `approve` instruction to delegate compressed tokens.
3212
+ *
3213
+ * @param payer Fee payer.
3214
+ * @param inputCompressedTokenAccounts Source compressed token accounts.
3215
+ * @param toAddress Owner to delegate to.
3216
+ * @param amount Amount of tokens to delegate.
3217
+ * @param recentValidityProof Recent validity proof.
3218
+ * @param recentInputStateRootIndices Recent state root indices.
3219
+ *
3220
+ * @returns instruction
3221
+ */
3222
+ static approve({ payer, inputCompressedTokenAccounts, toAddress, amount, recentValidityProof, recentInputStateRootIndices, }: ApproveParams): Promise<TransactionInstruction>;
3223
+ /**
3224
+ * Create `revoke` instruction to revoke delegation of compressed tokens.
3225
+ *
3226
+ * @param payer Fee payer.
3227
+ * @param inputCompressedTokenAccounts Source compressed token accounts.
3228
+ * @param recentValidityProof Recent validity proof.
3229
+ * @param recentInputStateRootIndices Recent state root indices.
3230
+ *
3231
+ * @returns instruction
3232
+ */
3233
+ static revoke({ payer, inputCompressedTokenAccounts, recentValidityProof, recentInputStateRootIndices, }: RevokeParams): Promise<TransactionInstruction>;
3234
+ }
2670
3235
 
2671
- export { type ApproveAndMintToParams, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type CompressParams, type CompressSplTokenAccountInstructionData, type CompressSplTokenAccountParams, type CompressedCpiContext, type CompressedTokenInstructionDataTransfer, CompressedTokenInstructionDataTransferLayout, CompressedTokenProgram, CpiContextLayout, type CreateMintParams, type CreateTokenProgramLookupTableParams, type DecompressParams, type DelegatedTransfer, DelegatedTransferLayout, ERROR_NO_ACCOUNTS_FOUND, IDL, type InputTokenDataWithContext, type LightCompressedToken, MINT_TO_DISCRIMINATOR, type MergeTokenAccountsParams, type MintToInstructionData, type MintToParams, POOL_SEED, type PackCompressedTokenAccountsParams, type PackedTokenTransferOutputData, type RegisterMintParams, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, TRANSFER_DISCRIMINATOR, type TokenData, type TokenTransferOutputData, type TransferParams, type approveAccountsLayoutParams, approveAndMintTo, compress, compressSplTokenAccount, compressSplTokenAccountInstructionDataLayout, createDecompressOutputState, createMint, createTokenPool, createTokenPoolAccountsLayout, type createTokenPoolAccountsLayoutParams, createTokenProgramLookupTable, createTransferOutputState, decodeCompressSplTokenAccountInstructionData, decodeMintToInstructionData, decodeTransferInstructionData, decompress, encodeCompressSplTokenAccountInstructionData, encodeMintToInstructionData, encodeTransferInstructionData, type freezeAccountsLayoutParams, mergeTokenAccounts, mintTo, mintToAccountsLayout, type mintToAccountsLayoutParams, mintToLayout, packCompressedTokenAccounts, parseTokenData, type revokeAccountsLayoutParams, selectMinCompressedTokenAccountsForTransfer, selectMinCompressedTokenAccountsForTransferOrPartial, selectSmartCompressedTokenAccountsForTransfer, selectSmartCompressedTokenAccountsForTransferOrPartial, sumUpTokenAmount, type thawAccountsLayoutParams, transfer, transferAccountsLayout, type transferAccountsLayoutParams, validateSameTokenOwner };
3236
+ export { ADD_TOKEN_POOL_DISCRIMINATOR, APPROVE_DISCRIMINATOR, Action, type AddTokenPoolParams, type ApproveAndMintToParams, type ApproveParams, BATCH_COMPRESS_DISCRIMINATOR, type BatchCompressInstructionData, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type CompressParams, type CompressSplTokenAccountInstructionData, type CompressSplTokenAccountParams, type CompressedTokenInstructionDataApprove, CompressedTokenInstructionDataApproveLayout, type CompressedTokenInstructionDataRevoke, CompressedTokenInstructionDataRevokeLayout, type CompressedTokenInstructionDataTransfer, CompressedTokenInstructionDataTransferLayout, CompressedTokenProgram, CpiContextLayout, type CreateMintParams, type CreateTokenPoolParams, type CreateTokenProgramLookupTableParams, type DecompressParams, type DelegatedTransfer, DelegatedTransferLayout, ERROR_NO_ACCOUNTS_FOUND, IDL, type InputTokenDataWithContext, type LightCompressedToken, MINT_TO_DISCRIMINATOR, type MergeTokenAccountsParams, type MintToInstructionData, type MintToParams, POOL_SEED, type PackCompressedTokenAccountsParams, type PackedTokenTransferOutputData, REVOKE_DISCRIMINATOR, type RevokeParams, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, TRANSFER_DISCRIMINATOR, type TokenData, type TokenPoolActivity, type TokenPoolInfo, type TokenTransferOutputData, type TransferParams, addTokenPoolAccountsLayout, type addTokenPoolAccountsLayoutParams, addTokenPools, approve, approveAccountsLayout, type approveAccountsLayoutParams, approveAndMintTo, batchCompressLayout, checkMint, checkTokenPoolInfo, compress, compressSplTokenAccount, compressSplTokenAccountInstructionDataLayout, createDecompressOutputState, createMint, createTokenPool, createTokenPoolAccountsLayout, type createTokenPoolAccountsLayoutParams, createTokenProgramLookupTable, createTransferOutputState, decodeApproveInstructionData, decodeBatchCompressInstructionData, decodeCompressSplTokenAccountInstructionData, decodeMintToInstructionData, decodeRevokeInstructionData, decodeTransferInstructionData, decompress, decompressDelegated, encodeApproveInstructionData, encodeBatchCompressInstructionData, encodeCompressSplTokenAccountInstructionData, encodeMintToInstructionData, encodeRevokeInstructionData, encodeTransferInstructionData, freezeAccountsLayout, type freezeAccountsLayoutParams, getTokenPoolInfos, isSingleTokenPoolInfo, mergeTokenAccounts, mintTo, mintToAccountsLayout, type mintToAccountsLayoutParams, mintToLayout, packCompressedTokenAccounts, parseMaybeDelegatedTransfer, parseTokenData, revoke, revokeAccountsLayout, type revokeAccountsLayoutParams, selectMinCompressedTokenAccountsForDecompression, selectMinCompressedTokenAccountsForTransfer, selectMinCompressedTokenAccountsForTransferOrPartial, selectSmartCompressedTokenAccountsForTransfer, selectSmartCompressedTokenAccountsForTransferOrPartial, selectTokenAccountsForApprove, selectTokenPoolInfo, selectTokenPoolInfosForDecompression, sumUpTokenAmount, thawAccountsLayout, type thawAccountsLayoutParams, transfer, transferAccountsLayout, type transferAccountsLayoutParams, transferDelegated, validateSameTokenOwner };