Skip to main content

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