Skip to main content

jup_perps_client/instructions/
create_increase_position_market_request.rs

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