1use borsh::{BorshDeserialize, BorshSerialize};
9
10pub const CREATE_DECREASE_POSITION_MARKET_REQUEST_DISCRIMINATOR: [u8; 8] =
11 [74, 198, 195, 86, 193, 99, 1, 79];
12
13#[derive(Debug)]
15pub struct CreateDecreasePositionMarketRequest {
16 pub owner: solana_program::pubkey::Pubkey,
17
18 pub receiving_account: solana_program::pubkey::Pubkey,
19
20 pub perpetuals: solana_program::pubkey::Pubkey,
21
22 pub pool: solana_program::pubkey::Pubkey,
23
24 pub position: solana_program::pubkey::Pubkey,
25
26 pub position_request: solana_program::pubkey::Pubkey,
27
28 pub position_request_ata: solana_program::pubkey::Pubkey,
29
30 pub custody: solana_program::pubkey::Pubkey,
31
32 pub collateral_custody: solana_program::pubkey::Pubkey,
33
34 pub desired_mint: solana_program::pubkey::Pubkey,
35
36 pub referral: Option<solana_program::pubkey::Pubkey>,
37
38 pub token_program: solana_program::pubkey::Pubkey,
39
40 pub associated_token_program: solana_program::pubkey::Pubkey,
41
42 pub system_program: solana_program::pubkey::Pubkey,
43
44 pub event_authority: solana_program::pubkey::Pubkey,
45
46 pub program: solana_program::pubkey::Pubkey,
47}
48
49impl CreateDecreasePositionMarketRequest {
50 pub fn instruction(
51 &self,
52 args: CreateDecreasePositionMarketRequestInstructionArgs,
53 ) -> solana_program::instruction::Instruction {
54 self.instruction_with_remaining_accounts(args, &[])
55 }
56 #[allow(clippy::arithmetic_side_effects)]
57 #[allow(clippy::vec_init_then_push)]
58 pub fn instruction_with_remaining_accounts(
59 &self,
60 args: CreateDecreasePositionMarketRequestInstructionArgs,
61 remaining_accounts: &[solana_program::instruction::AccountMeta],
62 ) -> solana_program::instruction::Instruction {
63 let mut accounts = Vec::with_capacity(16 + remaining_accounts.len());
64 accounts.push(solana_program::instruction::AccountMeta::new(
65 self.owner, true,
66 ));
67 accounts.push(solana_program::instruction::AccountMeta::new(
68 self.receiving_account,
69 false,
70 ));
71 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
72 self.perpetuals,
73 false,
74 ));
75 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
76 self.pool, false,
77 ));
78 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
79 self.position,
80 false,
81 ));
82 accounts.push(solana_program::instruction::AccountMeta::new(
83 self.position_request,
84 false,
85 ));
86 accounts.push(solana_program::instruction::AccountMeta::new(
87 self.position_request_ata,
88 false,
89 ));
90 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
91 self.custody,
92 false,
93 ));
94 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
95 self.collateral_custody,
96 false,
97 ));
98 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
99 self.desired_mint,
100 false,
101 ));
102 if let Some(referral) = self.referral {
103 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
104 referral, false,
105 ));
106 } else {
107 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
108 crate::PERPETUALS_ID,
109 false,
110 ));
111 }
112 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
113 self.token_program,
114 false,
115 ));
116 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
117 self.associated_token_program,
118 false,
119 ));
120 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
121 self.system_program,
122 false,
123 ));
124 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
125 self.event_authority,
126 false,
127 ));
128 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
129 self.program,
130 false,
131 ));
132 accounts.extend_from_slice(remaining_accounts);
133 let mut data =
134 borsh::to_vec(&CreateDecreasePositionMarketRequestInstructionData::new()).unwrap();
135 let mut args = borsh::to_vec(&args).unwrap();
136 data.append(&mut args);
137
138 solana_program::instruction::Instruction {
139 program_id: crate::PERPETUALS_ID,
140 accounts,
141 data,
142 }
143 }
144}
145
146#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)]
147#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
148pub struct CreateDecreasePositionMarketRequestInstructionData {
149 discriminator: [u8; 8],
150}
151
152impl CreateDecreasePositionMarketRequestInstructionData {
153 pub fn new() -> Self {
154 Self {
155 discriminator: [74, 198, 195, 86, 193, 99, 1, 79],
156 }
157 }
158}
159
160impl Default for CreateDecreasePositionMarketRequestInstructionData {
161 fn default() -> Self {
162 Self::new()
163 }
164}
165
166#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)]
167#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
168pub struct CreateDecreasePositionMarketRequestInstructionArgs {
169 pub collateral_usd_delta: u64,
170 pub size_usd_delta: u64,
171 pub price_slippage: u64,
172 pub jupiter_minimum_out: Option<u64>,
173 pub entire_position: Option<bool>,
174 pub counter: u64,
175}
176
177#[derive(Clone, Debug, Default)]
198pub struct CreateDecreasePositionMarketRequestBuilder {
199 owner: Option<solana_program::pubkey::Pubkey>,
200 receiving_account: Option<solana_program::pubkey::Pubkey>,
201 perpetuals: Option<solana_program::pubkey::Pubkey>,
202 pool: Option<solana_program::pubkey::Pubkey>,
203 position: Option<solana_program::pubkey::Pubkey>,
204 position_request: Option<solana_program::pubkey::Pubkey>,
205 position_request_ata: Option<solana_program::pubkey::Pubkey>,
206 custody: Option<solana_program::pubkey::Pubkey>,
207 collateral_custody: Option<solana_program::pubkey::Pubkey>,
208 desired_mint: Option<solana_program::pubkey::Pubkey>,
209 referral: Option<solana_program::pubkey::Pubkey>,
210 token_program: Option<solana_program::pubkey::Pubkey>,
211 associated_token_program: Option<solana_program::pubkey::Pubkey>,
212 system_program: Option<solana_program::pubkey::Pubkey>,
213 event_authority: Option<solana_program::pubkey::Pubkey>,
214 program: Option<solana_program::pubkey::Pubkey>,
215 collateral_usd_delta: Option<u64>,
216 size_usd_delta: Option<u64>,
217 price_slippage: Option<u64>,
218 jupiter_minimum_out: Option<u64>,
219 entire_position: Option<bool>,
220 counter: Option<u64>,
221 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
222}
223
224impl CreateDecreasePositionMarketRequestBuilder {
225 pub fn new() -> Self {
226 Self::default()
227 }
228 #[inline(always)]
229 pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self {
230 self.owner = Some(owner);
231 self
232 }
233 #[inline(always)]
234 pub fn receiving_account(
235 &mut self,
236 receiving_account: solana_program::pubkey::Pubkey,
237 ) -> &mut Self {
238 self.receiving_account = Some(receiving_account);
239 self
240 }
241 #[inline(always)]
242 pub fn perpetuals(&mut self, perpetuals: solana_program::pubkey::Pubkey) -> &mut Self {
243 self.perpetuals = Some(perpetuals);
244 self
245 }
246 #[inline(always)]
247 pub fn pool(&mut self, pool: solana_program::pubkey::Pubkey) -> &mut Self {
248 self.pool = Some(pool);
249 self
250 }
251 #[inline(always)]
252 pub fn position(&mut self, position: solana_program::pubkey::Pubkey) -> &mut Self {
253 self.position = Some(position);
254 self
255 }
256 #[inline(always)]
257 pub fn position_request(
258 &mut self,
259 position_request: solana_program::pubkey::Pubkey,
260 ) -> &mut Self {
261 self.position_request = Some(position_request);
262 self
263 }
264 #[inline(always)]
265 pub fn position_request_ata(
266 &mut self,
267 position_request_ata: solana_program::pubkey::Pubkey,
268 ) -> &mut Self {
269 self.position_request_ata = Some(position_request_ata);
270 self
271 }
272 #[inline(always)]
273 pub fn custody(&mut self, custody: solana_program::pubkey::Pubkey) -> &mut Self {
274 self.custody = Some(custody);
275 self
276 }
277 #[inline(always)]
278 pub fn collateral_custody(
279 &mut self,
280 collateral_custody: solana_program::pubkey::Pubkey,
281 ) -> &mut Self {
282 self.collateral_custody = Some(collateral_custody);
283 self
284 }
285 #[inline(always)]
286 pub fn desired_mint(&mut self, desired_mint: solana_program::pubkey::Pubkey) -> &mut Self {
287 self.desired_mint = Some(desired_mint);
288 self
289 }
290 #[inline(always)]
292 pub fn referral(&mut self, referral: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
293 self.referral = referral;
294 self
295 }
296 #[inline(always)]
298 pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
299 self.token_program = Some(token_program);
300 self
301 }
302 #[inline(always)]
303 pub fn associated_token_program(
304 &mut self,
305 associated_token_program: solana_program::pubkey::Pubkey,
306 ) -> &mut Self {
307 self.associated_token_program = Some(associated_token_program);
308 self
309 }
310 #[inline(always)]
312 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
313 self.system_program = Some(system_program);
314 self
315 }
316 #[inline(always)]
317 pub fn event_authority(
318 &mut self,
319 event_authority: solana_program::pubkey::Pubkey,
320 ) -> &mut Self {
321 self.event_authority = Some(event_authority);
322 self
323 }
324 #[inline(always)]
325 pub fn program(&mut self, program: solana_program::pubkey::Pubkey) -> &mut Self {
326 self.program = Some(program);
327 self
328 }
329 #[inline(always)]
330 pub fn collateral_usd_delta(&mut self, collateral_usd_delta: u64) -> &mut Self {
331 self.collateral_usd_delta = Some(collateral_usd_delta);
332 self
333 }
334 #[inline(always)]
335 pub fn size_usd_delta(&mut self, size_usd_delta: u64) -> &mut Self {
336 self.size_usd_delta = Some(size_usd_delta);
337 self
338 }
339 #[inline(always)]
340 pub fn price_slippage(&mut self, price_slippage: u64) -> &mut Self {
341 self.price_slippage = Some(price_slippage);
342 self
343 }
344 #[inline(always)]
346 pub fn jupiter_minimum_out(&mut self, jupiter_minimum_out: u64) -> &mut Self {
347 self.jupiter_minimum_out = Some(jupiter_minimum_out);
348 self
349 }
350 #[inline(always)]
352 pub fn entire_position(&mut self, entire_position: bool) -> &mut Self {
353 self.entire_position = Some(entire_position);
354 self
355 }
356 #[inline(always)]
357 pub fn counter(&mut self, counter: u64) -> &mut Self {
358 self.counter = Some(counter);
359 self
360 }
361 #[inline(always)]
363 pub fn add_remaining_account(
364 &mut self,
365 account: solana_program::instruction::AccountMeta,
366 ) -> &mut Self {
367 self.__remaining_accounts.push(account);
368 self
369 }
370 #[inline(always)]
372 pub fn add_remaining_accounts(
373 &mut self,
374 accounts: &[solana_program::instruction::AccountMeta],
375 ) -> &mut Self {
376 self.__remaining_accounts.extend_from_slice(accounts);
377 self
378 }
379 #[allow(clippy::clone_on_copy)]
380 pub fn instruction(&self) -> solana_program::instruction::Instruction {
381 let accounts = CreateDecreasePositionMarketRequest {
382 owner: self.owner.expect("owner is not set"),
383 receiving_account: self
384 .receiving_account
385 .expect("receiving_account is not set"),
386 perpetuals: self.perpetuals.expect("perpetuals is not set"),
387 pool: self.pool.expect("pool is not set"),
388 position: self.position.expect("position is not set"),
389 position_request: self.position_request.expect("position_request is not set"),
390 position_request_ata: self
391 .position_request_ata
392 .expect("position_request_ata is not set"),
393 custody: self.custody.expect("custody is not set"),
394 collateral_custody: self
395 .collateral_custody
396 .expect("collateral_custody is not set"),
397 desired_mint: self.desired_mint.expect("desired_mint is not set"),
398 referral: self.referral,
399 token_program: self.token_program.unwrap_or(solana_program::pubkey!(
400 "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
401 )),
402 associated_token_program: self
403 .associated_token_program
404 .expect("associated_token_program is not set"),
405 system_program: self
406 .system_program
407 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
408 event_authority: self.event_authority.expect("event_authority is not set"),
409 program: self.program.expect("program is not set"),
410 };
411 let args = CreateDecreasePositionMarketRequestInstructionArgs {
412 collateral_usd_delta: self
413 .collateral_usd_delta
414 .clone()
415 .expect("collateral_usd_delta is not set"),
416 size_usd_delta: self
417 .size_usd_delta
418 .clone()
419 .expect("size_usd_delta is not set"),
420 price_slippage: self
421 .price_slippage
422 .clone()
423 .expect("price_slippage is not set"),
424 jupiter_minimum_out: self.jupiter_minimum_out.clone(),
425 entire_position: self.entire_position.clone(),
426 counter: self.counter.clone().expect("counter is not set"),
427 };
428
429 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
430 }
431}
432
433pub struct CreateDecreasePositionMarketRequestCpiAccounts<'a, 'b> {
435 pub owner: &'b solana_program::account_info::AccountInfo<'a>,
436
437 pub receiving_account: &'b solana_program::account_info::AccountInfo<'a>,
438
439 pub perpetuals: &'b solana_program::account_info::AccountInfo<'a>,
440
441 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
442
443 pub position: &'b solana_program::account_info::AccountInfo<'a>,
444
445 pub position_request: &'b solana_program::account_info::AccountInfo<'a>,
446
447 pub position_request_ata: &'b solana_program::account_info::AccountInfo<'a>,
448
449 pub custody: &'b solana_program::account_info::AccountInfo<'a>,
450
451 pub collateral_custody: &'b solana_program::account_info::AccountInfo<'a>,
452
453 pub desired_mint: &'b solana_program::account_info::AccountInfo<'a>,
454
455 pub referral: Option<&'b solana_program::account_info::AccountInfo<'a>>,
456
457 pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
458
459 pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
460
461 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
462
463 pub event_authority: &'b solana_program::account_info::AccountInfo<'a>,
464
465 pub program: &'b solana_program::account_info::AccountInfo<'a>,
466}
467
468pub struct CreateDecreasePositionMarketRequestCpi<'a, 'b> {
470 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
472
473 pub owner: &'b solana_program::account_info::AccountInfo<'a>,
474
475 pub receiving_account: &'b solana_program::account_info::AccountInfo<'a>,
476
477 pub perpetuals: &'b solana_program::account_info::AccountInfo<'a>,
478
479 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
480
481 pub position: &'b solana_program::account_info::AccountInfo<'a>,
482
483 pub position_request: &'b solana_program::account_info::AccountInfo<'a>,
484
485 pub position_request_ata: &'b solana_program::account_info::AccountInfo<'a>,
486
487 pub custody: &'b solana_program::account_info::AccountInfo<'a>,
488
489 pub collateral_custody: &'b solana_program::account_info::AccountInfo<'a>,
490
491 pub desired_mint: &'b solana_program::account_info::AccountInfo<'a>,
492
493 pub referral: Option<&'b solana_program::account_info::AccountInfo<'a>>,
494
495 pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
496
497 pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
498
499 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
500
501 pub event_authority: &'b solana_program::account_info::AccountInfo<'a>,
502
503 pub program: &'b solana_program::account_info::AccountInfo<'a>,
504 pub __args: CreateDecreasePositionMarketRequestInstructionArgs,
506}
507
508impl<'a, 'b> CreateDecreasePositionMarketRequestCpi<'a, 'b> {
509 pub fn new(
510 program: &'b solana_program::account_info::AccountInfo<'a>,
511 accounts: CreateDecreasePositionMarketRequestCpiAccounts<'a, 'b>,
512 args: CreateDecreasePositionMarketRequestInstructionArgs,
513 ) -> Self {
514 Self {
515 __program: program,
516 owner: accounts.owner,
517 receiving_account: accounts.receiving_account,
518 perpetuals: accounts.perpetuals,
519 pool: accounts.pool,
520 position: accounts.position,
521 position_request: accounts.position_request,
522 position_request_ata: accounts.position_request_ata,
523 custody: accounts.custody,
524 collateral_custody: accounts.collateral_custody,
525 desired_mint: accounts.desired_mint,
526 referral: accounts.referral,
527 token_program: accounts.token_program,
528 associated_token_program: accounts.associated_token_program,
529 system_program: accounts.system_program,
530 event_authority: accounts.event_authority,
531 program: accounts.program,
532 __args: args,
533 }
534 }
535 #[inline(always)]
536 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
537 self.invoke_signed_with_remaining_accounts(&[], &[])
538 }
539 #[inline(always)]
540 pub fn invoke_with_remaining_accounts(
541 &self,
542 remaining_accounts: &[(
543 &'b solana_program::account_info::AccountInfo<'a>,
544 bool,
545 bool,
546 )],
547 ) -> solana_program::entrypoint::ProgramResult {
548 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
549 }
550 #[inline(always)]
551 pub fn invoke_signed(
552 &self,
553 signers_seeds: &[&[&[u8]]],
554 ) -> solana_program::entrypoint::ProgramResult {
555 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
556 }
557 #[allow(clippy::arithmetic_side_effects)]
558 #[allow(clippy::clone_on_copy)]
559 #[allow(clippy::vec_init_then_push)]
560 pub fn invoke_signed_with_remaining_accounts(
561 &self,
562 signers_seeds: &[&[&[u8]]],
563 remaining_accounts: &[(
564 &'b solana_program::account_info::AccountInfo<'a>,
565 bool,
566 bool,
567 )],
568 ) -> solana_program::entrypoint::ProgramResult {
569 let mut accounts = Vec::with_capacity(16 + remaining_accounts.len());
570 accounts.push(solana_program::instruction::AccountMeta::new(
571 *self.owner.key,
572 true,
573 ));
574 accounts.push(solana_program::instruction::AccountMeta::new(
575 *self.receiving_account.key,
576 false,
577 ));
578 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
579 *self.perpetuals.key,
580 false,
581 ));
582 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
583 *self.pool.key,
584 false,
585 ));
586 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
587 *self.position.key,
588 false,
589 ));
590 accounts.push(solana_program::instruction::AccountMeta::new(
591 *self.position_request.key,
592 false,
593 ));
594 accounts.push(solana_program::instruction::AccountMeta::new(
595 *self.position_request_ata.key,
596 false,
597 ));
598 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
599 *self.custody.key,
600 false,
601 ));
602 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
603 *self.collateral_custody.key,
604 false,
605 ));
606 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
607 *self.desired_mint.key,
608 false,
609 ));
610 if let Some(referral) = self.referral {
611 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
612 *referral.key,
613 false,
614 ));
615 } else {
616 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
617 crate::PERPETUALS_ID,
618 false,
619 ));
620 }
621 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
622 *self.token_program.key,
623 false,
624 ));
625 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
626 *self.associated_token_program.key,
627 false,
628 ));
629 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
630 *self.system_program.key,
631 false,
632 ));
633 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
634 *self.event_authority.key,
635 false,
636 ));
637 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
638 *self.program.key,
639 false,
640 ));
641 remaining_accounts.iter().for_each(|remaining_account| {
642 accounts.push(solana_program::instruction::AccountMeta {
643 pubkey: *remaining_account.0.key,
644 is_signer: remaining_account.1,
645 is_writable: remaining_account.2,
646 })
647 });
648 let mut data =
649 borsh::to_vec(&CreateDecreasePositionMarketRequestInstructionData::new()).unwrap();
650 let mut args = borsh::to_vec(&self.__args).unwrap();
651 data.append(&mut args);
652
653 let instruction = solana_program::instruction::Instruction {
654 program_id: crate::PERPETUALS_ID,
655 accounts,
656 data,
657 };
658 let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len());
659 account_infos.push(self.__program.clone());
660 account_infos.push(self.owner.clone());
661 account_infos.push(self.receiving_account.clone());
662 account_infos.push(self.perpetuals.clone());
663 account_infos.push(self.pool.clone());
664 account_infos.push(self.position.clone());
665 account_infos.push(self.position_request.clone());
666 account_infos.push(self.position_request_ata.clone());
667 account_infos.push(self.custody.clone());
668 account_infos.push(self.collateral_custody.clone());
669 account_infos.push(self.desired_mint.clone());
670 if let Some(referral) = self.referral {
671 account_infos.push(referral.clone());
672 }
673 account_infos.push(self.token_program.clone());
674 account_infos.push(self.associated_token_program.clone());
675 account_infos.push(self.system_program.clone());
676 account_infos.push(self.event_authority.clone());
677 account_infos.push(self.program.clone());
678 remaining_accounts
679 .iter()
680 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
681
682 if signers_seeds.is_empty() {
683 solana_program::program::invoke(&instruction, &account_infos)
684 } else {
685 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
686 }
687 }
688}
689
690#[derive(Clone, Debug)]
711pub struct CreateDecreasePositionMarketRequestCpiBuilder<'a, 'b> {
712 instruction: Box<CreateDecreasePositionMarketRequestCpiBuilderInstruction<'a, 'b>>,
713}
714
715impl<'a, 'b> CreateDecreasePositionMarketRequestCpiBuilder<'a, 'b> {
716 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
717 let instruction = Box::new(CreateDecreasePositionMarketRequestCpiBuilderInstruction {
718 __program: program,
719 owner: None,
720 receiving_account: None,
721 perpetuals: None,
722 pool: None,
723 position: None,
724 position_request: None,
725 position_request_ata: None,
726 custody: None,
727 collateral_custody: None,
728 desired_mint: None,
729 referral: None,
730 token_program: None,
731 associated_token_program: None,
732 system_program: None,
733 event_authority: None,
734 program: None,
735 collateral_usd_delta: None,
736 size_usd_delta: None,
737 price_slippage: None,
738 jupiter_minimum_out: None,
739 entire_position: None,
740 counter: None,
741 __remaining_accounts: Vec::new(),
742 });
743 Self { instruction }
744 }
745 #[inline(always)]
746 pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
747 self.instruction.owner = Some(owner);
748 self
749 }
750 #[inline(always)]
751 pub fn receiving_account(
752 &mut self,
753 receiving_account: &'b solana_program::account_info::AccountInfo<'a>,
754 ) -> &mut Self {
755 self.instruction.receiving_account = Some(receiving_account);
756 self
757 }
758 #[inline(always)]
759 pub fn perpetuals(
760 &mut self,
761 perpetuals: &'b solana_program::account_info::AccountInfo<'a>,
762 ) -> &mut Self {
763 self.instruction.perpetuals = Some(perpetuals);
764 self
765 }
766 #[inline(always)]
767 pub fn pool(&mut self, pool: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
768 self.instruction.pool = Some(pool);
769 self
770 }
771 #[inline(always)]
772 pub fn position(
773 &mut self,
774 position: &'b solana_program::account_info::AccountInfo<'a>,
775 ) -> &mut Self {
776 self.instruction.position = Some(position);
777 self
778 }
779 #[inline(always)]
780 pub fn position_request(
781 &mut self,
782 position_request: &'b solana_program::account_info::AccountInfo<'a>,
783 ) -> &mut Self {
784 self.instruction.position_request = Some(position_request);
785 self
786 }
787 #[inline(always)]
788 pub fn position_request_ata(
789 &mut self,
790 position_request_ata: &'b solana_program::account_info::AccountInfo<'a>,
791 ) -> &mut Self {
792 self.instruction.position_request_ata = Some(position_request_ata);
793 self
794 }
795 #[inline(always)]
796 pub fn custody(
797 &mut self,
798 custody: &'b solana_program::account_info::AccountInfo<'a>,
799 ) -> &mut Self {
800 self.instruction.custody = Some(custody);
801 self
802 }
803 #[inline(always)]
804 pub fn collateral_custody(
805 &mut self,
806 collateral_custody: &'b solana_program::account_info::AccountInfo<'a>,
807 ) -> &mut Self {
808 self.instruction.collateral_custody = Some(collateral_custody);
809 self
810 }
811 #[inline(always)]
812 pub fn desired_mint(
813 &mut self,
814 desired_mint: &'b solana_program::account_info::AccountInfo<'a>,
815 ) -> &mut Self {
816 self.instruction.desired_mint = Some(desired_mint);
817 self
818 }
819 #[inline(always)]
821 pub fn referral(
822 &mut self,
823 referral: Option<&'b solana_program::account_info::AccountInfo<'a>>,
824 ) -> &mut Self {
825 self.instruction.referral = referral;
826 self
827 }
828 #[inline(always)]
829 pub fn token_program(
830 &mut self,
831 token_program: &'b solana_program::account_info::AccountInfo<'a>,
832 ) -> &mut Self {
833 self.instruction.token_program = Some(token_program);
834 self
835 }
836 #[inline(always)]
837 pub fn associated_token_program(
838 &mut self,
839 associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
840 ) -> &mut Self {
841 self.instruction.associated_token_program = Some(associated_token_program);
842 self
843 }
844 #[inline(always)]
845 pub fn system_program(
846 &mut self,
847 system_program: &'b solana_program::account_info::AccountInfo<'a>,
848 ) -> &mut Self {
849 self.instruction.system_program = Some(system_program);
850 self
851 }
852 #[inline(always)]
853 pub fn event_authority(
854 &mut self,
855 event_authority: &'b solana_program::account_info::AccountInfo<'a>,
856 ) -> &mut Self {
857 self.instruction.event_authority = Some(event_authority);
858 self
859 }
860 #[inline(always)]
861 pub fn program(
862 &mut self,
863 program: &'b solana_program::account_info::AccountInfo<'a>,
864 ) -> &mut Self {
865 self.instruction.program = Some(program);
866 self
867 }
868 #[inline(always)]
869 pub fn collateral_usd_delta(&mut self, collateral_usd_delta: u64) -> &mut Self {
870 self.instruction.collateral_usd_delta = Some(collateral_usd_delta);
871 self
872 }
873 #[inline(always)]
874 pub fn size_usd_delta(&mut self, size_usd_delta: u64) -> &mut Self {
875 self.instruction.size_usd_delta = Some(size_usd_delta);
876 self
877 }
878 #[inline(always)]
879 pub fn price_slippage(&mut self, price_slippage: u64) -> &mut Self {
880 self.instruction.price_slippage = Some(price_slippage);
881 self
882 }
883 #[inline(always)]
885 pub fn jupiter_minimum_out(&mut self, jupiter_minimum_out: u64) -> &mut Self {
886 self.instruction.jupiter_minimum_out = Some(jupiter_minimum_out);
887 self
888 }
889 #[inline(always)]
891 pub fn entire_position(&mut self, entire_position: bool) -> &mut Self {
892 self.instruction.entire_position = Some(entire_position);
893 self
894 }
895 #[inline(always)]
896 pub fn counter(&mut self, counter: u64) -> &mut Self {
897 self.instruction.counter = Some(counter);
898 self
899 }
900 #[inline(always)]
902 pub fn add_remaining_account(
903 &mut self,
904 account: &'b solana_program::account_info::AccountInfo<'a>,
905 is_writable: bool,
906 is_signer: bool,
907 ) -> &mut Self {
908 self.instruction
909 .__remaining_accounts
910 .push((account, is_writable, is_signer));
911 self
912 }
913 #[inline(always)]
918 pub fn add_remaining_accounts(
919 &mut self,
920 accounts: &[(
921 &'b solana_program::account_info::AccountInfo<'a>,
922 bool,
923 bool,
924 )],
925 ) -> &mut Self {
926 self.instruction
927 .__remaining_accounts
928 .extend_from_slice(accounts);
929 self
930 }
931 #[inline(always)]
932 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
933 self.invoke_signed(&[])
934 }
935 #[allow(clippy::clone_on_copy)]
936 #[allow(clippy::vec_init_then_push)]
937 pub fn invoke_signed(
938 &self,
939 signers_seeds: &[&[&[u8]]],
940 ) -> solana_program::entrypoint::ProgramResult {
941 let args = CreateDecreasePositionMarketRequestInstructionArgs {
942 collateral_usd_delta: self
943 .instruction
944 .collateral_usd_delta
945 .clone()
946 .expect("collateral_usd_delta is not set"),
947 size_usd_delta: self
948 .instruction
949 .size_usd_delta
950 .clone()
951 .expect("size_usd_delta is not set"),
952 price_slippage: self
953 .instruction
954 .price_slippage
955 .clone()
956 .expect("price_slippage is not set"),
957 jupiter_minimum_out: self.instruction.jupiter_minimum_out.clone(),
958 entire_position: self.instruction.entire_position.clone(),
959 counter: self
960 .instruction
961 .counter
962 .clone()
963 .expect("counter is not set"),
964 };
965 let instruction = CreateDecreasePositionMarketRequestCpi {
966 __program: self.instruction.__program,
967
968 owner: self.instruction.owner.expect("owner is not set"),
969
970 receiving_account: self
971 .instruction
972 .receiving_account
973 .expect("receiving_account is not set"),
974
975 perpetuals: self.instruction.perpetuals.expect("perpetuals is not set"),
976
977 pool: self.instruction.pool.expect("pool is not set"),
978
979 position: self.instruction.position.expect("position is not set"),
980
981 position_request: self
982 .instruction
983 .position_request
984 .expect("position_request is not set"),
985
986 position_request_ata: self
987 .instruction
988 .position_request_ata
989 .expect("position_request_ata is not set"),
990
991 custody: self.instruction.custody.expect("custody is not set"),
992
993 collateral_custody: self
994 .instruction
995 .collateral_custody
996 .expect("collateral_custody is not set"),
997
998 desired_mint: self
999 .instruction
1000 .desired_mint
1001 .expect("desired_mint is not set"),
1002
1003 referral: self.instruction.referral,
1004
1005 token_program: self
1006 .instruction
1007 .token_program
1008 .expect("token_program is not set"),
1009
1010 associated_token_program: self
1011 .instruction
1012 .associated_token_program
1013 .expect("associated_token_program is not set"),
1014
1015 system_program: self
1016 .instruction
1017 .system_program
1018 .expect("system_program is not set"),
1019
1020 event_authority: self
1021 .instruction
1022 .event_authority
1023 .expect("event_authority is not set"),
1024
1025 program: self.instruction.program.expect("program is not set"),
1026 __args: args,
1027 };
1028 instruction.invoke_signed_with_remaining_accounts(
1029 signers_seeds,
1030 &self.instruction.__remaining_accounts,
1031 )
1032 }
1033}
1034
1035#[derive(Clone, Debug)]
1036struct CreateDecreasePositionMarketRequestCpiBuilderInstruction<'a, 'b> {
1037 __program: &'b solana_program::account_info::AccountInfo<'a>,
1038 owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1039 receiving_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1040 perpetuals: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1041 pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1042 position: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1043 position_request: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1044 position_request_ata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1045 custody: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1046 collateral_custody: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1047 desired_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1048 referral: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1049 token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1050 associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1051 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1052 event_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1053 program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1054 collateral_usd_delta: Option<u64>,
1055 size_usd_delta: Option<u64>,
1056 price_slippage: Option<u64>,
1057 jupiter_minimum_out: Option<u64>,
1058 entire_position: Option<bool>,
1059 counter: Option<u64>,
1060 __remaining_accounts: Vec<(
1062 &'b solana_program::account_info::AccountInfo<'a>,
1063 bool,
1064 bool,
1065 )>,
1066}