//! 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 crate::generated::types::RemainingAccountsInfo;
use borsh::BorshSerialize;
use borsh::BorshDeserialize;

pub const TWO_HOP_SWAP_DISCRIMINATOR: [u8; 8] = [195, 96, 237, 108, 68, 162, 219, 230];

/// Accounts.
#[derive(Debug)]
pub struct TwoHopSwap {
      
              
          pub fusion_pool_one: solana_pubkey::Pubkey,
          
              
          pub fusion_pool_two: solana_pubkey::Pubkey,
          
              
          pub token_mint_input: solana_pubkey::Pubkey,
          
              
          pub token_mint_intermediate: solana_pubkey::Pubkey,
          
              
          pub token_mint_output: solana_pubkey::Pubkey,
          
              
          pub token_program_input: solana_pubkey::Pubkey,
          
              
          pub token_program_intermediate: solana_pubkey::Pubkey,
          
              
          pub token_program_output: solana_pubkey::Pubkey,
          
              
          pub token_owner_account_input: solana_pubkey::Pubkey,
          
              
          pub token_vault_one_input: solana_pubkey::Pubkey,
          
              
          pub token_vault_one_intermediate: solana_pubkey::Pubkey,
          
              
          pub token_vault_two_intermediate: solana_pubkey::Pubkey,
          
              
          pub token_vault_two_output: solana_pubkey::Pubkey,
          
              
          pub token_owner_account_output: solana_pubkey::Pubkey,
          
              
          pub token_authority: solana_pubkey::Pubkey,
          
              
          pub tick_array_one0: solana_pubkey::Pubkey,
          
              
          pub tick_array_one1: solana_pubkey::Pubkey,
          
              
          pub tick_array_one2: solana_pubkey::Pubkey,
          
              
          pub tick_array_two0: solana_pubkey::Pubkey,
          
              
          pub tick_array_two1: solana_pubkey::Pubkey,
          
              
          pub tick_array_two2: solana_pubkey::Pubkey,
          
              
          pub memo_program: solana_pubkey::Pubkey,
      }

impl TwoHopSwap {
  pub fn instruction(&self, args: TwoHopSwapInstructionArgs) -> 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: TwoHopSwapInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
    let mut accounts = Vec::with_capacity(22+ remaining_accounts.len());
                            accounts.push(solana_instruction::AccountMeta::new(
            self.fusion_pool_one,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.fusion_pool_two,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.token_mint_input,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.token_mint_intermediate,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.token_mint_output,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.token_program_input,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.token_program_intermediate,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.token_program_output,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.token_owner_account_input,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.token_vault_one_input,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.token_vault_one_intermediate,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.token_vault_two_intermediate,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.token_vault_two_output,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.token_owner_account_output,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.token_authority,
            true
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.tick_array_one0,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.tick_array_one1,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.tick_array_one2,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.tick_array_two0,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.tick_array_two1,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            self.tick_array_two2,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            self.memo_program,
            false
          ));
                      accounts.extend_from_slice(remaining_accounts);
    let mut data = borsh::to_vec(&TwoHopSwapInstructionData::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 TwoHopSwapInstructionData {
            discriminator: [u8; 8],
                                                      }

impl TwoHopSwapInstructionData {
  pub fn new() -> Self {
    Self {
                        discriminator: [195, 96, 237, 108, 68, 162, 219, 230],
                                                                                                                                  }
  }
}

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

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
 pub struct TwoHopSwapInstructionArgs {
                  pub amount: u64,
                pub other_amount_threshold: u64,
                pub amount_specified_is_input: bool,
                pub a_to_b_one: bool,
                pub a_to_b_two: bool,
                pub sqrt_price_limit_one: u128,
                pub sqrt_price_limit_two: u128,
                pub remaining_accounts_info: Option<RemainingAccountsInfo>,
      }


/// Instruction builder for `TwoHopSwap`.
///
/// ### Accounts:
///
                ///   0. `[writable]` fusion_pool_one
                ///   1. `[writable]` fusion_pool_two
          ///   2. `[]` token_mint_input
          ///   3. `[]` token_mint_intermediate
          ///   4. `[]` token_mint_output
          ///   5. `[]` token_program_input
          ///   6. `[]` token_program_intermediate
          ///   7. `[]` token_program_output
                ///   8. `[writable]` token_owner_account_input
                ///   9. `[writable]` token_vault_one_input
                ///   10. `[writable]` token_vault_one_intermediate
                ///   11. `[writable]` token_vault_two_intermediate
                ///   12. `[writable]` token_vault_two_output
                ///   13. `[writable]` token_owner_account_output
                ///   14. `[signer]` token_authority
                ///   15. `[writable]` tick_array_one0
                ///   16. `[writable]` tick_array_one1
                ///   17. `[writable]` tick_array_one2
                ///   18. `[writable]` tick_array_two0
                ///   19. `[writable]` tick_array_two1
                ///   20. `[writable]` tick_array_two2
          ///   21. `[]` memo_program
#[derive(Clone, Debug, Default)]
pub struct TwoHopSwapBuilder {
            fusion_pool_one: Option<solana_pubkey::Pubkey>,
                fusion_pool_two: Option<solana_pubkey::Pubkey>,
                token_mint_input: Option<solana_pubkey::Pubkey>,
                token_mint_intermediate: Option<solana_pubkey::Pubkey>,
                token_mint_output: Option<solana_pubkey::Pubkey>,
                token_program_input: Option<solana_pubkey::Pubkey>,
                token_program_intermediate: Option<solana_pubkey::Pubkey>,
                token_program_output: Option<solana_pubkey::Pubkey>,
                token_owner_account_input: Option<solana_pubkey::Pubkey>,
                token_vault_one_input: Option<solana_pubkey::Pubkey>,
                token_vault_one_intermediate: Option<solana_pubkey::Pubkey>,
                token_vault_two_intermediate: Option<solana_pubkey::Pubkey>,
                token_vault_two_output: Option<solana_pubkey::Pubkey>,
                token_owner_account_output: Option<solana_pubkey::Pubkey>,
                token_authority: Option<solana_pubkey::Pubkey>,
                tick_array_one0: Option<solana_pubkey::Pubkey>,
                tick_array_one1: Option<solana_pubkey::Pubkey>,
                tick_array_one2: Option<solana_pubkey::Pubkey>,
                tick_array_two0: Option<solana_pubkey::Pubkey>,
                tick_array_two1: Option<solana_pubkey::Pubkey>,
                tick_array_two2: Option<solana_pubkey::Pubkey>,
                memo_program: Option<solana_pubkey::Pubkey>,
                        amount: Option<u64>,
                other_amount_threshold: Option<u64>,
                amount_specified_is_input: Option<bool>,
                a_to_b_one: Option<bool>,
                a_to_b_two: Option<bool>,
                sqrt_price_limit_one: Option<u128>,
                sqrt_price_limit_two: Option<u128>,
                remaining_accounts_info: Option<RemainingAccountsInfo>,
        __remaining_accounts: Vec<solana_instruction::AccountMeta>,
}

impl TwoHopSwapBuilder {
  pub fn new() -> Self {
    Self::default()
  }
            #[inline(always)]
    pub fn fusion_pool_one(&mut self, fusion_pool_one: solana_pubkey::Pubkey) -> &mut Self {
                        self.fusion_pool_one = Some(fusion_pool_one);
                    self
    }
            #[inline(always)]
    pub fn fusion_pool_two(&mut self, fusion_pool_two: solana_pubkey::Pubkey) -> &mut Self {
                        self.fusion_pool_two = Some(fusion_pool_two);
                    self
    }
            #[inline(always)]
    pub fn token_mint_input(&mut self, token_mint_input: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_mint_input = Some(token_mint_input);
                    self
    }
            #[inline(always)]
    pub fn token_mint_intermediate(&mut self, token_mint_intermediate: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_mint_intermediate = Some(token_mint_intermediate);
                    self
    }
            #[inline(always)]
    pub fn token_mint_output(&mut self, token_mint_output: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_mint_output = Some(token_mint_output);
                    self
    }
            #[inline(always)]
    pub fn token_program_input(&mut self, token_program_input: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_program_input = Some(token_program_input);
                    self
    }
            #[inline(always)]
    pub fn token_program_intermediate(&mut self, token_program_intermediate: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_program_intermediate = Some(token_program_intermediate);
                    self
    }
            #[inline(always)]
    pub fn token_program_output(&mut self, token_program_output: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_program_output = Some(token_program_output);
                    self
    }
            #[inline(always)]
    pub fn token_owner_account_input(&mut self, token_owner_account_input: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_owner_account_input = Some(token_owner_account_input);
                    self
    }
            #[inline(always)]
    pub fn token_vault_one_input(&mut self, token_vault_one_input: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_vault_one_input = Some(token_vault_one_input);
                    self
    }
            #[inline(always)]
    pub fn token_vault_one_intermediate(&mut self, token_vault_one_intermediate: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_vault_one_intermediate = Some(token_vault_one_intermediate);
                    self
    }
            #[inline(always)]
    pub fn token_vault_two_intermediate(&mut self, token_vault_two_intermediate: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_vault_two_intermediate = Some(token_vault_two_intermediate);
                    self
    }
            #[inline(always)]
    pub fn token_vault_two_output(&mut self, token_vault_two_output: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_vault_two_output = Some(token_vault_two_output);
                    self
    }
            #[inline(always)]
    pub fn token_owner_account_output(&mut self, token_owner_account_output: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_owner_account_output = Some(token_owner_account_output);
                    self
    }
            #[inline(always)]
    pub fn token_authority(&mut self, token_authority: solana_pubkey::Pubkey) -> &mut Self {
                        self.token_authority = Some(token_authority);
                    self
    }
            #[inline(always)]
    pub fn tick_array_one0(&mut self, tick_array_one0: solana_pubkey::Pubkey) -> &mut Self {
                        self.tick_array_one0 = Some(tick_array_one0);
                    self
    }
            #[inline(always)]
    pub fn tick_array_one1(&mut self, tick_array_one1: solana_pubkey::Pubkey) -> &mut Self {
                        self.tick_array_one1 = Some(tick_array_one1);
                    self
    }
            #[inline(always)]
    pub fn tick_array_one2(&mut self, tick_array_one2: solana_pubkey::Pubkey) -> &mut Self {
                        self.tick_array_one2 = Some(tick_array_one2);
                    self
    }
            #[inline(always)]
    pub fn tick_array_two0(&mut self, tick_array_two0: solana_pubkey::Pubkey) -> &mut Self {
                        self.tick_array_two0 = Some(tick_array_two0);
                    self
    }
            #[inline(always)]
    pub fn tick_array_two1(&mut self, tick_array_two1: solana_pubkey::Pubkey) -> &mut Self {
                        self.tick_array_two1 = Some(tick_array_two1);
                    self
    }
            #[inline(always)]
    pub fn tick_array_two2(&mut self, tick_array_two2: solana_pubkey::Pubkey) -> &mut Self {
                        self.tick_array_two2 = Some(tick_array_two2);
                    self
    }
            #[inline(always)]
    pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self {
                        self.memo_program = Some(memo_program);
                    self
    }
                    #[inline(always)]
      pub fn amount(&mut self, amount: u64) -> &mut Self {
        self.amount = Some(amount);
        self
      }
                #[inline(always)]
      pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self {
        self.other_amount_threshold = Some(other_amount_threshold);
        self
      }
                #[inline(always)]
      pub fn amount_specified_is_input(&mut self, amount_specified_is_input: bool) -> &mut Self {
        self.amount_specified_is_input = Some(amount_specified_is_input);
        self
      }
                #[inline(always)]
      pub fn a_to_b_one(&mut self, a_to_b_one: bool) -> &mut Self {
        self.a_to_b_one = Some(a_to_b_one);
        self
      }
                #[inline(always)]
      pub fn a_to_b_two(&mut self, a_to_b_two: bool) -> &mut Self {
        self.a_to_b_two = Some(a_to_b_two);
        self
      }
                #[inline(always)]
      pub fn sqrt_price_limit_one(&mut self, sqrt_price_limit_one: u128) -> &mut Self {
        self.sqrt_price_limit_one = Some(sqrt_price_limit_one);
        self
      }
                #[inline(always)]
      pub fn sqrt_price_limit_two(&mut self, sqrt_price_limit_two: u128) -> &mut Self {
        self.sqrt_price_limit_two = Some(sqrt_price_limit_two);
        self
      }
                /// `[optional argument]`
#[inline(always)]
      pub fn remaining_accounts_info(&mut self, remaining_accounts_info: RemainingAccountsInfo) -> &mut Self {
        self.remaining_accounts_info = Some(remaining_accounts_info);
        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 = TwoHopSwap {
                              fusion_pool_one: self.fusion_pool_one.expect("fusion_pool_one is not set"),
                                        fusion_pool_two: self.fusion_pool_two.expect("fusion_pool_two is not set"),
                                        token_mint_input: self.token_mint_input.expect("token_mint_input is not set"),
                                        token_mint_intermediate: self.token_mint_intermediate.expect("token_mint_intermediate is not set"),
                                        token_mint_output: self.token_mint_output.expect("token_mint_output is not set"),
                                        token_program_input: self.token_program_input.expect("token_program_input is not set"),
                                        token_program_intermediate: self.token_program_intermediate.expect("token_program_intermediate is not set"),
                                        token_program_output: self.token_program_output.expect("token_program_output is not set"),
                                        token_owner_account_input: self.token_owner_account_input.expect("token_owner_account_input is not set"),
                                        token_vault_one_input: self.token_vault_one_input.expect("token_vault_one_input is not set"),
                                        token_vault_one_intermediate: self.token_vault_one_intermediate.expect("token_vault_one_intermediate is not set"),
                                        token_vault_two_intermediate: self.token_vault_two_intermediate.expect("token_vault_two_intermediate is not set"),
                                        token_vault_two_output: self.token_vault_two_output.expect("token_vault_two_output is not set"),
                                        token_owner_account_output: self.token_owner_account_output.expect("token_owner_account_output is not set"),
                                        token_authority: self.token_authority.expect("token_authority is not set"),
                                        tick_array_one0: self.tick_array_one0.expect("tick_array_one0 is not set"),
                                        tick_array_one1: self.tick_array_one1.expect("tick_array_one1 is not set"),
                                        tick_array_one2: self.tick_array_one2.expect("tick_array_one2 is not set"),
                                        tick_array_two0: self.tick_array_two0.expect("tick_array_two0 is not set"),
                                        tick_array_two1: self.tick_array_two1.expect("tick_array_two1 is not set"),
                                        tick_array_two2: self.tick_array_two2.expect("tick_array_two2 is not set"),
                                        memo_program: self.memo_program.expect("memo_program is not set"),
                      };
          let args = TwoHopSwapInstructionArgs {
                                                              amount: self.amount.clone().expect("amount is not set"),
                                                                  other_amount_threshold: self.other_amount_threshold.clone().expect("other_amount_threshold is not set"),
                                                                  amount_specified_is_input: self.amount_specified_is_input.clone().expect("amount_specified_is_input is not set"),
                                                                  a_to_b_one: self.a_to_b_one.clone().expect("a_to_b_one is not set"),
                                                                  a_to_b_two: self.a_to_b_two.clone().expect("a_to_b_two is not set"),
                                                                  sqrt_price_limit_one: self.sqrt_price_limit_one.clone().expect("sqrt_price_limit_one is not set"),
                                                                  sqrt_price_limit_two: self.sqrt_price_limit_two.clone().expect("sqrt_price_limit_two is not set"),
                                                                  remaining_accounts_info: self.remaining_accounts_info.clone(),
                                    };
    
    accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
  }
}

  /// `two_hop_swap` CPI accounts.
  pub struct TwoHopSwapCpiAccounts<'a, 'b> {
          
                    
              pub fusion_pool_one: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub fusion_pool_two: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_mint_input: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_mint_intermediate: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_mint_output: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_program_input: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_program_intermediate: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_program_output: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_owner_account_input: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_vault_one_input: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_vault_one_intermediate: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_vault_two_intermediate: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_vault_two_output: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_owner_account_output: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub token_authority: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub tick_array_one0: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub tick_array_one1: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub tick_array_one2: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub tick_array_two0: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub tick_array_two1: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub tick_array_two2: &'b solana_account_info::AccountInfo<'a>,
                
                    
              pub memo_program: &'b solana_account_info::AccountInfo<'a>,
            }

/// `two_hop_swap` CPI instruction.
pub struct TwoHopSwapCpi<'a, 'b> {
  /// The program to invoke.
  pub __program: &'b solana_account_info::AccountInfo<'a>,
      
              
          pub fusion_pool_one: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub fusion_pool_two: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_mint_input: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_mint_intermediate: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_mint_output: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_program_input: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_program_intermediate: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_program_output: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_owner_account_input: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_vault_one_input: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_vault_one_intermediate: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_vault_two_intermediate: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_vault_two_output: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_owner_account_output: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub token_authority: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub tick_array_one0: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub tick_array_one1: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub tick_array_one2: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub tick_array_two0: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub tick_array_two1: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub tick_array_two2: &'b solana_account_info::AccountInfo<'a>,
          
              
          pub memo_program: &'b solana_account_info::AccountInfo<'a>,
            /// The arguments for the instruction.
    pub __args: TwoHopSwapInstructionArgs,
  }

impl<'a, 'b> TwoHopSwapCpi<'a, 'b> {
  pub fn new(
    program: &'b solana_account_info::AccountInfo<'a>,
          accounts: TwoHopSwapCpiAccounts<'a, 'b>,
              args: TwoHopSwapInstructionArgs,
      ) -> Self {
    Self {
      __program: program,
              fusion_pool_one: accounts.fusion_pool_one,
              fusion_pool_two: accounts.fusion_pool_two,
              token_mint_input: accounts.token_mint_input,
              token_mint_intermediate: accounts.token_mint_intermediate,
              token_mint_output: accounts.token_mint_output,
              token_program_input: accounts.token_program_input,
              token_program_intermediate: accounts.token_program_intermediate,
              token_program_output: accounts.token_program_output,
              token_owner_account_input: accounts.token_owner_account_input,
              token_vault_one_input: accounts.token_vault_one_input,
              token_vault_one_intermediate: accounts.token_vault_one_intermediate,
              token_vault_two_intermediate: accounts.token_vault_two_intermediate,
              token_vault_two_output: accounts.token_vault_two_output,
              token_owner_account_output: accounts.token_owner_account_output,
              token_authority: accounts.token_authority,
              tick_array_one0: accounts.tick_array_one0,
              tick_array_one1: accounts.tick_array_one1,
              tick_array_one2: accounts.tick_array_one2,
              tick_array_two0: accounts.tick_array_two0,
              tick_array_two1: accounts.tick_array_two1,
              tick_array_two2: accounts.tick_array_two2,
              memo_program: accounts.memo_program,
                    __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(22+ remaining_accounts.len());
                            accounts.push(solana_instruction::AccountMeta::new(
            *self.fusion_pool_one.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.fusion_pool_two.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.token_mint_input.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.token_mint_intermediate.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.token_mint_output.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.token_program_input.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.token_program_intermediate.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.token_program_output.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.token_owner_account_input.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.token_vault_one_input.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.token_vault_one_intermediate.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.token_vault_two_intermediate.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.token_vault_two_output.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.token_owner_account_output.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.token_authority.key,
            true
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.tick_array_one0.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.tick_array_one1.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.tick_array_one2.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.tick_array_two0.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.tick_array_two1.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new(
            *self.tick_array_two2.key,
            false
          ));
                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
            *self.memo_program.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(&TwoHopSwapInstructionData::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(23 + remaining_accounts.len());
    account_infos.push(self.__program.clone());
                  account_infos.push(self.fusion_pool_one.clone());
                        account_infos.push(self.fusion_pool_two.clone());
                        account_infos.push(self.token_mint_input.clone());
                        account_infos.push(self.token_mint_intermediate.clone());
                        account_infos.push(self.token_mint_output.clone());
                        account_infos.push(self.token_program_input.clone());
                        account_infos.push(self.token_program_intermediate.clone());
                        account_infos.push(self.token_program_output.clone());
                        account_infos.push(self.token_owner_account_input.clone());
                        account_infos.push(self.token_vault_one_input.clone());
                        account_infos.push(self.token_vault_one_intermediate.clone());
                        account_infos.push(self.token_vault_two_intermediate.clone());
                        account_infos.push(self.token_vault_two_output.clone());
                        account_infos.push(self.token_owner_account_output.clone());
                        account_infos.push(self.token_authority.clone());
                        account_infos.push(self.tick_array_one0.clone());
                        account_infos.push(self.tick_array_one1.clone());
                        account_infos.push(self.tick_array_one2.clone());
                        account_infos.push(self.tick_array_two0.clone());
                        account_infos.push(self.tick_array_two1.clone());
                        account_infos.push(self.tick_array_two2.clone());
                        account_infos.push(self.memo_program.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 `TwoHopSwap` via CPI.
///
/// ### Accounts:
///
                ///   0. `[writable]` fusion_pool_one
                ///   1. `[writable]` fusion_pool_two
          ///   2. `[]` token_mint_input
          ///   3. `[]` token_mint_intermediate
          ///   4. `[]` token_mint_output
          ///   5. `[]` token_program_input
          ///   6. `[]` token_program_intermediate
          ///   7. `[]` token_program_output
                ///   8. `[writable]` token_owner_account_input
                ///   9. `[writable]` token_vault_one_input
                ///   10. `[writable]` token_vault_one_intermediate
                ///   11. `[writable]` token_vault_two_intermediate
                ///   12. `[writable]` token_vault_two_output
                ///   13. `[writable]` token_owner_account_output
                ///   14. `[signer]` token_authority
                ///   15. `[writable]` tick_array_one0
                ///   16. `[writable]` tick_array_one1
                ///   17. `[writable]` tick_array_one2
                ///   18. `[writable]` tick_array_two0
                ///   19. `[writable]` tick_array_two1
                ///   20. `[writable]` tick_array_two2
          ///   21. `[]` memo_program
#[derive(Clone, Debug)]
pub struct TwoHopSwapCpiBuilder<'a, 'b> {
  instruction: Box<TwoHopSwapCpiBuilderInstruction<'a, 'b>>,
}

impl<'a, 'b> TwoHopSwapCpiBuilder<'a, 'b> {
  pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
    let instruction = Box::new(TwoHopSwapCpiBuilderInstruction {
      __program: program,
              fusion_pool_one: None,
              fusion_pool_two: None,
              token_mint_input: None,
              token_mint_intermediate: None,
              token_mint_output: None,
              token_program_input: None,
              token_program_intermediate: None,
              token_program_output: None,
              token_owner_account_input: None,
              token_vault_one_input: None,
              token_vault_one_intermediate: None,
              token_vault_two_intermediate: None,
              token_vault_two_output: None,
              token_owner_account_output: None,
              token_authority: None,
              tick_array_one0: None,
              tick_array_one1: None,
              tick_array_one2: None,
              tick_array_two0: None,
              tick_array_two1: None,
              tick_array_two2: None,
              memo_program: None,
                                            amount: None,
                                other_amount_threshold: None,
                                amount_specified_is_input: None,
                                a_to_b_one: None,
                                a_to_b_two: None,
                                sqrt_price_limit_one: None,
                                sqrt_price_limit_two: None,
                                remaining_accounts_info: None,
                    __remaining_accounts: Vec::new(),
    });
    Self { instruction }
  }
      #[inline(always)]
    pub fn fusion_pool_one(&mut self, fusion_pool_one: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.fusion_pool_one = Some(fusion_pool_one);
                    self
    }
      #[inline(always)]
    pub fn fusion_pool_two(&mut self, fusion_pool_two: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.fusion_pool_two = Some(fusion_pool_two);
                    self
    }
      #[inline(always)]
    pub fn token_mint_input(&mut self, token_mint_input: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_mint_input = Some(token_mint_input);
                    self
    }
      #[inline(always)]
    pub fn token_mint_intermediate(&mut self, token_mint_intermediate: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_mint_intermediate = Some(token_mint_intermediate);
                    self
    }
      #[inline(always)]
    pub fn token_mint_output(&mut self, token_mint_output: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_mint_output = Some(token_mint_output);
                    self
    }
      #[inline(always)]
    pub fn token_program_input(&mut self, token_program_input: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_program_input = Some(token_program_input);
                    self
    }
      #[inline(always)]
    pub fn token_program_intermediate(&mut self, token_program_intermediate: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_program_intermediate = Some(token_program_intermediate);
                    self
    }
      #[inline(always)]
    pub fn token_program_output(&mut self, token_program_output: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_program_output = Some(token_program_output);
                    self
    }
      #[inline(always)]
    pub fn token_owner_account_input(&mut self, token_owner_account_input: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_owner_account_input = Some(token_owner_account_input);
                    self
    }
      #[inline(always)]
    pub fn token_vault_one_input(&mut self, token_vault_one_input: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_vault_one_input = Some(token_vault_one_input);
                    self
    }
      #[inline(always)]
    pub fn token_vault_one_intermediate(&mut self, token_vault_one_intermediate: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_vault_one_intermediate = Some(token_vault_one_intermediate);
                    self
    }
      #[inline(always)]
    pub fn token_vault_two_intermediate(&mut self, token_vault_two_intermediate: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_vault_two_intermediate = Some(token_vault_two_intermediate);
                    self
    }
      #[inline(always)]
    pub fn token_vault_two_output(&mut self, token_vault_two_output: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_vault_two_output = Some(token_vault_two_output);
                    self
    }
      #[inline(always)]
    pub fn token_owner_account_output(&mut self, token_owner_account_output: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_owner_account_output = Some(token_owner_account_output);
                    self
    }
      #[inline(always)]
    pub fn token_authority(&mut self, token_authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.token_authority = Some(token_authority);
                    self
    }
      #[inline(always)]
    pub fn tick_array_one0(&mut self, tick_array_one0: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.tick_array_one0 = Some(tick_array_one0);
                    self
    }
      #[inline(always)]
    pub fn tick_array_one1(&mut self, tick_array_one1: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.tick_array_one1 = Some(tick_array_one1);
                    self
    }
      #[inline(always)]
    pub fn tick_array_one2(&mut self, tick_array_one2: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.tick_array_one2 = Some(tick_array_one2);
                    self
    }
      #[inline(always)]
    pub fn tick_array_two0(&mut self, tick_array_two0: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.tick_array_two0 = Some(tick_array_two0);
                    self
    }
      #[inline(always)]
    pub fn tick_array_two1(&mut self, tick_array_two1: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.tick_array_two1 = Some(tick_array_two1);
                    self
    }
      #[inline(always)]
    pub fn tick_array_two2(&mut self, tick_array_two2: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.tick_array_two2 = Some(tick_array_two2);
                    self
    }
      #[inline(always)]
    pub fn memo_program(&mut self, memo_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
                        self.instruction.memo_program = Some(memo_program);
                    self
    }
                    #[inline(always)]
      pub fn amount(&mut self, amount: u64) -> &mut Self {
        self.instruction.amount = Some(amount);
        self
      }
                #[inline(always)]
      pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self {
        self.instruction.other_amount_threshold = Some(other_amount_threshold);
        self
      }
                #[inline(always)]
      pub fn amount_specified_is_input(&mut self, amount_specified_is_input: bool) -> &mut Self {
        self.instruction.amount_specified_is_input = Some(amount_specified_is_input);
        self
      }
                #[inline(always)]
      pub fn a_to_b_one(&mut self, a_to_b_one: bool) -> &mut Self {
        self.instruction.a_to_b_one = Some(a_to_b_one);
        self
      }
                #[inline(always)]
      pub fn a_to_b_two(&mut self, a_to_b_two: bool) -> &mut Self {
        self.instruction.a_to_b_two = Some(a_to_b_two);
        self
      }
                #[inline(always)]
      pub fn sqrt_price_limit_one(&mut self, sqrt_price_limit_one: u128) -> &mut Self {
        self.instruction.sqrt_price_limit_one = Some(sqrt_price_limit_one);
        self
      }
                #[inline(always)]
      pub fn sqrt_price_limit_two(&mut self, sqrt_price_limit_two: u128) -> &mut Self {
        self.instruction.sqrt_price_limit_two = Some(sqrt_price_limit_two);
        self
      }
                /// `[optional argument]`
#[inline(always)]
      pub fn remaining_accounts_info(&mut self, remaining_accounts_info: RemainingAccountsInfo) -> &mut Self {
        self.instruction.remaining_accounts_info = Some(remaining_accounts_info);
        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 = TwoHopSwapInstructionArgs {
                                                              amount: self.instruction.amount.clone().expect("amount is not set"),
                                                                  other_amount_threshold: self.instruction.other_amount_threshold.clone().expect("other_amount_threshold is not set"),
                                                                  amount_specified_is_input: self.instruction.amount_specified_is_input.clone().expect("amount_specified_is_input is not set"),
                                                                  a_to_b_one: self.instruction.a_to_b_one.clone().expect("a_to_b_one is not set"),
                                                                  a_to_b_two: self.instruction.a_to_b_two.clone().expect("a_to_b_two is not set"),
                                                                  sqrt_price_limit_one: self.instruction.sqrt_price_limit_one.clone().expect("sqrt_price_limit_one is not set"),
                                                                  sqrt_price_limit_two: self.instruction.sqrt_price_limit_two.clone().expect("sqrt_price_limit_two is not set"),
                                                                  remaining_accounts_info: self.instruction.remaining_accounts_info.clone(),
                                    };
        let instruction = TwoHopSwapCpi {
        __program: self.instruction.__program,
                  
          fusion_pool_one: self.instruction.fusion_pool_one.expect("fusion_pool_one is not set"),
                  
          fusion_pool_two: self.instruction.fusion_pool_two.expect("fusion_pool_two is not set"),
                  
          token_mint_input: self.instruction.token_mint_input.expect("token_mint_input is not set"),
                  
          token_mint_intermediate: self.instruction.token_mint_intermediate.expect("token_mint_intermediate is not set"),
                  
          token_mint_output: self.instruction.token_mint_output.expect("token_mint_output is not set"),
                  
          token_program_input: self.instruction.token_program_input.expect("token_program_input is not set"),
                  
          token_program_intermediate: self.instruction.token_program_intermediate.expect("token_program_intermediate is not set"),
                  
          token_program_output: self.instruction.token_program_output.expect("token_program_output is not set"),
                  
          token_owner_account_input: self.instruction.token_owner_account_input.expect("token_owner_account_input is not set"),
                  
          token_vault_one_input: self.instruction.token_vault_one_input.expect("token_vault_one_input is not set"),
                  
          token_vault_one_intermediate: self.instruction.token_vault_one_intermediate.expect("token_vault_one_intermediate is not set"),
                  
          token_vault_two_intermediate: self.instruction.token_vault_two_intermediate.expect("token_vault_two_intermediate is not set"),
                  
          token_vault_two_output: self.instruction.token_vault_two_output.expect("token_vault_two_output is not set"),
                  
          token_owner_account_output: self.instruction.token_owner_account_output.expect("token_owner_account_output is not set"),
                  
          token_authority: self.instruction.token_authority.expect("token_authority is not set"),
                  
          tick_array_one0: self.instruction.tick_array_one0.expect("tick_array_one0 is not set"),
                  
          tick_array_one1: self.instruction.tick_array_one1.expect("tick_array_one1 is not set"),
                  
          tick_array_one2: self.instruction.tick_array_one2.expect("tick_array_one2 is not set"),
                  
          tick_array_two0: self.instruction.tick_array_two0.expect("tick_array_two0 is not set"),
                  
          tick_array_two1: self.instruction.tick_array_two1.expect("tick_array_two1 is not set"),
                  
          tick_array_two2: self.instruction.tick_array_two2.expect("tick_array_two2 is not set"),
                  
          memo_program: self.instruction.memo_program.expect("memo_program is not set"),
                          __args: args,
            };
    instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
  }
}

#[derive(Clone, Debug)]
struct TwoHopSwapCpiBuilderInstruction<'a, 'b> {
  __program: &'b solana_account_info::AccountInfo<'a>,
            fusion_pool_one: Option<&'b solana_account_info::AccountInfo<'a>>,
                fusion_pool_two: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_mint_input: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_mint_intermediate: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_mint_output: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_program_input: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_program_intermediate: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_program_output: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_owner_account_input: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_vault_one_input: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_vault_one_intermediate: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_vault_two_intermediate: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_vault_two_output: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_owner_account_output: Option<&'b solana_account_info::AccountInfo<'a>>,
                token_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
                tick_array_one0: Option<&'b solana_account_info::AccountInfo<'a>>,
                tick_array_one1: Option<&'b solana_account_info::AccountInfo<'a>>,
                tick_array_one2: Option<&'b solana_account_info::AccountInfo<'a>>,
                tick_array_two0: Option<&'b solana_account_info::AccountInfo<'a>>,
                tick_array_two1: Option<&'b solana_account_info::AccountInfo<'a>>,
                tick_array_two2: Option<&'b solana_account_info::AccountInfo<'a>>,
                memo_program: Option<&'b solana_account_info::AccountInfo<'a>>,
                        amount: Option<u64>,
                other_amount_threshold: Option<u64>,
                amount_specified_is_input: Option<bool>,
                a_to_b_one: Option<bool>,
                a_to_b_two: Option<bool>,
                sqrt_price_limit_one: Option<u128>,
                sqrt_price_limit_two: Option<u128>,
                remaining_accounts_info: Option<RemainingAccountsInfo>,
        /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
  __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
}

