Skip to main content

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