1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub struct DepositNftT22 {
13 pub owner: solana_program::pubkey::Pubkey,
15 pub pool: solana_program::pubkey::Pubkey,
17 pub whitelist: solana_program::pubkey::Pubkey,
20 pub mint_proof: Option<solana_program::pubkey::Pubkey>,
23 pub mint: solana_program::pubkey::Pubkey,
25 pub nft_receipt: solana_program::pubkey::Pubkey,
27 pub owner_ta: solana_program::pubkey::Pubkey,
29 pub pool_ta: solana_program::pubkey::Pubkey,
31 pub token_program: solana_program::pubkey::Pubkey,
33 pub associated_token_program: solana_program::pubkey::Pubkey,
35 pub system_program: solana_program::pubkey::Pubkey,
37}
38
39impl DepositNftT22 {
40 pub fn instruction(&self) -> solana_program::instruction::Instruction {
41 self.instruction_with_remaining_accounts(&[])
42 }
43 #[allow(clippy::vec_init_then_push)]
44 pub fn instruction_with_remaining_accounts(
45 &self,
46 remaining_accounts: &[solana_program::instruction::AccountMeta],
47 ) -> solana_program::instruction::Instruction {
48 let mut accounts = Vec::with_capacity(11 + remaining_accounts.len());
49 accounts.push(solana_program::instruction::AccountMeta::new(
50 self.owner, true,
51 ));
52 accounts.push(solana_program::instruction::AccountMeta::new(
53 self.pool, false,
54 ));
55 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
56 self.whitelist,
57 false,
58 ));
59 if let Some(mint_proof) = self.mint_proof {
60 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
61 mint_proof, false,
62 ));
63 } else {
64 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
65 crate::TENSOR_AMM_ID,
66 false,
67 ));
68 }
69 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
70 self.mint, false,
71 ));
72 accounts.push(solana_program::instruction::AccountMeta::new(
73 self.nft_receipt,
74 false,
75 ));
76 accounts.push(solana_program::instruction::AccountMeta::new(
77 self.owner_ta,
78 false,
79 ));
80 accounts.push(solana_program::instruction::AccountMeta::new(
81 self.pool_ta,
82 false,
83 ));
84 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
85 self.token_program,
86 false,
87 ));
88 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
89 self.associated_token_program,
90 false,
91 ));
92 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
93 self.system_program,
94 false,
95 ));
96 accounts.extend_from_slice(remaining_accounts);
97 let data = DepositNftT22InstructionData::new().try_to_vec().unwrap();
98
99 solana_program::instruction::Instruction {
100 program_id: crate::TENSOR_AMM_ID,
101 accounts,
102 data,
103 }
104 }
105}
106
107#[derive(BorshDeserialize, BorshSerialize)]
108pub struct DepositNftT22InstructionData {
109 discriminator: [u8; 8],
110}
111
112impl DepositNftT22InstructionData {
113 pub fn new() -> Self {
114 Self {
115 discriminator: [208, 34, 6, 147, 95, 218, 49, 160],
116 }
117 }
118}
119
120impl Default for DepositNftT22InstructionData {
121 fn default() -> Self {
122 Self::new()
123 }
124}
125
126#[derive(Clone, Debug, Default)]
142pub struct DepositNftT22Builder {
143 owner: Option<solana_program::pubkey::Pubkey>,
144 pool: Option<solana_program::pubkey::Pubkey>,
145 whitelist: Option<solana_program::pubkey::Pubkey>,
146 mint_proof: Option<solana_program::pubkey::Pubkey>,
147 mint: Option<solana_program::pubkey::Pubkey>,
148 nft_receipt: Option<solana_program::pubkey::Pubkey>,
149 owner_ta: Option<solana_program::pubkey::Pubkey>,
150 pool_ta: Option<solana_program::pubkey::Pubkey>,
151 token_program: Option<solana_program::pubkey::Pubkey>,
152 associated_token_program: Option<solana_program::pubkey::Pubkey>,
153 system_program: Option<solana_program::pubkey::Pubkey>,
154 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
155}
156
157impl DepositNftT22Builder {
158 pub fn new() -> Self {
159 Self::default()
160 }
161 #[inline(always)]
163 pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self {
164 self.owner = Some(owner);
165 self
166 }
167 #[inline(always)]
169 pub fn pool(&mut self, pool: solana_program::pubkey::Pubkey) -> &mut Self {
170 self.pool = Some(pool);
171 self
172 }
173 #[inline(always)]
176 pub fn whitelist(&mut self, whitelist: solana_program::pubkey::Pubkey) -> &mut Self {
177 self.whitelist = Some(whitelist);
178 self
179 }
180 #[inline(always)]
184 pub fn mint_proof(&mut self, mint_proof: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
185 self.mint_proof = mint_proof;
186 self
187 }
188 #[inline(always)]
190 pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
191 self.mint = Some(mint);
192 self
193 }
194 #[inline(always)]
196 pub fn nft_receipt(&mut self, nft_receipt: solana_program::pubkey::Pubkey) -> &mut Self {
197 self.nft_receipt = Some(nft_receipt);
198 self
199 }
200 #[inline(always)]
202 pub fn owner_ta(&mut self, owner_ta: solana_program::pubkey::Pubkey) -> &mut Self {
203 self.owner_ta = Some(owner_ta);
204 self
205 }
206 #[inline(always)]
208 pub fn pool_ta(&mut self, pool_ta: solana_program::pubkey::Pubkey) -> &mut Self {
209 self.pool_ta = Some(pool_ta);
210 self
211 }
212 #[inline(always)]
215 pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
216 self.token_program = Some(token_program);
217 self
218 }
219 #[inline(always)]
222 pub fn associated_token_program(
223 &mut self,
224 associated_token_program: solana_program::pubkey::Pubkey,
225 ) -> &mut Self {
226 self.associated_token_program = Some(associated_token_program);
227 self
228 }
229 #[inline(always)]
232 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
233 self.system_program = Some(system_program);
234 self
235 }
236 #[inline(always)]
238 pub fn add_remaining_account(
239 &mut self,
240 account: solana_program::instruction::AccountMeta,
241 ) -> &mut Self {
242 self.__remaining_accounts.push(account);
243 self
244 }
245 #[inline(always)]
247 pub fn add_remaining_accounts(
248 &mut self,
249 accounts: &[solana_program::instruction::AccountMeta],
250 ) -> &mut Self {
251 self.__remaining_accounts.extend_from_slice(accounts);
252 self
253 }
254 #[allow(clippy::clone_on_copy)]
255 pub fn instruction(&self) -> solana_program::instruction::Instruction {
256 let accounts = DepositNftT22 {
257 owner: self.owner.expect("owner is not set"),
258 pool: self.pool.expect("pool is not set"),
259 whitelist: self.whitelist.expect("whitelist is not set"),
260 mint_proof: self.mint_proof,
261 mint: self.mint.expect("mint is not set"),
262 nft_receipt: self.nft_receipt.expect("nft_receipt is not set"),
263 owner_ta: self.owner_ta.expect("owner_ta is not set"),
264 pool_ta: self.pool_ta.expect("pool_ta is not set"),
265 token_program: self.token_program.unwrap_or(solana_program::pubkey!(
266 "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
267 )),
268 associated_token_program: self.associated_token_program.unwrap_or(
269 solana_program::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),
270 ),
271 system_program: self
272 .system_program
273 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
274 };
275
276 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
277 }
278}
279
280pub struct DepositNftT22CpiAccounts<'a, 'b> {
282 pub owner: &'b solana_program::account_info::AccountInfo<'a>,
284 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
286 pub whitelist: &'b solana_program::account_info::AccountInfo<'a>,
289 pub mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
292 pub mint: &'b solana_program::account_info::AccountInfo<'a>,
294 pub nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
296 pub owner_ta: &'b solana_program::account_info::AccountInfo<'a>,
298 pub pool_ta: &'b solana_program::account_info::AccountInfo<'a>,
300 pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
302 pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
304 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
306}
307
308pub struct DepositNftT22Cpi<'a, 'b> {
310 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
312 pub owner: &'b solana_program::account_info::AccountInfo<'a>,
314 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
316 pub whitelist: &'b solana_program::account_info::AccountInfo<'a>,
319 pub mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
322 pub mint: &'b solana_program::account_info::AccountInfo<'a>,
324 pub nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
326 pub owner_ta: &'b solana_program::account_info::AccountInfo<'a>,
328 pub pool_ta: &'b solana_program::account_info::AccountInfo<'a>,
330 pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
332 pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
334 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
336}
337
338impl<'a, 'b> DepositNftT22Cpi<'a, 'b> {
339 pub fn new(
340 program: &'b solana_program::account_info::AccountInfo<'a>,
341 accounts: DepositNftT22CpiAccounts<'a, 'b>,
342 ) -> Self {
343 Self {
344 __program: program,
345 owner: accounts.owner,
346 pool: accounts.pool,
347 whitelist: accounts.whitelist,
348 mint_proof: accounts.mint_proof,
349 mint: accounts.mint,
350 nft_receipt: accounts.nft_receipt,
351 owner_ta: accounts.owner_ta,
352 pool_ta: accounts.pool_ta,
353 token_program: accounts.token_program,
354 associated_token_program: accounts.associated_token_program,
355 system_program: accounts.system_program,
356 }
357 }
358 #[inline(always)]
359 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
360 self.invoke_signed_with_remaining_accounts(&[], &[])
361 }
362 #[inline(always)]
363 pub fn invoke_with_remaining_accounts(
364 &self,
365 remaining_accounts: &[(
366 &'b solana_program::account_info::AccountInfo<'a>,
367 bool,
368 bool,
369 )],
370 ) -> solana_program::entrypoint::ProgramResult {
371 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
372 }
373 #[inline(always)]
374 pub fn invoke_signed(
375 &self,
376 signers_seeds: &[&[&[u8]]],
377 ) -> solana_program::entrypoint::ProgramResult {
378 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
379 }
380 #[allow(clippy::clone_on_copy)]
381 #[allow(clippy::vec_init_then_push)]
382 pub fn invoke_signed_with_remaining_accounts(
383 &self,
384 signers_seeds: &[&[&[u8]]],
385 remaining_accounts: &[(
386 &'b solana_program::account_info::AccountInfo<'a>,
387 bool,
388 bool,
389 )],
390 ) -> solana_program::entrypoint::ProgramResult {
391 let mut accounts = Vec::with_capacity(11 + remaining_accounts.len());
392 accounts.push(solana_program::instruction::AccountMeta::new(
393 *self.owner.key,
394 true,
395 ));
396 accounts.push(solana_program::instruction::AccountMeta::new(
397 *self.pool.key,
398 false,
399 ));
400 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
401 *self.whitelist.key,
402 false,
403 ));
404 if let Some(mint_proof) = self.mint_proof {
405 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
406 *mint_proof.key,
407 false,
408 ));
409 } else {
410 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
411 crate::TENSOR_AMM_ID,
412 false,
413 ));
414 }
415 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
416 *self.mint.key,
417 false,
418 ));
419 accounts.push(solana_program::instruction::AccountMeta::new(
420 *self.nft_receipt.key,
421 false,
422 ));
423 accounts.push(solana_program::instruction::AccountMeta::new(
424 *self.owner_ta.key,
425 false,
426 ));
427 accounts.push(solana_program::instruction::AccountMeta::new(
428 *self.pool_ta.key,
429 false,
430 ));
431 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
432 *self.token_program.key,
433 false,
434 ));
435 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
436 *self.associated_token_program.key,
437 false,
438 ));
439 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
440 *self.system_program.key,
441 false,
442 ));
443 remaining_accounts.iter().for_each(|remaining_account| {
444 accounts.push(solana_program::instruction::AccountMeta {
445 pubkey: *remaining_account.0.key,
446 is_signer: remaining_account.1,
447 is_writable: remaining_account.2,
448 })
449 });
450 let data = DepositNftT22InstructionData::new().try_to_vec().unwrap();
451
452 let instruction = solana_program::instruction::Instruction {
453 program_id: crate::TENSOR_AMM_ID,
454 accounts,
455 data,
456 };
457 let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len());
458 account_infos.push(self.__program.clone());
459 account_infos.push(self.owner.clone());
460 account_infos.push(self.pool.clone());
461 account_infos.push(self.whitelist.clone());
462 if let Some(mint_proof) = self.mint_proof {
463 account_infos.push(mint_proof.clone());
464 }
465 account_infos.push(self.mint.clone());
466 account_infos.push(self.nft_receipt.clone());
467 account_infos.push(self.owner_ta.clone());
468 account_infos.push(self.pool_ta.clone());
469 account_infos.push(self.token_program.clone());
470 account_infos.push(self.associated_token_program.clone());
471 account_infos.push(self.system_program.clone());
472 remaining_accounts
473 .iter()
474 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
475
476 if signers_seeds.is_empty() {
477 solana_program::program::invoke(&instruction, &account_infos)
478 } else {
479 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
480 }
481 }
482}
483
484#[derive(Clone, Debug)]
500pub struct DepositNftT22CpiBuilder<'a, 'b> {
501 instruction: Box<DepositNftT22CpiBuilderInstruction<'a, 'b>>,
502}
503
504impl<'a, 'b> DepositNftT22CpiBuilder<'a, 'b> {
505 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
506 let instruction = Box::new(DepositNftT22CpiBuilderInstruction {
507 __program: program,
508 owner: None,
509 pool: None,
510 whitelist: None,
511 mint_proof: None,
512 mint: None,
513 nft_receipt: None,
514 owner_ta: None,
515 pool_ta: None,
516 token_program: None,
517 associated_token_program: None,
518 system_program: None,
519 __remaining_accounts: Vec::new(),
520 });
521 Self { instruction }
522 }
523 #[inline(always)]
525 pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
526 self.instruction.owner = Some(owner);
527 self
528 }
529 #[inline(always)]
531 pub fn pool(&mut self, pool: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
532 self.instruction.pool = Some(pool);
533 self
534 }
535 #[inline(always)]
538 pub fn whitelist(
539 &mut self,
540 whitelist: &'b solana_program::account_info::AccountInfo<'a>,
541 ) -> &mut Self {
542 self.instruction.whitelist = Some(whitelist);
543 self
544 }
545 #[inline(always)]
549 pub fn mint_proof(
550 &mut self,
551 mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
552 ) -> &mut Self {
553 self.instruction.mint_proof = mint_proof;
554 self
555 }
556 #[inline(always)]
558 pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
559 self.instruction.mint = Some(mint);
560 self
561 }
562 #[inline(always)]
564 pub fn nft_receipt(
565 &mut self,
566 nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
567 ) -> &mut Self {
568 self.instruction.nft_receipt = Some(nft_receipt);
569 self
570 }
571 #[inline(always)]
573 pub fn owner_ta(
574 &mut self,
575 owner_ta: &'b solana_program::account_info::AccountInfo<'a>,
576 ) -> &mut Self {
577 self.instruction.owner_ta = Some(owner_ta);
578 self
579 }
580 #[inline(always)]
582 pub fn pool_ta(
583 &mut self,
584 pool_ta: &'b solana_program::account_info::AccountInfo<'a>,
585 ) -> &mut Self {
586 self.instruction.pool_ta = Some(pool_ta);
587 self
588 }
589 #[inline(always)]
591 pub fn token_program(
592 &mut self,
593 token_program: &'b solana_program::account_info::AccountInfo<'a>,
594 ) -> &mut Self {
595 self.instruction.token_program = Some(token_program);
596 self
597 }
598 #[inline(always)]
600 pub fn associated_token_program(
601 &mut self,
602 associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
603 ) -> &mut Self {
604 self.instruction.associated_token_program = Some(associated_token_program);
605 self
606 }
607 #[inline(always)]
609 pub fn system_program(
610 &mut self,
611 system_program: &'b solana_program::account_info::AccountInfo<'a>,
612 ) -> &mut Self {
613 self.instruction.system_program = Some(system_program);
614 self
615 }
616 #[inline(always)]
618 pub fn add_remaining_account(
619 &mut self,
620 account: &'b solana_program::account_info::AccountInfo<'a>,
621 is_writable: bool,
622 is_signer: bool,
623 ) -> &mut Self {
624 self.instruction
625 .__remaining_accounts
626 .push((account, is_writable, is_signer));
627 self
628 }
629 #[inline(always)]
634 pub fn add_remaining_accounts(
635 &mut self,
636 accounts: &[(
637 &'b solana_program::account_info::AccountInfo<'a>,
638 bool,
639 bool,
640 )],
641 ) -> &mut Self {
642 self.instruction
643 .__remaining_accounts
644 .extend_from_slice(accounts);
645 self
646 }
647 #[inline(always)]
648 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
649 self.invoke_signed(&[])
650 }
651 #[allow(clippy::clone_on_copy)]
652 #[allow(clippy::vec_init_then_push)]
653 pub fn invoke_signed(
654 &self,
655 signers_seeds: &[&[&[u8]]],
656 ) -> solana_program::entrypoint::ProgramResult {
657 let instruction = DepositNftT22Cpi {
658 __program: self.instruction.__program,
659
660 owner: self.instruction.owner.expect("owner is not set"),
661
662 pool: self.instruction.pool.expect("pool is not set"),
663
664 whitelist: self.instruction.whitelist.expect("whitelist is not set"),
665
666 mint_proof: self.instruction.mint_proof,
667
668 mint: self.instruction.mint.expect("mint is not set"),
669
670 nft_receipt: self
671 .instruction
672 .nft_receipt
673 .expect("nft_receipt is not set"),
674
675 owner_ta: self.instruction.owner_ta.expect("owner_ta is not set"),
676
677 pool_ta: self.instruction.pool_ta.expect("pool_ta is not set"),
678
679 token_program: self
680 .instruction
681 .token_program
682 .expect("token_program is not set"),
683
684 associated_token_program: self
685 .instruction
686 .associated_token_program
687 .expect("associated_token_program is not set"),
688
689 system_program: self
690 .instruction
691 .system_program
692 .expect("system_program is not set"),
693 };
694 instruction.invoke_signed_with_remaining_accounts(
695 signers_seeds,
696 &self.instruction.__remaining_accounts,
697 )
698 }
699}
700
701#[derive(Clone, Debug)]
702struct DepositNftT22CpiBuilderInstruction<'a, 'b> {
703 __program: &'b solana_program::account_info::AccountInfo<'a>,
704 owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
705 pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
706 whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>,
707 mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
708 mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
709 nft_receipt: Option<&'b solana_program::account_info::AccountInfo<'a>>,
710 owner_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
711 pool_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
712 token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
713 associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
714 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
715 __remaining_accounts: Vec<(
717 &'b solana_program::account_info::AccountInfo<'a>,
718 bool,
719 bool,
720 )>,
721}