Documentation ¶
Index ¶
Constants ¶
const (
PriceTimeout = 15 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
func GetBlockHeight ¶
Types ¶
type EventStream ¶
type EventStream interface { // ParamsUpdate signals a new Params update. // EventStream must provide, on startup, the // initial Params found on the chain. ParamsUpdate() <-chan Params // VotingPeriodStarted signals a new x/oracle // voting period has just started. VotingPeriodStarted() <-chan VotingPeriod // Close shuts down the EventStream. Close() }
EventStream defines the asynchronous stream of events required by the feeder's Loop function. EventStream must handle failures by itself.
type FetchPricesFunc ¶
FetchPricesFunc is the function used to fetch updated prices. The symbols passed are the symbols we require prices for. The returned map must map symbol to its float64 price, or an error. If there's a failure in updating only one price then the map can be returned without the provided symbol.
type NewBlockJSON ¶
type NewBlockJSON struct { Jsonrpc string `json:"jsonrpc"` ID int `json:"id"` Result struct { Query string `json:"query"` Data struct { Type string `json:"type"` Value struct { Block struct { Header struct { ChainID string `json:"chain_id"` Height string `json:"height"` Time time.Time `json:"time"` LastCommitHash string `json:"last_commit_hash"` } `json:"header"` Data struct { Txs []interface{} `json:"txs"` } `json:"data"` } `json:"block"` ResultBeginBlock struct { Events []TmEvent `json:"events"` } `json:"result_begin_block"` ResultEndBlock struct { ValidatorUpdates []interface{} `json:"validator_updates"` Events []TmEvent `json:"events"` } `json:"result_end_block"` } `json:"value"` } `json:"data"` } `json:"result"` }
todo mercilex split in concrete types instead of anonymous
type Params ¶
type Params struct { // Pairs are the symbols we need to provide prices for. Pairs []asset.Pair // VotePeriodBlocks is how VotePeriodBlocks uint64 }
Params is the x/oracle specific subset of parameters required for price feeding.
func ParamsFromOracleParams ¶
func ParamsFromOracleParams(p oracletypes.Params) Params
ParamsFromOracleParams converts oracletypes.Params into Params. Panics on invalid whitelist pairs.
type Price ¶
type Price struct { // Pair defines the symbol we're posting prices for. Pair asset.Pair // Price defines the symbol's price. Price float64 // SourceName defines the source which is providing the prices. SourceName string // Valid reports whether the price is valid or not. // If not valid then an abstain vote will be posted. // Computed from the update time. Valid bool }
Price defines the price of a symbol.
type PricePoster ¶
type PricePoster interface { // Whoami returns the validator address the PricePoster // is sending prices for. Whoami() types.ValAddress // SendPrices sends the provided slice of Price. SendPrices(vp VotingPeriod, prices []Price) // Close shuts down the PricePoster. Close() }
PricePoster defines the validator oracle client, which sends new prices. PricePoster must handle failures by itself.
type PriceProvider ¶
type PriceProvider interface { // GetPrice returns the Price for the given symbol. // Price.Pair, Price.Source must always be non-empty. // If there are errors whilst fetching prices, then // Price.Valid must be set to false. GetPrice(pair asset.Pair) Price // Close shuts down the PriceProvider. Close() }
PriceProvider defines an exchange API which provides prices for the given assets. PriceProvider must handle failures by itself.
type Source ¶
type Source interface { // PriceUpdates is a readonly channel which provides // the latest prices update. Updates can be provided // for one asset only or in batches, hence the map. PriceUpdates() <-chan map[Symbol]RawPrice // Close closes the Source. Close() }
Source defines a source for price provision. This source has no knowledge of nibiru internals and mappings across asset.Pair and the Source symbols.
type Symbol ¶
type Symbol string
Symbol refers to the ticker name used by the third party data source/exchange.
type TmEvent ¶
type TmEvent struct { Type string `json:"type"` Attributes []TmEventAttribute }
type TmEventAttribute ¶
type VotingPeriod ¶
type VotingPeriod struct { // Height is the height of the voting period. Height uint64 }
VotingPeriod contains information concerning the current voting period.