1use borsh::{BorshDeserialize, BorshSerialize};
9
10pub const INSTANT_DECREASE_POSITION2_DISCRIMINATOR: [u8; 8] = [162, 191, 200, 62, 139, 62, 176, 17];
11
12#[derive(Debug)]
14pub struct InstantDecreasePosition2 {
15 pub keeper: solana_program::pubkey::Pubkey,
16
17 pub api_keeper: solana_program::pubkey::Pubkey,
18
19 pub owner: solana_program::pubkey::Pubkey,
20
21 pub receiving_account: solana_program::pubkey::Pubkey,
22
23 pub transfer_authority: solana_program::pubkey::Pubkey,
24
25 pub perpetuals: solana_program::pubkey::Pubkey,
26
27 pub pool: solana_program::pubkey::Pubkey,
28
29 pub position: solana_program::pubkey::Pubkey,
30
31 pub custody: solana_program::pubkey::Pubkey,
32
33 pub custody_doves_price_account: solana_program::pubkey::Pubkey,
34
35 pub collateral_custody: solana_program::pubkey::Pubkey,
36
37 pub collateral_custody_doves_price_account: solana_program::pubkey::Pubkey,
38
39 pub collateral_custody_token_account: solana_program::pubkey::Pubkey,
40
41 pub desired_mint: solana_program::pubkey::Pubkey,
42
43 pub referral: Option<solana_program::pubkey::Pubkey>,
44
45 pub position_request: solana_program::pubkey::Pubkey,
46
47 pub position_request_ata: solana_program::pubkey::Pubkey,
48
49 pub token_program: solana_program::pubkey::Pubkey,
50
51 pub associated_token_program: solana_program::pubkey::Pubkey,
52
53 pub system_program: solana_program::pubkey::Pubkey,
54
55 pub event_authority: solana_program::pubkey::Pubkey,
56
57 pub program: solana_program::pubkey::Pubkey,
58}
59
60impl InstantDecreasePosition2 {
61 pub fn instruction(
62 &self,
63 args: InstantDecreasePosition2InstructionArgs,
64 ) -> solana_program::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(
70 &self,
71 args: InstantDecreasePosition2InstructionArgs,
72 remaining_accounts: &[solana_program::instruction::AccountMeta],
73 ) -> solana_program::instruction::Instruction {
74 let mut accounts = Vec::with_capacity(22 + remaining_accounts.len());
75 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
76 self.keeper,
77 true,
78 ));
79 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
80 self.api_keeper,
81 true,
82 ));
83 accounts.push(solana_program::instruction::AccountMeta::new(
84 self.owner, true,
85 ));
86 accounts.push(solana_program::instruction::AccountMeta::new(
87 self.receiving_account,
88 false,
89 ));
90 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
91 self.transfer_authority,
92 false,
93 ));
94 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
95 self.perpetuals,
96 false,
97 ));
98 accounts.push(solana_program::instruction::AccountMeta::new(
99 self.pool, false,
100 ));
101 accounts.push(solana_program::instruction::AccountMeta::new(
102 self.position,
103 false,
104 ));
105 accounts.push(solana_program::instruction::AccountMeta::new(
106 self.custody,
107 false,
108 ));
109 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
110 self.custody_doves_price_account,
111 false,
112 ));
113 accounts.push(solana_program::instruction::AccountMeta::new(
114 self.collateral_custody,
115 false,
116 ));
117 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
118 self.collateral_custody_doves_price_account,
119 false,
120 ));
121 accounts.push(solana_program::instruction::AccountMeta::new(
122 self.collateral_custody_token_account,
123 false,
124 ));
125 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
126 self.desired_mint,
127 false,
128 ));
129 if let Some(referral) = self.referral {
130 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
131 referral, false,
132 ));
133 } else {
134 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
135 crate::PERPETUALS_ID,
136 false,
137 ));
138 }
139 accounts.push(solana_program::instruction::AccountMeta::new(
140 self.position_request,
141 false,
142 ));
143 accounts.push(solana_program::instruction::AccountMeta::new(
144 self.position_request_ata,
145 false,
146 ));
147 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
148 self.token_program,
149 false,
150 ));
151 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
152 self.associated_token_program,
153 false,
154 ));
155 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
156 self.system_program,
157 false,
158 ));
159 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
160 self.event_authority,
161 false,
162 ));
163 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
164 self.program,
165 false,
166 ));
167 accounts.extend_from_slice(remaining_accounts);
168 let mut data = borsh::to_vec(&InstantDecreasePosition2InstructionData::new()).unwrap();
169 let mut args = borsh::to_vec(&args).unwrap();
170 data.append(&mut args);
171
172 solana_program::instruction::Instruction {
173 program_id: crate::PERPETUALS_ID,
174 accounts,
175 data,
176 }
177 }
178}
179
180#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)]
181#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
182pub struct InstantDecreasePosition2InstructionData {
183 discriminator: [u8; 8],
184}
185
186impl InstantDecreasePosition2InstructionData {
187 pub fn new() -> Self {
188 Self {
189 discriminator: [162, 191, 200, 62, 139, 62, 176, 17],
190 }
191 }
192}
193
194impl Default for InstantDecreasePosition2InstructionData {
195 fn default() -> Self {
196 Self::new()
197 }
198}
199
200#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)]
201#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
202pub struct InstantDecreasePosition2InstructionArgs {
203 pub collateral_usd_delta: u64,
204 pub size_usd_delta: u64,
205 pub price_slippage: u64,
206 pub entire_position: Option<bool>,
207 pub request_time: i64,
208 pub counter: u64,
209}
210
211#[derive(Clone, Debug, Default)]
238pub struct InstantDecreasePosition2Builder {
239 keeper: Option<solana_program::pubkey::Pubkey>,
240 api_keeper: Option<solana_program::pubkey::Pubkey>,
241 owner: Option<solana_program::pubkey::Pubkey>,
242 receiving_account: Option<solana_program::pubkey::Pubkey>,
243 transfer_authority: Option<solana_program::pubkey::Pubkey>,
244 perpetuals: Option<solana_program::pubkey::Pubkey>,
245 pool: Option<solana_program::pubkey::Pubkey>,
246 position: Option<solana_program::pubkey::Pubkey>,
247 custody: Option<solana_program::pubkey::Pubkey>,
248 custody_doves_price_account: Option<solana_program::pubkey::Pubkey>,
249 collateral_custody: Option<solana_program::pubkey::Pubkey>,
250 collateral_custody_doves_price_account: Option<solana_program::pubkey::Pubkey>,
251 collateral_custody_token_account: Option<solana_program::pubkey::Pubkey>,
252 desired_mint: Option<solana_program::pubkey::Pubkey>,
253 referral: Option<solana_program::pubkey::Pubkey>,
254 position_request: Option<solana_program::pubkey::Pubkey>,
255 position_request_ata: Option<solana_program::pubkey::Pubkey>,
256 token_program: Option<solana_program::pubkey::Pubkey>,
257 associated_token_program: Option<solana_program::pubkey::Pubkey>,
258 system_program: Option<solana_program::pubkey::Pubkey>,
259 event_authority: Option<solana_program::pubkey::Pubkey>,
260 program: Option<solana_program::pubkey::Pubkey>,
261 collateral_usd_delta: Option<u64>,
262 size_usd_delta: Option<u64>,
263 price_slippage: Option<u64>,
264 entire_position: Option<bool>,
265 request_time: Option<i64>,
266 counter: Option<u64>,
267 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
268}
269
270impl InstantDecreasePosition2Builder {
271 pub fn new() -> Self {
272 Self::default()
273 }
274 #[inline(always)]
275 pub fn keeper(&mut self, keeper: solana_program::pubkey::Pubkey) -> &mut Self {
276 self.keeper = Some(keeper);
277 self
278 }
279 #[inline(always)]
280 pub fn api_keeper(&mut self, api_keeper: solana_program::pubkey::Pubkey) -> &mut Self {
281 self.api_keeper = Some(api_keeper);
282 self
283 }
284 #[inline(always)]
285 pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self {
286 self.owner = Some(owner);
287 self
288 }
289 #[inline(always)]
290 pub fn receiving_account(
291 &mut self,
292 receiving_account: solana_program::pubkey::Pubkey,
293 ) -> &mut Self {
294 self.receiving_account = Some(receiving_account);
295 self
296 }
297 #[inline(always)]
298 pub fn transfer_authority(
299 &mut self,
300 transfer_authority: solana_program::pubkey::Pubkey,
301 ) -> &mut Self {
302 self.transfer_authority = Some(transfer_authority);
303 self
304 }
305 #[inline(always)]
306 pub fn perpetuals(&mut self, perpetuals: solana_program::pubkey::Pubkey) -> &mut Self {
307 self.perpetuals = Some(perpetuals);
308 self
309 }
310 #[inline(always)]
311 pub fn pool(&mut self, pool: solana_program::pubkey::Pubkey) -> &mut Self {
312 self.pool = Some(pool);
313 self
314 }
315 #[inline(always)]
316 pub fn position(&mut self, position: solana_program::pubkey::Pubkey) -> &mut Self {
317 self.position = Some(position);
318 self
319 }
320 #[inline(always)]
321 pub fn custody(&mut self, custody: solana_program::pubkey::Pubkey) -> &mut Self {
322 self.custody = Some(custody);
323 self
324 }
325 #[inline(always)]
326 pub fn custody_doves_price_account(
327 &mut self,
328 custody_doves_price_account: solana_program::pubkey::Pubkey,
329 ) -> &mut Self {
330 self.custody_doves_price_account = Some(custody_doves_price_account);
331 self
332 }
333 #[inline(always)]
334 pub fn collateral_custody(
335 &mut self,
336 collateral_custody: solana_program::pubkey::Pubkey,
337 ) -> &mut Self {
338 self.collateral_custody = Some(collateral_custody);
339 self
340 }
341 #[inline(always)]
342 pub fn collateral_custody_doves_price_account(
343 &mut self,
344 collateral_custody_doves_price_account: solana_program::pubkey::Pubkey,
345 ) -> &mut Self {
346 self.collateral_custody_doves_price_account = Some(collateral_custody_doves_price_account);
347 self
348 }
349 #[inline(always)]
350 pub fn collateral_custody_token_account(
351 &mut self,
352 collateral_custody_token_account: solana_program::pubkey::Pubkey,
353 ) -> &mut Self {
354 self.collateral_custody_token_account = Some(collateral_custody_token_account);
355 self
356 }
357 #[inline(always)]
358 pub fn desired_mint(&mut self, desired_mint: solana_program::pubkey::Pubkey) -> &mut Self {
359 self.desired_mint = Some(desired_mint);
360 self
361 }
362 #[inline(always)]
364 pub fn referral(&mut self, referral: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
365 self.referral = referral;
366 self
367 }
368 #[inline(always)]
369 pub fn position_request(
370 &mut self,
371 position_request: solana_program::pubkey::Pubkey,
372 ) -> &mut Self {
373 self.position_request = Some(position_request);
374 self
375 }
376 #[inline(always)]
377 pub fn position_request_ata(
378 &mut self,
379 position_request_ata: solana_program::pubkey::Pubkey,
380 ) -> &mut Self {
381 self.position_request_ata = Some(position_request_ata);
382 self
383 }
384 #[inline(always)]
386 pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
387 self.token_program = Some(token_program);
388 self
389 }
390 #[inline(always)]
391 pub fn associated_token_program(
392 &mut self,
393 associated_token_program: solana_program::pubkey::Pubkey,
394 ) -> &mut Self {
395 self.associated_token_program = Some(associated_token_program);
396 self
397 }
398 #[inline(always)]
400 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
401 self.system_program = Some(system_program);
402 self
403 }
404 #[inline(always)]
405 pub fn event_authority(
406 &mut self,
407 event_authority: solana_program::pubkey::Pubkey,
408 ) -> &mut Self {
409 self.event_authority = Some(event_authority);
410 self
411 }
412 #[inline(always)]
413 pub fn program(&mut self, program: solana_program::pubkey::Pubkey) -> &mut Self {
414 self.program = Some(program);
415 self
416 }
417 #[inline(always)]
418 pub fn collateral_usd_delta(&mut self, collateral_usd_delta: u64) -> &mut Self {
419 self.collateral_usd_delta = Some(collateral_usd_delta);
420 self
421 }
422 #[inline(always)]
423 pub fn size_usd_delta(&mut self, size_usd_delta: u64) -> &mut Self {
424 self.size_usd_delta = Some(size_usd_delta);
425 self
426 }
427 #[inline(always)]
428 pub fn price_slippage(&mut self, price_slippage: u64) -> &mut Self {
429 self.price_slippage = Some(price_slippage);
430 self
431 }
432 #[inline(always)]
434 pub fn entire_position(&mut self, entire_position: bool) -> &mut Self {
435 self.entire_position = Some(entire_position);
436 self
437 }
438 #[inline(always)]
439 pub fn request_time(&mut self, request_time: i64) -> &mut Self {
440 self.request_time = Some(request_time);
441 self
442 }
443 #[inline(always)]
444 pub fn counter(&mut self, counter: u64) -> &mut Self {
445 self.counter = Some(counter);
446 self
447 }
448 #[inline(always)]
450 pub fn add_remaining_account(
451 &mut self,
452 account: solana_program::instruction::AccountMeta,
453 ) -> &mut Self {
454 self.__remaining_accounts.push(account);
455 self
456 }
457 #[inline(always)]
459 pub fn add_remaining_accounts(
460 &mut self,
461 accounts: &[solana_program::instruction::AccountMeta],
462 ) -> &mut Self {
463 self.__remaining_accounts.extend_from_slice(accounts);
464 self
465 }
466 #[allow(clippy::clone_on_copy)]
467 pub fn instruction(&self) -> solana_program::instruction::Instruction {
468 let accounts = InstantDecreasePosition2 {
469 keeper: self.keeper.expect("keeper is not set"),
470 api_keeper: self.api_keeper.expect("api_keeper is not set"),
471 owner: self.owner.expect("owner is not set"),
472 receiving_account: self
473 .receiving_account
474 .expect("receiving_account is not set"),
475 transfer_authority: self
476 .transfer_authority
477 .expect("transfer_authority is not set"),
478 perpetuals: self.perpetuals.expect("perpetuals is not set"),
479 pool: self.pool.expect("pool is not set"),
480 position: self.position.expect("position is not set"),
481 custody: self.custody.expect("custody is not set"),
482 custody_doves_price_account: self
483 .custody_doves_price_account
484 .expect("custody_doves_price_account is not set"),
485 collateral_custody: self
486 .collateral_custody
487 .expect("collateral_custody is not set"),
488 collateral_custody_doves_price_account: self
489 .collateral_custody_doves_price_account
490 .expect("collateral_custody_doves_price_account is not set"),
491 collateral_custody_token_account: self
492 .collateral_custody_token_account
493 .expect("collateral_custody_token_account is not set"),
494 desired_mint: self.desired_mint.expect("desired_mint is not set"),
495 referral: self.referral,
496 position_request: self.position_request.expect("position_request is not set"),
497 position_request_ata: self
498 .position_request_ata
499 .expect("position_request_ata is not set"),
500 token_program: self.token_program.unwrap_or(solana_program::pubkey!(
501 "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
502 )),
503 associated_token_program: self
504 .associated_token_program
505 .expect("associated_token_program is not set"),
506 system_program: self
507 .system_program
508 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
509 event_authority: self.event_authority.expect("event_authority is not set"),
510 program: self.program.expect("program is not set"),
511 };
512 let args = InstantDecreasePosition2InstructionArgs {
513 collateral_usd_delta: self
514 .collateral_usd_delta
515 .clone()
516 .expect("collateral_usd_delta is not set"),
517 size_usd_delta: self
518 .size_usd_delta
519 .clone()
520 .expect("size_usd_delta is not set"),
521 price_slippage: self
522 .price_slippage
523 .clone()
524 .expect("price_slippage is not set"),
525 entire_position: self.entire_position.clone(),
526 request_time: self.request_time.clone().expect("request_time is not set"),
527 counter: self.counter.clone().expect("counter is not set"),
528 };
529
530 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
531 }
532}
533
534pub struct InstantDecreasePosition2CpiAccounts<'a, 'b> {
536 pub keeper: &'b solana_program::account_info::AccountInfo<'a>,
537
538 pub api_keeper: &'b solana_program::account_info::AccountInfo<'a>,
539
540 pub owner: &'b solana_program::account_info::AccountInfo<'a>,
541
542 pub receiving_account: &'b solana_program::account_info::AccountInfo<'a>,
543
544 pub transfer_authority: &'b solana_program::account_info::AccountInfo<'a>,
545
546 pub perpetuals: &'b solana_program::account_info::AccountInfo<'a>,
547
548 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
549
550 pub position: &'b solana_program::account_info::AccountInfo<'a>,
551
552 pub custody: &'b solana_program::account_info::AccountInfo<'a>,
553
554 pub custody_doves_price_account: &'b solana_program::account_info::AccountInfo<'a>,
555
556 pub collateral_custody: &'b solana_program::account_info::AccountInfo<'a>,
557
558 pub collateral_custody_doves_price_account: &'b solana_program::account_info::AccountInfo<'a>,
559
560 pub collateral_custody_token_account: &'b solana_program::account_info::AccountInfo<'a>,
561
562 pub desired_mint: &'b solana_program::account_info::AccountInfo<'a>,
563
564 pub referral: Option<&'b solana_program::account_info::AccountInfo<'a>>,
565
566 pub position_request: &'b solana_program::account_info::AccountInfo<'a>,
567
568 pub position_request_ata: &'b solana_program::account_info::AccountInfo<'a>,
569
570 pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
571
572 pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
573
574 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
575
576 pub event_authority: &'b solana_program::account_info::AccountInfo<'a>,
577
578 pub program: &'b solana_program::account_info::AccountInfo<'a>,
579}
580
581pub struct InstantDecreasePosition2Cpi<'a, 'b> {
583 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
585
586 pub keeper: &'b solana_program::account_info::AccountInfo<'a>,
587
588 pub api_keeper: &'b solana_program::account_info::AccountInfo<'a>,
589
590 pub owner: &'b solana_program::account_info::AccountInfo<'a>,
591
592 pub receiving_account: &'b solana_program::account_info::AccountInfo<'a>,
593
594 pub transfer_authority: &'b solana_program::account_info::AccountInfo<'a>,
595
596 pub perpetuals: &'b solana_program::account_info::AccountInfo<'a>,
597
598 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
599
600 pub position: &'b solana_program::account_info::AccountInfo<'a>,
601
602 pub custody: &'b solana_program::account_info::AccountInfo<'a>,
603
604 pub custody_doves_price_account: &'b solana_program::account_info::AccountInfo<'a>,
605
606 pub collateral_custody: &'b solana_program::account_info::AccountInfo<'a>,
607
608 pub collateral_custody_doves_price_account: &'b solana_program::account_info::AccountInfo<'a>,
609
610 pub collateral_custody_token_account: &'b solana_program::account_info::AccountInfo<'a>,
611
612 pub desired_mint: &'b solana_program::account_info::AccountInfo<'a>,
613
614 pub referral: Option<&'b solana_program::account_info::AccountInfo<'a>>,
615
616 pub position_request: &'b solana_program::account_info::AccountInfo<'a>,
617
618 pub position_request_ata: &'b solana_program::account_info::AccountInfo<'a>,
619
620 pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
621
622 pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
623
624 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
625
626 pub event_authority: &'b solana_program::account_info::AccountInfo<'a>,
627
628 pub program: &'b solana_program::account_info::AccountInfo<'a>,
629 pub __args: InstantDecreasePosition2InstructionArgs,
631}
632
633impl<'a, 'b> InstantDecreasePosition2Cpi<'a, 'b> {
634 pub fn new(
635 program: &'b solana_program::account_info::AccountInfo<'a>,
636 accounts: InstantDecreasePosition2CpiAccounts<'a, 'b>,
637 args: InstantDecreasePosition2InstructionArgs,
638 ) -> Self {
639 Self {
640 __program: program,
641 keeper: accounts.keeper,
642 api_keeper: accounts.api_keeper,
643 owner: accounts.owner,
644 receiving_account: accounts.receiving_account,
645 transfer_authority: accounts.transfer_authority,
646 perpetuals: accounts.perpetuals,
647 pool: accounts.pool,
648 position: accounts.position,
649 custody: accounts.custody,
650 custody_doves_price_account: accounts.custody_doves_price_account,
651 collateral_custody: accounts.collateral_custody,
652 collateral_custody_doves_price_account: accounts.collateral_custody_doves_price_account,
653 collateral_custody_token_account: accounts.collateral_custody_token_account,
654 desired_mint: accounts.desired_mint,
655 referral: accounts.referral,
656 position_request: accounts.position_request,
657 position_request_ata: accounts.position_request_ata,
658 token_program: accounts.token_program,
659 associated_token_program: accounts.associated_token_program,
660 system_program: accounts.system_program,
661 event_authority: accounts.event_authority,
662 program: accounts.program,
663 __args: args,
664 }
665 }
666 #[inline(always)]
667 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
668 self.invoke_signed_with_remaining_accounts(&[], &[])
669 }
670 #[inline(always)]
671 pub fn invoke_with_remaining_accounts(
672 &self,
673 remaining_accounts: &[(
674 &'b solana_program::account_info::AccountInfo<'a>,
675 bool,
676 bool,
677 )],
678 ) -> solana_program::entrypoint::ProgramResult {
679 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
680 }
681 #[inline(always)]
682 pub fn invoke_signed(
683 &self,
684 signers_seeds: &[&[&[u8]]],
685 ) -> solana_program::entrypoint::ProgramResult {
686 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
687 }
688 #[allow(clippy::arithmetic_side_effects)]
689 #[allow(clippy::clone_on_copy)]
690 #[allow(clippy::vec_init_then_push)]
691 pub fn invoke_signed_with_remaining_accounts(
692 &self,
693 signers_seeds: &[&[&[u8]]],
694 remaining_accounts: &[(
695 &'b solana_program::account_info::AccountInfo<'a>,
696 bool,
697 bool,
698 )],
699 ) -> solana_program::entrypoint::ProgramResult {
700 let mut accounts = Vec::with_capacity(22 + remaining_accounts.len());
701 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
702 *self.keeper.key,
703 true,
704 ));
705 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
706 *self.api_keeper.key,
707 true,
708 ));
709 accounts.push(solana_program::instruction::AccountMeta::new(
710 *self.owner.key,
711 true,
712 ));
713 accounts.push(solana_program::instruction::AccountMeta::new(
714 *self.receiving_account.key,
715 false,
716 ));
717 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
718 *self.transfer_authority.key,
719 false,
720 ));
721 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
722 *self.perpetuals.key,
723 false,
724 ));
725 accounts.push(solana_program::instruction::AccountMeta::new(
726 *self.pool.key,
727 false,
728 ));
729 accounts.push(solana_program::instruction::AccountMeta::new(
730 *self.position.key,
731 false,
732 ));
733 accounts.push(solana_program::instruction::AccountMeta::new(
734 *self.custody.key,
735 false,
736 ));
737 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
738 *self.custody_doves_price_account.key,
739 false,
740 ));
741 accounts.push(solana_program::instruction::AccountMeta::new(
742 *self.collateral_custody.key,
743 false,
744 ));
745 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
746 *self.collateral_custody_doves_price_account.key,
747 false,
748 ));
749 accounts.push(solana_program::instruction::AccountMeta::new(
750 *self.collateral_custody_token_account.key,
751 false,
752 ));
753 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
754 *self.desired_mint.key,
755 false,
756 ));
757 if let Some(referral) = self.referral {
758 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
759 *referral.key,
760 false,
761 ));
762 } else {
763 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
764 crate::PERPETUALS_ID,
765 false,
766 ));
767 }
768 accounts.push(solana_program::instruction::AccountMeta::new(
769 *self.position_request.key,
770 false,
771 ));
772 accounts.push(solana_program::instruction::AccountMeta::new(
773 *self.position_request_ata.key,
774 false,
775 ));
776 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
777 *self.token_program.key,
778 false,
779 ));
780 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
781 *self.associated_token_program.key,
782 false,
783 ));
784 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
785 *self.system_program.key,
786 false,
787 ));
788 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
789 *self.event_authority.key,
790 false,
791 ));
792 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
793 *self.program.key,
794 false,
795 ));
796 remaining_accounts.iter().for_each(|remaining_account| {
797 accounts.push(solana_program::instruction::AccountMeta {
798 pubkey: *remaining_account.0.key,
799 is_signer: remaining_account.1,
800 is_writable: remaining_account.2,
801 })
802 });
803 let mut data = borsh::to_vec(&InstantDecreasePosition2InstructionData::new()).unwrap();
804 let mut args = borsh::to_vec(&self.__args).unwrap();
805 data.append(&mut args);
806
807 let instruction = solana_program::instruction::Instruction {
808 program_id: crate::PERPETUALS_ID,
809 accounts,
810 data,
811 };
812 let mut account_infos = Vec::with_capacity(23 + remaining_accounts.len());
813 account_infos.push(self.__program.clone());
814 account_infos.push(self.keeper.clone());
815 account_infos.push(self.api_keeper.clone());
816 account_infos.push(self.owner.clone());
817 account_infos.push(self.receiving_account.clone());
818 account_infos.push(self.transfer_authority.clone());
819 account_infos.push(self.perpetuals.clone());
820 account_infos.push(self.pool.clone());
821 account_infos.push(self.position.clone());
822 account_infos.push(self.custody.clone());
823 account_infos.push(self.custody_doves_price_account.clone());
824 account_infos.push(self.collateral_custody.clone());
825 account_infos.push(self.collateral_custody_doves_price_account.clone());
826 account_infos.push(self.collateral_custody_token_account.clone());
827 account_infos.push(self.desired_mint.clone());
828 if let Some(referral) = self.referral {
829 account_infos.push(referral.clone());
830 }
831 account_infos.push(self.position_request.clone());
832 account_infos.push(self.position_request_ata.clone());
833 account_infos.push(self.token_program.clone());
834 account_infos.push(self.associated_token_program.clone());
835 account_infos.push(self.system_program.clone());
836 account_infos.push(self.event_authority.clone());
837 account_infos.push(self.program.clone());
838 remaining_accounts
839 .iter()
840 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
841
842 if signers_seeds.is_empty() {
843 solana_program::program::invoke(&instruction, &account_infos)
844 } else {
845 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
846 }
847 }
848}
849
850#[derive(Clone, Debug)]
877pub struct InstantDecreasePosition2CpiBuilder<'a, 'b> {
878 instruction: Box<InstantDecreasePosition2CpiBuilderInstruction<'a, 'b>>,
879}
880
881impl<'a, 'b> InstantDecreasePosition2CpiBuilder<'a, 'b> {
882 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
883 let instruction = Box::new(InstantDecreasePosition2CpiBuilderInstruction {
884 __program: program,
885 keeper: None,
886 api_keeper: None,
887 owner: None,
888 receiving_account: None,
889 transfer_authority: None,
890 perpetuals: None,
891 pool: None,
892 position: None,
893 custody: None,
894 custody_doves_price_account: None,
895 collateral_custody: None,
896 collateral_custody_doves_price_account: None,
897 collateral_custody_token_account: None,
898 desired_mint: None,
899 referral: None,
900 position_request: None,
901 position_request_ata: None,
902 token_program: None,
903 associated_token_program: None,
904 system_program: None,
905 event_authority: None,
906 program: None,
907 collateral_usd_delta: None,
908 size_usd_delta: None,
909 price_slippage: None,
910 entire_position: None,
911 request_time: None,
912 counter: None,
913 __remaining_accounts: Vec::new(),
914 });
915 Self { instruction }
916 }
917 #[inline(always)]
918 pub fn keeper(
919 &mut self,
920 keeper: &'b solana_program::account_info::AccountInfo<'a>,
921 ) -> &mut Self {
922 self.instruction.keeper = Some(keeper);
923 self
924 }
925 #[inline(always)]
926 pub fn api_keeper(
927 &mut self,
928 api_keeper: &'b solana_program::account_info::AccountInfo<'a>,
929 ) -> &mut Self {
930 self.instruction.api_keeper = Some(api_keeper);
931 self
932 }
933 #[inline(always)]
934 pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
935 self.instruction.owner = Some(owner);
936 self
937 }
938 #[inline(always)]
939 pub fn receiving_account(
940 &mut self,
941 receiving_account: &'b solana_program::account_info::AccountInfo<'a>,
942 ) -> &mut Self {
943 self.instruction.receiving_account = Some(receiving_account);
944 self
945 }
946 #[inline(always)]
947 pub fn transfer_authority(
948 &mut self,
949 transfer_authority: &'b solana_program::account_info::AccountInfo<'a>,
950 ) -> &mut Self {
951 self.instruction.transfer_authority = Some(transfer_authority);
952 self
953 }
954 #[inline(always)]
955 pub fn perpetuals(
956 &mut self,
957 perpetuals: &'b solana_program::account_info::AccountInfo<'a>,
958 ) -> &mut Self {
959 self.instruction.perpetuals = Some(perpetuals);
960 self
961 }
962 #[inline(always)]
963 pub fn pool(&mut self, pool: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
964 self.instruction.pool = Some(pool);
965 self
966 }
967 #[inline(always)]
968 pub fn position(
969 &mut self,
970 position: &'b solana_program::account_info::AccountInfo<'a>,
971 ) -> &mut Self {
972 self.instruction.position = Some(position);
973 self
974 }
975 #[inline(always)]
976 pub fn custody(
977 &mut self,
978 custody: &'b solana_program::account_info::AccountInfo<'a>,
979 ) -> &mut Self {
980 self.instruction.custody = Some(custody);
981 self
982 }
983 #[inline(always)]
984 pub fn custody_doves_price_account(
985 &mut self,
986 custody_doves_price_account: &'b solana_program::account_info::AccountInfo<'a>,
987 ) -> &mut Self {
988 self.instruction.custody_doves_price_account = Some(custody_doves_price_account);
989 self
990 }
991 #[inline(always)]
992 pub fn collateral_custody(
993 &mut self,
994 collateral_custody: &'b solana_program::account_info::AccountInfo<'a>,
995 ) -> &mut Self {
996 self.instruction.collateral_custody = Some(collateral_custody);
997 self
998 }
999 #[inline(always)]
1000 pub fn collateral_custody_doves_price_account(
1001 &mut self,
1002 collateral_custody_doves_price_account: &'b solana_program::account_info::AccountInfo<'a>,
1003 ) -> &mut Self {
1004 self.instruction.collateral_custody_doves_price_account =
1005 Some(collateral_custody_doves_price_account);
1006 self
1007 }
1008 #[inline(always)]
1009 pub fn collateral_custody_token_account(
1010 &mut self,
1011 collateral_custody_token_account: &'b solana_program::account_info::AccountInfo<'a>,
1012 ) -> &mut Self {
1013 self.instruction.collateral_custody_token_account = Some(collateral_custody_token_account);
1014 self
1015 }
1016 #[inline(always)]
1017 pub fn desired_mint(
1018 &mut self,
1019 desired_mint: &'b solana_program::account_info::AccountInfo<'a>,
1020 ) -> &mut Self {
1021 self.instruction.desired_mint = Some(desired_mint);
1022 self
1023 }
1024 #[inline(always)]
1026 pub fn referral(
1027 &mut self,
1028 referral: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1029 ) -> &mut Self {
1030 self.instruction.referral = referral;
1031 self
1032 }
1033 #[inline(always)]
1034 pub fn position_request(
1035 &mut self,
1036 position_request: &'b solana_program::account_info::AccountInfo<'a>,
1037 ) -> &mut Self {
1038 self.instruction.position_request = Some(position_request);
1039 self
1040 }
1041 #[inline(always)]
1042 pub fn position_request_ata(
1043 &mut self,
1044 position_request_ata: &'b solana_program::account_info::AccountInfo<'a>,
1045 ) -> &mut Self {
1046 self.instruction.position_request_ata = Some(position_request_ata);
1047 self
1048 }
1049 #[inline(always)]
1050 pub fn token_program(
1051 &mut self,
1052 token_program: &'b solana_program::account_info::AccountInfo<'a>,
1053 ) -> &mut Self {
1054 self.instruction.token_program = Some(token_program);
1055 self
1056 }
1057 #[inline(always)]
1058 pub fn associated_token_program(
1059 &mut self,
1060 associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
1061 ) -> &mut Self {
1062 self.instruction.associated_token_program = Some(associated_token_program);
1063 self
1064 }
1065 #[inline(always)]
1066 pub fn system_program(
1067 &mut self,
1068 system_program: &'b solana_program::account_info::AccountInfo<'a>,
1069 ) -> &mut Self {
1070 self.instruction.system_program = Some(system_program);
1071 self
1072 }
1073 #[inline(always)]
1074 pub fn event_authority(
1075 &mut self,
1076 event_authority: &'b solana_program::account_info::AccountInfo<'a>,
1077 ) -> &mut Self {
1078 self.instruction.event_authority = Some(event_authority);
1079 self
1080 }
1081 #[inline(always)]
1082 pub fn program(
1083 &mut self,
1084 program: &'b solana_program::account_info::AccountInfo<'a>,
1085 ) -> &mut Self {
1086 self.instruction.program = Some(program);
1087 self
1088 }
1089 #[inline(always)]
1090 pub fn collateral_usd_delta(&mut self, collateral_usd_delta: u64) -> &mut Self {
1091 self.instruction.collateral_usd_delta = Some(collateral_usd_delta);
1092 self
1093 }
1094 #[inline(always)]
1095 pub fn size_usd_delta(&mut self, size_usd_delta: u64) -> &mut Self {
1096 self.instruction.size_usd_delta = Some(size_usd_delta);
1097 self
1098 }
1099 #[inline(always)]
1100 pub fn price_slippage(&mut self, price_slippage: u64) -> &mut Self {
1101 self.instruction.price_slippage = Some(price_slippage);
1102 self
1103 }
1104 #[inline(always)]
1106 pub fn entire_position(&mut self, entire_position: bool) -> &mut Self {
1107 self.instruction.entire_position = Some(entire_position);
1108 self
1109 }
1110 #[inline(always)]
1111 pub fn request_time(&mut self, request_time: i64) -> &mut Self {
1112 self.instruction.request_time = Some(request_time);
1113 self
1114 }
1115 #[inline(always)]
1116 pub fn counter(&mut self, counter: u64) -> &mut Self {
1117 self.instruction.counter = Some(counter);
1118 self
1119 }
1120 #[inline(always)]
1122 pub fn add_remaining_account(
1123 &mut self,
1124 account: &'b solana_program::account_info::AccountInfo<'a>,
1125 is_writable: bool,
1126 is_signer: bool,
1127 ) -> &mut Self {
1128 self.instruction
1129 .__remaining_accounts
1130 .push((account, is_writable, is_signer));
1131 self
1132 }
1133 #[inline(always)]
1138 pub fn add_remaining_accounts(
1139 &mut self,
1140 accounts: &[(
1141 &'b solana_program::account_info::AccountInfo<'a>,
1142 bool,
1143 bool,
1144 )],
1145 ) -> &mut Self {
1146 self.instruction
1147 .__remaining_accounts
1148 .extend_from_slice(accounts);
1149 self
1150 }
1151 #[inline(always)]
1152 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
1153 self.invoke_signed(&[])
1154 }
1155 #[allow(clippy::clone_on_copy)]
1156 #[allow(clippy::vec_init_then_push)]
1157 pub fn invoke_signed(
1158 &self,
1159 signers_seeds: &[&[&[u8]]],
1160 ) -> solana_program::entrypoint::ProgramResult {
1161 let args = InstantDecreasePosition2InstructionArgs {
1162 collateral_usd_delta: self
1163 .instruction
1164 .collateral_usd_delta
1165 .clone()
1166 .expect("collateral_usd_delta is not set"),
1167 size_usd_delta: self
1168 .instruction
1169 .size_usd_delta
1170 .clone()
1171 .expect("size_usd_delta is not set"),
1172 price_slippage: self
1173 .instruction
1174 .price_slippage
1175 .clone()
1176 .expect("price_slippage is not set"),
1177 entire_position: self.instruction.entire_position.clone(),
1178 request_time: self
1179 .instruction
1180 .request_time
1181 .clone()
1182 .expect("request_time is not set"),
1183 counter: self
1184 .instruction
1185 .counter
1186 .clone()
1187 .expect("counter is not set"),
1188 };
1189 let instruction = InstantDecreasePosition2Cpi {
1190 __program: self.instruction.__program,
1191
1192 keeper: self.instruction.keeper.expect("keeper is not set"),
1193
1194 api_keeper: self.instruction.api_keeper.expect("api_keeper is not set"),
1195
1196 owner: self.instruction.owner.expect("owner is not set"),
1197
1198 receiving_account: self
1199 .instruction
1200 .receiving_account
1201 .expect("receiving_account is not set"),
1202
1203 transfer_authority: self
1204 .instruction
1205 .transfer_authority
1206 .expect("transfer_authority is not set"),
1207
1208 perpetuals: self.instruction.perpetuals.expect("perpetuals is not set"),
1209
1210 pool: self.instruction.pool.expect("pool is not set"),
1211
1212 position: self.instruction.position.expect("position is not set"),
1213
1214 custody: self.instruction.custody.expect("custody is not set"),
1215
1216 custody_doves_price_account: self
1217 .instruction
1218 .custody_doves_price_account
1219 .expect("custody_doves_price_account is not set"),
1220
1221 collateral_custody: self
1222 .instruction
1223 .collateral_custody
1224 .expect("collateral_custody is not set"),
1225
1226 collateral_custody_doves_price_account: self
1227 .instruction
1228 .collateral_custody_doves_price_account
1229 .expect("collateral_custody_doves_price_account is not set"),
1230
1231 collateral_custody_token_account: self
1232 .instruction
1233 .collateral_custody_token_account
1234 .expect("collateral_custody_token_account is not set"),
1235
1236 desired_mint: self
1237 .instruction
1238 .desired_mint
1239 .expect("desired_mint is not set"),
1240
1241 referral: self.instruction.referral,
1242
1243 position_request: self
1244 .instruction
1245 .position_request
1246 .expect("position_request is not set"),
1247
1248 position_request_ata: self
1249 .instruction
1250 .position_request_ata
1251 .expect("position_request_ata is not set"),
1252
1253 token_program: self
1254 .instruction
1255 .token_program
1256 .expect("token_program is not set"),
1257
1258 associated_token_program: self
1259 .instruction
1260 .associated_token_program
1261 .expect("associated_token_program is not set"),
1262
1263 system_program: self
1264 .instruction
1265 .system_program
1266 .expect("system_program is not set"),
1267
1268 event_authority: self
1269 .instruction
1270 .event_authority
1271 .expect("event_authority is not set"),
1272
1273 program: self.instruction.program.expect("program is not set"),
1274 __args: args,
1275 };
1276 instruction.invoke_signed_with_remaining_accounts(
1277 signers_seeds,
1278 &self.instruction.__remaining_accounts,
1279 )
1280 }
1281}
1282
1283#[derive(Clone, Debug)]
1284struct InstantDecreasePosition2CpiBuilderInstruction<'a, 'b> {
1285 __program: &'b solana_program::account_info::AccountInfo<'a>,
1286 keeper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1287 api_keeper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1288 owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1289 receiving_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1290 transfer_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1291 perpetuals: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1292 pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1293 position: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1294 custody: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1295 custody_doves_price_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1296 collateral_custody: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1297 collateral_custody_doves_price_account:
1298 Option<&'b solana_program::account_info::AccountInfo<'a>>,
1299 collateral_custody_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1300 desired_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1301 referral: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1302 position_request: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1303 position_request_ata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1304 token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1305 associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1306 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1307 event_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1308 program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1309 collateral_usd_delta: Option<u64>,
1310 size_usd_delta: Option<u64>,
1311 price_slippage: Option<u64>,
1312 entire_position: Option<bool>,
1313 request_time: Option<i64>,
1314 counter: Option<u64>,
1315 __remaining_accounts: Vec<(
1317 &'b solana_program::account_info::AccountInfo<'a>,
1318 bool,
1319 bool,
1320 )>,
1321}