Skip to main content

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