1use borsh::{BorshDeserialize, BorshSerialize};
8
9use crate::generated::types::WithdrawalAllocationMethod;
10
11pub struct InitializeVaultUpdateStateTracker {
13 pub config: solana_program::pubkey::Pubkey,
14
15 pub vault: solana_program::pubkey::Pubkey,
16
17 pub vault_update_state_tracker: solana_program::pubkey::Pubkey,
18
19 pub payer: solana_program::pubkey::Pubkey,
20
21 pub system_program: solana_program::pubkey::Pubkey,
22}
23
24impl InitializeVaultUpdateStateTracker {
25 pub fn instruction(
26 &self,
27 args: InitializeVaultUpdateStateTrackerInstructionArgs,
28 ) -> solana_program::instruction::Instruction {
29 self.instruction_with_remaining_accounts(args, &[])
30 }
31 #[allow(clippy::vec_init_then_push)]
32 pub fn instruction_with_remaining_accounts(
33 &self,
34 args: InitializeVaultUpdateStateTrackerInstructionArgs,
35 remaining_accounts: &[solana_program::instruction::AccountMeta],
36 ) -> solana_program::instruction::Instruction {
37 let mut accounts = Vec::with_capacity(5 + remaining_accounts.len());
38 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
39 self.config,
40 false,
41 ));
42 accounts.push(solana_program::instruction::AccountMeta::new(
43 self.vault, false,
44 ));
45 accounts.push(solana_program::instruction::AccountMeta::new(
46 self.vault_update_state_tracker,
47 false,
48 ));
49 accounts.push(solana_program::instruction::AccountMeta::new(
50 self.payer, false,
51 ));
52 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
53 self.system_program,
54 false,
55 ));
56 accounts.extend_from_slice(remaining_accounts);
57 let mut data = InitializeVaultUpdateStateTrackerInstructionData::new()
58 .try_to_vec()
59 .unwrap();
60 let mut args = args.try_to_vec().unwrap();
61 data.append(&mut args);
62
63 solana_program::instruction::Instruction {
64 program_id: crate::JITO_VAULT_ID,
65 accounts,
66 data,
67 }
68 }
69}
70
71#[derive(BorshDeserialize, BorshSerialize)]
72pub struct InitializeVaultUpdateStateTrackerInstructionData {
73 discriminator: u8,
74}
75
76impl InitializeVaultUpdateStateTrackerInstructionData {
77 pub fn new() -> Self {
78 Self { discriminator: 26 }
79 }
80}
81
82impl Default for InitializeVaultUpdateStateTrackerInstructionData {
83 fn default() -> Self {
84 Self::new()
85 }
86}
87
88#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
89#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
90pub struct InitializeVaultUpdateStateTrackerInstructionArgs {
91 pub withdrawal_allocation_method: WithdrawalAllocationMethod,
92}
93
94#[derive(Clone, Debug, Default)]
104pub struct InitializeVaultUpdateStateTrackerBuilder {
105 config: Option<solana_program::pubkey::Pubkey>,
106 vault: Option<solana_program::pubkey::Pubkey>,
107 vault_update_state_tracker: Option<solana_program::pubkey::Pubkey>,
108 payer: Option<solana_program::pubkey::Pubkey>,
109 system_program: Option<solana_program::pubkey::Pubkey>,
110 withdrawal_allocation_method: Option<WithdrawalAllocationMethod>,
111 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
112}
113
114impl InitializeVaultUpdateStateTrackerBuilder {
115 pub fn new() -> Self {
116 Self::default()
117 }
118 #[inline(always)]
119 pub fn config(&mut self, config: solana_program::pubkey::Pubkey) -> &mut Self {
120 self.config = Some(config);
121 self
122 }
123 #[inline(always)]
124 pub fn vault(&mut self, vault: solana_program::pubkey::Pubkey) -> &mut Self {
125 self.vault = Some(vault);
126 self
127 }
128 #[inline(always)]
129 pub fn vault_update_state_tracker(
130 &mut self,
131 vault_update_state_tracker: solana_program::pubkey::Pubkey,
132 ) -> &mut Self {
133 self.vault_update_state_tracker = Some(vault_update_state_tracker);
134 self
135 }
136 #[inline(always)]
137 pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
138 self.payer = Some(payer);
139 self
140 }
141 #[inline(always)]
143 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
144 self.system_program = Some(system_program);
145 self
146 }
147 #[inline(always)]
148 pub fn withdrawal_allocation_method(
149 &mut self,
150 withdrawal_allocation_method: WithdrawalAllocationMethod,
151 ) -> &mut Self {
152 self.withdrawal_allocation_method = Some(withdrawal_allocation_method);
153 self
154 }
155 #[inline(always)]
157 pub fn add_remaining_account(
158 &mut self,
159 account: solana_program::instruction::AccountMeta,
160 ) -> &mut Self {
161 self.__remaining_accounts.push(account);
162 self
163 }
164 #[inline(always)]
166 pub fn add_remaining_accounts(
167 &mut self,
168 accounts: &[solana_program::instruction::AccountMeta],
169 ) -> &mut Self {
170 self.__remaining_accounts.extend_from_slice(accounts);
171 self
172 }
173 #[allow(clippy::clone_on_copy)]
174 pub fn instruction(&self) -> solana_program::instruction::Instruction {
175 let accounts = InitializeVaultUpdateStateTracker {
176 config: self.config.expect("config is not set"),
177 vault: self.vault.expect("vault is not set"),
178 vault_update_state_tracker: self
179 .vault_update_state_tracker
180 .expect("vault_update_state_tracker is not set"),
181 payer: self.payer.expect("payer is not set"),
182 system_program: self
183 .system_program
184 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
185 };
186 let args = InitializeVaultUpdateStateTrackerInstructionArgs {
187 withdrawal_allocation_method: self
188 .withdrawal_allocation_method
189 .clone()
190 .expect("withdrawal_allocation_method is not set"),
191 };
192
193 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
194 }
195}
196
197pub struct InitializeVaultUpdateStateTrackerCpiAccounts<'a, 'b> {
199 pub config: &'b solana_program::account_info::AccountInfo<'a>,
200
201 pub vault: &'b solana_program::account_info::AccountInfo<'a>,
202
203 pub vault_update_state_tracker: &'b solana_program::account_info::AccountInfo<'a>,
204
205 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
206
207 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
208}
209
210pub struct InitializeVaultUpdateStateTrackerCpi<'a, 'b> {
212 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
214
215 pub config: &'b solana_program::account_info::AccountInfo<'a>,
216
217 pub vault: &'b solana_program::account_info::AccountInfo<'a>,
218
219 pub vault_update_state_tracker: &'b solana_program::account_info::AccountInfo<'a>,
220
221 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
222
223 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
224 pub __args: InitializeVaultUpdateStateTrackerInstructionArgs,
226}
227
228impl<'a, 'b> InitializeVaultUpdateStateTrackerCpi<'a, 'b> {
229 pub fn new(
230 program: &'b solana_program::account_info::AccountInfo<'a>,
231 accounts: InitializeVaultUpdateStateTrackerCpiAccounts<'a, 'b>,
232 args: InitializeVaultUpdateStateTrackerInstructionArgs,
233 ) -> Self {
234 Self {
235 __program: program,
236 config: accounts.config,
237 vault: accounts.vault,
238 vault_update_state_tracker: accounts.vault_update_state_tracker,
239 payer: accounts.payer,
240 system_program: accounts.system_program,
241 __args: args,
242 }
243 }
244 #[inline(always)]
245 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
246 self.invoke_signed_with_remaining_accounts(&[], &[])
247 }
248 #[inline(always)]
249 pub fn invoke_with_remaining_accounts(
250 &self,
251 remaining_accounts: &[(
252 &'b solana_program::account_info::AccountInfo<'a>,
253 bool,
254 bool,
255 )],
256 ) -> solana_program::entrypoint::ProgramResult {
257 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
258 }
259 #[inline(always)]
260 pub fn invoke_signed(
261 &self,
262 signers_seeds: &[&[&[u8]]],
263 ) -> solana_program::entrypoint::ProgramResult {
264 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
265 }
266 #[allow(clippy::clone_on_copy)]
267 #[allow(clippy::vec_init_then_push)]
268 pub fn invoke_signed_with_remaining_accounts(
269 &self,
270 signers_seeds: &[&[&[u8]]],
271 remaining_accounts: &[(
272 &'b solana_program::account_info::AccountInfo<'a>,
273 bool,
274 bool,
275 )],
276 ) -> solana_program::entrypoint::ProgramResult {
277 let mut accounts = Vec::with_capacity(5 + remaining_accounts.len());
278 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
279 *self.config.key,
280 false,
281 ));
282 accounts.push(solana_program::instruction::AccountMeta::new(
283 *self.vault.key,
284 false,
285 ));
286 accounts.push(solana_program::instruction::AccountMeta::new(
287 *self.vault_update_state_tracker.key,
288 false,
289 ));
290 accounts.push(solana_program::instruction::AccountMeta::new(
291 *self.payer.key,
292 false,
293 ));
294 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
295 *self.system_program.key,
296 false,
297 ));
298 remaining_accounts.iter().for_each(|remaining_account| {
299 accounts.push(solana_program::instruction::AccountMeta {
300 pubkey: *remaining_account.0.key,
301 is_signer: remaining_account.1,
302 is_writable: remaining_account.2,
303 })
304 });
305 let mut data = InitializeVaultUpdateStateTrackerInstructionData::new()
306 .try_to_vec()
307 .unwrap();
308 let mut args = self.__args.try_to_vec().unwrap();
309 data.append(&mut args);
310
311 let instruction = solana_program::instruction::Instruction {
312 program_id: crate::JITO_VAULT_ID,
313 accounts,
314 data,
315 };
316 let mut account_infos = Vec::with_capacity(5 + 1 + remaining_accounts.len());
317 account_infos.push(self.__program.clone());
318 account_infos.push(self.config.clone());
319 account_infos.push(self.vault.clone());
320 account_infos.push(self.vault_update_state_tracker.clone());
321 account_infos.push(self.payer.clone());
322 account_infos.push(self.system_program.clone());
323 remaining_accounts
324 .iter()
325 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
326
327 if signers_seeds.is_empty() {
328 solana_program::program::invoke(&instruction, &account_infos)
329 } else {
330 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
331 }
332 }
333}
334
335#[derive(Clone, Debug)]
345pub struct InitializeVaultUpdateStateTrackerCpiBuilder<'a, 'b> {
346 instruction: Box<InitializeVaultUpdateStateTrackerCpiBuilderInstruction<'a, 'b>>,
347}
348
349impl<'a, 'b> InitializeVaultUpdateStateTrackerCpiBuilder<'a, 'b> {
350 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
351 let instruction = Box::new(InitializeVaultUpdateStateTrackerCpiBuilderInstruction {
352 __program: program,
353 config: None,
354 vault: None,
355 vault_update_state_tracker: None,
356 payer: None,
357 system_program: None,
358 withdrawal_allocation_method: None,
359 __remaining_accounts: Vec::new(),
360 });
361 Self { instruction }
362 }
363 #[inline(always)]
364 pub fn config(
365 &mut self,
366 config: &'b solana_program::account_info::AccountInfo<'a>,
367 ) -> &mut Self {
368 self.instruction.config = Some(config);
369 self
370 }
371 #[inline(always)]
372 pub fn vault(&mut self, vault: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
373 self.instruction.vault = Some(vault);
374 self
375 }
376 #[inline(always)]
377 pub fn vault_update_state_tracker(
378 &mut self,
379 vault_update_state_tracker: &'b solana_program::account_info::AccountInfo<'a>,
380 ) -> &mut Self {
381 self.instruction.vault_update_state_tracker = Some(vault_update_state_tracker);
382 self
383 }
384 #[inline(always)]
385 pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
386 self.instruction.payer = Some(payer);
387 self
388 }
389 #[inline(always)]
390 pub fn system_program(
391 &mut self,
392 system_program: &'b solana_program::account_info::AccountInfo<'a>,
393 ) -> &mut Self {
394 self.instruction.system_program = Some(system_program);
395 self
396 }
397 #[inline(always)]
398 pub fn withdrawal_allocation_method(
399 &mut self,
400 withdrawal_allocation_method: WithdrawalAllocationMethod,
401 ) -> &mut Self {
402 self.instruction.withdrawal_allocation_method = Some(withdrawal_allocation_method);
403 self
404 }
405 #[inline(always)]
407 pub fn add_remaining_account(
408 &mut self,
409 account: &'b solana_program::account_info::AccountInfo<'a>,
410 is_writable: bool,
411 is_signer: bool,
412 ) -> &mut Self {
413 self.instruction
414 .__remaining_accounts
415 .push((account, is_writable, is_signer));
416 self
417 }
418 #[inline(always)]
423 pub fn add_remaining_accounts(
424 &mut self,
425 accounts: &[(
426 &'b solana_program::account_info::AccountInfo<'a>,
427 bool,
428 bool,
429 )],
430 ) -> &mut Self {
431 self.instruction
432 .__remaining_accounts
433 .extend_from_slice(accounts);
434 self
435 }
436 #[inline(always)]
437 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
438 self.invoke_signed(&[])
439 }
440 #[allow(clippy::clone_on_copy)]
441 #[allow(clippy::vec_init_then_push)]
442 pub fn invoke_signed(
443 &self,
444 signers_seeds: &[&[&[u8]]],
445 ) -> solana_program::entrypoint::ProgramResult {
446 let args = InitializeVaultUpdateStateTrackerInstructionArgs {
447 withdrawal_allocation_method: self
448 .instruction
449 .withdrawal_allocation_method
450 .clone()
451 .expect("withdrawal_allocation_method is not set"),
452 };
453 let instruction = InitializeVaultUpdateStateTrackerCpi {
454 __program: self.instruction.__program,
455
456 config: self.instruction.config.expect("config is not set"),
457
458 vault: self.instruction.vault.expect("vault is not set"),
459
460 vault_update_state_tracker: self
461 .instruction
462 .vault_update_state_tracker
463 .expect("vault_update_state_tracker is not set"),
464
465 payer: self.instruction.payer.expect("payer is not set"),
466
467 system_program: self
468 .instruction
469 .system_program
470 .expect("system_program is not set"),
471 __args: args,
472 };
473 instruction.invoke_signed_with_remaining_accounts(
474 signers_seeds,
475 &self.instruction.__remaining_accounts,
476 )
477 }
478}
479
480#[derive(Clone, Debug)]
481struct InitializeVaultUpdateStateTrackerCpiBuilderInstruction<'a, 'b> {
482 __program: &'b solana_program::account_info::AccountInfo<'a>,
483 config: Option<&'b solana_program::account_info::AccountInfo<'a>>,
484 vault: Option<&'b solana_program::account_info::AccountInfo<'a>>,
485 vault_update_state_tracker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
486 payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
487 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
488 withdrawal_allocation_method: Option<WithdrawalAllocationMethod>,
489 __remaining_accounts: Vec<(
491 &'b solana_program::account_info::AccountInfo<'a>,
492 bool,
493 bool,
494 )>,
495}