pub fn new_instruction_remove_liquidity_pool(
        &self,
        wallet_address: &Pubkey,
        pool_name: &str,
        ui_amount: f64,
    ) -> Result<Instruction, FarmClientError> {
        // get pool info
        let pool = self.get_pool(pool_name)?;

        // get tokens info
        let lp_token = self.get_token_by_ref_from_cache(&pool.lp_token_ref)?;

        // fill in instruction data
        let data = AmmInstruction::RemoveLiquidity {
            amount: self.to_token_amount_option(ui_amount, &lp_token)?,
        }
        .to_vec()?;

        let accounts = match pool.route {
            PoolRoute::Raydium { .. } => {
                self.get_remove_liquidity_accounts_raydium(wallet_address, pool_name)?
            }
            PoolRoute::Saber { .. } => {
                self.get_remove_liquidity_accounts_saber(wallet_address, pool_name)?
            }
            PoolRoute::Orca { .. } => {
                self.get_remove_liquidity_accounts_orca(wallet_address, pool_name)?
            }
        };

        Ok(Instruction {
            program_id: pool.router_program_id,
            data,
            accounts,
        })
    }
/// Creates a new Instruction for removing liquidity from the Pool
Creates a new Instruction for removing liquidity from the Pool
Creates a new Instruction for removing liquidity from the Pool
pub fn new_instruction_remove_liquidity_pool(
        &self,
        wallet_address: &Pubkey,
        pool_name: &str,
        ui_amount: f64,
    ) -> Result<Instruction, FarmClientError> {
        // get pool info
        let pool = self.get_pool(pool_name)?;
        // get tokens info
        let lp_token = self.get_token_by_ref_from_cache(&pool.lp_token_ref)?;
        // fill in instruction data
        let data = AmmInstruction::RemoveLiquidity {
            amount: self.to_token_amount_option(ui_amount, &lp_token)?,
        }
        .to_vec()?;
        let accounts = match pool.route {
            PoolRoute::Raydium { .. } => {
                self.get_remove_liquidity_accounts_raydium(wallet_address, pool_name)?
            }
            PoolRoute::Saber { .. } => {
                self.get_remove_liquidity_accounts_saber(wallet_address, pool_name)?
            }
            PoolRoute::Orca { .. } => {
                self.get_remove_liquidity_accounts_orca(wallet_address, pool_name)?
            }
        };
        Ok(Instruction {
            program_id: pool.router_program_id,
            data,
            accounts,
        })
    }
pub fn new_instruction_remove_liquidity_pool ( & self , wallet_address : & Pubkey , pool_name : & str , ui_amount : f64 , ) -> Result < Instruction , FarmClientError > { // get pool info let pool = self . get_pool ( pool_name ) ? ; // get tokens info let lp_token = self . get_token_by_ref_from_cache ( & pool . lp_token_ref ) ? ; // fill in instruction data let data = AmmInstruction :: RemoveLiquidity { amount : self . to_token_amount_option ( ui_amount , & lp_token ) ? , } . to_vec ( ) ? ; let accounts = match pool . route { PoolRoute :: Raydium { .. } => { self . get_remove_liquidity_accounts_raydium ( wallet_address , pool_name ) ? } PoolRoute :: Saber { .. } => { self . get_remove_liquidity_accounts_saber ( wallet_address , pool_name ) ? } PoolRoute :: Orca { .. } => { self . get_remove_liquidity_accounts_orca ( wallet_address , pool_name ) ? } } ; Ok ( Instruction { program_id : pool . router_program_id , data , accounts , } ) }
Creates a new Instruction for removing liquidity from the Pool
Creates a new Instruction for removing liquidity from the Pool
&self
wallet_address
&Pubkey
pool_name
&str
ui_amount
f64
&self
wallet_address
&Pubkey
pool_name
&str
ui_amount
f64