Documentation
¶
Index ¶
- Constants
- Variables
- func ConnectToB2(timeout time.Duration, logger zerolog.Logger) (*ethclient.Client, error)
- func ConnectToEthereum(timeout time.Duration, logger zerolog.Logger) (*ethclient.Client, error)
- func ConnectToNetwork(networkName string, timeout time.Duration, logger zerolog.Logger) (*ethclient.Client, error)
- func GetBlockHeight(msg []byte) (uint64, error)
- func GetRPCEndpoints(networkName string) ([]string, error)
- func TryEthereumRPCEndpoint(endpoint string, timeout time.Duration, logger zerolog.Logger) (*ethclient.Client, error)
- func TryRPCEndpoint(networkName, endpoint string, timeout time.Duration, logger zerolog.Logger) (*ethclient.Client, error)
- type EventStream
- type FetchPricesFunc
- type NetworkConfig
- type NewBlockJSON
- type NullPriceProvider
- type Params
- type Price
- type PricePoster
- type PriceProvider
- type RawPrice
- type Source
- type Symbol
- type TmEvent
- type TmEventAttribute
- type VotingPeriod
Constants ¶
const ( PriceTimeout = 15 * time.Second // PriceAbstain is the sentinel value (-1) used for invalid prices that // result in abstain votes being posted to the oracle instead of price // values. PriceAbstain float64 = -1 )
Variables ¶
var DefaultNetworkConfigs = map[string]NetworkConfig{ "ethereum": { Name: "ethereum", DefaultEndpoints: []string{ "https://eth.llamarpc.com", "https://eth-mainnet.public.blastapi.io", "https://rpc.flashbots.net/", "https://cloudflare-eth.com/", "https://ethereum.publicnode.com", }, EnvEndpoint: "ETHEREUM_RPC_ENDPOINT", EnvPublicEndpoints: "ETHEREUM_RPC_PUBLIC_ENDPOINTS", }, "b2": { Name: "b2", DefaultEndpoints: []string{ "https://rpc.bsquared.network", "https://mainnet.b2-rpc.com", "https://rpc.ankr.com/b2", "https://b2-mainnet.alt.technology", }, EnvEndpoint: "B2_RPC_ENDPOINT", EnvPublicEndpoints: "B2_RPC_PUBLIC_ENDPOINTS", }, }
DefaultNetworkConfigs provides configurations for supported networks
Functions ¶
func ConnectToB2 ¶ added in v1.1.0
func ConnectToEthereum ¶ added in v1.1.0
func ConnectToNetwork ¶ added in v1.1.0
func ConnectToNetwork(networkName string, timeout time.Duration, logger zerolog.Logger) (*ethclient.Client, error)
ConnectToNetwork creates a connection to the specified EVM network
func GetBlockHeight ¶
func GetRPCEndpoints ¶ added in v1.1.0
GetRPCEndpoints returns the list of RPC endpoints to try for a given network
func TryEthereumRPCEndpoint ¶ added in v1.1.0
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 ¶
type FetchPricesFunc func(symbols set.Set[Symbol], logger zerolog.Logger) (map[Symbol]float64, error)
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 NetworkConfig ¶ added in v1.1.0
type NetworkConfig struct {
Name string
DefaultEndpoints []string
EnvEndpoint string // Environment variable for single endpoint
EnvPublicEndpoints string // Environment variable for multiple endpoints
}
NetworkConfig holds configuration for an EVM network
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 []any `json:"txs"`
} `json:"data"`
} `json:"block"`
ResultBeginBlock struct {
Events []TmEvent `json:"events"`
} `json:"result_begin_block"`
ResultEndBlock struct {
ValidatorUpdates []any `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 NullPriceProvider ¶ added in v1.1.1
type NullPriceProvider struct{}
NullPriceProvider is a no-op implementation of PriceProvider that always returns invalid prices with PriceAbstain values.
Use NullPriceProvider as a fallback when source initialization fails, allowing the application to continue operating with other available providers rather than crashing.
NullPriceProvider implements the null object pattern for graceful error handling.
func (NullPriceProvider) Close ¶ added in v1.1.1
func (pp NullPriceProvider) Close()
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() sdk.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.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mock_types is a generated GoMock package.
|
Package mock_types is a generated GoMock package. |