/// Subtract borrow amount from available liquidity and add to borrows

Subtract borrow amount from available liquidity and add to borrows
Subtract borrow amount from available liquidity and add to borrows
pub fn borrow(&mut self, borrow_decimal: Decimal) -> ProgramResult {
        if borrow_decimal.try_ceil_u64()? > self.liquidity_amount()? {
            msg!("Insufficient liquidity due to fee reserved for reserve owner");
            return Err(PoolingError::InsufficientLiquidity.into());
        }
        self.available_amount = self
            .available_amount
            .checked_sub(borrow_decimal.try_round_u64()?)
            .ok_or(PoolingError::MathOverflow)?;
        self.borrowed_amount_wads = self.borrowed_amount_wads.try_add(borrow_decimal)?;
        Ok(())
    }
pub fn borrow ( & mut self , borrow_decimal : Decimal ) -> ProgramResult { if borrow_decimal . try_ceil_u64 ( ) ? > self . liquidity_amount ( ) ? { msg ! ( " " ) ; return Err ( PoolingError :: InsufficientLiquidity . into ( ) ) ; } self . available_amount = self . available_amount . checked_sub ( borrow_decimal . try_round_u64 ( ) ? ) . ok_or ( PoolingError :: MathOverflow ) ? ; self . borrowed_amount_wads = self . borrowed_amount_wads . try_add ( borrow_decimal ) ? ; Ok ( ( ) ) }
Subtract borrow amount from available liquidity and add to borrows
Subtract borrow amount from available liquidity and add to borrows
&mut self
borrow_decimal
Decimal