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