Skip to main content

satrush_client/generated/instructions/
create_public_automation.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 crate::generated::types::AutomationStrategy;
9use borsh::BorshSerialize;
10use borsh::BorshDeserialize;
11
12pub const CREATE_PUBLIC_AUTOMATION_DISCRIMINATOR: [u8; 8] = [195, 44, 245, 180, 58, 206, 203, 229];
13
14/// Accounts.
15#[derive(Debug)]
16pub struct CreatePublicAutomation {
17      
18              
19          pub authority: solana_address::Address,
20          
21              
22          pub satrush_config: solana_address::Address,
23                /// One automation per authority: `init` fails if one already exists.
24
25    
26              
27          pub public_automation: solana_address::Address,
28          
29              
30          pub usd_mint: solana_address::Address,
31                /// wallet automations, the miner PDA's for grubstake ones. The token
32/// program enforces that the transfer's signer owns it, and
33/// `transfer_checked` pins the mint.
34
35    
36              
37          pub authority_usd_ata: solana_address::Address,
38                /// The automation's escrow, created here. `init_if_needed` rather than
39/// `init`: the ATA address is derived from the automation PDA/USD mint
40/// alone, so anyone can pre-create it before this instruction runs; with
41/// plain `init` that pre-creation would permanently block this authority
42/// from ever creating their automation. A pre-existing balance is treated
43/// as a donation — it is swept out by `cancel`.
44
45    
46              
47          pub automation_usd_ata: solana_address::Address,
48                /// Miner profile for `authority`, created here if missing (user pays rent)
49/// so the crank-side execute never has to create it.
50
51    
52              
53          pub miner: solana_address::Address,
54                /// The affiliate a freshly created miner binds to. Optional; validated
55/// against the miner's bound tag when present. No accrual here — the
56/// deposit is not a deploy; volume accrues at execution.
57
58    
59              
60          pub affiliate: Option<solana_address::Address>,
61          
62              
63          pub token_program: solana_address::Address,
64          
65              
66          pub associated_token_program: solana_address::Address,
67          
68              
69          pub system_program: solana_address::Address,
70      }
71
72impl CreatePublicAutomation {
73  pub fn instruction(&self, args: CreatePublicAutomationInstructionArgs) -> solana_instruction::Instruction {
74    self.instruction_with_remaining_accounts(args, &[])
75  }
76  #[allow(clippy::arithmetic_side_effects)]
77  #[allow(clippy::vec_init_then_push)]
78  pub fn instruction_with_remaining_accounts(&self, args: CreatePublicAutomationInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
79    let mut accounts = Vec::with_capacity(11+ remaining_accounts.len());
80                            accounts.push(solana_instruction::AccountMeta::new(
81            self.authority,
82            true
83          ));
84                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
85            self.satrush_config,
86            false
87          ));
88                                          accounts.push(solana_instruction::AccountMeta::new(
89            self.public_automation,
90            false
91          ));
92                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
93            self.usd_mint,
94            false
95          ));
96                                          accounts.push(solana_instruction::AccountMeta::new(
97            self.authority_usd_ata,
98            false
99          ));
100                                          accounts.push(solana_instruction::AccountMeta::new(
101            self.automation_usd_ata,
102            false
103          ));
104                                          accounts.push(solana_instruction::AccountMeta::new(
105            self.miner,
106            false
107          ));
108                                                      if let Some(affiliate) = self.affiliate {
109              accounts.push(solana_instruction::AccountMeta::new_readonly(
110                affiliate,
111                false,
112              ));
113            } else {
114              accounts.push(solana_instruction::AccountMeta::new_readonly(
115                crate::SATRUSH_ID,
116                false,
117              ));
118            }
119                                                    accounts.push(solana_instruction::AccountMeta::new_readonly(
120            self.token_program,
121            false
122          ));
123                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
124            self.associated_token_program,
125            false
126          ));
127                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
128            self.system_program,
129            false
130          ));
131                      accounts.extend_from_slice(remaining_accounts);
132    let mut data = CreatePublicAutomationInstructionData::new().try_to_vec().unwrap();
133          let mut args = args.try_to_vec().unwrap();
134      data.append(&mut args);
135    
136    solana_instruction::Instruction {
137      program_id: crate::SATRUSH_ID,
138      accounts,
139      data,
140    }
141  }
142}
143
144#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
145 pub struct CreatePublicAutomationInstructionData {
146            discriminator: [u8; 8],
147                                          }
148
149impl CreatePublicAutomationInstructionData {
150  pub fn new() -> Self {
151    Self {
152                        discriminator: [195, 44, 245, 180, 58, 206, 203, 229],
153                                                                                                      }
154  }
155
156    pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
157    borsh::to_vec(self)
158  }
159  }
160
161impl Default for CreatePublicAutomationInstructionData {
162  fn default() -> Self {
163    Self::new()
164  }
165}
166
167#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
168 pub struct CreatePublicAutomationInstructionArgs {
169                  pub strategy: AutomationStrategy,
170                pub selection_mask: u32,
171                pub per_round_usd_amount: u64,
172                pub reload: bool,
173                pub deposit_usd_amount: u64,
174                pub is_grubstake_funded: bool,
175      }
176
177impl CreatePublicAutomationInstructionArgs {
178  pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
179    borsh::to_vec(self)
180  }
181}
182
183
184/// Instruction builder for `CreatePublicAutomation`.
185///
186/// ### Accounts:
187///
188                      ///   0. `[writable, signer]` authority
189          ///   1. `[]` satrush_config
190                ///   2. `[writable]` public_automation
191          ///   3. `[]` usd_mint
192                ///   4. `[writable]` authority_usd_ata
193                ///   5. `[writable]` automation_usd_ata
194                ///   6. `[writable]` miner
195                ///   7. `[optional]` affiliate
196                ///   8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`)
197                ///   9. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`)
198                ///   10. `[optional]` system_program (default to `11111111111111111111111111111111`)
199#[derive(Clone, Debug, Default)]
200pub struct CreatePublicAutomationBuilder {
201            authority: Option<solana_address::Address>,
202                satrush_config: Option<solana_address::Address>,
203                public_automation: Option<solana_address::Address>,
204                usd_mint: Option<solana_address::Address>,
205                authority_usd_ata: Option<solana_address::Address>,
206                automation_usd_ata: Option<solana_address::Address>,
207                miner: Option<solana_address::Address>,
208                affiliate: Option<solana_address::Address>,
209                token_program: Option<solana_address::Address>,
210                associated_token_program: Option<solana_address::Address>,
211                system_program: Option<solana_address::Address>,
212                        strategy: Option<AutomationStrategy>,
213                selection_mask: Option<u32>,
214                per_round_usd_amount: Option<u64>,
215                reload: Option<bool>,
216                deposit_usd_amount: Option<u64>,
217                is_grubstake_funded: Option<bool>,
218        __remaining_accounts: Vec<solana_instruction::AccountMeta>,
219}
220
221impl CreatePublicAutomationBuilder {
222  pub fn new() -> Self {
223    Self::default()
224  }
225            #[inline(always)]
226    pub fn authority(&mut self, authority: solana_address::Address) -> &mut Self {
227                        self.authority = Some(authority);
228                    self
229    }
230            #[inline(always)]
231    pub fn satrush_config(&mut self, satrush_config: solana_address::Address) -> &mut Self {
232                        self.satrush_config = Some(satrush_config);
233                    self
234    }
235            /// One automation per authority: `init` fails if one already exists.
236#[inline(always)]
237    pub fn public_automation(&mut self, public_automation: solana_address::Address) -> &mut Self {
238                        self.public_automation = Some(public_automation);
239                    self
240    }
241            #[inline(always)]
242    pub fn usd_mint(&mut self, usd_mint: solana_address::Address) -> &mut Self {
243                        self.usd_mint = Some(usd_mint);
244                    self
245    }
246            /// wallet automations, the miner PDA's for grubstake ones. The token
247/// program enforces that the transfer's signer owns it, and
248/// `transfer_checked` pins the mint.
249#[inline(always)]
250    pub fn authority_usd_ata(&mut self, authority_usd_ata: solana_address::Address) -> &mut Self {
251                        self.authority_usd_ata = Some(authority_usd_ata);
252                    self
253    }
254            /// The automation's escrow, created here. `init_if_needed` rather than
255/// `init`: the ATA address is derived from the automation PDA/USD mint
256/// alone, so anyone can pre-create it before this instruction runs; with
257/// plain `init` that pre-creation would permanently block this authority
258/// from ever creating their automation. A pre-existing balance is treated
259/// as a donation — it is swept out by `cancel`.
260#[inline(always)]
261    pub fn automation_usd_ata(&mut self, automation_usd_ata: solana_address::Address) -> &mut Self {
262                        self.automation_usd_ata = Some(automation_usd_ata);
263                    self
264    }
265            /// Miner profile for `authority`, created here if missing (user pays rent)
266/// so the crank-side execute never has to create it.
267#[inline(always)]
268    pub fn miner(&mut self, miner: solana_address::Address) -> &mut Self {
269                        self.miner = Some(miner);
270                    self
271    }
272            /// `[optional account]`
273/// The affiliate a freshly created miner binds to. Optional; validated
274/// against the miner's bound tag when present. No accrual here — the
275/// deposit is not a deploy; volume accrues at execution.
276#[inline(always)]
277    pub fn affiliate(&mut self, affiliate: Option<solana_address::Address>) -> &mut Self {
278                        self.affiliate = affiliate;
279                    self
280    }
281            /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']`
282#[inline(always)]
283    pub fn token_program(&mut self, token_program: solana_address::Address) -> &mut Self {
284                        self.token_program = Some(token_program);
285                    self
286    }
287            /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']`
288#[inline(always)]
289    pub fn associated_token_program(&mut self, associated_token_program: solana_address::Address) -> &mut Self {
290                        self.associated_token_program = Some(associated_token_program);
291                    self
292    }
293            /// `[optional account, default to '11111111111111111111111111111111']`
294#[inline(always)]
295    pub fn system_program(&mut self, system_program: solana_address::Address) -> &mut Self {
296                        self.system_program = Some(system_program);
297                    self
298    }
299                    #[inline(always)]
300      pub fn strategy(&mut self, strategy: AutomationStrategy) -> &mut Self {
301        self.strategy = Some(strategy);
302        self
303      }
304                #[inline(always)]
305      pub fn selection_mask(&mut self, selection_mask: u32) -> &mut Self {
306        self.selection_mask = Some(selection_mask);
307        self
308      }
309                #[inline(always)]
310      pub fn per_round_usd_amount(&mut self, per_round_usd_amount: u64) -> &mut Self {
311        self.per_round_usd_amount = Some(per_round_usd_amount);
312        self
313      }
314                #[inline(always)]
315      pub fn reload(&mut self, reload: bool) -> &mut Self {
316        self.reload = Some(reload);
317        self
318      }
319                #[inline(always)]
320      pub fn deposit_usd_amount(&mut self, deposit_usd_amount: u64) -> &mut Self {
321        self.deposit_usd_amount = Some(deposit_usd_amount);
322        self
323      }
324                #[inline(always)]
325      pub fn is_grubstake_funded(&mut self, is_grubstake_funded: bool) -> &mut Self {
326        self.is_grubstake_funded = Some(is_grubstake_funded);
327        self
328      }
329        /// Add an additional account to the instruction.
330  #[inline(always)]
331  pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
332    self.__remaining_accounts.push(account);
333    self
334  }
335  /// Add additional accounts to the instruction.
336  #[inline(always)]
337  pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
338    self.__remaining_accounts.extend_from_slice(accounts);
339    self
340  }
341  #[allow(clippy::clone_on_copy)]
342  pub fn instruction(&self) -> solana_instruction::Instruction {
343    let accounts = CreatePublicAutomation {
344                              authority: self.authority.expect("authority is not set"),
345                                        satrush_config: self.satrush_config.expect("satrush_config is not set"),
346                                        public_automation: self.public_automation.expect("public_automation is not set"),
347                                        usd_mint: self.usd_mint.expect("usd_mint is not set"),
348                                        authority_usd_ata: self.authority_usd_ata.expect("authority_usd_ata is not set"),
349                                        automation_usd_ata: self.automation_usd_ata.expect("automation_usd_ata is not set"),
350                                        miner: self.miner.expect("miner is not set"),
351                                        affiliate: self.affiliate,
352                                        token_program: self.token_program.unwrap_or(solana_address::address!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")),
353                                        associated_token_program: self.associated_token_program.unwrap_or(solana_address::address!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")),
354                                        system_program: self.system_program.unwrap_or(solana_address::address!("11111111111111111111111111111111")),
355                      };
356          let args = CreatePublicAutomationInstructionArgs {
357                                                              strategy: self.strategy.clone().expect("strategy is not set"),
358                                                                  selection_mask: self.selection_mask.clone().expect("selection_mask is not set"),
359                                                                  per_round_usd_amount: self.per_round_usd_amount.clone().expect("per_round_usd_amount is not set"),
360                                                                  reload: self.reload.clone().expect("reload is not set"),
361                                                                  deposit_usd_amount: self.deposit_usd_amount.clone().expect("deposit_usd_amount is not set"),
362                                                                  is_grubstake_funded: self.is_grubstake_funded.clone().expect("is_grubstake_funded is not set"),
363                                    };
364    
365    accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
366  }
367}
368
369  /// `create_public_automation` CPI accounts.
370  pub struct CreatePublicAutomationCpiAccounts<'a, 'b> {
371          
372                    
373              pub authority: &'b solana_account_info::AccountInfo<'a>,
374                
375                    
376              pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
377                        /// One automation per authority: `init` fails if one already exists.
378
379      
380                    
381              pub public_automation: &'b solana_account_info::AccountInfo<'a>,
382                
383                    
384              pub usd_mint: &'b solana_account_info::AccountInfo<'a>,
385                        /// wallet automations, the miner PDA's for grubstake ones. The token
386/// program enforces that the transfer's signer owns it, and
387/// `transfer_checked` pins the mint.
388
389      
390                    
391              pub authority_usd_ata: &'b solana_account_info::AccountInfo<'a>,
392                        /// The automation's escrow, created here. `init_if_needed` rather than
393/// `init`: the ATA address is derived from the automation PDA/USD mint
394/// alone, so anyone can pre-create it before this instruction runs; with
395/// plain `init` that pre-creation would permanently block this authority
396/// from ever creating their automation. A pre-existing balance is treated
397/// as a donation — it is swept out by `cancel`.
398
399      
400                    
401              pub automation_usd_ata: &'b solana_account_info::AccountInfo<'a>,
402                        /// Miner profile for `authority`, created here if missing (user pays rent)
403/// so the crank-side execute never has to create it.
404
405      
406                    
407              pub miner: &'b solana_account_info::AccountInfo<'a>,
408                        /// The affiliate a freshly created miner binds to. Optional; validated
409/// against the miner's bound tag when present. No accrual here — the
410/// deposit is not a deploy; volume accrues at execution.
411
412      
413                    
414              pub affiliate: Option<&'b solana_account_info::AccountInfo<'a>>,
415                
416                    
417              pub token_program: &'b solana_account_info::AccountInfo<'a>,
418                
419                    
420              pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,
421                
422                    
423              pub system_program: &'b solana_account_info::AccountInfo<'a>,
424            }
425
426/// `create_public_automation` CPI instruction.
427pub struct CreatePublicAutomationCpi<'a, 'b> {
428  /// The program to invoke.
429  pub __program: &'b solana_account_info::AccountInfo<'a>,
430      
431              
432          pub authority: &'b solana_account_info::AccountInfo<'a>,
433          
434              
435          pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
436                /// One automation per authority: `init` fails if one already exists.
437
438    
439              
440          pub public_automation: &'b solana_account_info::AccountInfo<'a>,
441          
442              
443          pub usd_mint: &'b solana_account_info::AccountInfo<'a>,
444                /// wallet automations, the miner PDA's for grubstake ones. The token
445/// program enforces that the transfer's signer owns it, and
446/// `transfer_checked` pins the mint.
447
448    
449              
450          pub authority_usd_ata: &'b solana_account_info::AccountInfo<'a>,
451                /// The automation's escrow, created here. `init_if_needed` rather than
452/// `init`: the ATA address is derived from the automation PDA/USD mint
453/// alone, so anyone can pre-create it before this instruction runs; with
454/// plain `init` that pre-creation would permanently block this authority
455/// from ever creating their automation. A pre-existing balance is treated
456/// as a donation — it is swept out by `cancel`.
457
458    
459              
460          pub automation_usd_ata: &'b solana_account_info::AccountInfo<'a>,
461                /// Miner profile for `authority`, created here if missing (user pays rent)
462/// so the crank-side execute never has to create it.
463
464    
465              
466          pub miner: &'b solana_account_info::AccountInfo<'a>,
467                /// The affiliate a freshly created miner binds to. Optional; validated
468/// against the miner's bound tag when present. No accrual here — the
469/// deposit is not a deploy; volume accrues at execution.
470
471    
472              
473          pub affiliate: Option<&'b solana_account_info::AccountInfo<'a>>,
474          
475              
476          pub token_program: &'b solana_account_info::AccountInfo<'a>,
477          
478              
479          pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,
480          
481              
482          pub system_program: &'b solana_account_info::AccountInfo<'a>,
483            /// The arguments for the instruction.
484    pub __args: CreatePublicAutomationInstructionArgs,
485  }
486
487impl<'a, 'b> CreatePublicAutomationCpi<'a, 'b> {
488  pub fn new(
489    program: &'b solana_account_info::AccountInfo<'a>,
490          accounts: CreatePublicAutomationCpiAccounts<'a, 'b>,
491              args: CreatePublicAutomationInstructionArgs,
492      ) -> Self {
493    Self {
494      __program: program,
495              authority: accounts.authority,
496              satrush_config: accounts.satrush_config,
497              public_automation: accounts.public_automation,
498              usd_mint: accounts.usd_mint,
499              authority_usd_ata: accounts.authority_usd_ata,
500              automation_usd_ata: accounts.automation_usd_ata,
501              miner: accounts.miner,
502              affiliate: accounts.affiliate,
503              token_program: accounts.token_program,
504              associated_token_program: accounts.associated_token_program,
505              system_program: accounts.system_program,
506                    __args: args,
507          }
508  }
509  #[inline(always)]
510  pub fn invoke(&self) -> solana_program_error::ProgramResult {
511    self.invoke_signed_with_remaining_accounts(&[], &[])
512  }
513  #[inline(always)]
514  pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
515    self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
516  }
517  #[inline(always)]
518  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
519    self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
520  }
521  #[allow(clippy::arithmetic_side_effects)]
522  #[allow(clippy::clone_on_copy)]
523  #[allow(clippy::vec_init_then_push)]
524  pub fn invoke_signed_with_remaining_accounts(
525    &self,
526    signers_seeds: &[&[&[u8]]],
527    remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
528  ) -> solana_program_error::ProgramResult {
529    let mut accounts = Vec::with_capacity(11+ remaining_accounts.len());
530                            accounts.push(solana_instruction::AccountMeta::new(
531            *self.authority.key,
532            true
533          ));
534                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
535            *self.satrush_config.key,
536            false
537          ));
538                                          accounts.push(solana_instruction::AccountMeta::new(
539            *self.public_automation.key,
540            false
541          ));
542                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
543            *self.usd_mint.key,
544            false
545          ));
546                                          accounts.push(solana_instruction::AccountMeta::new(
547            *self.authority_usd_ata.key,
548            false
549          ));
550                                          accounts.push(solana_instruction::AccountMeta::new(
551            *self.automation_usd_ata.key,
552            false
553          ));
554                                          accounts.push(solana_instruction::AccountMeta::new(
555            *self.miner.key,
556            false
557          ));
558                                          if let Some(affiliate) = self.affiliate {
559            accounts.push(solana_instruction::AccountMeta::new_readonly(
560              *affiliate.key,
561              false,
562            ));
563          } else {
564            accounts.push(solana_instruction::AccountMeta::new_readonly(
565              crate::SATRUSH_ID,
566              false,
567            ));
568          }
569                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
570            *self.token_program.key,
571            false
572          ));
573                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
574            *self.associated_token_program.key,
575            false
576          ));
577                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
578            *self.system_program.key,
579            false
580          ));
581                      remaining_accounts.iter().for_each(|remaining_account| {
582      accounts.push(solana_instruction::AccountMeta {
583          pubkey: *remaining_account.0.key,
584          is_signer: remaining_account.1,
585          is_writable: remaining_account.2,
586      })
587    });
588    let mut data = CreatePublicAutomationInstructionData::new().try_to_vec().unwrap();
589          let mut args = self.__args.try_to_vec().unwrap();
590      data.append(&mut args);
591    
592    let instruction = solana_instruction::Instruction {
593      program_id: crate::SATRUSH_ID,
594      accounts,
595      data,
596    };
597    let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len());
598    account_infos.push(self.__program.clone());
599                  account_infos.push(self.authority.clone());
600                        account_infos.push(self.satrush_config.clone());
601                        account_infos.push(self.public_automation.clone());
602                        account_infos.push(self.usd_mint.clone());
603                        account_infos.push(self.authority_usd_ata.clone());
604                        account_infos.push(self.automation_usd_ata.clone());
605                        account_infos.push(self.miner.clone());
606                        if let Some(affiliate) = self.affiliate {
607          account_infos.push(affiliate.clone());
608        }
609                        account_infos.push(self.token_program.clone());
610                        account_infos.push(self.associated_token_program.clone());
611                        account_infos.push(self.system_program.clone());
612              remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
613
614    if signers_seeds.is_empty() {
615      solana_cpi::invoke(&instruction, &account_infos)
616    } else {
617      solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
618    }
619  }
620}
621
622/// Instruction builder for `CreatePublicAutomation` via CPI.
623///
624/// ### Accounts:
625///
626                      ///   0. `[writable, signer]` authority
627          ///   1. `[]` satrush_config
628                ///   2. `[writable]` public_automation
629          ///   3. `[]` usd_mint
630                ///   4. `[writable]` authority_usd_ata
631                ///   5. `[writable]` automation_usd_ata
632                ///   6. `[writable]` miner
633                ///   7. `[optional]` affiliate
634          ///   8. `[]` token_program
635          ///   9. `[]` associated_token_program
636          ///   10. `[]` system_program
637#[derive(Clone, Debug)]
638pub struct CreatePublicAutomationCpiBuilder<'a, 'b> {
639  instruction: Box<CreatePublicAutomationCpiBuilderInstruction<'a, 'b>>,
640}
641
642impl<'a, 'b> CreatePublicAutomationCpiBuilder<'a, 'b> {
643  pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
644    let instruction = Box::new(CreatePublicAutomationCpiBuilderInstruction {
645      __program: program,
646              authority: None,
647              satrush_config: None,
648              public_automation: None,
649              usd_mint: None,
650              authority_usd_ata: None,
651              automation_usd_ata: None,
652              miner: None,
653              affiliate: None,
654              token_program: None,
655              associated_token_program: None,
656              system_program: None,
657                                            strategy: None,
658                                selection_mask: None,
659                                per_round_usd_amount: None,
660                                reload: None,
661                                deposit_usd_amount: None,
662                                is_grubstake_funded: None,
663                    __remaining_accounts: Vec::new(),
664    });
665    Self { instruction }
666  }
667      #[inline(always)]
668    pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
669                        self.instruction.authority = Some(authority);
670                    self
671    }
672      #[inline(always)]
673    pub fn satrush_config(&mut self, satrush_config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
674                        self.instruction.satrush_config = Some(satrush_config);
675                    self
676    }
677      /// One automation per authority: `init` fails if one already exists.
678#[inline(always)]
679    pub fn public_automation(&mut self, public_automation: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
680                        self.instruction.public_automation = Some(public_automation);
681                    self
682    }
683      #[inline(always)]
684    pub fn usd_mint(&mut self, usd_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
685                        self.instruction.usd_mint = Some(usd_mint);
686                    self
687    }
688      /// wallet automations, the miner PDA's for grubstake ones. The token
689/// program enforces that the transfer's signer owns it, and
690/// `transfer_checked` pins the mint.
691#[inline(always)]
692    pub fn authority_usd_ata(&mut self, authority_usd_ata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
693                        self.instruction.authority_usd_ata = Some(authority_usd_ata);
694                    self
695    }
696      /// The automation's escrow, created here. `init_if_needed` rather than
697/// `init`: the ATA address is derived from the automation PDA/USD mint
698/// alone, so anyone can pre-create it before this instruction runs; with
699/// plain `init` that pre-creation would permanently block this authority
700/// from ever creating their automation. A pre-existing balance is treated
701/// as a donation — it is swept out by `cancel`.
702#[inline(always)]
703    pub fn automation_usd_ata(&mut self, automation_usd_ata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
704                        self.instruction.automation_usd_ata = Some(automation_usd_ata);
705                    self
706    }
707      /// Miner profile for `authority`, created here if missing (user pays rent)
708/// so the crank-side execute never has to create it.
709#[inline(always)]
710    pub fn miner(&mut self, miner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
711                        self.instruction.miner = Some(miner);
712                    self
713    }
714      /// `[optional account]`
715/// The affiliate a freshly created miner binds to. Optional; validated
716/// against the miner's bound tag when present. No accrual here — the
717/// deposit is not a deploy; volume accrues at execution.
718#[inline(always)]
719    pub fn affiliate(&mut self, affiliate: Option<&'b solana_account_info::AccountInfo<'a>>) -> &mut Self {
720                        self.instruction.affiliate = affiliate;
721                    self
722    }
723      #[inline(always)]
724    pub fn token_program(&mut self, token_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
725                        self.instruction.token_program = Some(token_program);
726                    self
727    }
728      #[inline(always)]
729    pub fn associated_token_program(&mut self, associated_token_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
730                        self.instruction.associated_token_program = Some(associated_token_program);
731                    self
732    }
733      #[inline(always)]
734    pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
735                        self.instruction.system_program = Some(system_program);
736                    self
737    }
738                    #[inline(always)]
739      pub fn strategy(&mut self, strategy: AutomationStrategy) -> &mut Self {
740        self.instruction.strategy = Some(strategy);
741        self
742      }
743                #[inline(always)]
744      pub fn selection_mask(&mut self, selection_mask: u32) -> &mut Self {
745        self.instruction.selection_mask = Some(selection_mask);
746        self
747      }
748                #[inline(always)]
749      pub fn per_round_usd_amount(&mut self, per_round_usd_amount: u64) -> &mut Self {
750        self.instruction.per_round_usd_amount = Some(per_round_usd_amount);
751        self
752      }
753                #[inline(always)]
754      pub fn reload(&mut self, reload: bool) -> &mut Self {
755        self.instruction.reload = Some(reload);
756        self
757      }
758                #[inline(always)]
759      pub fn deposit_usd_amount(&mut self, deposit_usd_amount: u64) -> &mut Self {
760        self.instruction.deposit_usd_amount = Some(deposit_usd_amount);
761        self
762      }
763                #[inline(always)]
764      pub fn is_grubstake_funded(&mut self, is_grubstake_funded: bool) -> &mut Self {
765        self.instruction.is_grubstake_funded = Some(is_grubstake_funded);
766        self
767      }
768        /// Add an additional account to the instruction.
769  #[inline(always)]
770  pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
771    self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
772    self
773  }
774  /// Add additional accounts to the instruction.
775  ///
776  /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
777  /// and a `bool` indicating whether the account is a signer or not.
778  #[inline(always)]
779  pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
780    self.instruction.__remaining_accounts.extend_from_slice(accounts);
781    self
782  }
783  #[inline(always)]
784  pub fn invoke(&self) -> solana_program_error::ProgramResult {
785    self.invoke_signed(&[])
786  }
787  #[allow(clippy::clone_on_copy)]
788  #[allow(clippy::vec_init_then_push)]
789  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
790          let args = CreatePublicAutomationInstructionArgs {
791                                                              strategy: self.instruction.strategy.clone().expect("strategy is not set"),
792                                                                  selection_mask: self.instruction.selection_mask.clone().expect("selection_mask is not set"),
793                                                                  per_round_usd_amount: self.instruction.per_round_usd_amount.clone().expect("per_round_usd_amount is not set"),
794                                                                  reload: self.instruction.reload.clone().expect("reload is not set"),
795                                                                  deposit_usd_amount: self.instruction.deposit_usd_amount.clone().expect("deposit_usd_amount is not set"),
796                                                                  is_grubstake_funded: self.instruction.is_grubstake_funded.clone().expect("is_grubstake_funded is not set"),
797                                    };
798        let instruction = CreatePublicAutomationCpi {
799        __program: self.instruction.__program,
800                  
801          authority: self.instruction.authority.expect("authority is not set"),
802                  
803          satrush_config: self.instruction.satrush_config.expect("satrush_config is not set"),
804                  
805          public_automation: self.instruction.public_automation.expect("public_automation is not set"),
806                  
807          usd_mint: self.instruction.usd_mint.expect("usd_mint is not set"),
808                  
809          authority_usd_ata: self.instruction.authority_usd_ata.expect("authority_usd_ata is not set"),
810                  
811          automation_usd_ata: self.instruction.automation_usd_ata.expect("automation_usd_ata is not set"),
812                  
813          miner: self.instruction.miner.expect("miner is not set"),
814                  
815          affiliate: self.instruction.affiliate,
816                  
817          token_program: self.instruction.token_program.expect("token_program is not set"),
818                  
819          associated_token_program: self.instruction.associated_token_program.expect("associated_token_program is not set"),
820                  
821          system_program: self.instruction.system_program.expect("system_program is not set"),
822                          __args: args,
823            };
824    instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
825  }
826}
827
828#[derive(Clone, Debug)]
829struct CreatePublicAutomationCpiBuilderInstruction<'a, 'b> {
830  __program: &'b solana_account_info::AccountInfo<'a>,
831            authority: Option<&'b solana_account_info::AccountInfo<'a>>,
832                satrush_config: Option<&'b solana_account_info::AccountInfo<'a>>,
833                public_automation: Option<&'b solana_account_info::AccountInfo<'a>>,
834                usd_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
835                authority_usd_ata: Option<&'b solana_account_info::AccountInfo<'a>>,
836                automation_usd_ata: Option<&'b solana_account_info::AccountInfo<'a>>,
837                miner: Option<&'b solana_account_info::AccountInfo<'a>>,
838                affiliate: Option<&'b solana_account_info::AccountInfo<'a>>,
839                token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
840                associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
841                system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
842                        strategy: Option<AutomationStrategy>,
843                selection_mask: Option<u32>,
844                per_round_usd_amount: Option<u64>,
845                reload: Option<bool>,
846                deposit_usd_amount: Option<u64>,
847                is_grubstake_funded: Option<bool>,
848        /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
849  __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
850}
851