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