Skip to main content

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