1use borsh::BorshSerialize;
9use borsh::BorshDeserialize;
10
11pub const UPDATE_CAPITAL_CONDUCTOR_DISCRIMINATOR: [u8; 8] = [165, 155, 247, 206, 120, 197, 226, 27];
12
13#[derive(Debug)]
15pub struct UpdateCapitalConductor {
16
17
18 pub main: solana_pubkey::Pubkey,
19
20
21 pub admin: solana_pubkey::Pubkey,
22
23
24 pub system_program: solana_pubkey::Pubkey,
25
26
27 pub strategy: solana_pubkey::Pubkey,
28
29
30 pub admin_permissions: solana_pubkey::Pubkey,
31 }
32
33impl UpdateCapitalConductor {
34 pub fn instruction(&self, args: UpdateCapitalConductorInstructionArgs) -> solana_instruction::Instruction {
35 self.instruction_with_remaining_accounts(args, &[])
36 }
37 #[allow(clippy::arithmetic_side_effects)]
38 #[allow(clippy::vec_init_then_push)]
39 pub fn instruction_with_remaining_accounts(&self, args: UpdateCapitalConductorInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
40 let mut accounts = Vec::with_capacity(5+ remaining_accounts.len());
41 accounts.push(solana_instruction::AccountMeta::new(
42 self.main,
43 false
44 ));
45 accounts.push(solana_instruction::AccountMeta::new(
46 self.admin,
47 true
48 ));
49 accounts.push(solana_instruction::AccountMeta::new_readonly(
50 self.system_program,
51 false
52 ));
53 accounts.push(solana_instruction::AccountMeta::new(
54 self.strategy,
55 false
56 ));
57 accounts.push(solana_instruction::AccountMeta::new(
58 self.admin_permissions,
59 false
60 ));
61 accounts.extend_from_slice(remaining_accounts);
62 let mut data = UpdateCapitalConductorInstructionData::new().try_to_vec().unwrap();
63 let mut args = args.try_to_vec().unwrap();
64 data.append(&mut args);
65
66 solana_instruction::Instruction {
67 program_id: crate::REFLECT_MAIN_ID,
68 accounts,
69 data,
70 }
71 }
72}
73
74#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
75#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
76 pub struct UpdateCapitalConductorInstructionData {
77 discriminator: [u8; 8],
78 }
79
80impl UpdateCapitalConductorInstructionData {
81 pub fn new() -> Self {
82 Self {
83 discriminator: [165, 155, 247, 206, 120, 197, 226, 27],
84 }
85 }
86
87 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
88 borsh::to_vec(self)
89 }
90 }
91
92impl Default for UpdateCapitalConductorInstructionData {
93 fn default() -> Self {
94 Self::new()
95 }
96}
97
98#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
99#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
100 pub struct UpdateCapitalConductorInstructionArgs {
101 pub ratios: Option<Vec<u16>>,
102 pub max_deviation_bps: Option<u16>,
103 pub dust_threshold: Option<u64>,
104 pub min_per_leg_transfer: Option<u64>,
105 pub penalty_scale_factor: Option<u16>,
106 }
107
108impl UpdateCapitalConductorInstructionArgs {
109 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
110 borsh::to_vec(self)
111 }
112}
113
114
115#[derive(Clone, Debug, Default)]
125pub struct UpdateCapitalConductorBuilder {
126 main: Option<solana_pubkey::Pubkey>,
127 admin: Option<solana_pubkey::Pubkey>,
128 system_program: Option<solana_pubkey::Pubkey>,
129 strategy: Option<solana_pubkey::Pubkey>,
130 admin_permissions: Option<solana_pubkey::Pubkey>,
131 ratios: Option<Vec<u16>>,
132 max_deviation_bps: Option<u16>,
133 dust_threshold: Option<u64>,
134 min_per_leg_transfer: Option<u64>,
135 penalty_scale_factor: Option<u16>,
136 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
137}
138
139impl UpdateCapitalConductorBuilder {
140 pub fn new() -> Self {
141 Self::default()
142 }
143 #[inline(always)]
144 pub fn main(&mut self, main: solana_pubkey::Pubkey) -> &mut Self {
145 self.main = Some(main);
146 self
147 }
148 #[inline(always)]
149 pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self {
150 self.admin = Some(admin);
151 self
152 }
153 #[inline(always)]
155 pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self {
156 self.system_program = Some(system_program);
157 self
158 }
159 #[inline(always)]
160 pub fn strategy(&mut self, strategy: solana_pubkey::Pubkey) -> &mut Self {
161 self.strategy = Some(strategy);
162 self
163 }
164 #[inline(always)]
165 pub fn admin_permissions(&mut self, admin_permissions: solana_pubkey::Pubkey) -> &mut Self {
166 self.admin_permissions = Some(admin_permissions);
167 self
168 }
169 #[inline(always)]
171 pub fn ratios(&mut self, ratios: Vec<u16>) -> &mut Self {
172 self.ratios = Some(ratios);
173 self
174 }
175 #[inline(always)]
177 pub fn max_deviation_bps(&mut self, max_deviation_bps: u16) -> &mut Self {
178 self.max_deviation_bps = Some(max_deviation_bps);
179 self
180 }
181 #[inline(always)]
183 pub fn dust_threshold(&mut self, dust_threshold: u64) -> &mut Self {
184 self.dust_threshold = Some(dust_threshold);
185 self
186 }
187 #[inline(always)]
189 pub fn min_per_leg_transfer(&mut self, min_per_leg_transfer: u64) -> &mut Self {
190 self.min_per_leg_transfer = Some(min_per_leg_transfer);
191 self
192 }
193 #[inline(always)]
195 pub fn penalty_scale_factor(&mut self, penalty_scale_factor: u16) -> &mut Self {
196 self.penalty_scale_factor = Some(penalty_scale_factor);
197 self
198 }
199 #[inline(always)]
201 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
202 self.__remaining_accounts.push(account);
203 self
204 }
205 #[inline(always)]
207 pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
208 self.__remaining_accounts.extend_from_slice(accounts);
209 self
210 }
211 #[allow(clippy::clone_on_copy)]
212 pub fn instruction(&self) -> solana_instruction::Instruction {
213 let accounts = UpdateCapitalConductor {
214 main: self.main.expect("main is not set"),
215 admin: self.admin.expect("admin is not set"),
216 system_program: self.system_program.unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
217 strategy: self.strategy.expect("strategy is not set"),
218 admin_permissions: self.admin_permissions.expect("admin_permissions is not set"),
219 };
220 let args = UpdateCapitalConductorInstructionArgs {
221 ratios: self.ratios.clone(),
222 max_deviation_bps: self.max_deviation_bps.clone(),
223 dust_threshold: self.dust_threshold.clone(),
224 min_per_leg_transfer: self.min_per_leg_transfer.clone(),
225 penalty_scale_factor: self.penalty_scale_factor.clone(),
226 };
227
228 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
229 }
230}
231
232 pub struct UpdateCapitalConductorCpiAccounts<'a, 'b> {
234
235
236 pub main: &'b solana_account_info::AccountInfo<'a>,
237
238
239 pub admin: &'b solana_account_info::AccountInfo<'a>,
240
241
242 pub system_program: &'b solana_account_info::AccountInfo<'a>,
243
244
245 pub strategy: &'b solana_account_info::AccountInfo<'a>,
246
247
248 pub admin_permissions: &'b solana_account_info::AccountInfo<'a>,
249 }
250
251pub struct UpdateCapitalConductorCpi<'a, 'b> {
253 pub __program: &'b solana_account_info::AccountInfo<'a>,
255
256
257 pub main: &'b solana_account_info::AccountInfo<'a>,
258
259
260 pub admin: &'b solana_account_info::AccountInfo<'a>,
261
262
263 pub system_program: &'b solana_account_info::AccountInfo<'a>,
264
265
266 pub strategy: &'b solana_account_info::AccountInfo<'a>,
267
268
269 pub admin_permissions: &'b solana_account_info::AccountInfo<'a>,
270 pub __args: UpdateCapitalConductorInstructionArgs,
272 }
273
274impl<'a, 'b> UpdateCapitalConductorCpi<'a, 'b> {
275 pub fn new(
276 program: &'b solana_account_info::AccountInfo<'a>,
277 accounts: UpdateCapitalConductorCpiAccounts<'a, 'b>,
278 args: UpdateCapitalConductorInstructionArgs,
279 ) -> Self {
280 Self {
281 __program: program,
282 main: accounts.main,
283 admin: accounts.admin,
284 system_program: accounts.system_program,
285 strategy: accounts.strategy,
286 admin_permissions: accounts.admin_permissions,
287 __args: args,
288 }
289 }
290 #[inline(always)]
291 pub fn invoke(&self) -> solana_program_error::ProgramResult {
292 self.invoke_signed_with_remaining_accounts(&[], &[])
293 }
294 #[inline(always)]
295 pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
296 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
297 }
298 #[inline(always)]
299 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
300 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
301 }
302 #[allow(clippy::arithmetic_side_effects)]
303 #[allow(clippy::clone_on_copy)]
304 #[allow(clippy::vec_init_then_push)]
305 pub fn invoke_signed_with_remaining_accounts(
306 &self,
307 signers_seeds: &[&[&[u8]]],
308 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
309 ) -> solana_program_error::ProgramResult {
310 let mut accounts = Vec::with_capacity(5+ remaining_accounts.len());
311 accounts.push(solana_instruction::AccountMeta::new(
312 *self.main.key,
313 false
314 ));
315 accounts.push(solana_instruction::AccountMeta::new(
316 *self.admin.key,
317 true
318 ));
319 accounts.push(solana_instruction::AccountMeta::new_readonly(
320 *self.system_program.key,
321 false
322 ));
323 accounts.push(solana_instruction::AccountMeta::new(
324 *self.strategy.key,
325 false
326 ));
327 accounts.push(solana_instruction::AccountMeta::new(
328 *self.admin_permissions.key,
329 false
330 ));
331 remaining_accounts.iter().for_each(|remaining_account| {
332 accounts.push(solana_instruction::AccountMeta {
333 pubkey: *remaining_account.0.key,
334 is_signer: remaining_account.1,
335 is_writable: remaining_account.2,
336 })
337 });
338 let mut data = UpdateCapitalConductorInstructionData::new().try_to_vec().unwrap();
339 let mut args = self.__args.try_to_vec().unwrap();
340 data.append(&mut args);
341
342 let instruction = solana_instruction::Instruction {
343 program_id: crate::REFLECT_MAIN_ID,
344 accounts,
345 data,
346 };
347 let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len());
348 account_infos.push(self.__program.clone());
349 account_infos.push(self.main.clone());
350 account_infos.push(self.admin.clone());
351 account_infos.push(self.system_program.clone());
352 account_infos.push(self.strategy.clone());
353 account_infos.push(self.admin_permissions.clone());
354 remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
355
356 if signers_seeds.is_empty() {
357 solana_cpi::invoke(&instruction, &account_infos)
358 } else {
359 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
360 }
361 }
362}
363
364#[derive(Clone, Debug)]
374pub struct UpdateCapitalConductorCpiBuilder<'a, 'b> {
375 instruction: Box<UpdateCapitalConductorCpiBuilderInstruction<'a, 'b>>,
376}
377
378impl<'a, 'b> UpdateCapitalConductorCpiBuilder<'a, 'b> {
379 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
380 let instruction = Box::new(UpdateCapitalConductorCpiBuilderInstruction {
381 __program: program,
382 main: None,
383 admin: None,
384 system_program: None,
385 strategy: None,
386 admin_permissions: None,
387 ratios: None,
388 max_deviation_bps: None,
389 dust_threshold: None,
390 min_per_leg_transfer: None,
391 penalty_scale_factor: None,
392 __remaining_accounts: Vec::new(),
393 });
394 Self { instruction }
395 }
396 #[inline(always)]
397 pub fn main(&mut self, main: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
398 self.instruction.main = Some(main);
399 self
400 }
401 #[inline(always)]
402 pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
403 self.instruction.admin = Some(admin);
404 self
405 }
406 #[inline(always)]
407 pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
408 self.instruction.system_program = Some(system_program);
409 self
410 }
411 #[inline(always)]
412 pub fn strategy(&mut self, strategy: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
413 self.instruction.strategy = Some(strategy);
414 self
415 }
416 #[inline(always)]
417 pub fn admin_permissions(&mut self, admin_permissions: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
418 self.instruction.admin_permissions = Some(admin_permissions);
419 self
420 }
421 #[inline(always)]
423 pub fn ratios(&mut self, ratios: Vec<u16>) -> &mut Self {
424 self.instruction.ratios = Some(ratios);
425 self
426 }
427 #[inline(always)]
429 pub fn max_deviation_bps(&mut self, max_deviation_bps: u16) -> &mut Self {
430 self.instruction.max_deviation_bps = Some(max_deviation_bps);
431 self
432 }
433 #[inline(always)]
435 pub fn dust_threshold(&mut self, dust_threshold: u64) -> &mut Self {
436 self.instruction.dust_threshold = Some(dust_threshold);
437 self
438 }
439 #[inline(always)]
441 pub fn min_per_leg_transfer(&mut self, min_per_leg_transfer: u64) -> &mut Self {
442 self.instruction.min_per_leg_transfer = Some(min_per_leg_transfer);
443 self
444 }
445 #[inline(always)]
447 pub fn penalty_scale_factor(&mut self, penalty_scale_factor: u16) -> &mut Self {
448 self.instruction.penalty_scale_factor = Some(penalty_scale_factor);
449 self
450 }
451 #[inline(always)]
453 pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
454 self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
455 self
456 }
457 #[inline(always)]
462 pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
463 self.instruction.__remaining_accounts.extend_from_slice(accounts);
464 self
465 }
466 #[inline(always)]
467 pub fn invoke(&self) -> solana_program_error::ProgramResult {
468 self.invoke_signed(&[])
469 }
470 #[allow(clippy::clone_on_copy)]
471 #[allow(clippy::vec_init_then_push)]
472 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
473 let args = UpdateCapitalConductorInstructionArgs {
474 ratios: self.instruction.ratios.clone(),
475 max_deviation_bps: self.instruction.max_deviation_bps.clone(),
476 dust_threshold: self.instruction.dust_threshold.clone(),
477 min_per_leg_transfer: self.instruction.min_per_leg_transfer.clone(),
478 penalty_scale_factor: self.instruction.penalty_scale_factor.clone(),
479 };
480 let instruction = UpdateCapitalConductorCpi {
481 __program: self.instruction.__program,
482
483 main: self.instruction.main.expect("main is not set"),
484
485 admin: self.instruction.admin.expect("admin is not set"),
486
487 system_program: self.instruction.system_program.expect("system_program is not set"),
488
489 strategy: self.instruction.strategy.expect("strategy is not set"),
490
491 admin_permissions: self.instruction.admin_permissions.expect("admin_permissions is not set"),
492 __args: args,
493 };
494 instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
495 }
496}
497
498#[derive(Clone, Debug)]
499struct UpdateCapitalConductorCpiBuilderInstruction<'a, 'b> {
500 __program: &'b solana_account_info::AccountInfo<'a>,
501 main: Option<&'b solana_account_info::AccountInfo<'a>>,
502 admin: Option<&'b solana_account_info::AccountInfo<'a>>,
503 system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
504 strategy: Option<&'b solana_account_info::AccountInfo<'a>>,
505 admin_permissions: Option<&'b solana_account_info::AccountInfo<'a>>,
506 ratios: Option<Vec<u16>>,
507 max_deviation_bps: Option<u16>,
508 dust_threshold: Option<u64>,
509 min_per_leg_transfer: Option<u64>,
510 penalty_scale_factor: Option<u16>,
511 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
513}
514