Documentation
¶
Index ¶
- func ComputeVWAP(prices map[string]map[string]provider.TickerPrice) (map[string]sdk.Dec, error)
- func Connect(protoAddr string) (net.Conn, error)
- func GenerateExchangeRatesString(prices map[string]sdk.Dec) string
- func GenerateSalt(length int) (string, error)
- func ProtocolAndAddress(listenAddr string) (string, string)
- type Oracle
- func (o *Oracle) GetLastPriceSyncTimestamp() time.Time
- func (o *Oracle) GetParams() (oracletypes.Params, error)
- func (o *Oracle) GetPrices() map[string]sdk.Dec
- func (o *Oracle) SetPrices(acceptList oracletypes.DenomList) error
- func (o *Oracle) Start(ctx context.Context) error
- func (o *Oracle) Stop()
- type PreviousPrevote
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeVWAP ¶
ComputeVWAP computes the volume weighted average price for all price points for each ticker/exchange pair. The provided prices argument reflects a mapping of provider => {<base> => <TickerPrice>, ...}.
Ref: https://en.wikipedia.org/wiki/Volume-weighted_average_price
func Connect ¶
Connect dials the given address and returns a net.Conn. The protoAddr argument should be prefixed with the protocol, eg. "tcp://127.0.0.1:8080" or "unix:///tmp/test.sock".
func GenerateExchangeRatesString ¶
GenerateExchangeRatesString generates a canonical string representation of the aggregated exchange rates.
func GenerateSalt ¶
GenerateSalt generates a random salt, size length/2, as a HEX encoded string.
func ProtocolAndAddress ¶
ProtocolAndAddress splits an address into the protocol and address components. For instance, "tcp://127.0.0.1:8080" will be split into "tcp" and "127.0.0.1:8080". If the address has no protocol prefix, the default is "tcp".
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 the correct exchange rates to submit to the on-chain price oracle adhering the oracle specification.
func New ¶
func New(logger zerolog.Logger, oc client.OracleClient, currencyPairs []config.CurrencyPair) *Oracle
func (*Oracle) GetLastPriceSyncTimestamp ¶
GetLastPriceSyncTimestamp returns the latest timestamp at which prices where fetched from the oracle's set of exchange rate providers.
func (*Oracle) GetParams ¶
func (o *Oracle) GetParams() (oracletypes.Params, error)
GetParams returns the current on-chain parameters of the x/oracle module.
func (*Oracle) GetPrices ¶
GetPrices returns a copy of the current prices fetched from the oracle's set of exchange rate providers.
func (*Oracle) SetPrices ¶
func (o *Oracle) SetPrices(acceptList oracletypes.DenomList) error
SetPrices retrieve all the prices from our set of providers as determined in the config, average them out, and update the oracle's current exchange rates.
type PreviousPrevote ¶
PreviousPrevote defines a structure for defining the previous prevote submitted on-chain.
func NewPreviousPrevote ¶
func NewPreviousPrevote() *PreviousPrevote