tensor_amm/generated/instructions/
deposit_nft.rs

1//! This code was AUTOGENERATED using the codama library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun codama to update it.
4//!
5//! <https://github.com/codama-idl/codama>
6//!
7
8use crate::generated::types::AuthorizationDataLocal;
9use borsh::BorshDeserialize;
10use borsh::BorshSerialize;
11
12/// Accounts.
13pub struct DepositNft {
14    /// The owner of the pool and the NFT.
15    pub owner: solana_program::pubkey::Pubkey,
16    /// The pool the NFT is being transferred to/from.
17    pub pool: solana_program::pubkey::Pubkey,
18    /// The whitelist that gatekeeps which NFTs can be deposited into the pool.
19    /// Must match the whitelist stored in the pool state.
20    pub whitelist: solana_program::pubkey::Pubkey,
21    /// Optional account which must be passed in if the NFT must be verified against a
22    /// merkle proof condition in the whitelist.
23    pub mint_proof: Option<solana_program::pubkey::Pubkey>,
24    /// The mint account of the NFT.
25    pub mint: solana_program::pubkey::Pubkey,
26    /// The Token Metadata metadata account of the NFT.
27    pub metadata: solana_program::pubkey::Pubkey,
28    /// The Token Metadata edition account of the NFT.
29    pub edition: solana_program::pubkey::Pubkey,
30    /// The Token Metadata source token record account of the NFT.
31    pub user_token_record: Option<solana_program::pubkey::Pubkey>,
32    /// The Token Metadata token record for the destination.
33    pub pool_token_record: Option<solana_program::pubkey::Pubkey>,
34    /// The Token Metadata program account.
35    pub token_metadata_program: Option<solana_program::pubkey::Pubkey>,
36    /// The sysvar instructions account.
37    pub sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
38    /// The Metaplex Token Authority Rules account that stores royalty enforcement rules.
39    pub authorization_rules: Option<solana_program::pubkey::Pubkey>,
40    /// The Metaplex Token Authority Rules program account.
41    pub authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
42    /// The NFT deposit receipt, which ties an NFT to the pool it was deposited to.
43    pub nft_receipt: solana_program::pubkey::Pubkey,
44    /// The token account of the owner, where the NFT will be transferred from.
45    pub owner_ta: solana_program::pubkey::Pubkey,
46    /// The token account of the pool, where the NFT will be escrowed.
47    pub pool_ta: solana_program::pubkey::Pubkey,
48    /// The SPL Token program for the Mint and ATAs.
49    pub token_program: solana_program::pubkey::Pubkey,
50    /// The SPL associated token program.
51    pub associated_token_program: solana_program::pubkey::Pubkey,
52    /// The Solana system program.
53    pub system_program: solana_program::pubkey::Pubkey,
54}
55
56impl DepositNft {
57    pub fn instruction(
58        &self,
59        args: DepositNftInstructionArgs,
60    ) -> solana_program::instruction::Instruction {
61        self.instruction_with_remaining_accounts(args, &[])
62    }
63    #[allow(clippy::vec_init_then_push)]
64    pub fn instruction_with_remaining_accounts(
65        &self,
66        args: DepositNftInstructionArgs,
67        remaining_accounts: &[solana_program::instruction::AccountMeta],
68    ) -> solana_program::instruction::Instruction {
69        let mut accounts = Vec::with_capacity(19 + remaining_accounts.len());
70        accounts.push(solana_program::instruction::AccountMeta::new(
71            self.owner, true,
72        ));
73        accounts.push(solana_program::instruction::AccountMeta::new(
74            self.pool, false,
75        ));
76        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
77            self.whitelist,
78            false,
79        ));
80        if let Some(mint_proof) = self.mint_proof {
81            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
82                mint_proof, false,
83            ));
84        } else {
85            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
86                crate::TENSOR_AMM_ID,
87                false,
88            ));
89        }
90        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
91            self.mint, false,
92        ));
93        accounts.push(solana_program::instruction::AccountMeta::new(
94            self.metadata,
95            false,
96        ));
97        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
98            self.edition,
99            false,
100        ));
101        if let Some(user_token_record) = self.user_token_record {
102            accounts.push(solana_program::instruction::AccountMeta::new(
103                user_token_record,
104                false,
105            ));
106        } else {
107            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
108                crate::TENSOR_AMM_ID,
109                false,
110            ));
111        }
112        if let Some(pool_token_record) = self.pool_token_record {
113            accounts.push(solana_program::instruction::AccountMeta::new(
114                pool_token_record,
115                false,
116            ));
117        } else {
118            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
119                crate::TENSOR_AMM_ID,
120                false,
121            ));
122        }
123        if let Some(token_metadata_program) = self.token_metadata_program {
124            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
125                token_metadata_program,
126                false,
127            ));
128        } else {
129            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
130                crate::TENSOR_AMM_ID,
131                false,
132            ));
133        }
134        if let Some(sysvar_instructions) = self.sysvar_instructions {
135            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
136                sysvar_instructions,
137                false,
138            ));
139        } else {
140            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
141                crate::TENSOR_AMM_ID,
142                false,
143            ));
144        }
145        if let Some(authorization_rules) = self.authorization_rules {
146            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
147                authorization_rules,
148                false,
149            ));
150        } else {
151            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
152                crate::TENSOR_AMM_ID,
153                false,
154            ));
155        }
156        if let Some(authorization_rules_program) = self.authorization_rules_program {
157            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
158                authorization_rules_program,
159                false,
160            ));
161        } else {
162            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
163                crate::TENSOR_AMM_ID,
164                false,
165            ));
166        }
167        accounts.push(solana_program::instruction::AccountMeta::new(
168            self.nft_receipt,
169            false,
170        ));
171        accounts.push(solana_program::instruction::AccountMeta::new(
172            self.owner_ta,
173            false,
174        ));
175        accounts.push(solana_program::instruction::AccountMeta::new(
176            self.pool_ta,
177            false,
178        ));
179        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
180            self.token_program,
181            false,
182        ));
183        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
184            self.associated_token_program,
185            false,
186        ));
187        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
188            self.system_program,
189            false,
190        ));
191        accounts.extend_from_slice(remaining_accounts);
192        let mut data = DepositNftInstructionData::new().try_to_vec().unwrap();
193        let mut args = args.try_to_vec().unwrap();
194        data.append(&mut args);
195
196        solana_program::instruction::Instruction {
197            program_id: crate::TENSOR_AMM_ID,
198            accounts,
199            data,
200        }
201    }
202}
203
204#[derive(BorshDeserialize, BorshSerialize)]
205pub struct DepositNftInstructionData {
206    discriminator: [u8; 8],
207}
208
209impl DepositNftInstructionData {
210    pub fn new() -> Self {
211        Self {
212            discriminator: [93, 226, 132, 166, 141, 9, 48, 101],
213        }
214    }
215}
216
217impl Default for DepositNftInstructionData {
218    fn default() -> Self {
219        Self::new()
220    }
221}
222
223#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
224#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
225pub struct DepositNftInstructionArgs {
226    pub authorization_data: Option<AuthorizationDataLocal>,
227}
228
229/// Instruction builder for `DepositNft`.
230///
231/// ### Accounts:
232///
233///   0. `[writable, signer]` owner
234///   1. `[writable]` pool
235///   2. `[]` whitelist
236///   3. `[optional]` mint_proof
237///   4. `[]` mint
238///   5. `[writable]` metadata
239///   6. `[]` edition
240///   7. `[writable, optional]` user_token_record
241///   8. `[writable, optional]` pool_token_record
242///   9. `[optional]` token_metadata_program
243///   10. `[optional]` sysvar_instructions
244///   11. `[optional]` authorization_rules
245///   12. `[optional]` authorization_rules_program
246///   13. `[writable]` nft_receipt
247///   14. `[writable]` owner_ta
248///   15. `[writable]` pool_ta
249///   16. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`)
250///   17. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`)
251///   18. `[optional]` system_program (default to `11111111111111111111111111111111`)
252#[derive(Clone, Debug, Default)]
253pub struct DepositNftBuilder {
254    owner: Option<solana_program::pubkey::Pubkey>,
255    pool: Option<solana_program::pubkey::Pubkey>,
256    whitelist: Option<solana_program::pubkey::Pubkey>,
257    mint_proof: Option<solana_program::pubkey::Pubkey>,
258    mint: Option<solana_program::pubkey::Pubkey>,
259    metadata: Option<solana_program::pubkey::Pubkey>,
260    edition: Option<solana_program::pubkey::Pubkey>,
261    user_token_record: Option<solana_program::pubkey::Pubkey>,
262    pool_token_record: Option<solana_program::pubkey::Pubkey>,
263    token_metadata_program: Option<solana_program::pubkey::Pubkey>,
264    sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
265    authorization_rules: Option<solana_program::pubkey::Pubkey>,
266    authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
267    nft_receipt: Option<solana_program::pubkey::Pubkey>,
268    owner_ta: Option<solana_program::pubkey::Pubkey>,
269    pool_ta: Option<solana_program::pubkey::Pubkey>,
270    token_program: Option<solana_program::pubkey::Pubkey>,
271    associated_token_program: Option<solana_program::pubkey::Pubkey>,
272    system_program: Option<solana_program::pubkey::Pubkey>,
273    authorization_data: Option<AuthorizationDataLocal>,
274    __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
275}
276
277impl DepositNftBuilder {
278    pub fn new() -> Self {
279        Self::default()
280    }
281    /// The owner of the pool and the NFT.
282    #[inline(always)]
283    pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self {
284        self.owner = Some(owner);
285        self
286    }
287    /// The pool the NFT is being transferred to/from.
288    #[inline(always)]
289    pub fn pool(&mut self, pool: solana_program::pubkey::Pubkey) -> &mut Self {
290        self.pool = Some(pool);
291        self
292    }
293    /// The whitelist that gatekeeps which NFTs can be deposited into the pool.
294    /// Must match the whitelist stored in the pool state.
295    #[inline(always)]
296    pub fn whitelist(&mut self, whitelist: solana_program::pubkey::Pubkey) -> &mut Self {
297        self.whitelist = Some(whitelist);
298        self
299    }
300    /// `[optional account]`
301    /// Optional account which must be passed in if the NFT must be verified against a
302    /// merkle proof condition in the whitelist.
303    #[inline(always)]
304    pub fn mint_proof(&mut self, mint_proof: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
305        self.mint_proof = mint_proof;
306        self
307    }
308    /// The mint account of the NFT.
309    #[inline(always)]
310    pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
311        self.mint = Some(mint);
312        self
313    }
314    /// The Token Metadata metadata account of the NFT.
315    #[inline(always)]
316    pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
317        self.metadata = Some(metadata);
318        self
319    }
320    /// The Token Metadata edition account of the NFT.
321    #[inline(always)]
322    pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self {
323        self.edition = Some(edition);
324        self
325    }
326    /// `[optional account]`
327    /// The Token Metadata source token record account of the NFT.
328    #[inline(always)]
329    pub fn user_token_record(
330        &mut self,
331        user_token_record: Option<solana_program::pubkey::Pubkey>,
332    ) -> &mut Self {
333        self.user_token_record = user_token_record;
334        self
335    }
336    /// `[optional account]`
337    /// The Token Metadata token record for the destination.
338    #[inline(always)]
339    pub fn pool_token_record(
340        &mut self,
341        pool_token_record: Option<solana_program::pubkey::Pubkey>,
342    ) -> &mut Self {
343        self.pool_token_record = pool_token_record;
344        self
345    }
346    /// `[optional account]`
347    /// The Token Metadata program account.
348    #[inline(always)]
349    pub fn token_metadata_program(
350        &mut self,
351        token_metadata_program: Option<solana_program::pubkey::Pubkey>,
352    ) -> &mut Self {
353        self.token_metadata_program = token_metadata_program;
354        self
355    }
356    /// `[optional account]`
357    /// The sysvar instructions account.
358    #[inline(always)]
359    pub fn sysvar_instructions(
360        &mut self,
361        sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
362    ) -> &mut Self {
363        self.sysvar_instructions = sysvar_instructions;
364        self
365    }
366    /// `[optional account]`
367    /// The Metaplex Token Authority Rules account that stores royalty enforcement rules.
368    #[inline(always)]
369    pub fn authorization_rules(
370        &mut self,
371        authorization_rules: Option<solana_program::pubkey::Pubkey>,
372    ) -> &mut Self {
373        self.authorization_rules = authorization_rules;
374        self
375    }
376    /// `[optional account]`
377    /// The Metaplex Token Authority Rules program account.
378    #[inline(always)]
379    pub fn authorization_rules_program(
380        &mut self,
381        authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
382    ) -> &mut Self {
383        self.authorization_rules_program = authorization_rules_program;
384        self
385    }
386    /// The NFT deposit receipt, which ties an NFT to the pool it was deposited to.
387    #[inline(always)]
388    pub fn nft_receipt(&mut self, nft_receipt: solana_program::pubkey::Pubkey) -> &mut Self {
389        self.nft_receipt = Some(nft_receipt);
390        self
391    }
392    /// The token account of the owner, where the NFT will be transferred from.
393    #[inline(always)]
394    pub fn owner_ta(&mut self, owner_ta: solana_program::pubkey::Pubkey) -> &mut Self {
395        self.owner_ta = Some(owner_ta);
396        self
397    }
398    /// The token account of the pool, where the NFT will be escrowed.
399    #[inline(always)]
400    pub fn pool_ta(&mut self, pool_ta: solana_program::pubkey::Pubkey) -> &mut Self {
401        self.pool_ta = Some(pool_ta);
402        self
403    }
404    /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']`
405    /// The SPL Token program for the Mint and ATAs.
406    #[inline(always)]
407    pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
408        self.token_program = Some(token_program);
409        self
410    }
411    /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']`
412    /// The SPL associated token program.
413    #[inline(always)]
414    pub fn associated_token_program(
415        &mut self,
416        associated_token_program: solana_program::pubkey::Pubkey,
417    ) -> &mut Self {
418        self.associated_token_program = Some(associated_token_program);
419        self
420    }
421    /// `[optional account, default to '11111111111111111111111111111111']`
422    /// The Solana system program.
423    #[inline(always)]
424    pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
425        self.system_program = Some(system_program);
426        self
427    }
428    /// `[optional argument]`
429    #[inline(always)]
430    pub fn authorization_data(&mut self, authorization_data: AuthorizationDataLocal) -> &mut Self {
431        self.authorization_data = Some(authorization_data);
432        self
433    }
434    /// Add an additional account to the instruction.
435    #[inline(always)]
436    pub fn add_remaining_account(
437        &mut self,
438        account: solana_program::instruction::AccountMeta,
439    ) -> &mut Self {
440        self.__remaining_accounts.push(account);
441        self
442    }
443    /// Add additional accounts to the instruction.
444    #[inline(always)]
445    pub fn add_remaining_accounts(
446        &mut self,
447        accounts: &[solana_program::instruction::AccountMeta],
448    ) -> &mut Self {
449        self.__remaining_accounts.extend_from_slice(accounts);
450        self
451    }
452    #[allow(clippy::clone_on_copy)]
453    pub fn instruction(&self) -> solana_program::instruction::Instruction {
454        let accounts = DepositNft {
455            owner: self.owner.expect("owner is not set"),
456            pool: self.pool.expect("pool is not set"),
457            whitelist: self.whitelist.expect("whitelist is not set"),
458            mint_proof: self.mint_proof,
459            mint: self.mint.expect("mint is not set"),
460            metadata: self.metadata.expect("metadata is not set"),
461            edition: self.edition.expect("edition is not set"),
462            user_token_record: self.user_token_record,
463            pool_token_record: self.pool_token_record,
464            token_metadata_program: self.token_metadata_program,
465            sysvar_instructions: self.sysvar_instructions,
466            authorization_rules: self.authorization_rules,
467            authorization_rules_program: self.authorization_rules_program,
468            nft_receipt: self.nft_receipt.expect("nft_receipt is not set"),
469            owner_ta: self.owner_ta.expect("owner_ta is not set"),
470            pool_ta: self.pool_ta.expect("pool_ta is not set"),
471            token_program: self.token_program.unwrap_or(solana_program::pubkey!(
472                "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
473            )),
474            associated_token_program: self.associated_token_program.unwrap_or(
475                solana_program::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),
476            ),
477            system_program: self
478                .system_program
479                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
480        };
481        let args = DepositNftInstructionArgs {
482            authorization_data: self.authorization_data.clone(),
483        };
484
485        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
486    }
487}
488
489/// `deposit_nft` CPI accounts.
490pub struct DepositNftCpiAccounts<'a, 'b> {
491    /// The owner of the pool and the NFT.
492    pub owner: &'b solana_program::account_info::AccountInfo<'a>,
493    /// The pool the NFT is being transferred to/from.
494    pub pool: &'b solana_program::account_info::AccountInfo<'a>,
495    /// The whitelist that gatekeeps which NFTs can be deposited into the pool.
496    /// Must match the whitelist stored in the pool state.
497    pub whitelist: &'b solana_program::account_info::AccountInfo<'a>,
498    /// Optional account which must be passed in if the NFT must be verified against a
499    /// merkle proof condition in the whitelist.
500    pub mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
501    /// The mint account of the NFT.
502    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
503    /// The Token Metadata metadata account of the NFT.
504    pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
505    /// The Token Metadata edition account of the NFT.
506    pub edition: &'b solana_program::account_info::AccountInfo<'a>,
507    /// The Token Metadata source token record account of the NFT.
508    pub user_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
509    /// The Token Metadata token record for the destination.
510    pub pool_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
511    /// The Token Metadata program account.
512    pub token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
513    /// The sysvar instructions account.
514    pub sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
515    /// The Metaplex Token Authority Rules account that stores royalty enforcement rules.
516    pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
517    /// The Metaplex Token Authority Rules program account.
518    pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
519    /// The NFT deposit receipt, which ties an NFT to the pool it was deposited to.
520    pub nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
521    /// The token account of the owner, where the NFT will be transferred from.
522    pub owner_ta: &'b solana_program::account_info::AccountInfo<'a>,
523    /// The token account of the pool, where the NFT will be escrowed.
524    pub pool_ta: &'b solana_program::account_info::AccountInfo<'a>,
525    /// The SPL Token program for the Mint and ATAs.
526    pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
527    /// The SPL associated token program.
528    pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
529    /// The Solana system program.
530    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
531}
532
533/// `deposit_nft` CPI instruction.
534pub struct DepositNftCpi<'a, 'b> {
535    /// The program to invoke.
536    pub __program: &'b solana_program::account_info::AccountInfo<'a>,
537    /// The owner of the pool and the NFT.
538    pub owner: &'b solana_program::account_info::AccountInfo<'a>,
539    /// The pool the NFT is being transferred to/from.
540    pub pool: &'b solana_program::account_info::AccountInfo<'a>,
541    /// The whitelist that gatekeeps which NFTs can be deposited into the pool.
542    /// Must match the whitelist stored in the pool state.
543    pub whitelist: &'b solana_program::account_info::AccountInfo<'a>,
544    /// Optional account which must be passed in if the NFT must be verified against a
545    /// merkle proof condition in the whitelist.
546    pub mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
547    /// The mint account of the NFT.
548    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
549    /// The Token Metadata metadata account of the NFT.
550    pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
551    /// The Token Metadata edition account of the NFT.
552    pub edition: &'b solana_program::account_info::AccountInfo<'a>,
553    /// The Token Metadata source token record account of the NFT.
554    pub user_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
555    /// The Token Metadata token record for the destination.
556    pub pool_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
557    /// The Token Metadata program account.
558    pub token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
559    /// The sysvar instructions account.
560    pub sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
561    /// The Metaplex Token Authority Rules account that stores royalty enforcement rules.
562    pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
563    /// The Metaplex Token Authority Rules program account.
564    pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
565    /// The NFT deposit receipt, which ties an NFT to the pool it was deposited to.
566    pub nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
567    /// The token account of the owner, where the NFT will be transferred from.
568    pub owner_ta: &'b solana_program::account_info::AccountInfo<'a>,
569    /// The token account of the pool, where the NFT will be escrowed.
570    pub pool_ta: &'b solana_program::account_info::AccountInfo<'a>,
571    /// The SPL Token program for the Mint and ATAs.
572    pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
573    /// The SPL associated token program.
574    pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
575    /// The Solana system program.
576    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
577    /// The arguments for the instruction.
578    pub __args: DepositNftInstructionArgs,
579}
580
581impl<'a, 'b> DepositNftCpi<'a, 'b> {
582    pub fn new(
583        program: &'b solana_program::account_info::AccountInfo<'a>,
584        accounts: DepositNftCpiAccounts<'a, 'b>,
585        args: DepositNftInstructionArgs,
586    ) -> Self {
587        Self {
588            __program: program,
589            owner: accounts.owner,
590            pool: accounts.pool,
591            whitelist: accounts.whitelist,
592            mint_proof: accounts.mint_proof,
593            mint: accounts.mint,
594            metadata: accounts.metadata,
595            edition: accounts.edition,
596            user_token_record: accounts.user_token_record,
597            pool_token_record: accounts.pool_token_record,
598            token_metadata_program: accounts.token_metadata_program,
599            sysvar_instructions: accounts.sysvar_instructions,
600            authorization_rules: accounts.authorization_rules,
601            authorization_rules_program: accounts.authorization_rules_program,
602            nft_receipt: accounts.nft_receipt,
603            owner_ta: accounts.owner_ta,
604            pool_ta: accounts.pool_ta,
605            token_program: accounts.token_program,
606            associated_token_program: accounts.associated_token_program,
607            system_program: accounts.system_program,
608            __args: args,
609        }
610    }
611    #[inline(always)]
612    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
613        self.invoke_signed_with_remaining_accounts(&[], &[])
614    }
615    #[inline(always)]
616    pub fn invoke_with_remaining_accounts(
617        &self,
618        remaining_accounts: &[(
619            &'b solana_program::account_info::AccountInfo<'a>,
620            bool,
621            bool,
622        )],
623    ) -> solana_program::entrypoint::ProgramResult {
624        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
625    }
626    #[inline(always)]
627    pub fn invoke_signed(
628        &self,
629        signers_seeds: &[&[&[u8]]],
630    ) -> solana_program::entrypoint::ProgramResult {
631        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
632    }
633    #[allow(clippy::clone_on_copy)]
634    #[allow(clippy::vec_init_then_push)]
635    pub fn invoke_signed_with_remaining_accounts(
636        &self,
637        signers_seeds: &[&[&[u8]]],
638        remaining_accounts: &[(
639            &'b solana_program::account_info::AccountInfo<'a>,
640            bool,
641            bool,
642        )],
643    ) -> solana_program::entrypoint::ProgramResult {
644        let mut accounts = Vec::with_capacity(19 + remaining_accounts.len());
645        accounts.push(solana_program::instruction::AccountMeta::new(
646            *self.owner.key,
647            true,
648        ));
649        accounts.push(solana_program::instruction::AccountMeta::new(
650            *self.pool.key,
651            false,
652        ));
653        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
654            *self.whitelist.key,
655            false,
656        ));
657        if let Some(mint_proof) = self.mint_proof {
658            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
659                *mint_proof.key,
660                false,
661            ));
662        } else {
663            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
664                crate::TENSOR_AMM_ID,
665                false,
666            ));
667        }
668        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
669            *self.mint.key,
670            false,
671        ));
672        accounts.push(solana_program::instruction::AccountMeta::new(
673            *self.metadata.key,
674            false,
675        ));
676        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
677            *self.edition.key,
678            false,
679        ));
680        if let Some(user_token_record) = self.user_token_record {
681            accounts.push(solana_program::instruction::AccountMeta::new(
682                *user_token_record.key,
683                false,
684            ));
685        } else {
686            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
687                crate::TENSOR_AMM_ID,
688                false,
689            ));
690        }
691        if let Some(pool_token_record) = self.pool_token_record {
692            accounts.push(solana_program::instruction::AccountMeta::new(
693                *pool_token_record.key,
694                false,
695            ));
696        } else {
697            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
698                crate::TENSOR_AMM_ID,
699                false,
700            ));
701        }
702        if let Some(token_metadata_program) = self.token_metadata_program {
703            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
704                *token_metadata_program.key,
705                false,
706            ));
707        } else {
708            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
709                crate::TENSOR_AMM_ID,
710                false,
711            ));
712        }
713        if let Some(sysvar_instructions) = self.sysvar_instructions {
714            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
715                *sysvar_instructions.key,
716                false,
717            ));
718        } else {
719            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
720                crate::TENSOR_AMM_ID,
721                false,
722            ));
723        }
724        if let Some(authorization_rules) = self.authorization_rules {
725            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
726                *authorization_rules.key,
727                false,
728            ));
729        } else {
730            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
731                crate::TENSOR_AMM_ID,
732                false,
733            ));
734        }
735        if let Some(authorization_rules_program) = self.authorization_rules_program {
736            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
737                *authorization_rules_program.key,
738                false,
739            ));
740        } else {
741            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
742                crate::TENSOR_AMM_ID,
743                false,
744            ));
745        }
746        accounts.push(solana_program::instruction::AccountMeta::new(
747            *self.nft_receipt.key,
748            false,
749        ));
750        accounts.push(solana_program::instruction::AccountMeta::new(
751            *self.owner_ta.key,
752            false,
753        ));
754        accounts.push(solana_program::instruction::AccountMeta::new(
755            *self.pool_ta.key,
756            false,
757        ));
758        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
759            *self.token_program.key,
760            false,
761        ));
762        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
763            *self.associated_token_program.key,
764            false,
765        ));
766        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
767            *self.system_program.key,
768            false,
769        ));
770        remaining_accounts.iter().for_each(|remaining_account| {
771            accounts.push(solana_program::instruction::AccountMeta {
772                pubkey: *remaining_account.0.key,
773                is_signer: remaining_account.1,
774                is_writable: remaining_account.2,
775            })
776        });
777        let mut data = DepositNftInstructionData::new().try_to_vec().unwrap();
778        let mut args = self.__args.try_to_vec().unwrap();
779        data.append(&mut args);
780
781        let instruction = solana_program::instruction::Instruction {
782            program_id: crate::TENSOR_AMM_ID,
783            accounts,
784            data,
785        };
786        let mut account_infos = Vec::with_capacity(20 + remaining_accounts.len());
787        account_infos.push(self.__program.clone());
788        account_infos.push(self.owner.clone());
789        account_infos.push(self.pool.clone());
790        account_infos.push(self.whitelist.clone());
791        if let Some(mint_proof) = self.mint_proof {
792            account_infos.push(mint_proof.clone());
793        }
794        account_infos.push(self.mint.clone());
795        account_infos.push(self.metadata.clone());
796        account_infos.push(self.edition.clone());
797        if let Some(user_token_record) = self.user_token_record {
798            account_infos.push(user_token_record.clone());
799        }
800        if let Some(pool_token_record) = self.pool_token_record {
801            account_infos.push(pool_token_record.clone());
802        }
803        if let Some(token_metadata_program) = self.token_metadata_program {
804            account_infos.push(token_metadata_program.clone());
805        }
806        if let Some(sysvar_instructions) = self.sysvar_instructions {
807            account_infos.push(sysvar_instructions.clone());
808        }
809        if let Some(authorization_rules) = self.authorization_rules {
810            account_infos.push(authorization_rules.clone());
811        }
812        if let Some(authorization_rules_program) = self.authorization_rules_program {
813            account_infos.push(authorization_rules_program.clone());
814        }
815        account_infos.push(self.nft_receipt.clone());
816        account_infos.push(self.owner_ta.clone());
817        account_infos.push(self.pool_ta.clone());
818        account_infos.push(self.token_program.clone());
819        account_infos.push(self.associated_token_program.clone());
820        account_infos.push(self.system_program.clone());
821        remaining_accounts
822            .iter()
823            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
824
825        if signers_seeds.is_empty() {
826            solana_program::program::invoke(&instruction, &account_infos)
827        } else {
828            solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
829        }
830    }
831}
832
833/// Instruction builder for `DepositNft` via CPI.
834///
835/// ### Accounts:
836///
837///   0. `[writable, signer]` owner
838///   1. `[writable]` pool
839///   2. `[]` whitelist
840///   3. `[optional]` mint_proof
841///   4. `[]` mint
842///   5. `[writable]` metadata
843///   6. `[]` edition
844///   7. `[writable, optional]` user_token_record
845///   8. `[writable, optional]` pool_token_record
846///   9. `[optional]` token_metadata_program
847///   10. `[optional]` sysvar_instructions
848///   11. `[optional]` authorization_rules
849///   12. `[optional]` authorization_rules_program
850///   13. `[writable]` nft_receipt
851///   14. `[writable]` owner_ta
852///   15. `[writable]` pool_ta
853///   16. `[]` token_program
854///   17. `[]` associated_token_program
855///   18. `[]` system_program
856#[derive(Clone, Debug)]
857pub struct DepositNftCpiBuilder<'a, 'b> {
858    instruction: Box<DepositNftCpiBuilderInstruction<'a, 'b>>,
859}
860
861impl<'a, 'b> DepositNftCpiBuilder<'a, 'b> {
862    pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
863        let instruction = Box::new(DepositNftCpiBuilderInstruction {
864            __program: program,
865            owner: None,
866            pool: None,
867            whitelist: None,
868            mint_proof: None,
869            mint: None,
870            metadata: None,
871            edition: None,
872            user_token_record: None,
873            pool_token_record: None,
874            token_metadata_program: None,
875            sysvar_instructions: None,
876            authorization_rules: None,
877            authorization_rules_program: None,
878            nft_receipt: None,
879            owner_ta: None,
880            pool_ta: None,
881            token_program: None,
882            associated_token_program: None,
883            system_program: None,
884            authorization_data: None,
885            __remaining_accounts: Vec::new(),
886        });
887        Self { instruction }
888    }
889    /// The owner of the pool and the NFT.
890    #[inline(always)]
891    pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
892        self.instruction.owner = Some(owner);
893        self
894    }
895    /// The pool the NFT is being transferred to/from.
896    #[inline(always)]
897    pub fn pool(&mut self, pool: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
898        self.instruction.pool = Some(pool);
899        self
900    }
901    /// The whitelist that gatekeeps which NFTs can be deposited into the pool.
902    /// Must match the whitelist stored in the pool state.
903    #[inline(always)]
904    pub fn whitelist(
905        &mut self,
906        whitelist: &'b solana_program::account_info::AccountInfo<'a>,
907    ) -> &mut Self {
908        self.instruction.whitelist = Some(whitelist);
909        self
910    }
911    /// `[optional account]`
912    /// Optional account which must be passed in if the NFT must be verified against a
913    /// merkle proof condition in the whitelist.
914    #[inline(always)]
915    pub fn mint_proof(
916        &mut self,
917        mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
918    ) -> &mut Self {
919        self.instruction.mint_proof = mint_proof;
920        self
921    }
922    /// The mint account of the NFT.
923    #[inline(always)]
924    pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
925        self.instruction.mint = Some(mint);
926        self
927    }
928    /// The Token Metadata metadata account of the NFT.
929    #[inline(always)]
930    pub fn metadata(
931        &mut self,
932        metadata: &'b solana_program::account_info::AccountInfo<'a>,
933    ) -> &mut Self {
934        self.instruction.metadata = Some(metadata);
935        self
936    }
937    /// The Token Metadata edition account of the NFT.
938    #[inline(always)]
939    pub fn edition(
940        &mut self,
941        edition: &'b solana_program::account_info::AccountInfo<'a>,
942    ) -> &mut Self {
943        self.instruction.edition = Some(edition);
944        self
945    }
946    /// `[optional account]`
947    /// The Token Metadata source token record account of the NFT.
948    #[inline(always)]
949    pub fn user_token_record(
950        &mut self,
951        user_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
952    ) -> &mut Self {
953        self.instruction.user_token_record = user_token_record;
954        self
955    }
956    /// `[optional account]`
957    /// The Token Metadata token record for the destination.
958    #[inline(always)]
959    pub fn pool_token_record(
960        &mut self,
961        pool_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
962    ) -> &mut Self {
963        self.instruction.pool_token_record = pool_token_record;
964        self
965    }
966    /// `[optional account]`
967    /// The Token Metadata program account.
968    #[inline(always)]
969    pub fn token_metadata_program(
970        &mut self,
971        token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
972    ) -> &mut Self {
973        self.instruction.token_metadata_program = token_metadata_program;
974        self
975    }
976    /// `[optional account]`
977    /// The sysvar instructions account.
978    #[inline(always)]
979    pub fn sysvar_instructions(
980        &mut self,
981        sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
982    ) -> &mut Self {
983        self.instruction.sysvar_instructions = sysvar_instructions;
984        self
985    }
986    /// `[optional account]`
987    /// The Metaplex Token Authority Rules account that stores royalty enforcement rules.
988    #[inline(always)]
989    pub fn authorization_rules(
990        &mut self,
991        authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
992    ) -> &mut Self {
993        self.instruction.authorization_rules = authorization_rules;
994        self
995    }
996    /// `[optional account]`
997    /// The Metaplex Token Authority Rules program account.
998    #[inline(always)]
999    pub fn authorization_rules_program(
1000        &mut self,
1001        authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1002    ) -> &mut Self {
1003        self.instruction.authorization_rules_program = authorization_rules_program;
1004        self
1005    }
1006    /// The NFT deposit receipt, which ties an NFT to the pool it was deposited to.
1007    #[inline(always)]
1008    pub fn nft_receipt(
1009        &mut self,
1010        nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
1011    ) -> &mut Self {
1012        self.instruction.nft_receipt = Some(nft_receipt);
1013        self
1014    }
1015    /// The token account of the owner, where the NFT will be transferred from.
1016    #[inline(always)]
1017    pub fn owner_ta(
1018        &mut self,
1019        owner_ta: &'b solana_program::account_info::AccountInfo<'a>,
1020    ) -> &mut Self {
1021        self.instruction.owner_ta = Some(owner_ta);
1022        self
1023    }
1024    /// The token account of the pool, where the NFT will be escrowed.
1025    #[inline(always)]
1026    pub fn pool_ta(
1027        &mut self,
1028        pool_ta: &'b solana_program::account_info::AccountInfo<'a>,
1029    ) -> &mut Self {
1030        self.instruction.pool_ta = Some(pool_ta);
1031        self
1032    }
1033    /// The SPL Token program for the Mint and ATAs.
1034    #[inline(always)]
1035    pub fn token_program(
1036        &mut self,
1037        token_program: &'b solana_program::account_info::AccountInfo<'a>,
1038    ) -> &mut Self {
1039        self.instruction.token_program = Some(token_program);
1040        self
1041    }
1042    /// The SPL associated token program.
1043    #[inline(always)]
1044    pub fn associated_token_program(
1045        &mut self,
1046        associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
1047    ) -> &mut Self {
1048        self.instruction.associated_token_program = Some(associated_token_program);
1049        self
1050    }
1051    /// The Solana system program.
1052    #[inline(always)]
1053    pub fn system_program(
1054        &mut self,
1055        system_program: &'b solana_program::account_info::AccountInfo<'a>,
1056    ) -> &mut Self {
1057        self.instruction.system_program = Some(system_program);
1058        self
1059    }
1060    /// `[optional argument]`
1061    #[inline(always)]
1062    pub fn authorization_data(&mut self, authorization_data: AuthorizationDataLocal) -> &mut Self {
1063        self.instruction.authorization_data = Some(authorization_data);
1064        self
1065    }
1066    /// Add an additional account to the instruction.
1067    #[inline(always)]
1068    pub fn add_remaining_account(
1069        &mut self,
1070        account: &'b solana_program::account_info::AccountInfo<'a>,
1071        is_writable: bool,
1072        is_signer: bool,
1073    ) -> &mut Self {
1074        self.instruction
1075            .__remaining_accounts
1076            .push((account, is_writable, is_signer));
1077        self
1078    }
1079    /// Add additional accounts to the instruction.
1080    ///
1081    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
1082    /// and a `bool` indicating whether the account is a signer or not.
1083    #[inline(always)]
1084    pub fn add_remaining_accounts(
1085        &mut self,
1086        accounts: &[(
1087            &'b solana_program::account_info::AccountInfo<'a>,
1088            bool,
1089            bool,
1090        )],
1091    ) -> &mut Self {
1092        self.instruction
1093            .__remaining_accounts
1094            .extend_from_slice(accounts);
1095        self
1096    }
1097    #[inline(always)]
1098    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
1099        self.invoke_signed(&[])
1100    }
1101    #[allow(clippy::clone_on_copy)]
1102    #[allow(clippy::vec_init_then_push)]
1103    pub fn invoke_signed(
1104        &self,
1105        signers_seeds: &[&[&[u8]]],
1106    ) -> solana_program::entrypoint::ProgramResult {
1107        let args = DepositNftInstructionArgs {
1108            authorization_data: self.instruction.authorization_data.clone(),
1109        };
1110        let instruction = DepositNftCpi {
1111            __program: self.instruction.__program,
1112
1113            owner: self.instruction.owner.expect("owner is not set"),
1114
1115            pool: self.instruction.pool.expect("pool is not set"),
1116
1117            whitelist: self.instruction.whitelist.expect("whitelist is not set"),
1118
1119            mint_proof: self.instruction.mint_proof,
1120
1121            mint: self.instruction.mint.expect("mint is not set"),
1122
1123            metadata: self.instruction.metadata.expect("metadata is not set"),
1124
1125            edition: self.instruction.edition.expect("edition is not set"),
1126
1127            user_token_record: self.instruction.user_token_record,
1128
1129            pool_token_record: self.instruction.pool_token_record,
1130
1131            token_metadata_program: self.instruction.token_metadata_program,
1132
1133            sysvar_instructions: self.instruction.sysvar_instructions,
1134
1135            authorization_rules: self.instruction.authorization_rules,
1136
1137            authorization_rules_program: self.instruction.authorization_rules_program,
1138
1139            nft_receipt: self
1140                .instruction
1141                .nft_receipt
1142                .expect("nft_receipt is not set"),
1143
1144            owner_ta: self.instruction.owner_ta.expect("owner_ta is not set"),
1145
1146            pool_ta: self.instruction.pool_ta.expect("pool_ta is not set"),
1147
1148            token_program: self
1149                .instruction
1150                .token_program
1151                .expect("token_program is not set"),
1152
1153            associated_token_program: self
1154                .instruction
1155                .associated_token_program
1156                .expect("associated_token_program is not set"),
1157
1158            system_program: self
1159                .instruction
1160                .system_program
1161                .expect("system_program is not set"),
1162            __args: args,
1163        };
1164        instruction.invoke_signed_with_remaining_accounts(
1165            signers_seeds,
1166            &self.instruction.__remaining_accounts,
1167        )
1168    }
1169}
1170
1171#[derive(Clone, Debug)]
1172struct DepositNftCpiBuilderInstruction<'a, 'b> {
1173    __program: &'b solana_program::account_info::AccountInfo<'a>,
1174    owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1175    pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1176    whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1177    mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1178    mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1179    metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1180    edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1181    user_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1182    pool_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1183    token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1184    sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1185    authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1186    authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1187    nft_receipt: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1188    owner_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1189    pool_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1190    token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1191    associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1192    system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1193    authorization_data: Option<AuthorizationDataLocal>,
1194    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
1195    __remaining_accounts: Vec<(
1196        &'b solana_program::account_info::AccountInfo<'a>,
1197        bool,
1198        bool,
1199    )>,
1200}