fn calculate_ideal_balance(pool_id: CurrencyId) -> BalanceResult {
		let oracle_price = T::PriceSource::get_underlying_price(pool_id).ok_or(Error::<T>::InvalidFeedPrice)?;
		let balance_ratio = Self::liquidation_pools_data(pool_id).balance_ratio;

		// Liquidation pool ideal balance in USD: liquidity_pool_balance * balance_ratio * oracle_price
		let ideal_balance = Rate::from_inner(T::LiquidityPoolsManager::get_pool_available_liquidity(pool_id))
			.checked_mul(&balance_ratio)
			.and_then(|v| v.checked_mul(&oracle_price))
			.map(|x| x.into_inner())
			.ok_or(Error::<T>::BalanceOverflow)?;

		match Self::liquidation_pools_data(pool_id).max_ideal_balance {
			Some(max_ideal_balance) => Ok(ideal_balance.min(max_ideal_balance)),
			None => Ok(ideal_balance),
		}
	}
/// Calculates ideal balance for pool balancing
/// - `pool_id`: PoolID for which the ideal balance is calculated.
///
/// Returns minimum of (liquidity_pool_balance * balance_ratio * oracle_price) and
/// max_ideal_balance
Calculates ideal balance for pool balancing
`pool_id`: PoolID for which the ideal balance is calculated.


Calculates ideal balance for pool balancing ` pool_id ` : PoolID for which the ideal balance is calculated .
fn calculate_ideal_balance(pool_id: CurrencyId) -> BalanceResult {
		let oracle_price = T::PriceSource::get_underlying_price(pool_id).ok_or(Error::<T>::InvalidFeedPrice)?;
		let balance_ratio = Self::liquidation_pools_data(pool_id).balance_ratio;
		// Liquidation pool ideal balance in USD: liquidity_pool_balance * balance_ratio * oracle_price
		let ideal_balance = Rate::from_inner(T::LiquidityPoolsManager::get_pool_available_liquidity(pool_id))
			.checked_mul(&balance_ratio)
			.and_then(|v| v.checked_mul(&oracle_price))
			.map(|x| x.into_inner())
			.ok_or(Error::<T>::BalanceOverflow)?;
		match Self::liquidation_pools_data(pool_id).max_ideal_balance {
			Some(max_ideal_balance) => Ok(ideal_balance.min(max_ideal_balance)),
			None => Ok(ideal_balance),
		}
	}
fn calculate_ideal_balance ( pool_id : CurrencyId ) -> BalanceResult { let oracle_price = T :: PriceSource :: get_underlying_price ( pool_id ) . ok_or ( Error :: < T > :: InvalidFeedPrice ) ? ; let balance_ratio = Self :: liquidation_pools_data ( pool_id ) . balance_ratio ; // Liquidation pool ideal balance in USD: liquidity_pool_balance * balance_ratio * oracle_price let ideal_balance = Rate :: from_inner ( T :: LiquidityPoolsManager :: get_pool_available_liquidity ( pool_id ) ) . checked_mul ( & balance_ratio ) . and_then ( | v | v . checked_mul ( & oracle_price ) ) . map ( | x | x . into_inner ( ) ) . ok_or ( Error :: < T > :: BalanceOverflow ) ? ; match Self :: liquidation_pools_data ( pool_id ) . max_ideal_balance { Some ( max_ideal_balance ) => Ok ( ideal_balance . min ( max_ideal_balance ) ) , None => Ok ( ideal_balance ) , } }
Calculates ideal balance for pool balancing
 `pool_id`: PoolID for which the ideal balance is calculated.
Calculates ideal balance for pool balancing ` pool_id ` : PoolID for which the ideal balance is calculated .
pool_id
CurrencyId
pool_id
CurrencyId