fn do_borrow(who: &T::AccountId, underlying_asset: CurrencyId, borrow_amount: Balance) -> DispatchResult {
		ensure!(
			underlying_asset.is_supported_underlying_asset(),
			Error::<T>::NotValidUnderlyingAssetId
		);
		ensure!(
			T::ManagerLiquidityPools::pool_exists(&underlying_asset),
			liquidity_pools::Error::<T>::PoolNotFound
		);

		let pool_available_liquidity = T::ManagerLiquidityPools::get_pool_available_liquidity(underlying_asset);

		// Raise an error if protocol has insufficient underlying cash.
		ensure!(
			borrow_amount <= pool_available_liquidity,
			Error::<T>::NotEnoughLiquidityAvailable
		);

		ensure!(borrow_amount > Balance::zero(), Error::<T>::ZeroBalanceTransaction);

		T::ControllerManager::accrue_interest_rate(underlying_asset).map_err(|_| Error::<T>::AccrueInterestFailed)?;

		// Fail if borrow not allowed.
		ensure!(
			T::ControllerManager::is_operation_allowed(underlying_asset, Operation::Borrow),
			Error::<T>::OperationPaused
		);
		T::ControllerManager::borrow_allowed(underlying_asset, &who, borrow_amount)?;

		T::MntManager::update_mnt_borrow_index(underlying_asset)?;
		T::MntManager::distribute_borrower_mnt(underlying_asset, who, false)?;

		// Fetch the amount the borrower owes, with accumulated interest.
		let account_borrows = T::ControllerManager::borrow_balance_stored(&who, underlying_asset)?;

		<LiquidityPools<T>>::update_state_on_borrow(&who, underlying_asset, borrow_amount, account_borrows)?;

		// Transfer the borrow_amount from the protocol account to the borrower's account.
		T::MultiCurrency::transfer(
			underlying_asset,
			&T::ManagerLiquidityPools::pools_account_id(),
			&who,
			borrow_amount,
		)?;

		Ok(())
	}
/// Users borrow assets from the protocol to their own address
///
/// - `who`: the address of the user who borrows.
/// - `underlying_asset`: the currency ID of the underlying asset to borrow.
/// - `underlying_amount`: the amount of the underlying asset to borrow.
Users borrow assets from the protocol to their own address
`who`: the address of the user who borrows.
`underlying_asset`: the currency ID of the underlying asset to borrow.
`underlying_amount`: the amount of the underlying asset to borrow.
Users borrow assets from the protocol to their own address ` who ` : the address of the user who borrows . ` underlying_asset ` : the currency ID of the underlying asset to borrow . ` underlying_amount ` : the amount of the underlying asset to borrow .
fn do_borrow(who: &T::AccountId, underlying_asset: CurrencyId, borrow_amount: Balance) -> DispatchResult {
		ensure!(
			underlying_asset.is_supported_underlying_asset(),
			Error::<T>::NotValidUnderlyingAssetId
		);
		ensure!(
			T::ManagerLiquidityPools::pool_exists(&underlying_asset),
			liquidity_pools::Error::<T>::PoolNotFound
		);
		let pool_available_liquidity = T::ManagerLiquidityPools::get_pool_available_liquidity(underlying_asset);
		// Raise an error if protocol has insufficient underlying cash.
		ensure!(
			borrow_amount <= pool_available_liquidity,
			Error::<T>::NotEnoughLiquidityAvailable
		);
		ensure!(borrow_amount > Balance::zero(), Error::<T>::ZeroBalanceTransaction);
		T::ControllerManager::accrue_interest_rate(underlying_asset).map_err(|_| Error::<T>::AccrueInterestFailed)?;
		// Fail if borrow not allowed.
		ensure!(
			T::ControllerManager::is_operation_allowed(underlying_asset, Operation::Borrow),
			Error::<T>::OperationPaused
		);
		T::ControllerManager::borrow_allowed(underlying_asset, &who, borrow_amount)?;
		T::MntManager::update_mnt_borrow_index(underlying_asset)?;
		T::MntManager::distribute_borrower_mnt(underlying_asset, who, false)?;
		// Fetch the amount the borrower owes, with accumulated interest.
		let account_borrows = T::ControllerManager::borrow_balance_stored(&who, underlying_asset)?;
		<LiquidityPools<T>>::update_state_on_borrow(&who, underlying_asset, borrow_amount, account_borrows)?;
		// Transfer the borrow_amount from the protocol account to the borrower's account.
		T::MultiCurrency::transfer(
			underlying_asset,
			&T::ManagerLiquidityPools::pools_account_id(),
			&who,
			borrow_amount,
		)?;
		Ok(())
	}
fn do_borrow ( who : & T :: AccountId , underlying_asset : CurrencyId , borrow_amount : Balance ) -> DispatchResult { ensure ! ( underlying_asset is_supported_underlying_asset ( ) Error T NotValidUnderlyingAssetId ) ; ensure ! ( T ManagerLiquidityPools pool_exists ( underlying_asset ) liquidity_pools Error T PoolNotFound ) ; let pool_available_liquidity = T :: ManagerLiquidityPools :: get_pool_available_liquidity ( underlying_asset ) ; // Raise an error if protocol has insufficient underlying cash. ensure ! ( borrow_amount pool_available_liquidity Error T NotEnoughLiquidityAvailable ) ; ensure ! ( borrow_amount Balance zero ( ) Error T ZeroBalanceTransaction ) ; T :: ControllerManager :: accrue_interest_rate ( underlying_asset ) . map_err ( | _ | Error :: < T > :: AccrueInterestFailed ) ? ; // Fail if borrow not allowed. ensure ! ( T ControllerManager is_operation_allowed ( underlying_asset Operation Borrow ) Error T OperationPaused ) ; T :: ControllerManager :: borrow_allowed ( underlying_asset , & who , borrow_amount ) ? ; T :: MntManager :: update_mnt_borrow_index ( underlying_asset ) ? ; T :: MntManager :: distribute_borrower_mnt ( underlying_asset , who , false ) ? ; // Fetch the amount the borrower owes, with accumulated interest. let account_borrows = T :: ControllerManager :: borrow_balance_stored ( & who , underlying_asset ) ? ; < LiquidityPools < T > > :: update_state_on_borrow ( & who , underlying_asset , borrow_amount , account_borrows ) ? ; // Transfer the borrow_amount from the protocol account to the borrower's account. T :: MultiCurrency :: transfer ( underlying_asset , & T :: ManagerLiquidityPools :: pools_account_id ( ) , & who , borrow_amount , ) ? ; Ok ( ( ) ) }
Users borrow assets from the protocol to their own address
 `who`: the address of the user who borrows.
Users borrow assets from the protocol to their own address ` who ` : the address of the user who borrows .
who
&T::AccountId
underlying_asset
CurrencyId
borrow_amount
Balance
who
&T::AccountId
underlying_asset
CurrencyId
borrow_amount
Balance