tensor_amm/generated/instructions/
sell_nft_trade_pool.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 SellNftTradePool {
14    /// The owner of the pool and the buyer/recipient of the NFT.
15    pub owner: solana_program::pubkey::Pubkey,
16    /// The taker is the user buying or selling the NFT.
17    pub taker: solana_program::pubkey::Pubkey,
18    /// The original rent payer of the pool--stored on the pool. Used to refund rent in case the pool
19    /// is auto-closed.
20    pub rent_payer: solana_program::pubkey::Pubkey,
21    /// Fee vault account owned by the TFEE program.
22    pub fee_vault: solana_program::pubkey::Pubkey,
23    /// The Pool state account that the NFT is being sold into. Stores pool state and config,
24    /// but is also the owner of any NFTs in the pool, and also escrows any SOL.
25    /// Any active pool can be specified provided it is a Token type and the NFT passes at least one
26    /// whitelist condition.
27    pub pool: solana_program::pubkey::Pubkey,
28    /// The whitelist account that the pool uses to verify the NFTs being sold into it.
29    pub whitelist: solana_program::pubkey::Pubkey,
30    /// Optional account which must be passed in if the NFT must be verified against a
31    /// merkle proof condition in the whitelist.
32    pub mint_proof: Option<solana_program::pubkey::Pubkey>,
33    /// The shared escrow account for pools that have liquidity in a shared account.
34    pub shared_escrow: Option<solana_program::pubkey::Pubkey>,
35    /// The account that receives the maker broker fee.
36    pub maker_broker: Option<solana_program::pubkey::Pubkey>,
37    /// The account that receives the taker broker fee.
38    pub taker_broker: Option<solana_program::pubkey::Pubkey>,
39    /// The optional cosigner account that must be passed in if the pool has a cosigner.
40    pub cosigner: Option<solana_program::pubkey::Pubkey>,
41    /// The AMM program account, used for self-cpi logging.
42    pub amm_program: solana_program::pubkey::Pubkey,
43    /// The escrow program account for shared liquidity pools.
44    pub escrow_program: Option<solana_program::pubkey::Pubkey>,
45
46    pub native_program: solana_program::pubkey::Pubkey,
47    /// The mint account of the NFT.
48    pub mint: solana_program::pubkey::Pubkey,
49    /// The Token Metadata metadata account of the NFT.
50    pub metadata: solana_program::pubkey::Pubkey,
51    /// The Token Metadata edition account of the NFT.
52    pub edition: solana_program::pubkey::Pubkey,
53    /// The Token Metadata source token record account of the NFT.
54    pub user_token_record: Option<solana_program::pubkey::Pubkey>,
55    /// The Token Metadata token record for the destination.
56    pub pool_token_record: Option<solana_program::pubkey::Pubkey>,
57    /// The Token Metadata program account.
58    pub token_metadata_program: Option<solana_program::pubkey::Pubkey>,
59    /// The sysvar instructions account.
60    pub sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
61    /// The Metaplex Token Authority Rules account that stores royalty enforcement rules.
62    pub authorization_rules: Option<solana_program::pubkey::Pubkey>,
63    /// The Metaplex Token Authority Rules program account.
64    pub authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
65    /// The NFT deposit receipt, which ties an NFT to the pool it was deposited to.
66    pub nft_receipt: solana_program::pubkey::Pubkey,
67    /// The token account of the seller, where the NFT will be transferred from.
68    pub taker_ta: solana_program::pubkey::Pubkey,
69    /// The ATA of the pool, where the NFT will be transferred to.
70    pub pool_ta: solana_program::pubkey::Pubkey,
71    /// Either the legacy token program or token-2022.
72    pub token_program: solana_program::pubkey::Pubkey,
73    /// The SPL associated token program.
74    pub associated_token_program: solana_program::pubkey::Pubkey,
75    /// The Solana system program.
76    pub system_program: solana_program::pubkey::Pubkey,
77}
78
79impl SellNftTradePool {
80    pub fn instruction(
81        &self,
82        args: SellNftTradePoolInstructionArgs,
83    ) -> solana_program::instruction::Instruction {
84        self.instruction_with_remaining_accounts(args, &[])
85    }
86    #[allow(clippy::vec_init_then_push)]
87    pub fn instruction_with_remaining_accounts(
88        &self,
89        args: SellNftTradePoolInstructionArgs,
90        remaining_accounts: &[solana_program::instruction::AccountMeta],
91    ) -> solana_program::instruction::Instruction {
92        let mut accounts = Vec::with_capacity(29 + remaining_accounts.len());
93        accounts.push(solana_program::instruction::AccountMeta::new(
94            self.owner, false,
95        ));
96        accounts.push(solana_program::instruction::AccountMeta::new(
97            self.taker, true,
98        ));
99        accounts.push(solana_program::instruction::AccountMeta::new(
100            self.rent_payer,
101            false,
102        ));
103        accounts.push(solana_program::instruction::AccountMeta::new(
104            self.fee_vault,
105            false,
106        ));
107        accounts.push(solana_program::instruction::AccountMeta::new(
108            self.pool, false,
109        ));
110        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
111            self.whitelist,
112            false,
113        ));
114        if let Some(mint_proof) = self.mint_proof {
115            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
116                mint_proof, 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(shared_escrow) = self.shared_escrow {
125            accounts.push(solana_program::instruction::AccountMeta::new(
126                shared_escrow,
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(maker_broker) = self.maker_broker {
136            accounts.push(solana_program::instruction::AccountMeta::new(
137                maker_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(taker_broker) = self.taker_broker {
147            accounts.push(solana_program::instruction::AccountMeta::new(
148                taker_broker,
149                false,
150            ));
151        } else {
152            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
153                crate::TENSOR_AMM_ID,
154                false,
155            ));
156        }
157        if let Some(cosigner) = self.cosigner {
158            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
159                cosigner, true,
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_readonly(
168            self.amm_program,
169            false,
170        ));
171        if let Some(escrow_program) = self.escrow_program {
172            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
173                escrow_program,
174                false,
175            ));
176        } else {
177            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
178                crate::TENSOR_AMM_ID,
179                false,
180            ));
181        }
182        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
183            self.native_program,
184            false,
185        ));
186        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
187            self.mint, false,
188        ));
189        accounts.push(solana_program::instruction::AccountMeta::new(
190            self.metadata,
191            false,
192        ));
193        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
194            self.edition,
195            false,
196        ));
197        if let Some(user_token_record) = self.user_token_record {
198            accounts.push(solana_program::instruction::AccountMeta::new(
199                user_token_record,
200                false,
201            ));
202        } else {
203            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
204                crate::TENSOR_AMM_ID,
205                false,
206            ));
207        }
208        if let Some(pool_token_record) = self.pool_token_record {
209            accounts.push(solana_program::instruction::AccountMeta::new(
210                pool_token_record,
211                false,
212            ));
213        } else {
214            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
215                crate::TENSOR_AMM_ID,
216                false,
217            ));
218        }
219        if let Some(token_metadata_program) = self.token_metadata_program {
220            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
221                token_metadata_program,
222                false,
223            ));
224        } else {
225            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
226                crate::TENSOR_AMM_ID,
227                false,
228            ));
229        }
230        if let Some(sysvar_instructions) = self.sysvar_instructions {
231            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
232                sysvar_instructions,
233                false,
234            ));
235        } else {
236            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
237                crate::TENSOR_AMM_ID,
238                false,
239            ));
240        }
241        if let Some(authorization_rules) = self.authorization_rules {
242            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
243                authorization_rules,
244                false,
245            ));
246        } else {
247            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
248                crate::TENSOR_AMM_ID,
249                false,
250            ));
251        }
252        if let Some(authorization_rules_program) = self.authorization_rules_program {
253            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
254                authorization_rules_program,
255                false,
256            ));
257        } else {
258            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
259                crate::TENSOR_AMM_ID,
260                false,
261            ));
262        }
263        accounts.push(solana_program::instruction::AccountMeta::new(
264            self.nft_receipt,
265            false,
266        ));
267        accounts.push(solana_program::instruction::AccountMeta::new(
268            self.taker_ta,
269            false,
270        ));
271        accounts.push(solana_program::instruction::AccountMeta::new(
272            self.pool_ta,
273            false,
274        ));
275        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
276            self.token_program,
277            false,
278        ));
279        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
280            self.associated_token_program,
281            false,
282        ));
283        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
284            self.system_program,
285            false,
286        ));
287        accounts.extend_from_slice(remaining_accounts);
288        let mut data = SellNftTradePoolInstructionData::new().try_to_vec().unwrap();
289        let mut args = args.try_to_vec().unwrap();
290        data.append(&mut args);
291
292        solana_program::instruction::Instruction {
293            program_id: crate::TENSOR_AMM_ID,
294            accounts,
295            data,
296        }
297    }
298}
299
300#[derive(BorshDeserialize, BorshSerialize)]
301pub struct SellNftTradePoolInstructionData {
302    discriminator: [u8; 8],
303}
304
305impl SellNftTradePoolInstructionData {
306    pub fn new() -> Self {
307        Self {
308            discriminator: [131, 82, 125, 77, 13, 157, 36, 90],
309        }
310    }
311}
312
313impl Default for SellNftTradePoolInstructionData {
314    fn default() -> Self {
315        Self::new()
316    }
317}
318
319#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
320#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
321pub struct SellNftTradePoolInstructionArgs {
322    pub min_price: u64,
323    pub authorization_data: Option<AuthorizationDataLocal>,
324    pub optional_royalty_pct: Option<u16>,
325}
326
327/// Instruction builder for `SellNftTradePool`.
328///
329/// ### Accounts:
330///
331///   0. `[writable]` owner
332///   1. `[writable, signer]` taker
333///   2. `[writable]` rent_payer
334///   3. `[writable]` fee_vault
335///   4. `[writable]` pool
336///   5. `[]` whitelist
337///   6. `[optional]` mint_proof
338///   7. `[writable, optional]` shared_escrow
339///   8. `[writable, optional]` maker_broker
340///   9. `[writable, optional]` taker_broker
341///   10. `[signer, optional]` cosigner
342///   11. `[optional]` amm_program (default to `TAMM6ub33ij1mbetoMyVBLeKY5iP41i4UPUJQGkhfsg`)
343///   12. `[optional]` escrow_program
344///   13. `[optional]` native_program (default to `11111111111111111111111111111111`)
345///   14. `[]` mint
346///   15. `[writable]` metadata
347///   16. `[]` edition
348///   17. `[writable, optional]` user_token_record
349///   18. `[writable, optional]` pool_token_record
350///   19. `[optional]` token_metadata_program
351///   20. `[optional]` sysvar_instructions
352///   21. `[optional]` authorization_rules
353///   22. `[optional]` authorization_rules_program
354///   23. `[writable]` nft_receipt
355///   24. `[writable]` taker_ta
356///   25. `[writable]` pool_ta
357///   26. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`)
358///   27. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`)
359///   28. `[optional]` system_program (default to `11111111111111111111111111111111`)
360#[derive(Clone, Debug, Default)]
361pub struct SellNftTradePoolBuilder {
362    owner: Option<solana_program::pubkey::Pubkey>,
363    taker: Option<solana_program::pubkey::Pubkey>,
364    rent_payer: Option<solana_program::pubkey::Pubkey>,
365    fee_vault: Option<solana_program::pubkey::Pubkey>,
366    pool: Option<solana_program::pubkey::Pubkey>,
367    whitelist: Option<solana_program::pubkey::Pubkey>,
368    mint_proof: Option<solana_program::pubkey::Pubkey>,
369    shared_escrow: Option<solana_program::pubkey::Pubkey>,
370    maker_broker: Option<solana_program::pubkey::Pubkey>,
371    taker_broker: Option<solana_program::pubkey::Pubkey>,
372    cosigner: Option<solana_program::pubkey::Pubkey>,
373    amm_program: Option<solana_program::pubkey::Pubkey>,
374    escrow_program: Option<solana_program::pubkey::Pubkey>,
375    native_program: Option<solana_program::pubkey::Pubkey>,
376    mint: Option<solana_program::pubkey::Pubkey>,
377    metadata: Option<solana_program::pubkey::Pubkey>,
378    edition: Option<solana_program::pubkey::Pubkey>,
379    user_token_record: Option<solana_program::pubkey::Pubkey>,
380    pool_token_record: Option<solana_program::pubkey::Pubkey>,
381    token_metadata_program: Option<solana_program::pubkey::Pubkey>,
382    sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
383    authorization_rules: Option<solana_program::pubkey::Pubkey>,
384    authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
385    nft_receipt: Option<solana_program::pubkey::Pubkey>,
386    taker_ta: Option<solana_program::pubkey::Pubkey>,
387    pool_ta: Option<solana_program::pubkey::Pubkey>,
388    token_program: Option<solana_program::pubkey::Pubkey>,
389    associated_token_program: Option<solana_program::pubkey::Pubkey>,
390    system_program: Option<solana_program::pubkey::Pubkey>,
391    min_price: Option<u64>,
392    authorization_data: Option<AuthorizationDataLocal>,
393    optional_royalty_pct: Option<u16>,
394    __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
395}
396
397impl SellNftTradePoolBuilder {
398    pub fn new() -> Self {
399        Self::default()
400    }
401    /// The owner of the pool and the buyer/recipient of the NFT.
402    #[inline(always)]
403    pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self {
404        self.owner = Some(owner);
405        self
406    }
407    /// The taker is the user buying or selling the NFT.
408    #[inline(always)]
409    pub fn taker(&mut self, taker: solana_program::pubkey::Pubkey) -> &mut Self {
410        self.taker = Some(taker);
411        self
412    }
413    /// The original rent payer of the pool--stored on the pool. Used to refund rent in case the pool
414    /// is auto-closed.
415    #[inline(always)]
416    pub fn rent_payer(&mut self, rent_payer: solana_program::pubkey::Pubkey) -> &mut Self {
417        self.rent_payer = Some(rent_payer);
418        self
419    }
420    /// Fee vault account owned by the TFEE program.
421    #[inline(always)]
422    pub fn fee_vault(&mut self, fee_vault: solana_program::pubkey::Pubkey) -> &mut Self {
423        self.fee_vault = Some(fee_vault);
424        self
425    }
426    /// The Pool state account that the NFT is being sold into. Stores pool state and config,
427    /// but is also the owner of any NFTs in the pool, and also escrows any SOL.
428    /// Any active pool can be specified provided it is a Token type and the NFT passes at least one
429    /// whitelist condition.
430    #[inline(always)]
431    pub fn pool(&mut self, pool: solana_program::pubkey::Pubkey) -> &mut Self {
432        self.pool = Some(pool);
433        self
434    }
435    /// The whitelist account that the pool uses to verify the NFTs being sold into it.
436    #[inline(always)]
437    pub fn whitelist(&mut self, whitelist: solana_program::pubkey::Pubkey) -> &mut Self {
438        self.whitelist = Some(whitelist);
439        self
440    }
441    /// `[optional account]`
442    /// Optional account which must be passed in if the NFT must be verified against a
443    /// merkle proof condition in the whitelist.
444    #[inline(always)]
445    pub fn mint_proof(&mut self, mint_proof: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
446        self.mint_proof = mint_proof;
447        self
448    }
449    /// `[optional account]`
450    /// The shared escrow account for pools that have liquidity in a shared account.
451    #[inline(always)]
452    pub fn shared_escrow(
453        &mut self,
454        shared_escrow: Option<solana_program::pubkey::Pubkey>,
455    ) -> &mut Self {
456        self.shared_escrow = shared_escrow;
457        self
458    }
459    /// `[optional account]`
460    /// The account that receives the maker broker fee.
461    #[inline(always)]
462    pub fn maker_broker(
463        &mut self,
464        maker_broker: Option<solana_program::pubkey::Pubkey>,
465    ) -> &mut Self {
466        self.maker_broker = maker_broker;
467        self
468    }
469    /// `[optional account]`
470    /// The account that receives the taker broker fee.
471    #[inline(always)]
472    pub fn taker_broker(
473        &mut self,
474        taker_broker: Option<solana_program::pubkey::Pubkey>,
475    ) -> &mut Self {
476        self.taker_broker = taker_broker;
477        self
478    }
479    /// `[optional account]`
480    /// The optional cosigner account that must be passed in if the pool has a cosigner.
481    #[inline(always)]
482    pub fn cosigner(&mut self, cosigner: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
483        self.cosigner = cosigner;
484        self
485    }
486    /// `[optional account, default to 'TAMM6ub33ij1mbetoMyVBLeKY5iP41i4UPUJQGkhfsg']`
487    /// The AMM program account, used for self-cpi logging.
488    #[inline(always)]
489    pub fn amm_program(&mut self, amm_program: solana_program::pubkey::Pubkey) -> &mut Self {
490        self.amm_program = Some(amm_program);
491        self
492    }
493    /// `[optional account]`
494    /// The escrow program account for shared liquidity pools.
495    #[inline(always)]
496    pub fn escrow_program(
497        &mut self,
498        escrow_program: Option<solana_program::pubkey::Pubkey>,
499    ) -> &mut Self {
500        self.escrow_program = escrow_program;
501        self
502    }
503    /// `[optional account, default to '11111111111111111111111111111111']`
504    #[inline(always)]
505    pub fn native_program(&mut self, native_program: solana_program::pubkey::Pubkey) -> &mut Self {
506        self.native_program = Some(native_program);
507        self
508    }
509    /// The mint account of the NFT.
510    #[inline(always)]
511    pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
512        self.mint = Some(mint);
513        self
514    }
515    /// The Token Metadata metadata account of the NFT.
516    #[inline(always)]
517    pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
518        self.metadata = Some(metadata);
519        self
520    }
521    /// The Token Metadata edition account of the NFT.
522    #[inline(always)]
523    pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self {
524        self.edition = Some(edition);
525        self
526    }
527    /// `[optional account]`
528    /// The Token Metadata source token record account of the NFT.
529    #[inline(always)]
530    pub fn user_token_record(
531        &mut self,
532        user_token_record: Option<solana_program::pubkey::Pubkey>,
533    ) -> &mut Self {
534        self.user_token_record = user_token_record;
535        self
536    }
537    /// `[optional account]`
538    /// The Token Metadata token record for the destination.
539    #[inline(always)]
540    pub fn pool_token_record(
541        &mut self,
542        pool_token_record: Option<solana_program::pubkey::Pubkey>,
543    ) -> &mut Self {
544        self.pool_token_record = pool_token_record;
545        self
546    }
547    /// `[optional account]`
548    /// The Token Metadata program account.
549    #[inline(always)]
550    pub fn token_metadata_program(
551        &mut self,
552        token_metadata_program: Option<solana_program::pubkey::Pubkey>,
553    ) -> &mut Self {
554        self.token_metadata_program = token_metadata_program;
555        self
556    }
557    /// `[optional account]`
558    /// The sysvar instructions account.
559    #[inline(always)]
560    pub fn sysvar_instructions(
561        &mut self,
562        sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
563    ) -> &mut Self {
564        self.sysvar_instructions = sysvar_instructions;
565        self
566    }
567    /// `[optional account]`
568    /// The Metaplex Token Authority Rules account that stores royalty enforcement rules.
569    #[inline(always)]
570    pub fn authorization_rules(
571        &mut self,
572        authorization_rules: Option<solana_program::pubkey::Pubkey>,
573    ) -> &mut Self {
574        self.authorization_rules = authorization_rules;
575        self
576    }
577    /// `[optional account]`
578    /// The Metaplex Token Authority Rules program account.
579    #[inline(always)]
580    pub fn authorization_rules_program(
581        &mut self,
582        authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
583    ) -> &mut Self {
584        self.authorization_rules_program = authorization_rules_program;
585        self
586    }
587    /// The NFT deposit receipt, which ties an NFT to the pool it was deposited to.
588    #[inline(always)]
589    pub fn nft_receipt(&mut self, nft_receipt: solana_program::pubkey::Pubkey) -> &mut Self {
590        self.nft_receipt = Some(nft_receipt);
591        self
592    }
593    /// The token account of the seller, where the NFT will be transferred from.
594    #[inline(always)]
595    pub fn taker_ta(&mut self, taker_ta: solana_program::pubkey::Pubkey) -> &mut Self {
596        self.taker_ta = Some(taker_ta);
597        self
598    }
599    /// The ATA of the pool, where the NFT will be transferred to.
600    #[inline(always)]
601    pub fn pool_ta(&mut self, pool_ta: solana_program::pubkey::Pubkey) -> &mut Self {
602        self.pool_ta = Some(pool_ta);
603        self
604    }
605    /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']`
606    /// Either the legacy token program or token-2022.
607    #[inline(always)]
608    pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
609        self.token_program = Some(token_program);
610        self
611    }
612    /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']`
613    /// The SPL associated token program.
614    #[inline(always)]
615    pub fn associated_token_program(
616        &mut self,
617        associated_token_program: solana_program::pubkey::Pubkey,
618    ) -> &mut Self {
619        self.associated_token_program = Some(associated_token_program);
620        self
621    }
622    /// `[optional account, default to '11111111111111111111111111111111']`
623    /// The Solana system program.
624    #[inline(always)]
625    pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
626        self.system_program = Some(system_program);
627        self
628    }
629    #[inline(always)]
630    pub fn min_price(&mut self, min_price: u64) -> &mut Self {
631        self.min_price = Some(min_price);
632        self
633    }
634    /// `[optional argument]`
635    #[inline(always)]
636    pub fn authorization_data(&mut self, authorization_data: AuthorizationDataLocal) -> &mut Self {
637        self.authorization_data = Some(authorization_data);
638        self
639    }
640    /// `[optional argument]`
641    #[inline(always)]
642    pub fn optional_royalty_pct(&mut self, optional_royalty_pct: u16) -> &mut Self {
643        self.optional_royalty_pct = Some(optional_royalty_pct);
644        self
645    }
646    /// Add an additional account to the instruction.
647    #[inline(always)]
648    pub fn add_remaining_account(
649        &mut self,
650        account: solana_program::instruction::AccountMeta,
651    ) -> &mut Self {
652        self.__remaining_accounts.push(account);
653        self
654    }
655    /// Add additional accounts to the instruction.
656    #[inline(always)]
657    pub fn add_remaining_accounts(
658        &mut self,
659        accounts: &[solana_program::instruction::AccountMeta],
660    ) -> &mut Self {
661        self.__remaining_accounts.extend_from_slice(accounts);
662        self
663    }
664    #[allow(clippy::clone_on_copy)]
665    pub fn instruction(&self) -> solana_program::instruction::Instruction {
666        let accounts = SellNftTradePool {
667            owner: self.owner.expect("owner is not set"),
668            taker: self.taker.expect("taker is not set"),
669            rent_payer: self.rent_payer.expect("rent_payer is not set"),
670            fee_vault: self.fee_vault.expect("fee_vault is not set"),
671            pool: self.pool.expect("pool is not set"),
672            whitelist: self.whitelist.expect("whitelist is not set"),
673            mint_proof: self.mint_proof,
674            shared_escrow: self.shared_escrow,
675            maker_broker: self.maker_broker,
676            taker_broker: self.taker_broker,
677            cosigner: self.cosigner,
678            amm_program: self.amm_program.unwrap_or(solana_program::pubkey!(
679                "TAMM6ub33ij1mbetoMyVBLeKY5iP41i4UPUJQGkhfsg"
680            )),
681            escrow_program: self.escrow_program,
682            native_program: self
683                .native_program
684                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
685            mint: self.mint.expect("mint is not set"),
686            metadata: self.metadata.expect("metadata is not set"),
687            edition: self.edition.expect("edition is not set"),
688            user_token_record: self.user_token_record,
689            pool_token_record: self.pool_token_record,
690            token_metadata_program: self.token_metadata_program,
691            sysvar_instructions: self.sysvar_instructions,
692            authorization_rules: self.authorization_rules,
693            authorization_rules_program: self.authorization_rules_program,
694            nft_receipt: self.nft_receipt.expect("nft_receipt is not set"),
695            taker_ta: self.taker_ta.expect("taker_ta is not set"),
696            pool_ta: self.pool_ta.expect("pool_ta is not set"),
697            token_program: self.token_program.unwrap_or(solana_program::pubkey!(
698                "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
699            )),
700            associated_token_program: self.associated_token_program.unwrap_or(
701                solana_program::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),
702            ),
703            system_program: self
704                .system_program
705                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
706        };
707        let args = SellNftTradePoolInstructionArgs {
708            min_price: self.min_price.clone().expect("min_price is not set"),
709            authorization_data: self.authorization_data.clone(),
710            optional_royalty_pct: self.optional_royalty_pct.clone(),
711        };
712
713        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
714    }
715}
716
717/// `sell_nft_trade_pool` CPI accounts.
718pub struct SellNftTradePoolCpiAccounts<'a, 'b> {
719    /// The owner of the pool and the buyer/recipient of the NFT.
720    pub owner: &'b solana_program::account_info::AccountInfo<'a>,
721    /// The taker is the user buying or selling the NFT.
722    pub taker: &'b solana_program::account_info::AccountInfo<'a>,
723    /// The original rent payer of the pool--stored on the pool. Used to refund rent in case the pool
724    /// is auto-closed.
725    pub rent_payer: &'b solana_program::account_info::AccountInfo<'a>,
726    /// Fee vault account owned by the TFEE program.
727    pub fee_vault: &'b solana_program::account_info::AccountInfo<'a>,
728    /// The Pool state account that the NFT is being sold into. Stores pool state and config,
729    /// but is also the owner of any NFTs in the pool, and also escrows any SOL.
730    /// Any active pool can be specified provided it is a Token type and the NFT passes at least one
731    /// whitelist condition.
732    pub pool: &'b solana_program::account_info::AccountInfo<'a>,
733    /// The whitelist account that the pool uses to verify the NFTs being sold into it.
734    pub whitelist: &'b solana_program::account_info::AccountInfo<'a>,
735    /// Optional account which must be passed in if the NFT must be verified against a
736    /// merkle proof condition in the whitelist.
737    pub mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
738    /// The shared escrow account for pools that have liquidity in a shared account.
739    pub shared_escrow: Option<&'b solana_program::account_info::AccountInfo<'a>>,
740    /// The account that receives the maker broker fee.
741    pub maker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
742    /// The account that receives the taker broker fee.
743    pub taker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
744    /// The optional cosigner account that must be passed in if the pool has a cosigner.
745    pub cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
746    /// The AMM program account, used for self-cpi logging.
747    pub amm_program: &'b solana_program::account_info::AccountInfo<'a>,
748    /// The escrow program account for shared liquidity pools.
749    pub escrow_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
750
751    pub native_program: &'b solana_program::account_info::AccountInfo<'a>,
752    /// The mint account of the NFT.
753    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
754    /// The Token Metadata metadata account of the NFT.
755    pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
756    /// The Token Metadata edition account of the NFT.
757    pub edition: &'b solana_program::account_info::AccountInfo<'a>,
758    /// The Token Metadata source token record account of the NFT.
759    pub user_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
760    /// The Token Metadata token record for the destination.
761    pub pool_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
762    /// The Token Metadata program account.
763    pub token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
764    /// The sysvar instructions account.
765    pub sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
766    /// The Metaplex Token Authority Rules account that stores royalty enforcement rules.
767    pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
768    /// The Metaplex Token Authority Rules program account.
769    pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
770    /// The NFT deposit receipt, which ties an NFT to the pool it was deposited to.
771    pub nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
772    /// The token account of the seller, where the NFT will be transferred from.
773    pub taker_ta: &'b solana_program::account_info::AccountInfo<'a>,
774    /// The ATA of the pool, where the NFT will be transferred to.
775    pub pool_ta: &'b solana_program::account_info::AccountInfo<'a>,
776    /// Either the legacy token program or token-2022.
777    pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
778    /// The SPL associated token program.
779    pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
780    /// The Solana system program.
781    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
782}
783
784/// `sell_nft_trade_pool` CPI instruction.
785pub struct SellNftTradePoolCpi<'a, 'b> {
786    /// The program to invoke.
787    pub __program: &'b solana_program::account_info::AccountInfo<'a>,
788    /// The owner of the pool and the buyer/recipient of the NFT.
789    pub owner: &'b solana_program::account_info::AccountInfo<'a>,
790    /// The taker is the user buying or selling the NFT.
791    pub taker: &'b solana_program::account_info::AccountInfo<'a>,
792    /// The original rent payer of the pool--stored on the pool. Used to refund rent in case the pool
793    /// is auto-closed.
794    pub rent_payer: &'b solana_program::account_info::AccountInfo<'a>,
795    /// Fee vault account owned by the TFEE program.
796    pub fee_vault: &'b solana_program::account_info::AccountInfo<'a>,
797    /// The Pool state account that the NFT is being sold into. Stores pool state and config,
798    /// but is also the owner of any NFTs in the pool, and also escrows any SOL.
799    /// Any active pool can be specified provided it is a Token type and the NFT passes at least one
800    /// whitelist condition.
801    pub pool: &'b solana_program::account_info::AccountInfo<'a>,
802    /// The whitelist account that the pool uses to verify the NFTs being sold into it.
803    pub whitelist: &'b solana_program::account_info::AccountInfo<'a>,
804    /// Optional account which must be passed in if the NFT must be verified against a
805    /// merkle proof condition in the whitelist.
806    pub mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
807    /// The shared escrow account for pools that have liquidity in a shared account.
808    pub shared_escrow: Option<&'b solana_program::account_info::AccountInfo<'a>>,
809    /// The account that receives the maker broker fee.
810    pub maker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
811    /// The account that receives the taker broker fee.
812    pub taker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
813    /// The optional cosigner account that must be passed in if the pool has a cosigner.
814    pub cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
815    /// The AMM program account, used for self-cpi logging.
816    pub amm_program: &'b solana_program::account_info::AccountInfo<'a>,
817    /// The escrow program account for shared liquidity pools.
818    pub escrow_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
819
820    pub native_program: &'b solana_program::account_info::AccountInfo<'a>,
821    /// The mint account of the NFT.
822    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
823    /// The Token Metadata metadata account of the NFT.
824    pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
825    /// The Token Metadata edition account of the NFT.
826    pub edition: &'b solana_program::account_info::AccountInfo<'a>,
827    /// The Token Metadata source token record account of the NFT.
828    pub user_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
829    /// The Token Metadata token record for the destination.
830    pub pool_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
831    /// The Token Metadata program account.
832    pub token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
833    /// The sysvar instructions account.
834    pub sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
835    /// The Metaplex Token Authority Rules account that stores royalty enforcement rules.
836    pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
837    /// The Metaplex Token Authority Rules program account.
838    pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
839    /// The NFT deposit receipt, which ties an NFT to the pool it was deposited to.
840    pub nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
841    /// The token account of the seller, where the NFT will be transferred from.
842    pub taker_ta: &'b solana_program::account_info::AccountInfo<'a>,
843    /// The ATA of the pool, where the NFT will be transferred to.
844    pub pool_ta: &'b solana_program::account_info::AccountInfo<'a>,
845    /// Either the legacy token program or token-2022.
846    pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
847    /// The SPL associated token program.
848    pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
849    /// The Solana system program.
850    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
851    /// The arguments for the instruction.
852    pub __args: SellNftTradePoolInstructionArgs,
853}
854
855impl<'a, 'b> SellNftTradePoolCpi<'a, 'b> {
856    pub fn new(
857        program: &'b solana_program::account_info::AccountInfo<'a>,
858        accounts: SellNftTradePoolCpiAccounts<'a, 'b>,
859        args: SellNftTradePoolInstructionArgs,
860    ) -> Self {
861        Self {
862            __program: program,
863            owner: accounts.owner,
864            taker: accounts.taker,
865            rent_payer: accounts.rent_payer,
866            fee_vault: accounts.fee_vault,
867            pool: accounts.pool,
868            whitelist: accounts.whitelist,
869            mint_proof: accounts.mint_proof,
870            shared_escrow: accounts.shared_escrow,
871            maker_broker: accounts.maker_broker,
872            taker_broker: accounts.taker_broker,
873            cosigner: accounts.cosigner,
874            amm_program: accounts.amm_program,
875            escrow_program: accounts.escrow_program,
876            native_program: accounts.native_program,
877            mint: accounts.mint,
878            metadata: accounts.metadata,
879            edition: accounts.edition,
880            user_token_record: accounts.user_token_record,
881            pool_token_record: accounts.pool_token_record,
882            token_metadata_program: accounts.token_metadata_program,
883            sysvar_instructions: accounts.sysvar_instructions,
884            authorization_rules: accounts.authorization_rules,
885            authorization_rules_program: accounts.authorization_rules_program,
886            nft_receipt: accounts.nft_receipt,
887            taker_ta: accounts.taker_ta,
888            pool_ta: accounts.pool_ta,
889            token_program: accounts.token_program,
890            associated_token_program: accounts.associated_token_program,
891            system_program: accounts.system_program,
892            __args: args,
893        }
894    }
895    #[inline(always)]
896    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
897        self.invoke_signed_with_remaining_accounts(&[], &[])
898    }
899    #[inline(always)]
900    pub fn invoke_with_remaining_accounts(
901        &self,
902        remaining_accounts: &[(
903            &'b solana_program::account_info::AccountInfo<'a>,
904            bool,
905            bool,
906        )],
907    ) -> solana_program::entrypoint::ProgramResult {
908        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
909    }
910    #[inline(always)]
911    pub fn invoke_signed(
912        &self,
913        signers_seeds: &[&[&[u8]]],
914    ) -> solana_program::entrypoint::ProgramResult {
915        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
916    }
917    #[allow(clippy::clone_on_copy)]
918    #[allow(clippy::vec_init_then_push)]
919    pub fn invoke_signed_with_remaining_accounts(
920        &self,
921        signers_seeds: &[&[&[u8]]],
922        remaining_accounts: &[(
923            &'b solana_program::account_info::AccountInfo<'a>,
924            bool,
925            bool,
926        )],
927    ) -> solana_program::entrypoint::ProgramResult {
928        let mut accounts = Vec::with_capacity(29 + remaining_accounts.len());
929        accounts.push(solana_program::instruction::AccountMeta::new(
930            *self.owner.key,
931            false,
932        ));
933        accounts.push(solana_program::instruction::AccountMeta::new(
934            *self.taker.key,
935            true,
936        ));
937        accounts.push(solana_program::instruction::AccountMeta::new(
938            *self.rent_payer.key,
939            false,
940        ));
941        accounts.push(solana_program::instruction::AccountMeta::new(
942            *self.fee_vault.key,
943            false,
944        ));
945        accounts.push(solana_program::instruction::AccountMeta::new(
946            *self.pool.key,
947            false,
948        ));
949        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
950            *self.whitelist.key,
951            false,
952        ));
953        if let Some(mint_proof) = self.mint_proof {
954            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
955                *mint_proof.key,
956                false,
957            ));
958        } else {
959            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
960                crate::TENSOR_AMM_ID,
961                false,
962            ));
963        }
964        if let Some(shared_escrow) = self.shared_escrow {
965            accounts.push(solana_program::instruction::AccountMeta::new(
966                *shared_escrow.key,
967                false,
968            ));
969        } else {
970            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
971                crate::TENSOR_AMM_ID,
972                false,
973            ));
974        }
975        if let Some(maker_broker) = self.maker_broker {
976            accounts.push(solana_program::instruction::AccountMeta::new(
977                *maker_broker.key,
978                false,
979            ));
980        } else {
981            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
982                crate::TENSOR_AMM_ID,
983                false,
984            ));
985        }
986        if let Some(taker_broker) = self.taker_broker {
987            accounts.push(solana_program::instruction::AccountMeta::new(
988                *taker_broker.key,
989                false,
990            ));
991        } else {
992            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
993                crate::TENSOR_AMM_ID,
994                false,
995            ));
996        }
997        if let Some(cosigner) = self.cosigner {
998            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
999                *cosigner.key,
1000                true,
1001            ));
1002        } else {
1003            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1004                crate::TENSOR_AMM_ID,
1005                false,
1006            ));
1007        }
1008        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1009            *self.amm_program.key,
1010            false,
1011        ));
1012        if let Some(escrow_program) = self.escrow_program {
1013            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1014                *escrow_program.key,
1015                false,
1016            ));
1017        } else {
1018            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1019                crate::TENSOR_AMM_ID,
1020                false,
1021            ));
1022        }
1023        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1024            *self.native_program.key,
1025            false,
1026        ));
1027        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1028            *self.mint.key,
1029            false,
1030        ));
1031        accounts.push(solana_program::instruction::AccountMeta::new(
1032            *self.metadata.key,
1033            false,
1034        ));
1035        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1036            *self.edition.key,
1037            false,
1038        ));
1039        if let Some(user_token_record) = self.user_token_record {
1040            accounts.push(solana_program::instruction::AccountMeta::new(
1041                *user_token_record.key,
1042                false,
1043            ));
1044        } else {
1045            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1046                crate::TENSOR_AMM_ID,
1047                false,
1048            ));
1049        }
1050        if let Some(pool_token_record) = self.pool_token_record {
1051            accounts.push(solana_program::instruction::AccountMeta::new(
1052                *pool_token_record.key,
1053                false,
1054            ));
1055        } else {
1056            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1057                crate::TENSOR_AMM_ID,
1058                false,
1059            ));
1060        }
1061        if let Some(token_metadata_program) = self.token_metadata_program {
1062            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1063                *token_metadata_program.key,
1064                false,
1065            ));
1066        } else {
1067            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1068                crate::TENSOR_AMM_ID,
1069                false,
1070            ));
1071        }
1072        if let Some(sysvar_instructions) = self.sysvar_instructions {
1073            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1074                *sysvar_instructions.key,
1075                false,
1076            ));
1077        } else {
1078            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1079                crate::TENSOR_AMM_ID,
1080                false,
1081            ));
1082        }
1083        if let Some(authorization_rules) = self.authorization_rules {
1084            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1085                *authorization_rules.key,
1086                false,
1087            ));
1088        } else {
1089            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1090                crate::TENSOR_AMM_ID,
1091                false,
1092            ));
1093        }
1094        if let Some(authorization_rules_program) = self.authorization_rules_program {
1095            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1096                *authorization_rules_program.key,
1097                false,
1098            ));
1099        } else {
1100            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1101                crate::TENSOR_AMM_ID,
1102                false,
1103            ));
1104        }
1105        accounts.push(solana_program::instruction::AccountMeta::new(
1106            *self.nft_receipt.key,
1107            false,
1108        ));
1109        accounts.push(solana_program::instruction::AccountMeta::new(
1110            *self.taker_ta.key,
1111            false,
1112        ));
1113        accounts.push(solana_program::instruction::AccountMeta::new(
1114            *self.pool_ta.key,
1115            false,
1116        ));
1117        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1118            *self.token_program.key,
1119            false,
1120        ));
1121        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1122            *self.associated_token_program.key,
1123            false,
1124        ));
1125        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
1126            *self.system_program.key,
1127            false,
1128        ));
1129        remaining_accounts.iter().for_each(|remaining_account| {
1130            accounts.push(solana_program::instruction::AccountMeta {
1131                pubkey: *remaining_account.0.key,
1132                is_signer: remaining_account.1,
1133                is_writable: remaining_account.2,
1134            })
1135        });
1136        let mut data = SellNftTradePoolInstructionData::new().try_to_vec().unwrap();
1137        let mut args = self.__args.try_to_vec().unwrap();
1138        data.append(&mut args);
1139
1140        let instruction = solana_program::instruction::Instruction {
1141            program_id: crate::TENSOR_AMM_ID,
1142            accounts,
1143            data,
1144        };
1145        let mut account_infos = Vec::with_capacity(30 + remaining_accounts.len());
1146        account_infos.push(self.__program.clone());
1147        account_infos.push(self.owner.clone());
1148        account_infos.push(self.taker.clone());
1149        account_infos.push(self.rent_payer.clone());
1150        account_infos.push(self.fee_vault.clone());
1151        account_infos.push(self.pool.clone());
1152        account_infos.push(self.whitelist.clone());
1153        if let Some(mint_proof) = self.mint_proof {
1154            account_infos.push(mint_proof.clone());
1155        }
1156        if let Some(shared_escrow) = self.shared_escrow {
1157            account_infos.push(shared_escrow.clone());
1158        }
1159        if let Some(maker_broker) = self.maker_broker {
1160            account_infos.push(maker_broker.clone());
1161        }
1162        if let Some(taker_broker) = self.taker_broker {
1163            account_infos.push(taker_broker.clone());
1164        }
1165        if let Some(cosigner) = self.cosigner {
1166            account_infos.push(cosigner.clone());
1167        }
1168        account_infos.push(self.amm_program.clone());
1169        if let Some(escrow_program) = self.escrow_program {
1170            account_infos.push(escrow_program.clone());
1171        }
1172        account_infos.push(self.native_program.clone());
1173        account_infos.push(self.mint.clone());
1174        account_infos.push(self.metadata.clone());
1175        account_infos.push(self.edition.clone());
1176        if let Some(user_token_record) = self.user_token_record {
1177            account_infos.push(user_token_record.clone());
1178        }
1179        if let Some(pool_token_record) = self.pool_token_record {
1180            account_infos.push(pool_token_record.clone());
1181        }
1182        if let Some(token_metadata_program) = self.token_metadata_program {
1183            account_infos.push(token_metadata_program.clone());
1184        }
1185        if let Some(sysvar_instructions) = self.sysvar_instructions {
1186            account_infos.push(sysvar_instructions.clone());
1187        }
1188        if let Some(authorization_rules) = self.authorization_rules {
1189            account_infos.push(authorization_rules.clone());
1190        }
1191        if let Some(authorization_rules_program) = self.authorization_rules_program {
1192            account_infos.push(authorization_rules_program.clone());
1193        }
1194        account_infos.push(self.nft_receipt.clone());
1195        account_infos.push(self.taker_ta.clone());
1196        account_infos.push(self.pool_ta.clone());
1197        account_infos.push(self.token_program.clone());
1198        account_infos.push(self.associated_token_program.clone());
1199        account_infos.push(self.system_program.clone());
1200        remaining_accounts
1201            .iter()
1202            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
1203
1204        if signers_seeds.is_empty() {
1205            solana_program::program::invoke(&instruction, &account_infos)
1206        } else {
1207            solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
1208        }
1209    }
1210}
1211
1212/// Instruction builder for `SellNftTradePool` via CPI.
1213///
1214/// ### Accounts:
1215///
1216///   0. `[writable]` owner
1217///   1. `[writable, signer]` taker
1218///   2. `[writable]` rent_payer
1219///   3. `[writable]` fee_vault
1220///   4. `[writable]` pool
1221///   5. `[]` whitelist
1222///   6. `[optional]` mint_proof
1223///   7. `[writable, optional]` shared_escrow
1224///   8. `[writable, optional]` maker_broker
1225///   9. `[writable, optional]` taker_broker
1226///   10. `[signer, optional]` cosigner
1227///   11. `[]` amm_program
1228///   12. `[optional]` escrow_program
1229///   13. `[]` native_program
1230///   14. `[]` mint
1231///   15. `[writable]` metadata
1232///   16. `[]` edition
1233///   17. `[writable, optional]` user_token_record
1234///   18. `[writable, optional]` pool_token_record
1235///   19. `[optional]` token_metadata_program
1236///   20. `[optional]` sysvar_instructions
1237///   21. `[optional]` authorization_rules
1238///   22. `[optional]` authorization_rules_program
1239///   23. `[writable]` nft_receipt
1240///   24. `[writable]` taker_ta
1241///   25. `[writable]` pool_ta
1242///   26. `[]` token_program
1243///   27. `[]` associated_token_program
1244///   28. `[]` system_program
1245#[derive(Clone, Debug)]
1246pub struct SellNftTradePoolCpiBuilder<'a, 'b> {
1247    instruction: Box<SellNftTradePoolCpiBuilderInstruction<'a, 'b>>,
1248}
1249
1250impl<'a, 'b> SellNftTradePoolCpiBuilder<'a, 'b> {
1251    pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
1252        let instruction = Box::new(SellNftTradePoolCpiBuilderInstruction {
1253            __program: program,
1254            owner: None,
1255            taker: None,
1256            rent_payer: None,
1257            fee_vault: None,
1258            pool: None,
1259            whitelist: None,
1260            mint_proof: None,
1261            shared_escrow: None,
1262            maker_broker: None,
1263            taker_broker: None,
1264            cosigner: None,
1265            amm_program: None,
1266            escrow_program: None,
1267            native_program: None,
1268            mint: None,
1269            metadata: None,
1270            edition: None,
1271            user_token_record: None,
1272            pool_token_record: None,
1273            token_metadata_program: None,
1274            sysvar_instructions: None,
1275            authorization_rules: None,
1276            authorization_rules_program: None,
1277            nft_receipt: None,
1278            taker_ta: None,
1279            pool_ta: None,
1280            token_program: None,
1281            associated_token_program: None,
1282            system_program: None,
1283            min_price: None,
1284            authorization_data: None,
1285            optional_royalty_pct: None,
1286            __remaining_accounts: Vec::new(),
1287        });
1288        Self { instruction }
1289    }
1290    /// The owner of the pool and the buyer/recipient of the NFT.
1291    #[inline(always)]
1292    pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
1293        self.instruction.owner = Some(owner);
1294        self
1295    }
1296    /// The taker is the user buying or selling the NFT.
1297    #[inline(always)]
1298    pub fn taker(&mut self, taker: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
1299        self.instruction.taker = Some(taker);
1300        self
1301    }
1302    /// The original rent payer of the pool--stored on the pool. Used to refund rent in case the pool
1303    /// is auto-closed.
1304    #[inline(always)]
1305    pub fn rent_payer(
1306        &mut self,
1307        rent_payer: &'b solana_program::account_info::AccountInfo<'a>,
1308    ) -> &mut Self {
1309        self.instruction.rent_payer = Some(rent_payer);
1310        self
1311    }
1312    /// Fee vault account owned by the TFEE program.
1313    #[inline(always)]
1314    pub fn fee_vault(
1315        &mut self,
1316        fee_vault: &'b solana_program::account_info::AccountInfo<'a>,
1317    ) -> &mut Self {
1318        self.instruction.fee_vault = Some(fee_vault);
1319        self
1320    }
1321    /// The Pool state account that the NFT is being sold into. Stores pool state and config,
1322    /// but is also the owner of any NFTs in the pool, and also escrows any SOL.
1323    /// Any active pool can be specified provided it is a Token type and the NFT passes at least one
1324    /// whitelist condition.
1325    #[inline(always)]
1326    pub fn pool(&mut self, pool: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
1327        self.instruction.pool = Some(pool);
1328        self
1329    }
1330    /// The whitelist account that the pool uses to verify the NFTs being sold into it.
1331    #[inline(always)]
1332    pub fn whitelist(
1333        &mut self,
1334        whitelist: &'b solana_program::account_info::AccountInfo<'a>,
1335    ) -> &mut Self {
1336        self.instruction.whitelist = Some(whitelist);
1337        self
1338    }
1339    /// `[optional account]`
1340    /// Optional account which must be passed in if the NFT must be verified against a
1341    /// merkle proof condition in the whitelist.
1342    #[inline(always)]
1343    pub fn mint_proof(
1344        &mut self,
1345        mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1346    ) -> &mut Self {
1347        self.instruction.mint_proof = mint_proof;
1348        self
1349    }
1350    /// `[optional account]`
1351    /// The shared escrow account for pools that have liquidity in a shared account.
1352    #[inline(always)]
1353    pub fn shared_escrow(
1354        &mut self,
1355        shared_escrow: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1356    ) -> &mut Self {
1357        self.instruction.shared_escrow = shared_escrow;
1358        self
1359    }
1360    /// `[optional account]`
1361    /// The account that receives the maker broker fee.
1362    #[inline(always)]
1363    pub fn maker_broker(
1364        &mut self,
1365        maker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1366    ) -> &mut Self {
1367        self.instruction.maker_broker = maker_broker;
1368        self
1369    }
1370    /// `[optional account]`
1371    /// The account that receives the taker broker fee.
1372    #[inline(always)]
1373    pub fn taker_broker(
1374        &mut self,
1375        taker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1376    ) -> &mut Self {
1377        self.instruction.taker_broker = taker_broker;
1378        self
1379    }
1380    /// `[optional account]`
1381    /// The optional cosigner account that must be passed in if the pool has a cosigner.
1382    #[inline(always)]
1383    pub fn cosigner(
1384        &mut self,
1385        cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1386    ) -> &mut Self {
1387        self.instruction.cosigner = cosigner;
1388        self
1389    }
1390    /// The AMM program account, used for self-cpi logging.
1391    #[inline(always)]
1392    pub fn amm_program(
1393        &mut self,
1394        amm_program: &'b solana_program::account_info::AccountInfo<'a>,
1395    ) -> &mut Self {
1396        self.instruction.amm_program = Some(amm_program);
1397        self
1398    }
1399    /// `[optional account]`
1400    /// The escrow program account for shared liquidity pools.
1401    #[inline(always)]
1402    pub fn escrow_program(
1403        &mut self,
1404        escrow_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1405    ) -> &mut Self {
1406        self.instruction.escrow_program = escrow_program;
1407        self
1408    }
1409    #[inline(always)]
1410    pub fn native_program(
1411        &mut self,
1412        native_program: &'b solana_program::account_info::AccountInfo<'a>,
1413    ) -> &mut Self {
1414        self.instruction.native_program = Some(native_program);
1415        self
1416    }
1417    /// The mint account of the NFT.
1418    #[inline(always)]
1419    pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
1420        self.instruction.mint = Some(mint);
1421        self
1422    }
1423    /// The Token Metadata metadata account of the NFT.
1424    #[inline(always)]
1425    pub fn metadata(
1426        &mut self,
1427        metadata: &'b solana_program::account_info::AccountInfo<'a>,
1428    ) -> &mut Self {
1429        self.instruction.metadata = Some(metadata);
1430        self
1431    }
1432    /// The Token Metadata edition account of the NFT.
1433    #[inline(always)]
1434    pub fn edition(
1435        &mut self,
1436        edition: &'b solana_program::account_info::AccountInfo<'a>,
1437    ) -> &mut Self {
1438        self.instruction.edition = Some(edition);
1439        self
1440    }
1441    /// `[optional account]`
1442    /// The Token Metadata source token record account of the NFT.
1443    #[inline(always)]
1444    pub fn user_token_record(
1445        &mut self,
1446        user_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1447    ) -> &mut Self {
1448        self.instruction.user_token_record = user_token_record;
1449        self
1450    }
1451    /// `[optional account]`
1452    /// The Token Metadata token record for the destination.
1453    #[inline(always)]
1454    pub fn pool_token_record(
1455        &mut self,
1456        pool_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1457    ) -> &mut Self {
1458        self.instruction.pool_token_record = pool_token_record;
1459        self
1460    }
1461    /// `[optional account]`
1462    /// The Token Metadata program account.
1463    #[inline(always)]
1464    pub fn token_metadata_program(
1465        &mut self,
1466        token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1467    ) -> &mut Self {
1468        self.instruction.token_metadata_program = token_metadata_program;
1469        self
1470    }
1471    /// `[optional account]`
1472    /// The sysvar instructions account.
1473    #[inline(always)]
1474    pub fn sysvar_instructions(
1475        &mut self,
1476        sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1477    ) -> &mut Self {
1478        self.instruction.sysvar_instructions = sysvar_instructions;
1479        self
1480    }
1481    /// `[optional account]`
1482    /// The Metaplex Token Authority Rules account that stores royalty enforcement rules.
1483    #[inline(always)]
1484    pub fn authorization_rules(
1485        &mut self,
1486        authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1487    ) -> &mut Self {
1488        self.instruction.authorization_rules = authorization_rules;
1489        self
1490    }
1491    /// `[optional account]`
1492    /// The Metaplex Token Authority Rules program account.
1493    #[inline(always)]
1494    pub fn authorization_rules_program(
1495        &mut self,
1496        authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1497    ) -> &mut Self {
1498        self.instruction.authorization_rules_program = authorization_rules_program;
1499        self
1500    }
1501    /// The NFT deposit receipt, which ties an NFT to the pool it was deposited to.
1502    #[inline(always)]
1503    pub fn nft_receipt(
1504        &mut self,
1505        nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
1506    ) -> &mut Self {
1507        self.instruction.nft_receipt = Some(nft_receipt);
1508        self
1509    }
1510    /// The token account of the seller, where the NFT will be transferred from.
1511    #[inline(always)]
1512    pub fn taker_ta(
1513        &mut self,
1514        taker_ta: &'b solana_program::account_info::AccountInfo<'a>,
1515    ) -> &mut Self {
1516        self.instruction.taker_ta = Some(taker_ta);
1517        self
1518    }
1519    /// The ATA of the pool, where the NFT will be transferred to.
1520    #[inline(always)]
1521    pub fn pool_ta(
1522        &mut self,
1523        pool_ta: &'b solana_program::account_info::AccountInfo<'a>,
1524    ) -> &mut Self {
1525        self.instruction.pool_ta = Some(pool_ta);
1526        self
1527    }
1528    /// Either the legacy token program or token-2022.
1529    #[inline(always)]
1530    pub fn token_program(
1531        &mut self,
1532        token_program: &'b solana_program::account_info::AccountInfo<'a>,
1533    ) -> &mut Self {
1534        self.instruction.token_program = Some(token_program);
1535        self
1536    }
1537    /// The SPL associated token program.
1538    #[inline(always)]
1539    pub fn associated_token_program(
1540        &mut self,
1541        associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
1542    ) -> &mut Self {
1543        self.instruction.associated_token_program = Some(associated_token_program);
1544        self
1545    }
1546    /// The Solana system program.
1547    #[inline(always)]
1548    pub fn system_program(
1549        &mut self,
1550        system_program: &'b solana_program::account_info::AccountInfo<'a>,
1551    ) -> &mut Self {
1552        self.instruction.system_program = Some(system_program);
1553        self
1554    }
1555    #[inline(always)]
1556    pub fn min_price(&mut self, min_price: u64) -> &mut Self {
1557        self.instruction.min_price = Some(min_price);
1558        self
1559    }
1560    /// `[optional argument]`
1561    #[inline(always)]
1562    pub fn authorization_data(&mut self, authorization_data: AuthorizationDataLocal) -> &mut Self {
1563        self.instruction.authorization_data = Some(authorization_data);
1564        self
1565    }
1566    /// `[optional argument]`
1567    #[inline(always)]
1568    pub fn optional_royalty_pct(&mut self, optional_royalty_pct: u16) -> &mut Self {
1569        self.instruction.optional_royalty_pct = Some(optional_royalty_pct);
1570        self
1571    }
1572    /// Add an additional account to the instruction.
1573    #[inline(always)]
1574    pub fn add_remaining_account(
1575        &mut self,
1576        account: &'b solana_program::account_info::AccountInfo<'a>,
1577        is_writable: bool,
1578        is_signer: bool,
1579    ) -> &mut Self {
1580        self.instruction
1581            .__remaining_accounts
1582            .push((account, is_writable, is_signer));
1583        self
1584    }
1585    /// Add additional accounts to the instruction.
1586    ///
1587    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
1588    /// and a `bool` indicating whether the account is a signer or not.
1589    #[inline(always)]
1590    pub fn add_remaining_accounts(
1591        &mut self,
1592        accounts: &[(
1593            &'b solana_program::account_info::AccountInfo<'a>,
1594            bool,
1595            bool,
1596        )],
1597    ) -> &mut Self {
1598        self.instruction
1599            .__remaining_accounts
1600            .extend_from_slice(accounts);
1601        self
1602    }
1603    #[inline(always)]
1604    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
1605        self.invoke_signed(&[])
1606    }
1607    #[allow(clippy::clone_on_copy)]
1608    #[allow(clippy::vec_init_then_push)]
1609    pub fn invoke_signed(
1610        &self,
1611        signers_seeds: &[&[&[u8]]],
1612    ) -> solana_program::entrypoint::ProgramResult {
1613        let args = SellNftTradePoolInstructionArgs {
1614            min_price: self
1615                .instruction
1616                .min_price
1617                .clone()
1618                .expect("min_price is not set"),
1619            authorization_data: self.instruction.authorization_data.clone(),
1620            optional_royalty_pct: self.instruction.optional_royalty_pct.clone(),
1621        };
1622        let instruction = SellNftTradePoolCpi {
1623            __program: self.instruction.__program,
1624
1625            owner: self.instruction.owner.expect("owner is not set"),
1626
1627            taker: self.instruction.taker.expect("taker is not set"),
1628
1629            rent_payer: self.instruction.rent_payer.expect("rent_payer is not set"),
1630
1631            fee_vault: self.instruction.fee_vault.expect("fee_vault is not set"),
1632
1633            pool: self.instruction.pool.expect("pool is not set"),
1634
1635            whitelist: self.instruction.whitelist.expect("whitelist is not set"),
1636
1637            mint_proof: self.instruction.mint_proof,
1638
1639            shared_escrow: self.instruction.shared_escrow,
1640
1641            maker_broker: self.instruction.maker_broker,
1642
1643            taker_broker: self.instruction.taker_broker,
1644
1645            cosigner: self.instruction.cosigner,
1646
1647            amm_program: self
1648                .instruction
1649                .amm_program
1650                .expect("amm_program is not set"),
1651
1652            escrow_program: self.instruction.escrow_program,
1653
1654            native_program: self
1655                .instruction
1656                .native_program
1657                .expect("native_program is not set"),
1658
1659            mint: self.instruction.mint.expect("mint is not set"),
1660
1661            metadata: self.instruction.metadata.expect("metadata is not set"),
1662
1663            edition: self.instruction.edition.expect("edition is not set"),
1664
1665            user_token_record: self.instruction.user_token_record,
1666
1667            pool_token_record: self.instruction.pool_token_record,
1668
1669            token_metadata_program: self.instruction.token_metadata_program,
1670
1671            sysvar_instructions: self.instruction.sysvar_instructions,
1672
1673            authorization_rules: self.instruction.authorization_rules,
1674
1675            authorization_rules_program: self.instruction.authorization_rules_program,
1676
1677            nft_receipt: self
1678                .instruction
1679                .nft_receipt
1680                .expect("nft_receipt is not set"),
1681
1682            taker_ta: self.instruction.taker_ta.expect("taker_ta is not set"),
1683
1684            pool_ta: self.instruction.pool_ta.expect("pool_ta is not set"),
1685
1686            token_program: self
1687                .instruction
1688                .token_program
1689                .expect("token_program is not set"),
1690
1691            associated_token_program: self
1692                .instruction
1693                .associated_token_program
1694                .expect("associated_token_program is not set"),
1695
1696            system_program: self
1697                .instruction
1698                .system_program
1699                .expect("system_program is not set"),
1700            __args: args,
1701        };
1702        instruction.invoke_signed_with_remaining_accounts(
1703            signers_seeds,
1704            &self.instruction.__remaining_accounts,
1705        )
1706    }
1707}
1708
1709#[derive(Clone, Debug)]
1710struct SellNftTradePoolCpiBuilderInstruction<'a, 'b> {
1711    __program: &'b solana_program::account_info::AccountInfo<'a>,
1712    owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1713    taker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1714    rent_payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1715    fee_vault: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1716    pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1717    whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1718    mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1719    shared_escrow: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1720    maker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1721    taker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1722    cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1723    amm_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1724    escrow_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1725    native_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1726    mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1727    metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1728    edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1729    user_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1730    pool_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1731    token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1732    sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1733    authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1734    authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1735    nft_receipt: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1736    taker_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1737    pool_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1738    token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1739    associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1740    system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1741    min_price: Option<u64>,
1742    authorization_data: Option<AuthorizationDataLocal>,
1743    optional_royalty_pct: Option<u16>,
1744    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
1745    __remaining_accounts: Vec<(
1746        &'b solana_program::account_info::AccountInfo<'a>,
1747        bool,
1748        bool,
1749    )>,
1750}