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