Skip to main content

jup_perps_client/instructions/
close_position_request2.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 borsh::{BorshDeserialize, BorshSerialize};
9
10pub const CLOSE_POSITION_REQUEST2_DISCRIMINATOR: [u8; 8] = [121, 68, 162, 28, 216, 47, 200, 66];
11
12/// Accounts.
13#[derive(Debug)]
14pub struct ClosePositionRequest2 {
15    pub keeper: Option<solana_program::pubkey::Pubkey>,
16
17    pub owner: solana_program::pubkey::Pubkey,
18
19    pub owner_ata: solana_program::pubkey::Pubkey,
20
21    pub pool: solana_program::pubkey::Pubkey,
22
23    pub position_request: solana_program::pubkey::Pubkey,
24
25    pub position_request_ata: solana_program::pubkey::Pubkey,
26
27    pub position: solana_program::pubkey::Pubkey,
28
29    pub mint: solana_program::pubkey::Pubkey,
30
31    pub token_program: solana_program::pubkey::Pubkey,
32
33    pub system_program: solana_program::pubkey::Pubkey,
34
35    pub associated_token_program: solana_program::pubkey::Pubkey,
36
37    pub event_authority: solana_program::pubkey::Pubkey,
38
39    pub program: solana_program::pubkey::Pubkey,
40}
41
42impl ClosePositionRequest2 {
43    pub fn instruction(&self) -> solana_program::instruction::Instruction {
44        self.instruction_with_remaining_accounts(&[])
45    }
46    #[allow(clippy::arithmetic_side_effects)]
47    #[allow(clippy::vec_init_then_push)]
48    pub fn instruction_with_remaining_accounts(
49        &self,
50        remaining_accounts: &[solana_program::instruction::AccountMeta],
51    ) -> solana_program::instruction::Instruction {
52        let mut accounts = Vec::with_capacity(13 + remaining_accounts.len());
53        if let Some(keeper) = self.keeper {
54            accounts.push(solana_program::instruction::AccountMeta::new(keeper, true));
55        } else {
56            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
57                crate::PERPETUALS_ID,
58                false,
59            ));
60        }
61        accounts.push(solana_program::instruction::AccountMeta::new(
62            self.owner, false,
63        ));
64        accounts.push(solana_program::instruction::AccountMeta::new(
65            self.owner_ata,
66            false,
67        ));
68        accounts.push(solana_program::instruction::AccountMeta::new(
69            self.pool, false,
70        ));
71        accounts.push(solana_program::instruction::AccountMeta::new(
72            self.position_request,
73            false,
74        ));
75        accounts.push(solana_program::instruction::AccountMeta::new(
76            self.position_request_ata,
77            false,
78        ));
79        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
80            self.position,
81            false,
82        ));
83        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
84            self.mint, false,
85        ));
86        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
87            self.token_program,
88            false,
89        ));
90        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
91            self.system_program,
92            false,
93        ));
94        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
95            self.associated_token_program,
96            false,
97        ));
98        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
99            self.event_authority,
100            false,
101        ));
102        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
103            self.program,
104            false,
105        ));
106        accounts.extend_from_slice(remaining_accounts);
107        let data = borsh::to_vec(&ClosePositionRequest2InstructionData::new()).unwrap();
108
109        solana_program::instruction::Instruction {
110            program_id: crate::PERPETUALS_ID,
111            accounts,
112            data,
113        }
114    }
115}
116
117#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)]
118#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
119pub struct ClosePositionRequest2InstructionData {
120    discriminator: [u8; 8],
121}
122
123impl ClosePositionRequest2InstructionData {
124    pub fn new() -> Self {
125        Self {
126            discriminator: [121, 68, 162, 28, 216, 47, 200, 66],
127        }
128    }
129}
130
131impl Default for ClosePositionRequest2InstructionData {
132    fn default() -> Self {
133        Self::new()
134    }
135}
136
137/// Instruction builder for `ClosePositionRequest2`.
138///
139/// ### Accounts:
140///
141///   0. `[writable, signer, optional]` keeper
142///   1. `[writable]` owner
143///   2. `[writable]` owner_ata
144///   3. `[writable]` pool
145///   4. `[writable]` position_request
146///   5. `[writable]` position_request_ata
147///   6. `[]` position
148///   7. `[]` mint
149///   8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`)
150///   9. `[optional]` system_program (default to `11111111111111111111111111111111`)
151///   10. `[]` associated_token_program
152///   11. `[]` event_authority
153///   12. `[]` program
154#[derive(Clone, Debug, Default)]
155pub struct ClosePositionRequest2Builder {
156    keeper: Option<solana_program::pubkey::Pubkey>,
157    owner: Option<solana_program::pubkey::Pubkey>,
158    owner_ata: Option<solana_program::pubkey::Pubkey>,
159    pool: Option<solana_program::pubkey::Pubkey>,
160    position_request: Option<solana_program::pubkey::Pubkey>,
161    position_request_ata: Option<solana_program::pubkey::Pubkey>,
162    position: Option<solana_program::pubkey::Pubkey>,
163    mint: Option<solana_program::pubkey::Pubkey>,
164    token_program: Option<solana_program::pubkey::Pubkey>,
165    system_program: Option<solana_program::pubkey::Pubkey>,
166    associated_token_program: Option<solana_program::pubkey::Pubkey>,
167    event_authority: Option<solana_program::pubkey::Pubkey>,
168    program: Option<solana_program::pubkey::Pubkey>,
169    __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
170}
171
172impl ClosePositionRequest2Builder {
173    pub fn new() -> Self {
174        Self::default()
175    }
176    /// `[optional account]`
177    #[inline(always)]
178    pub fn keeper(&mut self, keeper: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
179        self.keeper = keeper;
180        self
181    }
182    #[inline(always)]
183    pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self {
184        self.owner = Some(owner);
185        self
186    }
187    #[inline(always)]
188    pub fn owner_ata(&mut self, owner_ata: solana_program::pubkey::Pubkey) -> &mut Self {
189        self.owner_ata = Some(owner_ata);
190        self
191    }
192    #[inline(always)]
193    pub fn pool(&mut self, pool: solana_program::pubkey::Pubkey) -> &mut Self {
194        self.pool = Some(pool);
195        self
196    }
197    #[inline(always)]
198    pub fn position_request(
199        &mut self,
200        position_request: solana_program::pubkey::Pubkey,
201    ) -> &mut Self {
202        self.position_request = Some(position_request);
203        self
204    }
205    #[inline(always)]
206    pub fn position_request_ata(
207        &mut self,
208        position_request_ata: solana_program::pubkey::Pubkey,
209    ) -> &mut Self {
210        self.position_request_ata = Some(position_request_ata);
211        self
212    }
213    #[inline(always)]
214    pub fn position(&mut self, position: solana_program::pubkey::Pubkey) -> &mut Self {
215        self.position = Some(position);
216        self
217    }
218    #[inline(always)]
219    pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
220        self.mint = Some(mint);
221        self
222    }
223    /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']`
224    #[inline(always)]
225    pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
226        self.token_program = Some(token_program);
227        self
228    }
229    /// `[optional account, default to '11111111111111111111111111111111']`
230    #[inline(always)]
231    pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
232        self.system_program = Some(system_program);
233        self
234    }
235    #[inline(always)]
236    pub fn associated_token_program(
237        &mut self,
238        associated_token_program: solana_program::pubkey::Pubkey,
239    ) -> &mut Self {
240        self.associated_token_program = Some(associated_token_program);
241        self
242    }
243    #[inline(always)]
244    pub fn event_authority(
245        &mut self,
246        event_authority: solana_program::pubkey::Pubkey,
247    ) -> &mut Self {
248        self.event_authority = Some(event_authority);
249        self
250    }
251    #[inline(always)]
252    pub fn program(&mut self, program: solana_program::pubkey::Pubkey) -> &mut Self {
253        self.program = Some(program);
254        self
255    }
256    /// Add an additional account to the instruction.
257    #[inline(always)]
258    pub fn add_remaining_account(
259        &mut self,
260        account: solana_program::instruction::AccountMeta,
261    ) -> &mut Self {
262        self.__remaining_accounts.push(account);
263        self
264    }
265    /// Add additional accounts to the instruction.
266    #[inline(always)]
267    pub fn add_remaining_accounts(
268        &mut self,
269        accounts: &[solana_program::instruction::AccountMeta],
270    ) -> &mut Self {
271        self.__remaining_accounts.extend_from_slice(accounts);
272        self
273    }
274    #[allow(clippy::clone_on_copy)]
275    pub fn instruction(&self) -> solana_program::instruction::Instruction {
276        let accounts = ClosePositionRequest2 {
277            keeper: self.keeper,
278            owner: self.owner.expect("owner is not set"),
279            owner_ata: self.owner_ata.expect("owner_ata is not set"),
280            pool: self.pool.expect("pool is not set"),
281            position_request: self.position_request.expect("position_request is not set"),
282            position_request_ata: self
283                .position_request_ata
284                .expect("position_request_ata is not set"),
285            position: self.position.expect("position is not set"),
286            mint: self.mint.expect("mint is not set"),
287            token_program: self.token_program.unwrap_or(solana_program::pubkey!(
288                "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
289            )),
290            system_program: self
291                .system_program
292                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
293            associated_token_program: self
294                .associated_token_program
295                .expect("associated_token_program is not set"),
296            event_authority: self.event_authority.expect("event_authority is not set"),
297            program: self.program.expect("program is not set"),
298        };
299
300        accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
301    }
302}
303
304/// `close_position_request2` CPI accounts.
305pub struct ClosePositionRequest2CpiAccounts<'a, 'b> {
306    pub keeper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
307
308    pub owner: &'b solana_program::account_info::AccountInfo<'a>,
309
310    pub owner_ata: &'b solana_program::account_info::AccountInfo<'a>,
311
312    pub pool: &'b solana_program::account_info::AccountInfo<'a>,
313
314    pub position_request: &'b solana_program::account_info::AccountInfo<'a>,
315
316    pub position_request_ata: &'b solana_program::account_info::AccountInfo<'a>,
317
318    pub position: &'b solana_program::account_info::AccountInfo<'a>,
319
320    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
321
322    pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
323
324    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
325
326    pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
327
328    pub event_authority: &'b solana_program::account_info::AccountInfo<'a>,
329
330    pub program: &'b solana_program::account_info::AccountInfo<'a>,
331}
332
333/// `close_position_request2` CPI instruction.
334pub struct ClosePositionRequest2Cpi<'a, 'b> {
335    /// The program to invoke.
336    pub __program: &'b solana_program::account_info::AccountInfo<'a>,
337
338    pub keeper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
339
340    pub owner: &'b solana_program::account_info::AccountInfo<'a>,
341
342    pub owner_ata: &'b solana_program::account_info::AccountInfo<'a>,
343
344    pub pool: &'b solana_program::account_info::AccountInfo<'a>,
345
346    pub position_request: &'b solana_program::account_info::AccountInfo<'a>,
347
348    pub position_request_ata: &'b solana_program::account_info::AccountInfo<'a>,
349
350    pub position: &'b solana_program::account_info::AccountInfo<'a>,
351
352    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
353
354    pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
355
356    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
357
358    pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
359
360    pub event_authority: &'b solana_program::account_info::AccountInfo<'a>,
361
362    pub program: &'b solana_program::account_info::AccountInfo<'a>,
363}
364
365impl<'a, 'b> ClosePositionRequest2Cpi<'a, 'b> {
366    pub fn new(
367        program: &'b solana_program::account_info::AccountInfo<'a>,
368        accounts: ClosePositionRequest2CpiAccounts<'a, 'b>,
369    ) -> Self {
370        Self {
371            __program: program,
372            keeper: accounts.keeper,
373            owner: accounts.owner,
374            owner_ata: accounts.owner_ata,
375            pool: accounts.pool,
376            position_request: accounts.position_request,
377            position_request_ata: accounts.position_request_ata,
378            position: accounts.position,
379            mint: accounts.mint,
380            token_program: accounts.token_program,
381            system_program: accounts.system_program,
382            associated_token_program: accounts.associated_token_program,
383            event_authority: accounts.event_authority,
384            program: accounts.program,
385        }
386    }
387    #[inline(always)]
388    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
389        self.invoke_signed_with_remaining_accounts(&[], &[])
390    }
391    #[inline(always)]
392    pub fn invoke_with_remaining_accounts(
393        &self,
394        remaining_accounts: &[(
395            &'b solana_program::account_info::AccountInfo<'a>,
396            bool,
397            bool,
398        )],
399    ) -> solana_program::entrypoint::ProgramResult {
400        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
401    }
402    #[inline(always)]
403    pub fn invoke_signed(
404        &self,
405        signers_seeds: &[&[&[u8]]],
406    ) -> solana_program::entrypoint::ProgramResult {
407        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
408    }
409    #[allow(clippy::arithmetic_side_effects)]
410    #[allow(clippy::clone_on_copy)]
411    #[allow(clippy::vec_init_then_push)]
412    pub fn invoke_signed_with_remaining_accounts(
413        &self,
414        signers_seeds: &[&[&[u8]]],
415        remaining_accounts: &[(
416            &'b solana_program::account_info::AccountInfo<'a>,
417            bool,
418            bool,
419        )],
420    ) -> solana_program::entrypoint::ProgramResult {
421        let mut accounts = Vec::with_capacity(13 + remaining_accounts.len());
422        if let Some(keeper) = self.keeper {
423            accounts.push(solana_program::instruction::AccountMeta::new(
424                *keeper.key,
425                true,
426            ));
427        } else {
428            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
429                crate::PERPETUALS_ID,
430                false,
431            ));
432        }
433        accounts.push(solana_program::instruction::AccountMeta::new(
434            *self.owner.key,
435            false,
436        ));
437        accounts.push(solana_program::instruction::AccountMeta::new(
438            *self.owner_ata.key,
439            false,
440        ));
441        accounts.push(solana_program::instruction::AccountMeta::new(
442            *self.pool.key,
443            false,
444        ));
445        accounts.push(solana_program::instruction::AccountMeta::new(
446            *self.position_request.key,
447            false,
448        ));
449        accounts.push(solana_program::instruction::AccountMeta::new(
450            *self.position_request_ata.key,
451            false,
452        ));
453        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
454            *self.position.key,
455            false,
456        ));
457        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
458            *self.mint.key,
459            false,
460        ));
461        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
462            *self.token_program.key,
463            false,
464        ));
465        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
466            *self.system_program.key,
467            false,
468        ));
469        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
470            *self.associated_token_program.key,
471            false,
472        ));
473        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
474            *self.event_authority.key,
475            false,
476        ));
477        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
478            *self.program.key,
479            false,
480        ));
481        remaining_accounts.iter().for_each(|remaining_account| {
482            accounts.push(solana_program::instruction::AccountMeta {
483                pubkey: *remaining_account.0.key,
484                is_signer: remaining_account.1,
485                is_writable: remaining_account.2,
486            })
487        });
488        let data = borsh::to_vec(&ClosePositionRequest2InstructionData::new()).unwrap();
489
490        let instruction = solana_program::instruction::Instruction {
491            program_id: crate::PERPETUALS_ID,
492            accounts,
493            data,
494        };
495        let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len());
496        account_infos.push(self.__program.clone());
497        if let Some(keeper) = self.keeper {
498            account_infos.push(keeper.clone());
499        }
500        account_infos.push(self.owner.clone());
501        account_infos.push(self.owner_ata.clone());
502        account_infos.push(self.pool.clone());
503        account_infos.push(self.position_request.clone());
504        account_infos.push(self.position_request_ata.clone());
505        account_infos.push(self.position.clone());
506        account_infos.push(self.mint.clone());
507        account_infos.push(self.token_program.clone());
508        account_infos.push(self.system_program.clone());
509        account_infos.push(self.associated_token_program.clone());
510        account_infos.push(self.event_authority.clone());
511        account_infos.push(self.program.clone());
512        remaining_accounts
513            .iter()
514            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
515
516        if signers_seeds.is_empty() {
517            solana_program::program::invoke(&instruction, &account_infos)
518        } else {
519            solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
520        }
521    }
522}
523
524/// Instruction builder for `ClosePositionRequest2` via CPI.
525///
526/// ### Accounts:
527///
528///   0. `[writable, signer, optional]` keeper
529///   1. `[writable]` owner
530///   2. `[writable]` owner_ata
531///   3. `[writable]` pool
532///   4. `[writable]` position_request
533///   5. `[writable]` position_request_ata
534///   6. `[]` position
535///   7. `[]` mint
536///   8. `[]` token_program
537///   9. `[]` system_program
538///   10. `[]` associated_token_program
539///   11. `[]` event_authority
540///   12. `[]` program
541#[derive(Clone, Debug)]
542pub struct ClosePositionRequest2CpiBuilder<'a, 'b> {
543    instruction: Box<ClosePositionRequest2CpiBuilderInstruction<'a, 'b>>,
544}
545
546impl<'a, 'b> ClosePositionRequest2CpiBuilder<'a, 'b> {
547    pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
548        let instruction = Box::new(ClosePositionRequest2CpiBuilderInstruction {
549            __program: program,
550            keeper: None,
551            owner: None,
552            owner_ata: None,
553            pool: None,
554            position_request: None,
555            position_request_ata: None,
556            position: None,
557            mint: None,
558            token_program: None,
559            system_program: None,
560            associated_token_program: None,
561            event_authority: None,
562            program: None,
563            __remaining_accounts: Vec::new(),
564        });
565        Self { instruction }
566    }
567    /// `[optional account]`
568    #[inline(always)]
569    pub fn keeper(
570        &mut self,
571        keeper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
572    ) -> &mut Self {
573        self.instruction.keeper = keeper;
574        self
575    }
576    #[inline(always)]
577    pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
578        self.instruction.owner = Some(owner);
579        self
580    }
581    #[inline(always)]
582    pub fn owner_ata(
583        &mut self,
584        owner_ata: &'b solana_program::account_info::AccountInfo<'a>,
585    ) -> &mut Self {
586        self.instruction.owner_ata = Some(owner_ata);
587        self
588    }
589    #[inline(always)]
590    pub fn pool(&mut self, pool: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
591        self.instruction.pool = Some(pool);
592        self
593    }
594    #[inline(always)]
595    pub fn position_request(
596        &mut self,
597        position_request: &'b solana_program::account_info::AccountInfo<'a>,
598    ) -> &mut Self {
599        self.instruction.position_request = Some(position_request);
600        self
601    }
602    #[inline(always)]
603    pub fn position_request_ata(
604        &mut self,
605        position_request_ata: &'b solana_program::account_info::AccountInfo<'a>,
606    ) -> &mut Self {
607        self.instruction.position_request_ata = Some(position_request_ata);
608        self
609    }
610    #[inline(always)]
611    pub fn position(
612        &mut self,
613        position: &'b solana_program::account_info::AccountInfo<'a>,
614    ) -> &mut Self {
615        self.instruction.position = Some(position);
616        self
617    }
618    #[inline(always)]
619    pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
620        self.instruction.mint = Some(mint);
621        self
622    }
623    #[inline(always)]
624    pub fn token_program(
625        &mut self,
626        token_program: &'b solana_program::account_info::AccountInfo<'a>,
627    ) -> &mut Self {
628        self.instruction.token_program = Some(token_program);
629        self
630    }
631    #[inline(always)]
632    pub fn system_program(
633        &mut self,
634        system_program: &'b solana_program::account_info::AccountInfo<'a>,
635    ) -> &mut Self {
636        self.instruction.system_program = Some(system_program);
637        self
638    }
639    #[inline(always)]
640    pub fn associated_token_program(
641        &mut self,
642        associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
643    ) -> &mut Self {
644        self.instruction.associated_token_program = Some(associated_token_program);
645        self
646    }
647    #[inline(always)]
648    pub fn event_authority(
649        &mut self,
650        event_authority: &'b solana_program::account_info::AccountInfo<'a>,
651    ) -> &mut Self {
652        self.instruction.event_authority = Some(event_authority);
653        self
654    }
655    #[inline(always)]
656    pub fn program(
657        &mut self,
658        program: &'b solana_program::account_info::AccountInfo<'a>,
659    ) -> &mut Self {
660        self.instruction.program = Some(program);
661        self
662    }
663    /// Add an additional account to the instruction.
664    #[inline(always)]
665    pub fn add_remaining_account(
666        &mut self,
667        account: &'b solana_program::account_info::AccountInfo<'a>,
668        is_writable: bool,
669        is_signer: bool,
670    ) -> &mut Self {
671        self.instruction
672            .__remaining_accounts
673            .push((account, is_writable, is_signer));
674        self
675    }
676    /// Add additional accounts to the instruction.
677    ///
678    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
679    /// and a `bool` indicating whether the account is a signer or not.
680    #[inline(always)]
681    pub fn add_remaining_accounts(
682        &mut self,
683        accounts: &[(
684            &'b solana_program::account_info::AccountInfo<'a>,
685            bool,
686            bool,
687        )],
688    ) -> &mut Self {
689        self.instruction
690            .__remaining_accounts
691            .extend_from_slice(accounts);
692        self
693    }
694    #[inline(always)]
695    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
696        self.invoke_signed(&[])
697    }
698    #[allow(clippy::clone_on_copy)]
699    #[allow(clippy::vec_init_then_push)]
700    pub fn invoke_signed(
701        &self,
702        signers_seeds: &[&[&[u8]]],
703    ) -> solana_program::entrypoint::ProgramResult {
704        let instruction = ClosePositionRequest2Cpi {
705            __program: self.instruction.__program,
706
707            keeper: self.instruction.keeper,
708
709            owner: self.instruction.owner.expect("owner is not set"),
710
711            owner_ata: self.instruction.owner_ata.expect("owner_ata is not set"),
712
713            pool: self.instruction.pool.expect("pool is not set"),
714
715            position_request: self
716                .instruction
717                .position_request
718                .expect("position_request is not set"),
719
720            position_request_ata: self
721                .instruction
722                .position_request_ata
723                .expect("position_request_ata is not set"),
724
725            position: self.instruction.position.expect("position is not set"),
726
727            mint: self.instruction.mint.expect("mint is not set"),
728
729            token_program: self
730                .instruction
731                .token_program
732                .expect("token_program is not set"),
733
734            system_program: self
735                .instruction
736                .system_program
737                .expect("system_program is not set"),
738
739            associated_token_program: self
740                .instruction
741                .associated_token_program
742                .expect("associated_token_program is not set"),
743
744            event_authority: self
745                .instruction
746                .event_authority
747                .expect("event_authority is not set"),
748
749            program: self.instruction.program.expect("program is not set"),
750        };
751        instruction.invoke_signed_with_remaining_accounts(
752            signers_seeds,
753            &self.instruction.__remaining_accounts,
754        )
755    }
756}
757
758#[derive(Clone, Debug)]
759struct ClosePositionRequest2CpiBuilderInstruction<'a, 'b> {
760    __program: &'b solana_program::account_info::AccountInfo<'a>,
761    keeper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
762    owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
763    owner_ata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
764    pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
765    position_request: Option<&'b solana_program::account_info::AccountInfo<'a>>,
766    position_request_ata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
767    position: Option<&'b solana_program::account_info::AccountInfo<'a>>,
768    mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
769    token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
770    system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
771    associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
772    event_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
773    program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
774    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
775    __remaining_accounts: Vec<(
776        &'b solana_program::account_info::AccountInfo<'a>,
777        bool,
778        bool,
779    )>,
780}