pub struct MarketConfiguration {Show 17 fields
pub time_chunk_configuration: TimeChunkConfiguration,
pub borrow_asset: FungibleAsset<BorrowAsset>,
pub collateral_asset: FungibleAsset<CollateralAsset>,
pub price_oracle_configuration: PriceOracleConfiguration,
pub borrow_mcr_maintenance: Decimal,
pub borrow_mcr_liquidation: Decimal,
pub borrow_asset_maximum_usage_ratio: Decimal,
pub borrow_origination_fee: Fee<BorrowAsset>,
pub borrow_interest_rate_strategy: InterestRateStrategy,
pub borrow_maximum_duration_ms: Option<U64>,
pub borrow_range: ValidAmountRange<BorrowAsset>,
pub supply_range: ValidAmountRange<BorrowAsset>,
pub supply_withdrawal_range: ValidAmountRange<BorrowAsset>,
pub supply_withdrawal_fee: TimeBasedFee<BorrowAsset>,
pub yield_weights: YieldWeights,
pub protocol_account_id: AccountId,
pub liquidation_maximum_spread: Decimal,
}
Expand description
Configuration for a single asset-pair borrow market.
A market’s configuration is immutable after deployment.
Fields§
§time_chunk_configuration: TimeChunkConfiguration
As time passes, the market creates snapshots of its state. These snapshots are used to calculate the interest charged to borrowers, yield earned by suppliers, etc. A time chunk represents the period of time over which a snapshot is taken, and is used as a disambiguating index for snapshots.
borrow_asset: FungibleAsset<BorrowAsset>
The borrow asset supported by this market.
collateral_asset: FungibleAsset<CollateralAsset>
The collateral asset supported by this market.
price_oracle_configuration: PriceOracleConfiguration
The market communicates with a price oracle to determine asset valuations.
borrow_mcr_maintenance: Decimal
A borrow position must satisfy this minimum collateralization ratio after any modifications (e.g. withdrawing collateral).
Must be greater than or equal to borrow_mcr_liquidation
.
borrow_mcr_liquidation: Decimal
A borrow position is eligible for liquidation if it does not satisfy this minimu collateralization ratio.
Must be less than or equal to borrow_mcr_maintenance
.
borrow_asset_maximum_usage_ratio: Decimal
Maintain a reserve of some% of the deposited supply; how much of the deposited principal may be lent out (up to 100%)? This is a matter of protection for supply providers.
borrow_origination_fee: Fee<BorrowAsset>
The origination fee is a one-time amount added to the principal of the borrow. That is to say, the origination fee is denominated in units of the borrow asset and is paid by the borrowing account during repayment (or liquidation).
borrow_interest_rate_strategy: InterestRateStrategy
Interest rate is decided by a function of utilization ratio [0.0, 1.0].
borrow_maximum_duration_ms: Option<U64>
If a maximum borrow duration is configured, a borrow position is instantly eligible for liquidation (regardless of collateralization ratio) after this period has expired.
borrow_range: ValidAmountRange<BorrowAsset>
A borrow position’s principal must be within this range after modification.
supply_range: ValidAmountRange<BorrowAsset>
A supply position’s deposit must be within this range after modification.
supply_withdrawal_range: ValidAmountRange<BorrowAsset>
A supply position may only request to withdraw amounts within this range.
supply_withdrawal_fee: TimeBasedFee<BorrowAsset>
A time-bound fee for supply, to discourage extremely short-lived supply positions.
yield_weights: YieldWeights
Determines how yield is distributed between suppliers (dynamically allocated based on deposit) and statically-configured accounts (e.g. a protocol insurance account).
protocol_account_id: AccountId
For collecting supply withdrawal fees.
Supply withdrawal fees cannot be distributed to other suppliers because there may not be any suppliers to earn those fees after the last one withdraws.
liquidation_maximum_spread: Decimal
How far below market rate to accept liquidation? This is effectively the liquidator’s spread.
For example, if a 100USDC borrow is (under)collateralized with $110 of NEAR, a “maximum liquidator spread” of 1% would mean that a liquidator could liquidate this borrow by sending 108.9USDC, netting the liquidator $110 * 1% = $1.1 of NEAR.
Implementations§
Source§impl MarketConfiguration
impl MarketConfiguration
Sourcepub fn validate(&self) -> Result<(), ConfigurationValidationError>
pub fn validate(&self) -> Result<(), ConfigurationValidationError>
§Errors
If the configuration is invalid.
pub fn borrow_status( &self, collateralization_ratio: Option<Decimal>, started_at_block_timestamp_ms: Option<impl Into<u64>>, block_timestamp_ms: u64, ) -> BorrowStatus
pub fn minimum_acceptable_liquidation_amount( &self, amount: CollateralAssetAmount, price_pair: &PricePair, ) -> Option<BorrowAssetAmount>
pub fn single_snapshot_maximum_interest(&self) -> Decimal
pub fn supply_yield_rate_from_interest(&self, snapshot: &Snapshot) -> Decimal
Trait Implementations§
Source§impl BorshDeserialize for MarketConfiguration
impl BorshDeserialize for MarketConfiguration
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for MarketConfiguration
impl BorshSerialize for MarketConfiguration
Source§impl Clone for MarketConfiguration
impl Clone for MarketConfiguration
Source§fn clone(&self) -> MarketConfiguration
fn clone(&self) -> MarketConfiguration
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for MarketConfiguration
impl Debug for MarketConfiguration
Source§impl<'de> Deserialize<'de> for MarketConfiguration
impl<'de> Deserialize<'de> for MarketConfiguration
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for MarketConfiguration
impl PartialEq for MarketConfiguration
Source§impl Serialize for MarketConfiguration
impl Serialize for MarketConfiguration
impl Eq for MarketConfiguration
impl StructuralPartialEq for MarketConfiguration
Auto Trait Implementations§
impl Freeze for MarketConfiguration
impl RefUnwindSafe for MarketConfiguration
impl Send for MarketConfiguration
impl Sync for MarketConfiguration
impl Unpin for MarketConfiguration
impl UnwindSafe for MarketConfiguration
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.