Oracle

Overview

Parallel oracle implement with orml-oracle , serval approved members can feed prices to on-chain oracle, and then aggregated on-chain.
Tip: follow the link for more info about orml-oracle.

Oracle Architecture

Prices Pallet

This pallet provides the price from Oracle Module by implementing thePriceFeeder trait. In case of emergency, the price can be set directly by Oracle Collective.

View Data Storage

EmergencyPrice

Mapping from currency id to it's emergency price
Code
View Method
1
pub type EmergencyPrice<T: Config> = StorageMap<_, Twox64Concat, CurrencyId, PriceWithDecimal, OptionQuery>;
Copied!
1
EmergencyPrice::T::get(currency_id: &CurrencyId)
2
Self::emergency_price(currency_id: &CurrencyId)
Copied!
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
Tip: Follow the link to know more about 'CurrencyId'.

View Methods

Set_price()

Set emergency price
1
pub fn set_price(origin: OriginFor<T>, currency_id: CurrencyId, price: PriceWithDecimal,) -> DispatchResultWithPostInfo
Copied!
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
currency_id
-
CurrencyId
The currency id price to be set
price
-
PriceWithDecimal
The price with decimal to be set
RETURN: Returns Ok() when set_price succeeds, otherwise return a substrate error type.
Tip: Follow the link to know more about 'PriceWithDecimal'.

Reset_price()

Reset emergency price
1
pub fn reset_price(origin: OriginFor<T>, currency_id: CurrencyId,) -> DispatchResultWithPostInfo
Copied!
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
currency_id
-
CurrencyId
The currency id price to be set
RETURN: Returns Ok() when reset_price succeeds, otherwise return a substrate error type.

View Event

SetPrice

Set emergency price. [currency_id, price_detail]
SetPrice(CurrencyId, PriceWithDecimal)

ResetPrice

Reset emergency price. [currency_id]
ResetPrice(CurrencyId)
Last modified 3mo ago