Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Oracle ¶
type Oracle struct {
// contains filtered or unexported fields
}
Oracle implements the core component responsible for fetching exchange rates for a given set of currency pairs and determining exchange rates.
func New ¶
func New( logger log.Logger, oracleTicker time.Duration, providers []types.Provider, aggregateFn types.AggregateFn, ) *Oracle
New returns a new instance of an Oracle. The oracle inputs providers that are responsible for fetching prices for a given set of currency pairs (base, quote). The oracle will fetch new prices concurrently every oracleTicker interval. In the case where the oracle fails to fetch prices from a given provider, it will continue to fetch prices from the remaining providers. The oracle currently assumes that each provider aggregates prices using TWAPs, TVWAPs, etc. When determining final prices, the oracle will utilize the aggregateFn to compute the final price for each currency pair. By default, the oracle will compute the median price across all providers.
func NewDefaultOracle ¶
func NewDefaultOracle( logger log.Logger, oracleTicker time.Duration, providers []types.Provider, currencyPairs []oracletypes.CurrencyPair, ) *Oracle
NewDefaultOracle returns a new instance of an Oracle with a default aggregate function. It registers the given providers with the same set of currency pairs. The default aggregate function computes the median price across all providers.
func NewOracleFromConfig ¶
NewOracleFromConfig returns a new oracle instance from the given OracleConfig.
func (*Oracle) GetLastSyncTime ¶
GetLastSyncTime returns the last time the oracle successfully updated prices.
func (*Oracle) GetPrices ¶
func (o *Oracle) GetPrices() map[oracletypes.CurrencyPair]*uint256.Int
GetPrices returns the aggregate prices from the oracle.
func (*Oracle) SetLastSyncTime ¶
SetLastSyncTime sets the last time the oracle successfully updated prices.