Oracles & Alarms

Price Is Calculated Using the Exponential Moving Average (EMA) Method

Market Data Price Oracle

It is an on-chain oracle providing market data prices to the rest of the system. The Market Data Price Oracle allows other components to notify upon reaching a specified price. There may be multiple price values a component is willing to monitor.

Market Data Price Feeder

The Market Data Price Feeder obtains a set of denomination pairs from the Market Data Price Oracle and retrieves prices from Osmosis for the supported pairs. The feeder aggregates the prices by average and pushes the data with updated feed messages. A price feeder needs to be approved by governance in order to be in the active set and to provide prices to the Oracle. The last price pushed in a certain interval (for example, every 2 seconds), is the one that the Oracle contract receives.

The set of supported currency pairs is configurable through governance. A contract instantiates with a base currency in the prices provided. The base currency is not possible to be updated later. A resolution list defines the path from a currency A to B. The most straightforward resolution is with length 1, i.e., [A/B] or [B/A]. Longer lists should be ordered in a traversable way from A to B or back, for example, [A/C, B/C], or [A/C, C/B], or [C/A, B/C], etc.

A contract is configured upon instantiation with a set of supported currencies by providing a list of the base currency. A contract provides a set of currency pairs to receive market data upon request. Market data may be provided for the reverse pairs instead of the requested ones. For example, receiving data for A/B is acceptable, although B/A is the pair included in the set.

Price Calculation Algorithm

The price feeders utilize a variant of the Exponential Moving Average (EMA) algorithm to calculate the price of a given cryptocurrency pair. This is used to optimize for additional security. Through the use of this algorithm, one can put additional weights on more recently observed prices for a given period. More precisely, this can be tweaked by making use of a so-called discounting factor that takes values from 0 (excl.) to 1. The higher the value of this factor the faster old observations get discounted. This is the core difference to the Standard Moving Average (SMA) which applies equal weights to all observed price feeds for a given period.

Global Time Oracle

It is an on-chain timer providing global time to the rest of the system. It updates the time from the Tendermint block time of the last Market Data Price Feed, and the Global Time Alarm allows other components to notify upon reaching a specified time.