Skip to main content

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