pub fn redeem_collateral(&mut self, collateral_amount: u64) -> Result<u64, ProgramError> {
        let collateral_exchange_rate = self.collateral_exchange_rate()?;
        let liquidity_amount =
            collateral_exchange_rate.collateral_to_liquidity(collateral_amount)?;
        if liquidity_amount > self.liquidity.available_amount {
            return Err(LendingError::InsufficientLiquidity.into());
        }

        self.liquidity.available_amount -= liquidity_amount;
        self.collateral.mint_total_supply -= collateral_amount;

        Ok(liquidity_amount)
    }
/// Record redeemed collateral and return amount of liquidity to withdraw
Record redeemed collateral and return amount of liquidity to withdraw
Record redeemed collateral and return amount of liquidity to withdraw
pub fn redeem_collateral(&mut self, collateral_amount: u64) -> Result<u64, ProgramError> {
        let collateral_exchange_rate = self.collateral_exchange_rate()?;
        let liquidity_amount =
            collateral_exchange_rate.collateral_to_liquidity(collateral_amount)?;
        if liquidity_amount > self.liquidity.available_amount {
            return Err(LendingError::InsufficientLiquidity.into());
        }
        self.liquidity.available_amount -= liquidity_amount;
        self.collateral.mint_total_supply -= collateral_amount;
        Ok(liquidity_amount)
    }
pub fn redeem_collateral ( & mut self , collateral_amount : u64 ) -> Result < u64 , ProgramError > { let collateral_exchange_rate = self . collateral_exchange_rate ( ) ? ; let liquidity_amount = collateral_exchange_rate . collateral_to_liquidity ( collateral_amount ) ? ; if liquidity_amount > self . liquidity . available_amount { return Err ( LendingError :: InsufficientLiquidity . into ( ) ) ; } self . liquidity . available_amount -= liquidity_amount ; self . collateral . mint_total_supply -= collateral_amount ; Ok ( liquidity_amount ) }
Record redeemed collateral and return amount of liquidity to withdraw
Record redeemed collateral and return amount of liquidity to withdraw
&mut self
collateral_amount
u64