1use borsh::BorshSerialize;
9use borsh::BorshDeserialize;
10
11pub const CREATE_KAMINO_USER_ACCOUNTS_DISCRIMINATOR: [u8; 8] = [37, 248, 26, 124, 176, 250, 89, 196];
12
13#[derive(Debug)]
15pub struct CreateKaminoUserAccounts {
16
17
18 pub main: solana_pubkey::Pubkey,
19
20
21 pub controller: solana_pubkey::Pubkey,
22
23
24 pub admin: solana_pubkey::Pubkey,
25
26
27 pub admin_permissions: solana_pubkey::Pubkey,
28
29
30 pub instruction_sysvar_account: solana_pubkey::Pubkey,
31
32
33 pub rent: solana_pubkey::Pubkey,
34
35
36 pub system_program: solana_pubkey::Pubkey,
37 pub user_metadata: solana_pubkey::Pubkey,
42
43
44 pub obligation: solana_pubkey::Pubkey,
45
46
47 pub lending_market: solana_pubkey::Pubkey,
48
49
50 pub lending_market_authority: solana_pubkey::Pubkey,
51
52
53 pub reserve: solana_pubkey::Pubkey,
54
55
56 pub obligation_farm_state: solana_pubkey::Pubkey,
57
58
59 pub reserve_farm_state: solana_pubkey::Pubkey,
60
61
62 pub klend_program: solana_pubkey::Pubkey,
63
64
65 pub farms_program: solana_pubkey::Pubkey,
66 pub earn_mint: solana_pubkey::Pubkey,
71
72
73 pub controller_token_account: solana_pubkey::Pubkey,
74
75
76 pub user_usdc_account: solana_pubkey::Pubkey,
77
78
79 pub reserve_collateral: solana_pubkey::Pubkey,
80
81
82 pub scope_oracle: solana_pubkey::Pubkey,
83
84
85 pub token_program: solana_pubkey::Pubkey,
86
87
88 pub reserve_liquidity_supply: solana_pubkey::Pubkey,
89
90
91 pub reserve_collateral_mint: solana_pubkey::Pubkey,
92
93
94 pub reserve_destination_deposit_collateral: solana_pubkey::Pubkey,
95 }
96
97impl CreateKaminoUserAccounts {
98 pub fn instruction(&self) -> solana_instruction::Instruction {
99 self.instruction_with_remaining_accounts(&[])
100 }
101 #[allow(clippy::arithmetic_side_effects)]
102 #[allow(clippy::vec_init_then_push)]
103 pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
104 let mut accounts = Vec::with_capacity(25+ remaining_accounts.len());
105 accounts.push(solana_instruction::AccountMeta::new(
106 self.main,
107 false
108 ));
109 accounts.push(solana_instruction::AccountMeta::new(
110 self.controller,
111 false
112 ));
113 accounts.push(solana_instruction::AccountMeta::new(
114 self.admin,
115 true
116 ));
117 accounts.push(solana_instruction::AccountMeta::new_readonly(
118 self.admin_permissions,
119 false
120 ));
121 accounts.push(solana_instruction::AccountMeta::new_readonly(
122 self.instruction_sysvar_account,
123 false
124 ));
125 accounts.push(solana_instruction::AccountMeta::new_readonly(
126 self.rent,
127 false
128 ));
129 accounts.push(solana_instruction::AccountMeta::new_readonly(
130 self.system_program,
131 false
132 ));
133 accounts.push(solana_instruction::AccountMeta::new(
134 self.user_metadata,
135 false
136 ));
137 accounts.push(solana_instruction::AccountMeta::new(
138 self.obligation,
139 false
140 ));
141 accounts.push(solana_instruction::AccountMeta::new_readonly(
142 self.lending_market,
143 false
144 ));
145 accounts.push(solana_instruction::AccountMeta::new_readonly(
146 self.lending_market_authority,
147 false
148 ));
149 accounts.push(solana_instruction::AccountMeta::new(
150 self.reserve,
151 false
152 ));
153 accounts.push(solana_instruction::AccountMeta::new(
154 self.obligation_farm_state,
155 false
156 ));
157 accounts.push(solana_instruction::AccountMeta::new(
158 self.reserve_farm_state,
159 false
160 ));
161 accounts.push(solana_instruction::AccountMeta::new_readonly(
162 self.klend_program,
163 false
164 ));
165 accounts.push(solana_instruction::AccountMeta::new_readonly(
166 self.farms_program,
167 false
168 ));
169 accounts.push(solana_instruction::AccountMeta::new_readonly(
170 self.earn_mint,
171 false
172 ));
173 accounts.push(solana_instruction::AccountMeta::new(
174 self.controller_token_account,
175 false
176 ));
177 accounts.push(solana_instruction::AccountMeta::new(
178 self.user_usdc_account,
179 false
180 ));
181 accounts.push(solana_instruction::AccountMeta::new_readonly(
182 self.reserve_collateral,
183 false
184 ));
185 accounts.push(solana_instruction::AccountMeta::new_readonly(
186 self.scope_oracle,
187 false
188 ));
189 accounts.push(solana_instruction::AccountMeta::new_readonly(
190 self.token_program,
191 false
192 ));
193 accounts.push(solana_instruction::AccountMeta::new(
194 self.reserve_liquidity_supply,
195 false
196 ));
197 accounts.push(solana_instruction::AccountMeta::new(
198 self.reserve_collateral_mint,
199 false
200 ));
201 accounts.push(solana_instruction::AccountMeta::new(
202 self.reserve_destination_deposit_collateral,
203 false
204 ));
205 accounts.extend_from_slice(remaining_accounts);
206 let data = CreateKaminoUserAccountsInstructionData::new().try_to_vec().unwrap();
207
208 solana_instruction::Instruction {
209 program_id: crate::REFLECT_MAIN_ID,
210 accounts,
211 data,
212 }
213 }
214}
215
216#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
217#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
218 pub struct CreateKaminoUserAccountsInstructionData {
219 discriminator: [u8; 8],
220 }
221
222impl CreateKaminoUserAccountsInstructionData {
223 pub fn new() -> Self {
224 Self {
225 discriminator: [37, 248, 26, 124, 176, 250, 89, 196],
226 }
227 }
228
229 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
230 borsh::to_vec(self)
231 }
232 }
233
234impl Default for CreateKaminoUserAccountsInstructionData {
235 fn default() -> Self {
236 Self::new()
237 }
238}
239
240
241
242#[derive(Clone, Debug, Default)]
272pub struct CreateKaminoUserAccountsBuilder {
273 main: Option<solana_pubkey::Pubkey>,
274 controller: Option<solana_pubkey::Pubkey>,
275 admin: Option<solana_pubkey::Pubkey>,
276 admin_permissions: Option<solana_pubkey::Pubkey>,
277 instruction_sysvar_account: Option<solana_pubkey::Pubkey>,
278 rent: Option<solana_pubkey::Pubkey>,
279 system_program: Option<solana_pubkey::Pubkey>,
280 user_metadata: Option<solana_pubkey::Pubkey>,
281 obligation: Option<solana_pubkey::Pubkey>,
282 lending_market: Option<solana_pubkey::Pubkey>,
283 lending_market_authority: Option<solana_pubkey::Pubkey>,
284 reserve: Option<solana_pubkey::Pubkey>,
285 obligation_farm_state: Option<solana_pubkey::Pubkey>,
286 reserve_farm_state: Option<solana_pubkey::Pubkey>,
287 klend_program: Option<solana_pubkey::Pubkey>,
288 farms_program: Option<solana_pubkey::Pubkey>,
289 earn_mint: Option<solana_pubkey::Pubkey>,
290 controller_token_account: Option<solana_pubkey::Pubkey>,
291 user_usdc_account: Option<solana_pubkey::Pubkey>,
292 reserve_collateral: Option<solana_pubkey::Pubkey>,
293 scope_oracle: Option<solana_pubkey::Pubkey>,
294 token_program: Option<solana_pubkey::Pubkey>,
295 reserve_liquidity_supply: Option<solana_pubkey::Pubkey>,
296 reserve_collateral_mint: Option<solana_pubkey::Pubkey>,
297 reserve_destination_deposit_collateral: Option<solana_pubkey::Pubkey>,
298 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
299}
300
301impl CreateKaminoUserAccountsBuilder {
302 pub fn new() -> Self {
303 Self::default()
304 }
305 #[inline(always)]
306 pub fn main(&mut self, main: solana_pubkey::Pubkey) -> &mut Self {
307 self.main = Some(main);
308 self
309 }
310 #[inline(always)]
311 pub fn controller(&mut self, controller: solana_pubkey::Pubkey) -> &mut Self {
312 self.controller = Some(controller);
313 self
314 }
315 #[inline(always)]
316 pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self {
317 self.admin = Some(admin);
318 self
319 }
320 #[inline(always)]
321 pub fn admin_permissions(&mut self, admin_permissions: solana_pubkey::Pubkey) -> &mut Self {
322 self.admin_permissions = Some(admin_permissions);
323 self
324 }
325 #[inline(always)]
327 pub fn instruction_sysvar_account(&mut self, instruction_sysvar_account: solana_pubkey::Pubkey) -> &mut Self {
328 self.instruction_sysvar_account = Some(instruction_sysvar_account);
329 self
330 }
331 #[inline(always)]
333 pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self {
334 self.rent = Some(rent);
335 self
336 }
337 #[inline(always)]
339 pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self {
340 self.system_program = Some(system_program);
341 self
342 }
343 #[inline(always)]
345 pub fn user_metadata(&mut self, user_metadata: solana_pubkey::Pubkey) -> &mut Self {
346 self.user_metadata = Some(user_metadata);
347 self
348 }
349 #[inline(always)]
350 pub fn obligation(&mut self, obligation: solana_pubkey::Pubkey) -> &mut Self {
351 self.obligation = Some(obligation);
352 self
353 }
354 #[inline(always)]
355 pub fn lending_market(&mut self, lending_market: solana_pubkey::Pubkey) -> &mut Self {
356 self.lending_market = Some(lending_market);
357 self
358 }
359 #[inline(always)]
360 pub fn lending_market_authority(&mut self, lending_market_authority: solana_pubkey::Pubkey) -> &mut Self {
361 self.lending_market_authority = Some(lending_market_authority);
362 self
363 }
364 #[inline(always)]
365 pub fn reserve(&mut self, reserve: solana_pubkey::Pubkey) -> &mut Self {
366 self.reserve = Some(reserve);
367 self
368 }
369 #[inline(always)]
370 pub fn obligation_farm_state(&mut self, obligation_farm_state: solana_pubkey::Pubkey) -> &mut Self {
371 self.obligation_farm_state = Some(obligation_farm_state);
372 self
373 }
374 #[inline(always)]
375 pub fn reserve_farm_state(&mut self, reserve_farm_state: solana_pubkey::Pubkey) -> &mut Self {
376 self.reserve_farm_state = Some(reserve_farm_state);
377 self
378 }
379 #[inline(always)]
381 pub fn klend_program(&mut self, klend_program: solana_pubkey::Pubkey) -> &mut Self {
382 self.klend_program = Some(klend_program);
383 self
384 }
385 #[inline(always)]
387 pub fn farms_program(&mut self, farms_program: solana_pubkey::Pubkey) -> &mut Self {
388 self.farms_program = Some(farms_program);
389 self
390 }
391 #[inline(always)]
393 pub fn earn_mint(&mut self, earn_mint: solana_pubkey::Pubkey) -> &mut Self {
394 self.earn_mint = Some(earn_mint);
395 self
396 }
397 #[inline(always)]
398 pub fn controller_token_account(&mut self, controller_token_account: solana_pubkey::Pubkey) -> &mut Self {
399 self.controller_token_account = Some(controller_token_account);
400 self
401 }
402 #[inline(always)]
403 pub fn user_usdc_account(&mut self, user_usdc_account: solana_pubkey::Pubkey) -> &mut Self {
404 self.user_usdc_account = Some(user_usdc_account);
405 self
406 }
407 #[inline(always)]
408 pub fn reserve_collateral(&mut self, reserve_collateral: solana_pubkey::Pubkey) -> &mut Self {
409 self.reserve_collateral = Some(reserve_collateral);
410 self
411 }
412 #[inline(always)]
413 pub fn scope_oracle(&mut self, scope_oracle: solana_pubkey::Pubkey) -> &mut Self {
414 self.scope_oracle = Some(scope_oracle);
415 self
416 }
417 #[inline(always)]
419 pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self {
420 self.token_program = Some(token_program);
421 self
422 }
423 #[inline(always)]
424 pub fn reserve_liquidity_supply(&mut self, reserve_liquidity_supply: solana_pubkey::Pubkey) -> &mut Self {
425 self.reserve_liquidity_supply = Some(reserve_liquidity_supply);
426 self
427 }
428 #[inline(always)]
429 pub fn reserve_collateral_mint(&mut self, reserve_collateral_mint: solana_pubkey::Pubkey) -> &mut Self {
430 self.reserve_collateral_mint = Some(reserve_collateral_mint);
431 self
432 }
433 #[inline(always)]
434 pub fn reserve_destination_deposit_collateral(&mut self, reserve_destination_deposit_collateral: solana_pubkey::Pubkey) -> &mut Self {
435 self.reserve_destination_deposit_collateral = Some(reserve_destination_deposit_collateral);
436 self
437 }
438 #[inline(always)]
440 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
441 self.__remaining_accounts.push(account);
442 self
443 }
444 #[inline(always)]
446 pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
447 self.__remaining_accounts.extend_from_slice(accounts);
448 self
449 }
450 #[allow(clippy::clone_on_copy)]
451 pub fn instruction(&self) -> solana_instruction::Instruction {
452 let accounts = CreateKaminoUserAccounts {
453 main: self.main.expect("main is not set"),
454 controller: self.controller.expect("controller is not set"),
455 admin: self.admin.expect("admin is not set"),
456 admin_permissions: self.admin_permissions.expect("admin_permissions is not set"),
457 instruction_sysvar_account: self.instruction_sysvar_account.unwrap_or(solana_pubkey::pubkey!("Sysvar1nstructions1111111111111111111111111")),
458 rent: self.rent.unwrap_or(solana_pubkey::pubkey!("SysvarRent111111111111111111111111111111111")),
459 system_program: self.system_program.unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
460 user_metadata: self.user_metadata.expect("user_metadata is not set"),
461 obligation: self.obligation.expect("obligation is not set"),
462 lending_market: self.lending_market.expect("lending_market is not set"),
463 lending_market_authority: self.lending_market_authority.expect("lending_market_authority is not set"),
464 reserve: self.reserve.expect("reserve is not set"),
465 obligation_farm_state: self.obligation_farm_state.expect("obligation_farm_state is not set"),
466 reserve_farm_state: self.reserve_farm_state.expect("reserve_farm_state is not set"),
467 klend_program: self.klend_program.unwrap_or(solana_pubkey::pubkey!("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD")),
468 farms_program: self.farms_program.unwrap_or(solana_pubkey::pubkey!("FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr")),
469 earn_mint: self.earn_mint.expect("earn_mint is not set"),
470 controller_token_account: self.controller_token_account.expect("controller_token_account is not set"),
471 user_usdc_account: self.user_usdc_account.expect("user_usdc_account is not set"),
472 reserve_collateral: self.reserve_collateral.expect("reserve_collateral is not set"),
473 scope_oracle: self.scope_oracle.expect("scope_oracle is not set"),
474 token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")),
475 reserve_liquidity_supply: self.reserve_liquidity_supply.expect("reserve_liquidity_supply is not set"),
476 reserve_collateral_mint: self.reserve_collateral_mint.expect("reserve_collateral_mint is not set"),
477 reserve_destination_deposit_collateral: self.reserve_destination_deposit_collateral.expect("reserve_destination_deposit_collateral is not set"),
478 };
479
480 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
481 }
482}
483
484 pub struct CreateKaminoUserAccountsCpiAccounts<'a, 'b> {
486
487
488 pub main: &'b solana_account_info::AccountInfo<'a>,
489
490
491 pub controller: &'b solana_account_info::AccountInfo<'a>,
492
493
494 pub admin: &'b solana_account_info::AccountInfo<'a>,
495
496
497 pub admin_permissions: &'b solana_account_info::AccountInfo<'a>,
498
499
500 pub instruction_sysvar_account: &'b solana_account_info::AccountInfo<'a>,
501
502
503 pub rent: &'b solana_account_info::AccountInfo<'a>,
504
505
506 pub system_program: &'b solana_account_info::AccountInfo<'a>,
507 pub user_metadata: &'b solana_account_info::AccountInfo<'a>,
512
513
514 pub obligation: &'b solana_account_info::AccountInfo<'a>,
515
516
517 pub lending_market: &'b solana_account_info::AccountInfo<'a>,
518
519
520 pub lending_market_authority: &'b solana_account_info::AccountInfo<'a>,
521
522
523 pub reserve: &'b solana_account_info::AccountInfo<'a>,
524
525
526 pub obligation_farm_state: &'b solana_account_info::AccountInfo<'a>,
527
528
529 pub reserve_farm_state: &'b solana_account_info::AccountInfo<'a>,
530
531
532 pub klend_program: &'b solana_account_info::AccountInfo<'a>,
533
534
535 pub farms_program: &'b solana_account_info::AccountInfo<'a>,
536 pub earn_mint: &'b solana_account_info::AccountInfo<'a>,
541
542
543 pub controller_token_account: &'b solana_account_info::AccountInfo<'a>,
544
545
546 pub user_usdc_account: &'b solana_account_info::AccountInfo<'a>,
547
548
549 pub reserve_collateral: &'b solana_account_info::AccountInfo<'a>,
550
551
552 pub scope_oracle: &'b solana_account_info::AccountInfo<'a>,
553
554
555 pub token_program: &'b solana_account_info::AccountInfo<'a>,
556
557
558 pub reserve_liquidity_supply: &'b solana_account_info::AccountInfo<'a>,
559
560
561 pub reserve_collateral_mint: &'b solana_account_info::AccountInfo<'a>,
562
563
564 pub reserve_destination_deposit_collateral: &'b solana_account_info::AccountInfo<'a>,
565 }
566
567pub struct CreateKaminoUserAccountsCpi<'a, 'b> {
569 pub __program: &'b solana_account_info::AccountInfo<'a>,
571
572
573 pub main: &'b solana_account_info::AccountInfo<'a>,
574
575
576 pub controller: &'b solana_account_info::AccountInfo<'a>,
577
578
579 pub admin: &'b solana_account_info::AccountInfo<'a>,
580
581
582 pub admin_permissions: &'b solana_account_info::AccountInfo<'a>,
583
584
585 pub instruction_sysvar_account: &'b solana_account_info::AccountInfo<'a>,
586
587
588 pub rent: &'b solana_account_info::AccountInfo<'a>,
589
590
591 pub system_program: &'b solana_account_info::AccountInfo<'a>,
592 pub user_metadata: &'b solana_account_info::AccountInfo<'a>,
597
598
599 pub obligation: &'b solana_account_info::AccountInfo<'a>,
600
601
602 pub lending_market: &'b solana_account_info::AccountInfo<'a>,
603
604
605 pub lending_market_authority: &'b solana_account_info::AccountInfo<'a>,
606
607
608 pub reserve: &'b solana_account_info::AccountInfo<'a>,
609
610
611 pub obligation_farm_state: &'b solana_account_info::AccountInfo<'a>,
612
613
614 pub reserve_farm_state: &'b solana_account_info::AccountInfo<'a>,
615
616
617 pub klend_program: &'b solana_account_info::AccountInfo<'a>,
618
619
620 pub farms_program: &'b solana_account_info::AccountInfo<'a>,
621 pub earn_mint: &'b solana_account_info::AccountInfo<'a>,
626
627
628 pub controller_token_account: &'b solana_account_info::AccountInfo<'a>,
629
630
631 pub user_usdc_account: &'b solana_account_info::AccountInfo<'a>,
632
633
634 pub reserve_collateral: &'b solana_account_info::AccountInfo<'a>,
635
636
637 pub scope_oracle: &'b solana_account_info::AccountInfo<'a>,
638
639
640 pub token_program: &'b solana_account_info::AccountInfo<'a>,
641
642
643 pub reserve_liquidity_supply: &'b solana_account_info::AccountInfo<'a>,
644
645
646 pub reserve_collateral_mint: &'b solana_account_info::AccountInfo<'a>,
647
648
649 pub reserve_destination_deposit_collateral: &'b solana_account_info::AccountInfo<'a>,
650 }
651
652impl<'a, 'b> CreateKaminoUserAccountsCpi<'a, 'b> {
653 pub fn new(
654 program: &'b solana_account_info::AccountInfo<'a>,
655 accounts: CreateKaminoUserAccountsCpiAccounts<'a, 'b>,
656 ) -> Self {
657 Self {
658 __program: program,
659 main: accounts.main,
660 controller: accounts.controller,
661 admin: accounts.admin,
662 admin_permissions: accounts.admin_permissions,
663 instruction_sysvar_account: accounts.instruction_sysvar_account,
664 rent: accounts.rent,
665 system_program: accounts.system_program,
666 user_metadata: accounts.user_metadata,
667 obligation: accounts.obligation,
668 lending_market: accounts.lending_market,
669 lending_market_authority: accounts.lending_market_authority,
670 reserve: accounts.reserve,
671 obligation_farm_state: accounts.obligation_farm_state,
672 reserve_farm_state: accounts.reserve_farm_state,
673 klend_program: accounts.klend_program,
674 farms_program: accounts.farms_program,
675 earn_mint: accounts.earn_mint,
676 controller_token_account: accounts.controller_token_account,
677 user_usdc_account: accounts.user_usdc_account,
678 reserve_collateral: accounts.reserve_collateral,
679 scope_oracle: accounts.scope_oracle,
680 token_program: accounts.token_program,
681 reserve_liquidity_supply: accounts.reserve_liquidity_supply,
682 reserve_collateral_mint: accounts.reserve_collateral_mint,
683 reserve_destination_deposit_collateral: accounts.reserve_destination_deposit_collateral,
684 }
685 }
686 #[inline(always)]
687 pub fn invoke(&self) -> solana_program_error::ProgramResult {
688 self.invoke_signed_with_remaining_accounts(&[], &[])
689 }
690 #[inline(always)]
691 pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
692 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
693 }
694 #[inline(always)]
695 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
696 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
697 }
698 #[allow(clippy::arithmetic_side_effects)]
699 #[allow(clippy::clone_on_copy)]
700 #[allow(clippy::vec_init_then_push)]
701 pub fn invoke_signed_with_remaining_accounts(
702 &self,
703 signers_seeds: &[&[&[u8]]],
704 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
705 ) -> solana_program_error::ProgramResult {
706 let mut accounts = Vec::with_capacity(25+ remaining_accounts.len());
707 accounts.push(solana_instruction::AccountMeta::new(
708 *self.main.key,
709 false
710 ));
711 accounts.push(solana_instruction::AccountMeta::new(
712 *self.controller.key,
713 false
714 ));
715 accounts.push(solana_instruction::AccountMeta::new(
716 *self.admin.key,
717 true
718 ));
719 accounts.push(solana_instruction::AccountMeta::new_readonly(
720 *self.admin_permissions.key,
721 false
722 ));
723 accounts.push(solana_instruction::AccountMeta::new_readonly(
724 *self.instruction_sysvar_account.key,
725 false
726 ));
727 accounts.push(solana_instruction::AccountMeta::new_readonly(
728 *self.rent.key,
729 false
730 ));
731 accounts.push(solana_instruction::AccountMeta::new_readonly(
732 *self.system_program.key,
733 false
734 ));
735 accounts.push(solana_instruction::AccountMeta::new(
736 *self.user_metadata.key,
737 false
738 ));
739 accounts.push(solana_instruction::AccountMeta::new(
740 *self.obligation.key,
741 false
742 ));
743 accounts.push(solana_instruction::AccountMeta::new_readonly(
744 *self.lending_market.key,
745 false
746 ));
747 accounts.push(solana_instruction::AccountMeta::new_readonly(
748 *self.lending_market_authority.key,
749 false
750 ));
751 accounts.push(solana_instruction::AccountMeta::new(
752 *self.reserve.key,
753 false
754 ));
755 accounts.push(solana_instruction::AccountMeta::new(
756 *self.obligation_farm_state.key,
757 false
758 ));
759 accounts.push(solana_instruction::AccountMeta::new(
760 *self.reserve_farm_state.key,
761 false
762 ));
763 accounts.push(solana_instruction::AccountMeta::new_readonly(
764 *self.klend_program.key,
765 false
766 ));
767 accounts.push(solana_instruction::AccountMeta::new_readonly(
768 *self.farms_program.key,
769 false
770 ));
771 accounts.push(solana_instruction::AccountMeta::new_readonly(
772 *self.earn_mint.key,
773 false
774 ));
775 accounts.push(solana_instruction::AccountMeta::new(
776 *self.controller_token_account.key,
777 false
778 ));
779 accounts.push(solana_instruction::AccountMeta::new(
780 *self.user_usdc_account.key,
781 false
782 ));
783 accounts.push(solana_instruction::AccountMeta::new_readonly(
784 *self.reserve_collateral.key,
785 false
786 ));
787 accounts.push(solana_instruction::AccountMeta::new_readonly(
788 *self.scope_oracle.key,
789 false
790 ));
791 accounts.push(solana_instruction::AccountMeta::new_readonly(
792 *self.token_program.key,
793 false
794 ));
795 accounts.push(solana_instruction::AccountMeta::new(
796 *self.reserve_liquidity_supply.key,
797 false
798 ));
799 accounts.push(solana_instruction::AccountMeta::new(
800 *self.reserve_collateral_mint.key,
801 false
802 ));
803 accounts.push(solana_instruction::AccountMeta::new(
804 *self.reserve_destination_deposit_collateral.key,
805 false
806 ));
807 remaining_accounts.iter().for_each(|remaining_account| {
808 accounts.push(solana_instruction::AccountMeta {
809 pubkey: *remaining_account.0.key,
810 is_signer: remaining_account.1,
811 is_writable: remaining_account.2,
812 })
813 });
814 let data = CreateKaminoUserAccountsInstructionData::new().try_to_vec().unwrap();
815
816 let instruction = solana_instruction::Instruction {
817 program_id: crate::REFLECT_MAIN_ID,
818 accounts,
819 data,
820 };
821 let mut account_infos = Vec::with_capacity(26 + remaining_accounts.len());
822 account_infos.push(self.__program.clone());
823 account_infos.push(self.main.clone());
824 account_infos.push(self.controller.clone());
825 account_infos.push(self.admin.clone());
826 account_infos.push(self.admin_permissions.clone());
827 account_infos.push(self.instruction_sysvar_account.clone());
828 account_infos.push(self.rent.clone());
829 account_infos.push(self.system_program.clone());
830 account_infos.push(self.user_metadata.clone());
831 account_infos.push(self.obligation.clone());
832 account_infos.push(self.lending_market.clone());
833 account_infos.push(self.lending_market_authority.clone());
834 account_infos.push(self.reserve.clone());
835 account_infos.push(self.obligation_farm_state.clone());
836 account_infos.push(self.reserve_farm_state.clone());
837 account_infos.push(self.klend_program.clone());
838 account_infos.push(self.farms_program.clone());
839 account_infos.push(self.earn_mint.clone());
840 account_infos.push(self.controller_token_account.clone());
841 account_infos.push(self.user_usdc_account.clone());
842 account_infos.push(self.reserve_collateral.clone());
843 account_infos.push(self.scope_oracle.clone());
844 account_infos.push(self.token_program.clone());
845 account_infos.push(self.reserve_liquidity_supply.clone());
846 account_infos.push(self.reserve_collateral_mint.clone());
847 account_infos.push(self.reserve_destination_deposit_collateral.clone());
848 remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
849
850 if signers_seeds.is_empty() {
851 solana_cpi::invoke(&instruction, &account_infos)
852 } else {
853 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
854 }
855 }
856}
857
858#[derive(Clone, Debug)]
888pub struct CreateKaminoUserAccountsCpiBuilder<'a, 'b> {
889 instruction: Box<CreateKaminoUserAccountsCpiBuilderInstruction<'a, 'b>>,
890}
891
892impl<'a, 'b> CreateKaminoUserAccountsCpiBuilder<'a, 'b> {
893 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
894 let instruction = Box::new(CreateKaminoUserAccountsCpiBuilderInstruction {
895 __program: program,
896 main: None,
897 controller: None,
898 admin: None,
899 admin_permissions: None,
900 instruction_sysvar_account: None,
901 rent: None,
902 system_program: None,
903 user_metadata: None,
904 obligation: None,
905 lending_market: None,
906 lending_market_authority: None,
907 reserve: None,
908 obligation_farm_state: None,
909 reserve_farm_state: None,
910 klend_program: None,
911 farms_program: None,
912 earn_mint: None,
913 controller_token_account: None,
914 user_usdc_account: None,
915 reserve_collateral: None,
916 scope_oracle: None,
917 token_program: None,
918 reserve_liquidity_supply: None,
919 reserve_collateral_mint: None,
920 reserve_destination_deposit_collateral: None,
921 __remaining_accounts: Vec::new(),
922 });
923 Self { instruction }
924 }
925 #[inline(always)]
926 pub fn main(&mut self, main: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
927 self.instruction.main = Some(main);
928 self
929 }
930 #[inline(always)]
931 pub fn controller(&mut self, controller: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
932 self.instruction.controller = Some(controller);
933 self
934 }
935 #[inline(always)]
936 pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
937 self.instruction.admin = Some(admin);
938 self
939 }
940 #[inline(always)]
941 pub fn admin_permissions(&mut self, admin_permissions: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
942 self.instruction.admin_permissions = Some(admin_permissions);
943 self
944 }
945 #[inline(always)]
946 pub fn instruction_sysvar_account(&mut self, instruction_sysvar_account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
947 self.instruction.instruction_sysvar_account = Some(instruction_sysvar_account);
948 self
949 }
950 #[inline(always)]
951 pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
952 self.instruction.rent = Some(rent);
953 self
954 }
955 #[inline(always)]
956 pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
957 self.instruction.system_program = Some(system_program);
958 self
959 }
960 #[inline(always)]
962 pub fn user_metadata(&mut self, user_metadata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
963 self.instruction.user_metadata = Some(user_metadata);
964 self
965 }
966 #[inline(always)]
967 pub fn obligation(&mut self, obligation: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
968 self.instruction.obligation = Some(obligation);
969 self
970 }
971 #[inline(always)]
972 pub fn lending_market(&mut self, lending_market: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
973 self.instruction.lending_market = Some(lending_market);
974 self
975 }
976 #[inline(always)]
977 pub fn lending_market_authority(&mut self, lending_market_authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
978 self.instruction.lending_market_authority = Some(lending_market_authority);
979 self
980 }
981 #[inline(always)]
982 pub fn reserve(&mut self, reserve: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
983 self.instruction.reserve = Some(reserve);
984 self
985 }
986 #[inline(always)]
987 pub fn obligation_farm_state(&mut self, obligation_farm_state: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
988 self.instruction.obligation_farm_state = Some(obligation_farm_state);
989 self
990 }
991 #[inline(always)]
992 pub fn reserve_farm_state(&mut self, reserve_farm_state: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
993 self.instruction.reserve_farm_state = Some(reserve_farm_state);
994 self
995 }
996 #[inline(always)]
997 pub fn klend_program(&mut self, klend_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
998 self.instruction.klend_program = Some(klend_program);
999 self
1000 }
1001 #[inline(always)]
1002 pub fn farms_program(&mut self, farms_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
1003 self.instruction.farms_program = Some(farms_program);
1004 self
1005 }
1006 #[inline(always)]
1008 pub fn earn_mint(&mut self, earn_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
1009 self.instruction.earn_mint = Some(earn_mint);
1010 self
1011 }
1012 #[inline(always)]
1013 pub fn controller_token_account(&mut self, controller_token_account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
1014 self.instruction.controller_token_account = Some(controller_token_account);
1015 self
1016 }
1017 #[inline(always)]
1018 pub fn user_usdc_account(&mut self, user_usdc_account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
1019 self.instruction.user_usdc_account = Some(user_usdc_account);
1020 self
1021 }
1022 #[inline(always)]
1023 pub fn reserve_collateral(&mut self, reserve_collateral: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
1024 self.instruction.reserve_collateral = Some(reserve_collateral);
1025 self
1026 }
1027 #[inline(always)]
1028 pub fn scope_oracle(&mut self, scope_oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
1029 self.instruction.scope_oracle = Some(scope_oracle);
1030 self
1031 }
1032 #[inline(always)]
1033 pub fn token_program(&mut self, token_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
1034 self.instruction.token_program = Some(token_program);
1035 self
1036 }
1037 #[inline(always)]
1038 pub fn reserve_liquidity_supply(&mut self, reserve_liquidity_supply: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
1039 self.instruction.reserve_liquidity_supply = Some(reserve_liquidity_supply);
1040 self
1041 }
1042 #[inline(always)]
1043 pub fn reserve_collateral_mint(&mut self, reserve_collateral_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
1044 self.instruction.reserve_collateral_mint = Some(reserve_collateral_mint);
1045 self
1046 }
1047 #[inline(always)]
1048 pub fn reserve_destination_deposit_collateral(&mut self, reserve_destination_deposit_collateral: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
1049 self.instruction.reserve_destination_deposit_collateral = Some(reserve_destination_deposit_collateral);
1050 self
1051 }
1052 #[inline(always)]
1054 pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
1055 self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
1056 self
1057 }
1058 #[inline(always)]
1063 pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
1064 self.instruction.__remaining_accounts.extend_from_slice(accounts);
1065 self
1066 }
1067 #[inline(always)]
1068 pub fn invoke(&self) -> solana_program_error::ProgramResult {
1069 self.invoke_signed(&[])
1070 }
1071 #[allow(clippy::clone_on_copy)]
1072 #[allow(clippy::vec_init_then_push)]
1073 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
1074 let instruction = CreateKaminoUserAccountsCpi {
1075 __program: self.instruction.__program,
1076
1077 main: self.instruction.main.expect("main is not set"),
1078
1079 controller: self.instruction.controller.expect("controller is not set"),
1080
1081 admin: self.instruction.admin.expect("admin is not set"),
1082
1083 admin_permissions: self.instruction.admin_permissions.expect("admin_permissions is not set"),
1084
1085 instruction_sysvar_account: self.instruction.instruction_sysvar_account.expect("instruction_sysvar_account is not set"),
1086
1087 rent: self.instruction.rent.expect("rent is not set"),
1088
1089 system_program: self.instruction.system_program.expect("system_program is not set"),
1090
1091 user_metadata: self.instruction.user_metadata.expect("user_metadata is not set"),
1092
1093 obligation: self.instruction.obligation.expect("obligation is not set"),
1094
1095 lending_market: self.instruction.lending_market.expect("lending_market is not set"),
1096
1097 lending_market_authority: self.instruction.lending_market_authority.expect("lending_market_authority is not set"),
1098
1099 reserve: self.instruction.reserve.expect("reserve is not set"),
1100
1101 obligation_farm_state: self.instruction.obligation_farm_state.expect("obligation_farm_state is not set"),
1102
1103 reserve_farm_state: self.instruction.reserve_farm_state.expect("reserve_farm_state is not set"),
1104
1105 klend_program: self.instruction.klend_program.expect("klend_program is not set"),
1106
1107 farms_program: self.instruction.farms_program.expect("farms_program is not set"),
1108
1109 earn_mint: self.instruction.earn_mint.expect("earn_mint is not set"),
1110
1111 controller_token_account: self.instruction.controller_token_account.expect("controller_token_account is not set"),
1112
1113 user_usdc_account: self.instruction.user_usdc_account.expect("user_usdc_account is not set"),
1114
1115 reserve_collateral: self.instruction.reserve_collateral.expect("reserve_collateral is not set"),
1116
1117 scope_oracle: self.instruction.scope_oracle.expect("scope_oracle is not set"),
1118
1119 token_program: self.instruction.token_program.expect("token_program is not set"),
1120
1121 reserve_liquidity_supply: self.instruction.reserve_liquidity_supply.expect("reserve_liquidity_supply is not set"),
1122
1123 reserve_collateral_mint: self.instruction.reserve_collateral_mint.expect("reserve_collateral_mint is not set"),
1124
1125 reserve_destination_deposit_collateral: self.instruction.reserve_destination_deposit_collateral.expect("reserve_destination_deposit_collateral is not set"),
1126 };
1127 instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
1128 }
1129}
1130
1131#[derive(Clone, Debug)]
1132struct CreateKaminoUserAccountsCpiBuilderInstruction<'a, 'b> {
1133 __program: &'b solana_account_info::AccountInfo<'a>,
1134 main: Option<&'b solana_account_info::AccountInfo<'a>>,
1135 controller: Option<&'b solana_account_info::AccountInfo<'a>>,
1136 admin: Option<&'b solana_account_info::AccountInfo<'a>>,
1137 admin_permissions: Option<&'b solana_account_info::AccountInfo<'a>>,
1138 instruction_sysvar_account: Option<&'b solana_account_info::AccountInfo<'a>>,
1139 rent: Option<&'b solana_account_info::AccountInfo<'a>>,
1140 system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
1141 user_metadata: Option<&'b solana_account_info::AccountInfo<'a>>,
1142 obligation: Option<&'b solana_account_info::AccountInfo<'a>>,
1143 lending_market: Option<&'b solana_account_info::AccountInfo<'a>>,
1144 lending_market_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
1145 reserve: Option<&'b solana_account_info::AccountInfo<'a>>,
1146 obligation_farm_state: Option<&'b solana_account_info::AccountInfo<'a>>,
1147 reserve_farm_state: Option<&'b solana_account_info::AccountInfo<'a>>,
1148 klend_program: Option<&'b solana_account_info::AccountInfo<'a>>,
1149 farms_program: Option<&'b solana_account_info::AccountInfo<'a>>,
1150 earn_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
1151 controller_token_account: Option<&'b solana_account_info::AccountInfo<'a>>,
1152 user_usdc_account: Option<&'b solana_account_info::AccountInfo<'a>>,
1153 reserve_collateral: Option<&'b solana_account_info::AccountInfo<'a>>,
1154 scope_oracle: Option<&'b solana_account_info::AccountInfo<'a>>,
1155 token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
1156 reserve_liquidity_supply: Option<&'b solana_account_info::AccountInfo<'a>>,
1157 reserve_collateral_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
1158 reserve_destination_deposit_collateral: Option<&'b solana_account_info::AccountInfo<'a>>,
1159 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
1161}
1162