pub fn remove_unlocked_liquidity_vault(
        &self,
        signer: &dyn Signer,
        vault_name: &str,
        ui_amount: f64,
    ) -> Result<Signature, FarmClientError> {
        // check user accounts
        let mut inst = Vec::<Instruction>::new();
        self.check_vault_accounts(signer, vault_name, 0.0, 0.0, 0.0, false, false, &mut inst)?;
        if !inst.is_empty() {
            self.sign_and_send_instructions(&[signer], inst.as_slice())?;
            inst.clear();
        }

        // check if the user has unlocked balance
        if ui_amount > 0.0 {
            let lp_debt = self
                .get_vault_user_info(&signer.pubkey(), vault_name)?
                .lp_tokens_debt;
            let pool_token_decimals = self.get_vault_lp_token_decimals(vault_name)?;
            if self.tokens_to_ui_amount_with_decimals(lp_debt, pool_token_decimals) < ui_amount {
                return Err(FarmClientError::InsufficientBalance(
                    "Not enough unlocked tokens to remove".to_string(),
                ));
            }
        }

        inst.push(self.new_instruction_remove_liquidity_vault(
            &signer.pubkey(),
            vault_name,
            ui_amount,
        )?);

        // check if tokens need to be unwrapped
        let (is_token_a_sol, is_token_b_sol) = self.vault_has_sol_tokens(vault_name)?;
        let pool_name = self.get_underlying_pool(vault_name)?.name.to_string();
        let (is_token_a_wrapped, is_token_b_wrapped) =
            self.pool_has_saber_wrapped_tokens(&pool_name)?;

        if is_token_a_wrapped {
            inst.push(self.new_instruction_unwrap_token(
                &signer.pubkey(),
                &pool_name,
                TokenSelector::TokenA,
                0.0,
            )?);
        }
        if is_token_b_wrapped {
            inst.push(self.new_instruction_unwrap_token(
                &signer.pubkey(),
                &pool_name,
                TokenSelector::TokenB,
                0.0,
            )?);
        }
        if is_token_a_sol || is_token_b_sol {
            inst.push(self.new_instruction_close_token_account(&signer.pubkey(), "SOL")?);
        }

        self.sign_and_send_instructions(&[signer], inst.as_slice())
    }
/// Removes unlocked liquidity from the Vault.
/// Useful if remove liquidity operation failed after unlock step.
Removes unlocked liquidity from the Vault.
Useful if remove liquidity operation failed after unlock step.
Removes unlocked liquidity from the Vault . Useful if remove liquidity operation failed after unlock step .
pub fn remove_unlocked_liquidity_vault(
        &self,
        signer: &dyn Signer,
        vault_name: &str,
        ui_amount: f64,
    ) -> Result<Signature, FarmClientError> {
        // check user accounts
        let mut inst = Vec::<Instruction>::new();
        self.check_vault_accounts(signer, vault_name, 0.0, 0.0, 0.0, false, false, &mut inst)?;
        if !inst.is_empty() {
            self.sign_and_send_instructions(&[signer], inst.as_slice())?;
            inst.clear();
        }
        // check if the user has unlocked balance
        if ui_amount > 0.0 {
            let lp_debt = self
                .get_vault_user_info(&signer.pubkey(), vault_name)?
                .lp_tokens_debt;
            let pool_token_decimals = self.get_vault_lp_token_decimals(vault_name)?;
            if self.tokens_to_ui_amount_with_decimals(lp_debt, pool_token_decimals) < ui_amount {
                return Err(FarmClientError::InsufficientBalance(
                    "Not enough unlocked tokens to remove".to_string(),
                ));
            }
        }
        inst.push(self.new_instruction_remove_liquidity_vault(
            &signer.pubkey(),
            vault_name,
            ui_amount,
        )?);
        // check if tokens need to be unwrapped
        let (is_token_a_sol, is_token_b_sol) = self.vault_has_sol_tokens(vault_name)?;
        let pool_name = self.get_underlying_pool(vault_name)?.name.to_string();
        let (is_token_a_wrapped, is_token_b_wrapped) =
            self.pool_has_saber_wrapped_tokens(&pool_name)?;
        if is_token_a_wrapped {
            inst.push(self.new_instruction_unwrap_token(
                &signer.pubkey(),
                &pool_name,
                TokenSelector::TokenA,
                0.0,
            )?);
        }
        if is_token_b_wrapped {
            inst.push(self.new_instruction_unwrap_token(
                &signer.pubkey(),
                &pool_name,
                TokenSelector::TokenB,
                0.0,
            )?);
        }
        if is_token_a_sol || is_token_b_sol {
            inst.push(self.new_instruction_close_token_account(&signer.pubkey(), "SOL")?);
        }
        self.sign_and_send_instructions(&[signer], inst.as_slice())
    }
pub fn remove_unlocked_liquidity_vault ( & self , signer : & dyn Signer , vault_name : & str , ui_amount : f64 , ) -> Result < Signature , FarmClientError > { // check user accounts let mut inst = Vec :: < Instruction > :: new ( ) ; self . check_vault_accounts ( signer , vault_name , 0.0 , 0.0 , 0.0 , false , false , & mut inst ) ? ; if ! inst . is_empty ( ) { self . sign_and_send_instructions ( & [ signer ] , inst . as_slice ( ) ) ? ; inst . clear ( ) ; } // check if the user has unlocked balance if ui_amount > 0.0 { let lp_debt = self . get_vault_user_info ( & signer . pubkey ( ) , vault_name ) ? . lp_tokens_debt ; let pool_token_decimals = self . get_vault_lp_token_decimals ( vault_name ) ? ; if self . tokens_to_ui_amount_with_decimals ( lp_debt , pool_token_decimals ) < ui_amount { return Err ( FarmClientError :: InsufficientBalance ( " " . to_string ( ) , ) ) ; } } inst . push ( self . new_instruction_remove_liquidity_vault ( & signer . pubkey ( ) , vault_name , ui_amount , ) ? ) ; // check if tokens need to be unwrapped let ( is_token_a_sol , is_token_b_sol ) = self . vault_has_sol_tokens ( vault_name ) ? ; let pool_name = self . get_underlying_pool ( vault_name ) ? . name . to_string ( ) ; let ( is_token_a_wrapped , is_token_b_wrapped ) = self . pool_has_saber_wrapped_tokens ( & pool_name ) ? ; if is_token_a_wrapped { inst . push ( self . new_instruction_unwrap_token ( & signer . pubkey ( ) , & pool_name , TokenSelector :: TokenA , 0.0 , ) ? ) ; } if is_token_b_wrapped { inst . push ( self . new_instruction_unwrap_token ( & signer . pubkey ( ) , & pool_name , TokenSelector :: TokenB , 0.0 , ) ? ) ; } if is_token_a_sol || is_token_b_sol { inst . push ( self . new_instruction_close_token_account ( & signer . pubkey ( ) , " " ) ? ) ; } self . sign_and_send_instructions ( & [ signer ] , inst . as_slice ( ) ) }
Removes unlocked liquidity from the Vault.
Removes unlocked liquidity from the Vault .
&self
signer
&dyn Signer
vault_name
&str
ui_amount
f64
&self
signer
&dyn Signer
vault_name
&str
ui_amount
f64