//! This code was AUTOGENERATED using the codama library.
//! Please DO NOT EDIT THIS FILE, instead use visitors
//! to add features, then rerun codama to update it.
//!
//! <https://github.com/codama-idl/codama>
//!

use borsh::BorshSerialize;
use borsh::BorshDeserialize;

pub const INITIALIZE_POOL_DISCRIMINATOR: [u8; 8] = [95, 180, 10, 172, 84, 174, 232, 40];

/// Accounts.
#[derive(Debug)]
pub struct InitializePool {
      
              
          pub fusion_pools_config: solana_pubkey::Pubkey,
          
              
          pub token_mint_a: solana_pubkey::Pubkey,
          
              
          pub token_mint_b: solana_pubkey::Pubkey,
          
              
          pub token_badge_a: solana_pubkey::Pubkey,
          
              
          pub token_badge_b: solana_pubkey::Pubkey,
          
              
          pub funder: solana_pubkey::Pubkey,
          
              
          pub fusion_pool: solana_pubkey::Pubkey,
          
              
          pub token_vault_a: solana_pubkey::Pubkey,
          
              
          pub token_vault_b: solana_pubkey::Pubkey,
          
              
          pub token_program_a: solana_pubkey::Pubkey,
          
              
          pub token_program_b: solana_pubkey::Pubkey,
          
              
          pub system_program: solana_pubkey::Pubkey,
          
              
          pub rent: solana_pubkey::Pubkey,
      }

impl InitializePool {
  pub fn instruction(&self, args: InitializePoolInstructionArgs) -> solana_instruction::Instruction {
    self.instruction_with_remaining_accounts(args, &[])
  }
  #[allow(clippy::arithmetic_side_effects)]
  #[allow(clippy::vec_init_then_push)]
  pub fn instruction_with_remaining_accounts(&self, args: InitializePoolInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
    let mut accounts = Vec::with_capacity(13+ remaining_accounts.len());
                            accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.fusion_pools_config,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.token_mint_a,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.token_mint_b,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.token_badge_a,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.token_badge_b,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.funder,
            true
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.fusion_pool,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.token_vault_a,
            true
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.token_vault_b,
            true
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.token_program_a,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.token_program_b,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.system_program,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.rent,
            false
          ));
                      accounts.extend_from_slice(remaining_accounts);
    let mut data = borsh::to_vec(&InitializePoolInstructionData::new()).unwrap();
          let mut args = borsh::to_vec(&args).unwrap();
      data.append(&mut args);
    
    solana_instruction::Instruction {
      program_id: crate::FUSIONAMM_ID,
      accounts,
      data,
    }
  }
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
 pub struct InitializePoolInstructionData {
            discriminator: [u8; 8],
                        }

impl InitializePoolInstructionData {
  pub fn new() -> Self {
    Self {
                        discriminator: [95, 180, 10, 172, 84, 174, 232, 40],
                                                            }
  }
}

impl Default for InitializePoolInstructionData {
  fn default() -> Self {
    Self::new()
  }
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
 pub struct InitializePoolInstructionArgs {
                  pub tick_spacing: u16,
                pub fee_rate: u16,
                pub initial_sqrt_price: u128,
      }


/// Instruction builder for `InitializePool`.
///
/// ### Accounts:
///
          ///   0. `[]` fusion_pools_config
          ///   1. `[]` token_mint_a
          ///   2. `[]` token_mint_b
          ///   3. `[]` token_badge_a
          ///   4. `[]` token_badge_b
                      ///   5. `[writable, signer]` funder
                ///   6. `[writable]` fusion_pool
                      ///   7. `[writable, signer]` token_vault_a
                      ///   8. `[writable, signer]` token_vault_b
          ///   9. `[]` token_program_a
          ///   10. `[]` token_program_b
                ///   11. `[optional]` system_program (default to `11111111111111111111111111111111`)
                ///   12. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`)
#[derive(Clone, Debug, Default)]
pub struct InitializePoolBuilder {
            fusion_pools_config: Option<solana_pubkey::Pubkey>,
                token_mint_a: Option<solana_pubkey::Pubkey>,
                token_mint_b: Option<solana_pubkey::Pubkey>,
                token_badge_a: Option<solana_pubkey::Pubkey>,
                token_badge_b: Option<solana_pubkey::Pubkey>,
                funder: Option<solana_pubkey::Pubkey>,
                fusion_pool: Option<solana_pubkey::Pubkey>,
                token_vault_a: Option<solana_pubkey::Pubkey>,
                token_vault_b: Option<solana_pubkey::Pubkey>,
                token_program_a: Option<solana_pubkey::Pubkey>,
                token_program_b: Option<solana_pubkey::Pubkey>,
                system_program: Option<solana_pubkey::Pubkey>,
                rent: Option<solana_pubkey::Pubkey>,
                        tick_spacing: Option<u16>,
                fee_rate: Option<u16>,
                initial_sqrt_price: Option<u128>,
        __remaining_accounts: Vec<solana_instruction::AccountMeta>,
}

impl InitializePoolBuilder {
  pub fn new() -> Self {
    Self::default()
  }
            #[inline(always)]
    pub fn fusion_pools_config(&mut self, fusion_pools_config: solana_pubkey::Pubkey) -> &mut Self {
                        self.fusion_pools_config = Some(fusion_pools_config);
                    self
    }
            #[inline(always)]
    pub fn token_mint_a(&mut self, token_mint_a: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_mint_a = Some(token_mint_a);
                    self
    }
            #[inline(always)]
    pub fn token_mint_b(&mut self, token_mint_b: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_mint_b = Some(token_mint_b);
                    self
    }
            #[inline(always)]
    pub fn token_badge_a(&mut self, token_badge_a: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_badge_a = Some(token_badge_a);
                    self
    }
            #[inline(always)]
    pub fn token_badge_b(&mut self, token_badge_b: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_badge_b = Some(token_badge_b);
                    self
    }
            #[inline(always)]
    pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self {
                        self.funder = Some(funder);
                    self
    }
            #[inline(always)]
    pub fn fusion_pool(&mut self, fusion_pool: solana_pubkey::Pubkey) -> &mut Self {
                        self.fusion_pool = Some(fusion_pool);
                    self
    }
            #[inline(always)]
    pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_vault_a = Some(token_vault_a);
                    self
    }
            #[inline(always)]
    pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_vault_b = Some(token_vault_b);
                    self
    }
            #[inline(always)]
    pub fn token_program_a(&mut self, token_program_a: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_program_a = Some(token_program_a);
                    self
    }
            #[inline(always)]
    pub fn token_program_b(&mut self, token_program_b: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_program_b = Some(token_program_b);
                    self
    }
            /// `[optional account, default to '11111111111111111111111111111111']`
#[inline(always)]
    pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self {
                        self.system_program = Some(system_program);
                    self
    }
            /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']`
#[inline(always)]
    pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self {
                        self.rent = Some(rent);
                    self
    }
                    #[inline(always)]
      pub fn tick_spacing(&mut self, tick_spacing: u16) -> &mut Self {
        self.tick_spacing = Some(tick_spacing);
        self
      }
                #[inline(always)]
      pub fn fee_rate(&mut self, fee_rate: u16) -> &mut Self {
        self.fee_rate = Some(fee_rate);
        self
      }
                #[inline(always)]
      pub fn initial_sqrt_price(&mut self, initial_sqrt_price: u128) -> &mut Self {
        self.initial_sqrt_price = Some(initial_sqrt_price);
        self
      }
        /// Add an additional account to the instruction.
  #[inline(always)]
  pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
    self.__remaining_accounts.push(account);
    self
  }
  /// Add additional accounts to the instruction.
  #[inline(always)]
  pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
    self.__remaining_accounts.extend_from_slice(accounts);
    self
  }
  #[allow(clippy::clone_on_copy)]
  pub fn instruction(&self) -> solana_instruction::Instruction {
    let accounts = InitializePool {
                              fusion_pools_config: self.fusion_pools_config.expect("fusion_pools_config is not set"),
                                        token_mint_a: self.token_mint_a.expect("token_mint_a is not set"),
                                        token_mint_b: self.token_mint_b.expect("token_mint_b is not set"),
                                        token_badge_a: self.token_badge_a.expect("token_badge_a is not set"),
                                        token_badge_b: self.token_badge_b.expect("token_badge_b is not set"),
                                        funder: self.funder.expect("funder is not set"),
                                        fusion_pool: self.fusion_pool.expect("fusion_pool is not set"),
                                        token_vault_a: self.token_vault_a.expect("token_vault_a is not set"),
                                        token_vault_b: self.token_vault_b.expect("token_vault_b is not set"),
                                        token_program_a: self.token_program_a.expect("token_program_a is not set"),
                                        token_program_b: self.token_program_b.expect("token_program_b is not set"),
                                        system_program: self.system_program.unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
                                        rent: self.rent.unwrap_or(solana_pubkey::pubkey!("SysvarRent111111111111111111111111111111111")),
                      };
          let args = InitializePoolInstructionArgs {
                                                              tick_spacing: self.tick_spacing.clone().expect("tick_spacing is not set"),
                                                                  fee_rate: self.fee_rate.clone().expect("fee_rate is not set"),
                                                                  initial_sqrt_price: self.initial_sqrt_price.clone().expect("initial_sqrt_price is not set"),
                                    };
    
    accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
  }
}

  /// `initialize_pool` CPI accounts.
  pub struct InitializePoolCpiAccounts<'a, 'b> {
          
                    
              pub fusion_pools_config: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_mint_a: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_mint_b: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_badge_a: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_badge_b: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub funder: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub fusion_pool: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_vault_a: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_vault_b: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_program_a: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_program_b: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub system_program: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub rent: &'b solana_account_info::AccountInfo<'a>,
            }

/// `initialize_pool` CPI instruction.
pub struct InitializePoolCpi<'a, 'b> {
  /// The program to invoke.
  pub __program: &'b solana_account_info::AccountInfo<'a>,
      
              
          pub fusion_pools_config: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_mint_a: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_mint_b: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_badge_a: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_badge_b: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub funder: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub fusion_pool: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_vault_a: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_vault_b: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_program_a: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_program_b: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub system_program: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub rent: &'b solana_account_info::AccountInfo<'a>,
            /// The arguments for the instruction.
    pub __args: InitializePoolInstructionArgs,
  }

impl<'a, 'b> InitializePoolCpi<'a, 'b> {
  pub fn new(
    program: &'b solana_account_info::AccountInfo<'a>,
          accounts: InitializePoolCpiAccounts<'a, 'b>,
              args: InitializePoolInstructionArgs,
      ) -> Self {
    Self {
      __program: program,
              fusion_pools_config: accounts.fusion_pools_config,
              token_mint_a: accounts.token_mint_a,
              token_mint_b: accounts.token_mint_b,
              token_badge_a: accounts.token_badge_a,
              token_badge_b: accounts.token_badge_b,
              funder: accounts.funder,
              fusion_pool: accounts.fusion_pool,
              token_vault_a: accounts.token_vault_a,
              token_vault_b: accounts.token_vault_b,
              token_program_a: accounts.token_program_a,
              token_program_b: accounts.token_program_b,
              system_program: accounts.system_program,
              rent: accounts.rent,
                    __args: args,
          }
  }
  #[inline(always)]
  pub fn invoke(&self) -> solana_program_error::ProgramResult {
    self.invoke_signed_with_remaining_accounts(&[], &[])
  }
  #[inline(always)]
  pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
    self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
  }
  #[inline(always)]
  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
    self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
  }
  #[allow(clippy::arithmetic_side_effects)]
  #[allow(clippy::clone_on_copy)]
  #[allow(clippy::vec_init_then_push)]
  pub fn invoke_signed_with_remaining_accounts(
    &self,
    signers_seeds: &[&[&[u8]]],
    remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
  ) -> solana_program_error::ProgramResult {
    let mut accounts = Vec::with_capacity(13+ remaining_accounts.len());
                            accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.fusion_pools_config.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.token_mint_a.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.token_mint_b.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.token_badge_a.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.token_badge_b.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.funder.key,
            true
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.fusion_pool.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.token_vault_a.key,
            true
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.token_vault_b.key,
            true
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.token_program_a.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.token_program_b.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.system_program.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.rent.key,
            false
          ));
                      remaining_accounts.iter().for_each(|remaining_account| {
      accounts.push(solana_instruction::AccountMeta {
          pubkey: *remaining_account.0.key,
          is_signer: remaining_account.1,
          is_writable: remaining_account.2,
      })
    });
    let mut data = borsh::to_vec(&InitializePoolInstructionData::new()).unwrap();
          let mut args = borsh::to_vec(&self.__args).unwrap();
      data.append(&mut args);
    
    let instruction = solana_instruction::Instruction {
      program_id: crate::FUSIONAMM_ID,
      accounts,
      data,
    };
    let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len());
    account_infos.push(self.__program.clone());
                  account_infos.push(self.fusion_pools_config.clone());
                        account_infos.push(self.token_mint_a.clone());
                        account_infos.push(self.token_mint_b.clone());
                        account_infos.push(self.token_badge_a.clone());
                        account_infos.push(self.token_badge_b.clone());
                        account_infos.push(self.funder.clone());
                        account_infos.push(self.fusion_pool.clone());
                        account_infos.push(self.token_vault_a.clone());
                        account_infos.push(self.token_vault_b.clone());
                        account_infos.push(self.token_program_a.clone());
                        account_infos.push(self.token_program_b.clone());
                        account_infos.push(self.system_program.clone());
                        account_infos.push(self.rent.clone());
              remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));

    if signers_seeds.is_empty() {
      solana_cpi::invoke(&instruction, &account_infos)
    } else {
      solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
    }
  }
}

/// Instruction builder for `InitializePool` via CPI.
///
/// ### Accounts:
///
          ///   0. `[]` fusion_pools_config
          ///   1. `[]` token_mint_a
          ///   2. `[]` token_mint_b
          ///   3. `[]` token_badge_a
          ///   4. `[]` token_badge_b
                      ///   5. `[writable, signer]` funder
                ///   6. `[writable]` fusion_pool
                      ///   7. `[writable, signer]` token_vault_a
                      ///   8. `[writable, signer]` token_vault_b
          ///   9. `[]` token_program_a
          ///   10. `[]` token_program_b
          ///   11. `[]` system_program
          ///   12. `[]` rent
#[derive(Clone, Debug)]
pub struct InitializePoolCpiBuilder<'a, 'b> {
  instruction: Box<InitializePoolCpiBuilderInstruction<'a, 'b>>,
}

impl<'a, 'b> InitializePoolCpiBuilder<'a, 'b> {
  pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
    let instruction = Box::new(InitializePoolCpiBuilderInstruction {
      __program: program,
              fusion_pools_config: None,
              token_mint_a: None,
              token_mint_b: None,
              token_badge_a: None,
              token_badge_b: None,
              funder: None,
              fusion_pool: None,
              token_vault_a: None,
              token_vault_b: None,
              token_program_a: None,
              token_program_b: None,
              system_program: None,
              rent: None,
                                            tick_spacing: None,
                                fee_rate: None,
                                initial_sqrt_price: None,
                    __remaining_accounts: Vec::new(),
    });
    Self { instruction }
  }
      #[inline(always)]
    pub fn fusion_pools_config(&mut self, fusion_pools_config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.fusion_pools_config = Some(fusion_pools_config);
                    self
    }
      #[inline(always)]
    pub fn token_mint_a(&mut self, token_mint_a: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_mint_a = Some(token_mint_a);
                    self
    }
      #[inline(always)]
    pub fn token_mint_b(&mut self, token_mint_b: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_mint_b = Some(token_mint_b);
                    self
    }
      #[inline(always)]
    pub fn token_badge_a(&mut self, token_badge_a: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_badge_a = Some(token_badge_a);
                    self
    }
      #[inline(always)]
    pub fn token_badge_b(&mut self, token_badge_b: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_badge_b = Some(token_badge_b);
                    self
    }
      #[inline(always)]
    pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.funder = Some(funder);
                    self
    }
      #[inline(always)]
    pub fn fusion_pool(&mut self, fusion_pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.fusion_pool = Some(fusion_pool);
                    self
    }
      #[inline(always)]
    pub fn token_vault_a(&mut self, token_vault_a: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_vault_a = Some(token_vault_a);
                    self
    }
      #[inline(always)]
    pub fn token_vault_b(&mut self, token_vault_b: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_vault_b = Some(token_vault_b);
                    self
    }
      #[inline(always)]
    pub fn token_program_a(&mut self, token_program_a: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_program_a = Some(token_program_a);
                    self
    }
      #[inline(always)]
    pub fn token_program_b(&mut self, token_program_b: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_program_b = Some(token_program_b);
                    self
    }
      #[inline(always)]
    pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.system_program = Some(system_program);
                    self
    }
      #[inline(always)]
    pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.rent = Some(rent);
                    self
    }
                    #[inline(always)]
      pub fn tick_spacing(&mut self, tick_spacing: u16) -> &mut Self {
        self.instruction.tick_spacing = Some(tick_spacing);
        self
      }
                #[inline(always)]
      pub fn fee_rate(&mut self, fee_rate: u16) -> &mut Self {
        self.instruction.fee_rate = Some(fee_rate);
        self
      }
                #[inline(always)]
      pub fn initial_sqrt_price(&mut self, initial_sqrt_price: u128) -> &mut Self {
        self.instruction.initial_sqrt_price = Some(initial_sqrt_price);
        self
      }
        /// Add an additional account to the instruction.
  #[inline(always)]
  pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
    self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
    self
  }
  /// Add additional accounts to the instruction.
  ///
  /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
  /// and a `bool` indicating whether the account is a signer or not.
  #[inline(always)]
  pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
    self.instruction.__remaining_accounts.extend_from_slice(accounts);
    self
  }
  #[inline(always)]
  pub fn invoke(&self) -> solana_program_error::ProgramResult {
    self.invoke_signed(&[])
  }
  #[allow(clippy::clone_on_copy)]
  #[allow(clippy::vec_init_then_push)]
  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
          let args = InitializePoolInstructionArgs {
                                                              tick_spacing: self.instruction.tick_spacing.clone().expect("tick_spacing is not set"),
                                                                  fee_rate: self.instruction.fee_rate.clone().expect("fee_rate is not set"),
                                                                  initial_sqrt_price: self.instruction.initial_sqrt_price.clone().expect("initial_sqrt_price is not set"),
                                    };
        let instruction = InitializePoolCpi {
        __program: self.instruction.__program,
                  
          fusion_pools_config: self.instruction.fusion_pools_config.expect("fusion_pools_config is not set"),
                  
          token_mint_a: self.instruction.token_mint_a.expect("token_mint_a is not set"),
                  
          token_mint_b: self.instruction.token_mint_b.expect("token_mint_b is not set"),
                  
          token_badge_a: self.instruction.token_badge_a.expect("token_badge_a is not set"),
                  
          token_badge_b: self.instruction.token_badge_b.expect("token_badge_b is not set"),
                  
          funder: self.instruction.funder.expect("funder is not set"),
                  
          fusion_pool: self.instruction.fusion_pool.expect("fusion_pool is not set"),
                  
          token_vault_a: self.instruction.token_vault_a.expect("token_vault_a is not set"),
                  
          token_vault_b: self.instruction.token_vault_b.expect("token_vault_b is not set"),
                  
          token_program_a: self.instruction.token_program_a.expect("token_program_a is not set"),
                  
          token_program_b: self.instruction.token_program_b.expect("token_program_b is not set"),
                  
          system_program: self.instruction.system_program.expect("system_program is not set"),
                  
          rent: self.instruction.rent.expect("rent is not set"),
                          __args: args,
            };
    instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
  }
}

#[derive(Clone, Debug)]
struct InitializePoolCpiBuilderInstruction<'a, 'b> {
  __program: &'b solana_account_info::AccountInfo<'a>,
            fusion_pools_config: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_mint_a: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_mint_b: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_badge_a: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_badge_b: Option<&'b solana_account_info::AccountInfo<'a>>,
                funder: Option<&'b solana_account_info::AccountInfo<'a>>,
                fusion_pool: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_program_a: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_program_b: Option<&'b solana_account_info::AccountInfo<'a>>,
                system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
                rent: Option<&'b solana_account_info::AccountInfo<'a>>,
                        tick_spacing: Option<u16>,
                fee_rate: Option<u16>,
                initial_sqrt_price: Option<u128>,
        /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
  __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
}

