Skip to main content

tensor_price_lock/generated/instructions/
withdraw_collateral_t22.rs

1//! This code was AUTOGENERATED using the kinobi library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun kinobi to update it.
4//!
5//! <https://github.com/kinobi-so/kinobi>
6//!
7
8use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11/// Accounts.
12pub struct WithdrawCollateralT22 {
13    pub signer: solana_program::pubkey::Pubkey,
14
15    pub order_state: solana_program::pubkey::Pubkey,
16
17    pub order_vault: solana_program::pubkey::Pubkey,
18
19    pub maker: solana_program::pubkey::Pubkey,
20
21    pub taker: solana_program::pubkey::Pubkey,
22
23    pub destination: solana_program::pubkey::Pubkey,
24
25    pub system: solana_program::pubkey::Pubkey,
26
27    pub tlock_program: solana_program::pubkey::Pubkey,
28
29    pub mint: solana_program::pubkey::Pubkey,
30
31    pub order_ta: solana_program::pubkey::Pubkey,
32
33    pub destination_ta: solana_program::pubkey::Pubkey,
34
35    pub token_program: solana_program::pubkey::Pubkey,
36
37    pub associated_token_program: solana_program::pubkey::Pubkey,
38
39    pub system_program: solana_program::pubkey::Pubkey,
40
41    pub whitelist: solana_program::pubkey::Pubkey,
42
43    pub mint_proof: Option<solana_program::pubkey::Pubkey>,
44
45    pub order_nft_receipt: solana_program::pubkey::Pubkey,
46}
47
48impl WithdrawCollateralT22 {
49    pub fn instruction(
50        &self,
51        args: WithdrawCollateralT22InstructionArgs,
52    ) -> solana_program::instruction::Instruction {
53        self.instruction_with_remaining_accounts(args, &[])
54    }
55    #[allow(clippy::vec_init_then_push)]
56    pub fn instruction_with_remaining_accounts(
57        &self,
58        args: WithdrawCollateralT22InstructionArgs,
59        remaining_accounts: &[solana_program::instruction::AccountMeta],
60    ) -> solana_program::instruction::Instruction {
61        let mut accounts = Vec::with_capacity(17 + remaining_accounts.len());
62        accounts.push(solana_program::instruction::AccountMeta::new(
63            self.signer,
64            true,
65        ));
66        accounts.push(solana_program::instruction::AccountMeta::new(
67            self.order_state,
68            false,
69        ));
70        accounts.push(solana_program::instruction::AccountMeta::new(
71            self.order_vault,
72            false,
73        ));
74        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
75            self.maker, false,
76        ));
77        accounts.push(solana_program::instruction::AccountMeta::new(
78            self.taker, false,
79        ));
80        accounts.push(solana_program::instruction::AccountMeta::new(
81            self.destination,
82            false,
83        ));
84        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
85            self.system,
86            false,
87        ));
88        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
89            self.tlock_program,
90            false,
91        ));
92        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
93            self.mint, false,
94        ));
95        accounts.push(solana_program::instruction::AccountMeta::new(
96            self.order_ta,
97            false,
98        ));
99        accounts.push(solana_program::instruction::AccountMeta::new(
100            self.destination_ta,
101            false,
102        ));
103        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
104            self.token_program,
105            false,
106        ));
107        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
108            self.associated_token_program,
109            false,
110        ));
111        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
112            self.system_program,
113            false,
114        ));
115        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
116            self.whitelist,
117            false,
118        ));
119        if let Some(mint_proof) = self.mint_proof {
120            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
121                mint_proof, false,
122            ));
123        } else {
124            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
125                crate::TENSOR_PRICE_LOCK_ID,
126                false,
127            ));
128        }
129        accounts.push(solana_program::instruction::AccountMeta::new(
130            self.order_nft_receipt,
131            false,
132        ));
133        accounts.extend_from_slice(remaining_accounts);
134        let mut data = WithdrawCollateralT22InstructionData::new()
135            .try_to_vec()
136            .unwrap();
137        let mut args = args.try_to_vec().unwrap();
138        data.append(&mut args);
139
140        solana_program::instruction::Instruction {
141            program_id: crate::TENSOR_PRICE_LOCK_ID,
142            accounts,
143            data,
144        }
145    }
146}
147
148#[derive(BorshDeserialize, BorshSerialize)]
149pub struct WithdrawCollateralT22InstructionData {
150    discriminator: [u8; 8],
151}
152
153impl WithdrawCollateralT22InstructionData {
154    pub fn new() -> Self {
155        Self {
156            discriminator: [204, 50, 48, 136, 1, 128, 151, 244],
157        }
158    }
159}
160
161impl Default for WithdrawCollateralT22InstructionData {
162    fn default() -> Self {
163        Self::new()
164    }
165}
166
167#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
168#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
169pub struct WithdrawCollateralT22InstructionArgs {
170    pub to_maker: bool,
171}
172
173/// Instruction builder for `WithdrawCollateralT22`.
174///
175/// ### Accounts:
176///
177///   0. `[writable, signer]` signer
178///   1. `[writable]` order_state
179///   2. `[writable]` order_vault
180///   3. `[]` maker
181///   4. `[writable]` taker
182///   5. `[writable]` destination
183///   6. `[optional]` system (default to `11111111111111111111111111111111`)
184///   7. `[]` tlock_program
185///   8. `[]` mint
186///   9. `[writable]` order_ta
187///   10. `[writable]` destination_ta
188///   11. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`)
189///   12. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`)
190///   13. `[optional]` system_program (default to `11111111111111111111111111111111`)
191///   14. `[]` whitelist
192///   15. `[optional]` mint_proof
193///   16. `[writable]` order_nft_receipt
194#[derive(Clone, Debug, Default)]
195pub struct WithdrawCollateralT22Builder {
196    signer: Option<solana_program::pubkey::Pubkey>,
197    order_state: Option<solana_program::pubkey::Pubkey>,
198    order_vault: Option<solana_program::pubkey::Pubkey>,
199    maker: Option<solana_program::pubkey::Pubkey>,
200    taker: Option<solana_program::pubkey::Pubkey>,
201    destination: Option<solana_program::pubkey::Pubkey>,
202    system: Option<solana_program::pubkey::Pubkey>,
203    tlock_program: Option<solana_program::pubkey::Pubkey>,
204    mint: Option<solana_program::pubkey::Pubkey>,
205    order_ta: Option<solana_program::pubkey::Pubkey>,
206    destination_ta: Option<solana_program::pubkey::Pubkey>,
207    token_program: Option<solana_program::pubkey::Pubkey>,
208    associated_token_program: Option<solana_program::pubkey::Pubkey>,
209    system_program: Option<solana_program::pubkey::Pubkey>,
210    whitelist: Option<solana_program::pubkey::Pubkey>,
211    mint_proof: Option<solana_program::pubkey::Pubkey>,
212    order_nft_receipt: Option<solana_program::pubkey::Pubkey>,
213    to_maker: Option<bool>,
214    __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
215}
216
217impl WithdrawCollateralT22Builder {
218    pub fn new() -> Self {
219        Self::default()
220    }
221    #[inline(always)]
222    pub fn signer(&mut self, signer: solana_program::pubkey::Pubkey) -> &mut Self {
223        self.signer = Some(signer);
224        self
225    }
226    #[inline(always)]
227    pub fn order_state(&mut self, order_state: solana_program::pubkey::Pubkey) -> &mut Self {
228        self.order_state = Some(order_state);
229        self
230    }
231    #[inline(always)]
232    pub fn order_vault(&mut self, order_vault: solana_program::pubkey::Pubkey) -> &mut Self {
233        self.order_vault = Some(order_vault);
234        self
235    }
236    #[inline(always)]
237    pub fn maker(&mut self, maker: solana_program::pubkey::Pubkey) -> &mut Self {
238        self.maker = Some(maker);
239        self
240    }
241    #[inline(always)]
242    pub fn taker(&mut self, taker: solana_program::pubkey::Pubkey) -> &mut Self {
243        self.taker = Some(taker);
244        self
245    }
246    #[inline(always)]
247    pub fn destination(&mut self, destination: solana_program::pubkey::Pubkey) -> &mut Self {
248        self.destination = Some(destination);
249        self
250    }
251    /// `[optional account, default to '11111111111111111111111111111111']`
252    #[inline(always)]
253    pub fn system(&mut self, system: solana_program::pubkey::Pubkey) -> &mut Self {
254        self.system = Some(system);
255        self
256    }
257    #[inline(always)]
258    pub fn tlock_program(&mut self, tlock_program: solana_program::pubkey::Pubkey) -> &mut Self {
259        self.tlock_program = Some(tlock_program);
260        self
261    }
262    #[inline(always)]
263    pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
264        self.mint = Some(mint);
265        self
266    }
267    #[inline(always)]
268    pub fn order_ta(&mut self, order_ta: solana_program::pubkey::Pubkey) -> &mut Self {
269        self.order_ta = Some(order_ta);
270        self
271    }
272    #[inline(always)]
273    pub fn destination_ta(&mut self, destination_ta: solana_program::pubkey::Pubkey) -> &mut Self {
274        self.destination_ta = Some(destination_ta);
275        self
276    }
277    /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']`
278    #[inline(always)]
279    pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
280        self.token_program = Some(token_program);
281        self
282    }
283    /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']`
284    #[inline(always)]
285    pub fn associated_token_program(
286        &mut self,
287        associated_token_program: solana_program::pubkey::Pubkey,
288    ) -> &mut Self {
289        self.associated_token_program = Some(associated_token_program);
290        self
291    }
292    /// `[optional account, default to '11111111111111111111111111111111']`
293    #[inline(always)]
294    pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
295        self.system_program = Some(system_program);
296        self
297    }
298    #[inline(always)]
299    pub fn whitelist(&mut self, whitelist: solana_program::pubkey::Pubkey) -> &mut Self {
300        self.whitelist = Some(whitelist);
301        self
302    }
303    /// `[optional account]`
304    #[inline(always)]
305    pub fn mint_proof(&mut self, mint_proof: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
306        self.mint_proof = mint_proof;
307        self
308    }
309    #[inline(always)]
310    pub fn order_nft_receipt(
311        &mut self,
312        order_nft_receipt: solana_program::pubkey::Pubkey,
313    ) -> &mut Self {
314        self.order_nft_receipt = Some(order_nft_receipt);
315        self
316    }
317    #[inline(always)]
318    pub fn to_maker(&mut self, to_maker: bool) -> &mut Self {
319        self.to_maker = Some(to_maker);
320        self
321    }
322    /// Add an aditional account to the instruction.
323    #[inline(always)]
324    pub fn add_remaining_account(
325        &mut self,
326        account: solana_program::instruction::AccountMeta,
327    ) -> &mut Self {
328        self.__remaining_accounts.push(account);
329        self
330    }
331    /// Add additional accounts to the instruction.
332    #[inline(always)]
333    pub fn add_remaining_accounts(
334        &mut self,
335        accounts: &[solana_program::instruction::AccountMeta],
336    ) -> &mut Self {
337        self.__remaining_accounts.extend_from_slice(accounts);
338        self
339    }
340    #[allow(clippy::clone_on_copy)]
341    pub fn instruction(&self) -> solana_program::instruction::Instruction {
342        let accounts = WithdrawCollateralT22 {
343            signer: self.signer.expect("signer is not set"),
344            order_state: self.order_state.expect("order_state is not set"),
345            order_vault: self.order_vault.expect("order_vault is not set"),
346            maker: self.maker.expect("maker is not set"),
347            taker: self.taker.expect("taker is not set"),
348            destination: self.destination.expect("destination is not set"),
349            system: self
350                .system
351                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
352            tlock_program: self.tlock_program.expect("tlock_program is not set"),
353            mint: self.mint.expect("mint is not set"),
354            order_ta: self.order_ta.expect("order_ta is not set"),
355            destination_ta: self.destination_ta.expect("destination_ta is not set"),
356            token_program: self.token_program.unwrap_or(solana_program::pubkey!(
357                "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
358            )),
359            associated_token_program: self.associated_token_program.unwrap_or(
360                solana_program::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),
361            ),
362            system_program: self
363                .system_program
364                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
365            whitelist: self.whitelist.expect("whitelist is not set"),
366            mint_proof: self.mint_proof,
367            order_nft_receipt: self
368                .order_nft_receipt
369                .expect("order_nft_receipt is not set"),
370        };
371        let args = WithdrawCollateralT22InstructionArgs {
372            to_maker: self.to_maker.clone().expect("to_maker is not set"),
373        };
374
375        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
376    }
377}
378
379/// `withdraw_collateral_t22` CPI accounts.
380pub struct WithdrawCollateralT22CpiAccounts<'a, 'b> {
381    pub signer: &'b solana_program::account_info::AccountInfo<'a>,
382
383    pub order_state: &'b solana_program::account_info::AccountInfo<'a>,
384
385    pub order_vault: &'b solana_program::account_info::AccountInfo<'a>,
386
387    pub maker: &'b solana_program::account_info::AccountInfo<'a>,
388
389    pub taker: &'b solana_program::account_info::AccountInfo<'a>,
390
391    pub destination: &'b solana_program::account_info::AccountInfo<'a>,
392
393    pub system: &'b solana_program::account_info::AccountInfo<'a>,
394
395    pub tlock_program: &'b solana_program::account_info::AccountInfo<'a>,
396
397    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
398
399    pub order_ta: &'b solana_program::account_info::AccountInfo<'a>,
400
401    pub destination_ta: &'b solana_program::account_info::AccountInfo<'a>,
402
403    pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
404
405    pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
406
407    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
408
409    pub whitelist: &'b solana_program::account_info::AccountInfo<'a>,
410
411    pub mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
412
413    pub order_nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
414}
415
416/// `withdraw_collateral_t22` CPI instruction.
417pub struct WithdrawCollateralT22Cpi<'a, 'b> {
418    /// The program to invoke.
419    pub __program: &'b solana_program::account_info::AccountInfo<'a>,
420
421    pub signer: &'b solana_program::account_info::AccountInfo<'a>,
422
423    pub order_state: &'b solana_program::account_info::AccountInfo<'a>,
424
425    pub order_vault: &'b solana_program::account_info::AccountInfo<'a>,
426
427    pub maker: &'b solana_program::account_info::AccountInfo<'a>,
428
429    pub taker: &'b solana_program::account_info::AccountInfo<'a>,
430
431    pub destination: &'b solana_program::account_info::AccountInfo<'a>,
432
433    pub system: &'b solana_program::account_info::AccountInfo<'a>,
434
435    pub tlock_program: &'b solana_program::account_info::AccountInfo<'a>,
436
437    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
438
439    pub order_ta: &'b solana_program::account_info::AccountInfo<'a>,
440
441    pub destination_ta: &'b solana_program::account_info::AccountInfo<'a>,
442
443    pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
444
445    pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
446
447    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
448
449    pub whitelist: &'b solana_program::account_info::AccountInfo<'a>,
450
451    pub mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
452
453    pub order_nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
454    /// The arguments for the instruction.
455    pub __args: WithdrawCollateralT22InstructionArgs,
456}
457
458impl<'a, 'b> WithdrawCollateralT22Cpi<'a, 'b> {
459    pub fn new(
460        program: &'b solana_program::account_info::AccountInfo<'a>,
461        accounts: WithdrawCollateralT22CpiAccounts<'a, 'b>,
462        args: WithdrawCollateralT22InstructionArgs,
463    ) -> Self {
464        Self {
465            __program: program,
466            signer: accounts.signer,
467            order_state: accounts.order_state,
468            order_vault: accounts.order_vault,
469            maker: accounts.maker,
470            taker: accounts.taker,
471            destination: accounts.destination,
472            system: accounts.system,
473            tlock_program: accounts.tlock_program,
474            mint: accounts.mint,
475            order_ta: accounts.order_ta,
476            destination_ta: accounts.destination_ta,
477            token_program: accounts.token_program,
478            associated_token_program: accounts.associated_token_program,
479            system_program: accounts.system_program,
480            whitelist: accounts.whitelist,
481            mint_proof: accounts.mint_proof,
482            order_nft_receipt: accounts.order_nft_receipt,
483            __args: args,
484        }
485    }
486    #[inline(always)]
487    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
488        self.invoke_signed_with_remaining_accounts(&[], &[])
489    }
490    #[inline(always)]
491    pub fn invoke_with_remaining_accounts(
492        &self,
493        remaining_accounts: &[(
494            &'b solana_program::account_info::AccountInfo<'a>,
495            bool,
496            bool,
497        )],
498    ) -> solana_program::entrypoint::ProgramResult {
499        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
500    }
501    #[inline(always)]
502    pub fn invoke_signed(
503        &self,
504        signers_seeds: &[&[&[u8]]],
505    ) -> solana_program::entrypoint::ProgramResult {
506        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
507    }
508    #[allow(clippy::clone_on_copy)]
509    #[allow(clippy::vec_init_then_push)]
510    pub fn invoke_signed_with_remaining_accounts(
511        &self,
512        signers_seeds: &[&[&[u8]]],
513        remaining_accounts: &[(
514            &'b solana_program::account_info::AccountInfo<'a>,
515            bool,
516            bool,
517        )],
518    ) -> solana_program::entrypoint::ProgramResult {
519        let mut accounts = Vec::with_capacity(17 + remaining_accounts.len());
520        accounts.push(solana_program::instruction::AccountMeta::new(
521            *self.signer.key,
522            true,
523        ));
524        accounts.push(solana_program::instruction::AccountMeta::new(
525            *self.order_state.key,
526            false,
527        ));
528        accounts.push(solana_program::instruction::AccountMeta::new(
529            *self.order_vault.key,
530            false,
531        ));
532        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
533            *self.maker.key,
534            false,
535        ));
536        accounts.push(solana_program::instruction::AccountMeta::new(
537            *self.taker.key,
538            false,
539        ));
540        accounts.push(solana_program::instruction::AccountMeta::new(
541            *self.destination.key,
542            false,
543        ));
544        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
545            *self.system.key,
546            false,
547        ));
548        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
549            *self.tlock_program.key,
550            false,
551        ));
552        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
553            *self.mint.key,
554            false,
555        ));
556        accounts.push(solana_program::instruction::AccountMeta::new(
557            *self.order_ta.key,
558            false,
559        ));
560        accounts.push(solana_program::instruction::AccountMeta::new(
561            *self.destination_ta.key,
562            false,
563        ));
564        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
565            *self.token_program.key,
566            false,
567        ));
568        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
569            *self.associated_token_program.key,
570            false,
571        ));
572        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
573            *self.system_program.key,
574            false,
575        ));
576        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
577            *self.whitelist.key,
578            false,
579        ));
580        if let Some(mint_proof) = self.mint_proof {
581            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
582                *mint_proof.key,
583                false,
584            ));
585        } else {
586            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
587                crate::TENSOR_PRICE_LOCK_ID,
588                false,
589            ));
590        }
591        accounts.push(solana_program::instruction::AccountMeta::new(
592            *self.order_nft_receipt.key,
593            false,
594        ));
595        remaining_accounts.iter().for_each(|remaining_account| {
596            accounts.push(solana_program::instruction::AccountMeta {
597                pubkey: *remaining_account.0.key,
598                is_signer: remaining_account.1,
599                is_writable: remaining_account.2,
600            })
601        });
602        let mut data = WithdrawCollateralT22InstructionData::new()
603            .try_to_vec()
604            .unwrap();
605        let mut args = self.__args.try_to_vec().unwrap();
606        data.append(&mut args);
607
608        let instruction = solana_program::instruction::Instruction {
609            program_id: crate::TENSOR_PRICE_LOCK_ID,
610            accounts,
611            data,
612        };
613        let mut account_infos = Vec::with_capacity(17 + 1 + remaining_accounts.len());
614        account_infos.push(self.__program.clone());
615        account_infos.push(self.signer.clone());
616        account_infos.push(self.order_state.clone());
617        account_infos.push(self.order_vault.clone());
618        account_infos.push(self.maker.clone());
619        account_infos.push(self.taker.clone());
620        account_infos.push(self.destination.clone());
621        account_infos.push(self.system.clone());
622        account_infos.push(self.tlock_program.clone());
623        account_infos.push(self.mint.clone());
624        account_infos.push(self.order_ta.clone());
625        account_infos.push(self.destination_ta.clone());
626        account_infos.push(self.token_program.clone());
627        account_infos.push(self.associated_token_program.clone());
628        account_infos.push(self.system_program.clone());
629        account_infos.push(self.whitelist.clone());
630        if let Some(mint_proof) = self.mint_proof {
631            account_infos.push(mint_proof.clone());
632        }
633        account_infos.push(self.order_nft_receipt.clone());
634        remaining_accounts
635            .iter()
636            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
637
638        if signers_seeds.is_empty() {
639            solana_program::program::invoke(&instruction, &account_infos)
640        } else {
641            solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
642        }
643    }
644}
645
646/// Instruction builder for `WithdrawCollateralT22` via CPI.
647///
648/// ### Accounts:
649///
650///   0. `[writable, signer]` signer
651///   1. `[writable]` order_state
652///   2. `[writable]` order_vault
653///   3. `[]` maker
654///   4. `[writable]` taker
655///   5. `[writable]` destination
656///   6. `[]` system
657///   7. `[]` tlock_program
658///   8. `[]` mint
659///   9. `[writable]` order_ta
660///   10. `[writable]` destination_ta
661///   11. `[]` token_program
662///   12. `[]` associated_token_program
663///   13. `[]` system_program
664///   14. `[]` whitelist
665///   15. `[optional]` mint_proof
666///   16. `[writable]` order_nft_receipt
667#[derive(Clone, Debug)]
668pub struct WithdrawCollateralT22CpiBuilder<'a, 'b> {
669    instruction: Box<WithdrawCollateralT22CpiBuilderInstruction<'a, 'b>>,
670}
671
672impl<'a, 'b> WithdrawCollateralT22CpiBuilder<'a, 'b> {
673    pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
674        let instruction = Box::new(WithdrawCollateralT22CpiBuilderInstruction {
675            __program: program,
676            signer: None,
677            order_state: None,
678            order_vault: None,
679            maker: None,
680            taker: None,
681            destination: None,
682            system: None,
683            tlock_program: None,
684            mint: None,
685            order_ta: None,
686            destination_ta: None,
687            token_program: None,
688            associated_token_program: None,
689            system_program: None,
690            whitelist: None,
691            mint_proof: None,
692            order_nft_receipt: None,
693            to_maker: None,
694            __remaining_accounts: Vec::new(),
695        });
696        Self { instruction }
697    }
698    #[inline(always)]
699    pub fn signer(
700        &mut self,
701        signer: &'b solana_program::account_info::AccountInfo<'a>,
702    ) -> &mut Self {
703        self.instruction.signer = Some(signer);
704        self
705    }
706    #[inline(always)]
707    pub fn order_state(
708        &mut self,
709        order_state: &'b solana_program::account_info::AccountInfo<'a>,
710    ) -> &mut Self {
711        self.instruction.order_state = Some(order_state);
712        self
713    }
714    #[inline(always)]
715    pub fn order_vault(
716        &mut self,
717        order_vault: &'b solana_program::account_info::AccountInfo<'a>,
718    ) -> &mut Self {
719        self.instruction.order_vault = Some(order_vault);
720        self
721    }
722    #[inline(always)]
723    pub fn maker(&mut self, maker: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
724        self.instruction.maker = Some(maker);
725        self
726    }
727    #[inline(always)]
728    pub fn taker(&mut self, taker: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
729        self.instruction.taker = Some(taker);
730        self
731    }
732    #[inline(always)]
733    pub fn destination(
734        &mut self,
735        destination: &'b solana_program::account_info::AccountInfo<'a>,
736    ) -> &mut Self {
737        self.instruction.destination = Some(destination);
738        self
739    }
740    #[inline(always)]
741    pub fn system(
742        &mut self,
743        system: &'b solana_program::account_info::AccountInfo<'a>,
744    ) -> &mut Self {
745        self.instruction.system = Some(system);
746        self
747    }
748    #[inline(always)]
749    pub fn tlock_program(
750        &mut self,
751        tlock_program: &'b solana_program::account_info::AccountInfo<'a>,
752    ) -> &mut Self {
753        self.instruction.tlock_program = Some(tlock_program);
754        self
755    }
756    #[inline(always)]
757    pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
758        self.instruction.mint = Some(mint);
759        self
760    }
761    #[inline(always)]
762    pub fn order_ta(
763        &mut self,
764        order_ta: &'b solana_program::account_info::AccountInfo<'a>,
765    ) -> &mut Self {
766        self.instruction.order_ta = Some(order_ta);
767        self
768    }
769    #[inline(always)]
770    pub fn destination_ta(
771        &mut self,
772        destination_ta: &'b solana_program::account_info::AccountInfo<'a>,
773    ) -> &mut Self {
774        self.instruction.destination_ta = Some(destination_ta);
775        self
776    }
777    #[inline(always)]
778    pub fn token_program(
779        &mut self,
780        token_program: &'b solana_program::account_info::AccountInfo<'a>,
781    ) -> &mut Self {
782        self.instruction.token_program = Some(token_program);
783        self
784    }
785    #[inline(always)]
786    pub fn associated_token_program(
787        &mut self,
788        associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
789    ) -> &mut Self {
790        self.instruction.associated_token_program = Some(associated_token_program);
791        self
792    }
793    #[inline(always)]
794    pub fn system_program(
795        &mut self,
796        system_program: &'b solana_program::account_info::AccountInfo<'a>,
797    ) -> &mut Self {
798        self.instruction.system_program = Some(system_program);
799        self
800    }
801    #[inline(always)]
802    pub fn whitelist(
803        &mut self,
804        whitelist: &'b solana_program::account_info::AccountInfo<'a>,
805    ) -> &mut Self {
806        self.instruction.whitelist = Some(whitelist);
807        self
808    }
809    /// `[optional account]`
810    #[inline(always)]
811    pub fn mint_proof(
812        &mut self,
813        mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
814    ) -> &mut Self {
815        self.instruction.mint_proof = mint_proof;
816        self
817    }
818    #[inline(always)]
819    pub fn order_nft_receipt(
820        &mut self,
821        order_nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
822    ) -> &mut Self {
823        self.instruction.order_nft_receipt = Some(order_nft_receipt);
824        self
825    }
826    #[inline(always)]
827    pub fn to_maker(&mut self, to_maker: bool) -> &mut Self {
828        self.instruction.to_maker = Some(to_maker);
829        self
830    }
831    /// Add an additional account to the instruction.
832    #[inline(always)]
833    pub fn add_remaining_account(
834        &mut self,
835        account: &'b solana_program::account_info::AccountInfo<'a>,
836        is_writable: bool,
837        is_signer: bool,
838    ) -> &mut Self {
839        self.instruction
840            .__remaining_accounts
841            .push((account, is_writable, is_signer));
842        self
843    }
844    /// Add additional accounts to the instruction.
845    ///
846    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
847    /// and a `bool` indicating whether the account is a signer or not.
848    #[inline(always)]
849    pub fn add_remaining_accounts(
850        &mut self,
851        accounts: &[(
852            &'b solana_program::account_info::AccountInfo<'a>,
853            bool,
854            bool,
855        )],
856    ) -> &mut Self {
857        self.instruction
858            .__remaining_accounts
859            .extend_from_slice(accounts);
860        self
861    }
862    #[inline(always)]
863    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
864        self.invoke_signed(&[])
865    }
866    #[allow(clippy::clone_on_copy)]
867    #[allow(clippy::vec_init_then_push)]
868    pub fn invoke_signed(
869        &self,
870        signers_seeds: &[&[&[u8]]],
871    ) -> solana_program::entrypoint::ProgramResult {
872        let args = WithdrawCollateralT22InstructionArgs {
873            to_maker: self
874                .instruction
875                .to_maker
876                .clone()
877                .expect("to_maker is not set"),
878        };
879        let instruction = WithdrawCollateralT22Cpi {
880            __program: self.instruction.__program,
881
882            signer: self.instruction.signer.expect("signer is not set"),
883
884            order_state: self
885                .instruction
886                .order_state
887                .expect("order_state is not set"),
888
889            order_vault: self
890                .instruction
891                .order_vault
892                .expect("order_vault is not set"),
893
894            maker: self.instruction.maker.expect("maker is not set"),
895
896            taker: self.instruction.taker.expect("taker is not set"),
897
898            destination: self
899                .instruction
900                .destination
901                .expect("destination is not set"),
902
903            system: self.instruction.system.expect("system is not set"),
904
905            tlock_program: self
906                .instruction
907                .tlock_program
908                .expect("tlock_program is not set"),
909
910            mint: self.instruction.mint.expect("mint is not set"),
911
912            order_ta: self.instruction.order_ta.expect("order_ta is not set"),
913
914            destination_ta: self
915                .instruction
916                .destination_ta
917                .expect("destination_ta is not set"),
918
919            token_program: self
920                .instruction
921                .token_program
922                .expect("token_program is not set"),
923
924            associated_token_program: self
925                .instruction
926                .associated_token_program
927                .expect("associated_token_program is not set"),
928
929            system_program: self
930                .instruction
931                .system_program
932                .expect("system_program is not set"),
933
934            whitelist: self.instruction.whitelist.expect("whitelist is not set"),
935
936            mint_proof: self.instruction.mint_proof,
937
938            order_nft_receipt: self
939                .instruction
940                .order_nft_receipt
941                .expect("order_nft_receipt is not set"),
942            __args: args,
943        };
944        instruction.invoke_signed_with_remaining_accounts(
945            signers_seeds,
946            &self.instruction.__remaining_accounts,
947        )
948    }
949}
950
951#[derive(Clone, Debug)]
952struct WithdrawCollateralT22CpiBuilderInstruction<'a, 'b> {
953    __program: &'b solana_program::account_info::AccountInfo<'a>,
954    signer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
955    order_state: Option<&'b solana_program::account_info::AccountInfo<'a>>,
956    order_vault: Option<&'b solana_program::account_info::AccountInfo<'a>>,
957    maker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
958    taker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
959    destination: Option<&'b solana_program::account_info::AccountInfo<'a>>,
960    system: Option<&'b solana_program::account_info::AccountInfo<'a>>,
961    tlock_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
962    mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
963    order_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
964    destination_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
965    token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
966    associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
967    system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
968    whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>,
969    mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
970    order_nft_receipt: Option<&'b solana_program::account_info::AccountInfo<'a>>,
971    to_maker: Option<bool>,
972    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
973    __remaining_accounts: Vec<(
974        &'b solana_program::account_info::AccountInfo<'a>,
975        bool,
976        bool,
977    )>,
978}