oracle

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2022 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeVWAP

func ComputeVWAP(prices map[string]map[string]provider.TickerPrice) (map[string]sdk.Dec, error)

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

func Connect(protoAddr string) (net.Conn, error)

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

func GenerateExchangeRatesString(prices map[string]sdk.Dec) string

GenerateExchangeRatesString generates a canonical string representation of the aggregated exchange rates.

func GenerateSalt

func GenerateSalt(length int) (string, error)

GenerateSalt generates a random salt, size length/2, as a HEX encoded string.

func ProtocolAndAddress

func ProtocolAndAddress(listenAddr string) (string, string)

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

func (o *Oracle) GetLastPriceSyncTimestamp() time.Time

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

func (o *Oracle) GetPrices() map[string]sdk.Dec

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.

func (*Oracle) Start

func (o *Oracle) Start(ctx context.Context) error

Start starts the oracle process in a blocking fashion.

func (*Oracle) Stop

func (o *Oracle) Stop()

Stop stops the oracle process and waits for it to gracefully exit.

type PreviousPrevote

type PreviousPrevote struct {
	ExchangeRates     string
	Salt              string
	SubmitBlockHeight int64
}

PreviousPrevote defines a structure for defining the previous prevote submitted on-chain.

func NewPreviousPrevote

func NewPreviousPrevote() *PreviousPrevote

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL