pub fn calculate_exchange_rate(
		total_cash: Balance,
		total_supply: Balance,
		total_protocol_interest: Balance,
		total_borrowed: Balance,
	) -> RateResult {
		let rate = match total_supply.is_zero() {
			// If there are no tokens minted: exchange_rate = initial_exchange_rate.
			true => T::InitialExchangeRate::get(),

			// Otherwise: exchange_rate = (total_cash + total_borrowed - total_protocol_interest) / total_supply
			_ => Rate::saturating_from_rational(
				total_cash
					.checked_add(total_borrowed)
					.and_then(|v| v.checked_sub(total_protocol_interest))
					.ok_or(Error::<T>::ExchangeRateCalculationError)?,
				total_supply,
			),
		};

		Ok(rate)
	}
/// Calculates the exchange rate from the underlying to the mToken.
/// - `total_cash`: The total amount of underlying tokens the pool has.
/// - `total_supply`: Total number of wrapped tokens in circulation.
/// - `total_protocol_interest`: Total amount of interest of the underlying held in the pool.
/// - `total_borrowed`: Total amount of outstanding borrows of the underlying in this pool.
///
/// returns `exchange_rate = (total_cash + total_borrowed - total_protocol_interest) /
/// total_supply`.
Calculates the exchange rate from the underlying to the mToken.
`total_cash`: The total amount of underlying tokens the pool has.
`total_supply`: Total number of wrapped tokens in circulation.
`total_protocol_interest`: Total amount of interest of the underlying held in the pool.
`total_borrowed`: Total amount of outstanding borrows of the underlying in this pool.


Calculates the exchange rate from the underlying to the mToken . ` total_cash ` : The total amount of underlying tokens the pool has . ` total_supply ` : Total number of wrapped tokens in circulation . ` total_protocol_interest ` : Total amount of interest of the underlying held in the pool . ` total_borrowed ` : Total amount of outstanding borrows of the underlying in this pool .
pub fn calculate_exchange_rate(
		total_cash: Balance,
		total_supply: Balance,
		total_protocol_interest: Balance,
		total_borrowed: Balance,
	) -> RateResult {
		let rate = match total_supply.is_zero() {
			// If there are no tokens minted: exchange_rate = initial_exchange_rate.
			true => T::InitialExchangeRate::get(),
			// Otherwise: exchange_rate = (total_cash + total_borrowed - total_protocol_interest) / total_supply
			_ => Rate::saturating_from_rational(
				total_cash
					.checked_add(total_borrowed)
					.and_then(|v| v.checked_sub(total_protocol_interest))
					.ok_or(Error::<T>::ExchangeRateCalculationError)?,
				total_supply,
			),
		};
		Ok(rate)
	}
pub fn calculate_exchange_rate ( total_cash : Balance , total_supply : Balance , total_protocol_interest : Balance , total_borrowed : Balance , ) -> RateResult { let rate = match total_supply . is_zero ( ) { // If there are no tokens minted: exchange_rate = initial_exchange_rate. true => T :: InitialExchangeRate :: get ( ) , // Otherwise: exchange_rate = (total_cash + total_borrowed - total_protocol_interest) / total_supply _ => Rate :: saturating_from_rational ( total_cash . checked_add ( total_borrowed ) . and_then ( | v | v . checked_sub ( total_protocol_interest ) ) . ok_or ( Error :: < T > :: ExchangeRateCalculationError ) ? , total_supply , ) , } ; Ok ( rate ) }
Calculates the exchange rate from the underlying to the mToken.
Calculates the exchange rate from the underlying to the mToken .
total_cash
Balance
total_supply
Balance
total_protocol_interest
Balance
total_borrowed
Balance
total_cash
Balance
total_supply
Balance
total_protocol_interest
Balance
total_borrowed
Balance