feeder

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InitTimeout = 15 * time.Second
View Source
var MaxSaltNumber = big.NewInt(9999) // NOTE(mercilex): max salt length is 4

MaxSaltNumber is the maximum salt number we can use for randomness. NOTE: max length of the salt is 4. TODO(mercilex): if we used digits + alphanumerics it's more randomized

Functions

func NewAggregatePriceProvider added in v1.1.1

func NewAggregatePriceProvider(
	sourcesToPairSymbolMap map[string]map[asset.Pair]types.Symbol,
	sourceConfigMap map[string]json.RawMessage,
	logger zerolog.Logger,
) types.PriceProvider

NewAggregatePriceProvider instantiates a new AggregatePriceProvider instance given multiple PriceProvider.

func NewPriceProvider added in v1.1.1

func NewPriceProvider(
	sourceName string,
	pairToSymbolMap map[asset.Pair]types.Symbol,
	config json.RawMessage,
	logger zerolog.Logger,
) types.PriceProvider

NewPriceProvider returns a types.PriceProvider given the price source we want to gather prices from, the mapping between nibiru asset.Pair and the source's symbols, and a zerolog.Logger instance.

func NewWebsocket added in v1.1.1

func NewWebsocket(url string, onOpenMsg []byte, logger zerolog.Logger) *ws

NewWebsocket creates a new WebSocket connection to the specified URL. The connection automatically sends onOpenMsg as a binary message immediately after establishing the connection. The function returns a WebSocket instance that runs in a background goroutine, handling connection, reconnection, and message reading.

Parameters:

  • url: The WebSocket server URL (e.g., "wss://echo.websocket.org")
  • onOpenMsg: A binary message to send immediately after connection is established
  • logger: A zerolog logger instance for logging connection events and errors

The WebSocket will automatically attempt to reconnect with exponential backoff if the connection is lost (up to 10 retry attempts). Messages can be read from the channel returned by the message() method.

func TryUntilDone added in v1.1.1

func TryUntilDone(
	ctx context.Context,
	wait time.Duration,
	f func() error,
) error

TryUntilDone will try to execute the given function until it succeeds or the context is cancelled.

Types

type AggregatePriceProvider added in v1.1.1

type AggregatePriceProvider struct {
	// contains filtered or unexported fields
}

AggregatePriceProvider aggregates multiple price providers and queries them for prices.

func (AggregatePriceProvider) Close added in v1.1.1

func (a AggregatePriceProvider) Close()

func (AggregatePriceProvider) GetPrice added in v1.1.1

func (a AggregatePriceProvider) GetPrice(pair asset.Pair) types.Price

GetPrice fetches the first available and correct price from the wrapped PriceProviders. Iteration is exhaustive and random. If no correct PriceResponse is found, then an invalid PriceResponse is returned.

type Auth added in v1.1.1

type ClientPricePoster added in v1.1.1

type ClientPricePoster struct {
	// contains filtered or unexported fields
}

func DialPricePoster added in v1.1.1

func DialPricePoster(
	grpcEndpoint string,
	chainID string,
	enableTLS bool,
	keyBase keyring.Keyring,
	validator sdk.ValAddress,
	feeder sdk.AccAddress,
	logger zerolog.Logger,
) *ClientPricePoster

func (*ClientPricePoster) Close added in v1.1.1

func (c *ClientPricePoster) Close()

func (*ClientPricePoster) GetOracleClient added in v1.1.1

func (c *ClientPricePoster) GetOracleClient() Oracle

GetOracleClient returns the oracle client for testing purposes.

func (*ClientPricePoster) SendPrices added in v1.1.1

func (c *ClientPricePoster) SendPrices(vp types.VotingPeriod, prices []types.Price)

func (*ClientPricePoster) Whoami added in v1.1.1

func (c *ClientPricePoster) Whoami() sdk.ValAddress

type Feeder

type Feeder struct {
	EventStream   types.EventStream
	PricePoster   types.PricePoster
	PriceProvider types.PriceProvider
	// contains filtered or unexported fields
}

Feeder is the price feeder.

func NewFeeder

func NewFeeder(
	eventStream types.EventStream,
	priceProvider types.PriceProvider,
	pricePoster types.PricePoster,
	logger zerolog.Logger,
) *Feeder

func (*Feeder) Close

func (f *Feeder) Close()

func (*Feeder) Run

func (f *Feeder) Run()

Run instantiates a new Feeder instance.

type Oracle added in v1.1.1

type PriceProvider added in v1.1.1

type PriceProvider struct {
	// contains filtered or unexported fields
}

PriceProvider implements the types.PriceProvider interface. it wraps a Source and handles conversions between nibiru asset pair to exchange symbols.

func (*PriceProvider) Close added in v1.1.1

func (p *PriceProvider) Close()

func (*PriceProvider) GetPrice added in v1.1.1

func (p *PriceProvider) GetPrice(pair asset.Pair) types.Price

GetPrice returns the types.Price for the given asset.Pair in case price has expired, or for some reason it's impossible to get the last available price, then an invalid types.Price is returned.

type Stream added in v1.1.1

type Stream struct {
	// contains filtered or unexported fields
}

func DialEventStream added in v1.1.1

func DialEventStream(tendermintRPCEndpoint string, grpcEndpoint string, enableTLS bool, logger zerolog.Logger) *Stream

DialEventStream opens two connections to the given endpoint, one for the websocket and one for the oracle grpc.

func (*Stream) Close added in v1.1.1

func (s *Stream) Close()

func (*Stream) ParamsUpdate added in v1.1.1

func (s *Stream) ParamsUpdate() <-chan types.Params

func (*Stream) VotingPeriodStarted added in v1.1.1

func (s *Stream) VotingPeriodStarted() <-chan types.VotingPeriod

type TxService added in v1.1.1

type TxService interface {
	BroadcastTx(context.Context, *txservice.BroadcastTxRequest, ...grpc.CallOption) (*txservice.BroadcastTxResponse, error)
}

Jump to

Keyboard shortcuts

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