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