Skip to main content

satrush_client/generated/instructions/
distribute_epoch_reward.rs

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