fn is_borrow_cap_reached(pool_id: CurrencyId, borrow_amount: Balance) -> Result<bool, DispatchError> {
		if let Some(borrow_cap) = Self::controller_dates(pool_id).borrow_cap {
			let oracle_price = T::PriceSource::get_underlying_price(pool_id).ok_or(Error::<T>::InvalidFeedPrice)?;
			let pool_borrow_underlying = T::LiquidityPoolsManager::get_pool_total_borrowed(pool_id);

			// new_borrow_balance_in_usd = (pool_borrow_underlying + borrow_amount) * oracle_price
			let new_pool_borrows = pool_borrow_underlying
				.checked_add(borrow_amount)
				.ok_or(Error::<T>::BalanceOverflow)?;

			let new_borrow_balance_in_usd = Rate::from_inner(new_pool_borrows)
				.checked_mul(&oracle_price)
				.map(|x| x.into_inner())
				.ok_or(Error::<T>::BalanceOverflow)?;

			Ok(new_borrow_balance_in_usd >= borrow_cap)
		} else {
			Ok(false)
		}
	}
/// Checks if borrow cap is reached.
///
/// Return true if total borrow per pool will exceed borrow cap, otherwise false.
Checks if borrow cap is reached.
Return true if total borrow per pool will exceed borrow cap, otherwise false.
Checks if borrow cap is reached . Return true if total borrow per pool will exceed borrow cap otherwise false .
fn is_borrow_cap_reached(pool_id: CurrencyId, borrow_amount: Balance) -> Result<bool, DispatchError> {
		if let Some(borrow_cap) = Self::controller_dates(pool_id).borrow_cap {
			let oracle_price = T::PriceSource::get_underlying_price(pool_id).ok_or(Error::<T>::InvalidFeedPrice)?;
			let pool_borrow_underlying = T::LiquidityPoolsManager::get_pool_total_borrowed(pool_id);
			// new_borrow_balance_in_usd = (pool_borrow_underlying + borrow_amount) * oracle_price
			let new_pool_borrows = pool_borrow_underlying
				.checked_add(borrow_amount)
				.ok_or(Error::<T>::BalanceOverflow)?;
			let new_borrow_balance_in_usd = Rate::from_inner(new_pool_borrows)
				.checked_mul(&oracle_price)
				.map(|x| x.into_inner())
				.ok_or(Error::<T>::BalanceOverflow)?;
			Ok(new_borrow_balance_in_usd >= borrow_cap)
		} else {
			Ok(false)
		}
	}
fn is_borrow_cap_reached ( pool_id : CurrencyId , borrow_amount : Balance ) -> Result < bool , DispatchError > { if let Some ( borrow_cap ) = Self :: controller_dates ( pool_id ) . borrow_cap { let oracle_price = T :: PriceSource :: get_underlying_price ( pool_id ) . ok_or ( Error :: < T > :: InvalidFeedPrice ) ? ; let pool_borrow_underlying = T :: LiquidityPoolsManager :: get_pool_total_borrowed ( pool_id ) ; // new_borrow_balance_in_usd = (pool_borrow_underlying + borrow_amount) * oracle_price let new_pool_borrows = pool_borrow_underlying . checked_add ( borrow_amount ) . ok_or ( Error :: < T > :: BalanceOverflow ) ? ; let new_borrow_balance_in_usd = Rate :: from_inner ( new_pool_borrows ) . checked_mul ( & oracle_price ) . map ( | x | x . into_inner ( ) ) . ok_or ( Error :: < T > :: BalanceOverflow ) ? ; Ok ( new_borrow_balance_in_usd >= borrow_cap ) } else { Ok ( false ) } }
Checks if borrow cap is reached.
Checks if borrow cap is reached .
pool_id
CurrencyId
borrow_amount
Balance
pool_id
CurrencyId
borrow_amount
Balance