provider

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const RocketPoolPairETH = "RETH/ETH"
View Source
const RocketPoolPairUSD = "RETH/USD"

Variables

This section is empty.

Functions

This section is empty.

Types

type HookParams

type HookParams map[string]map[string]any

func NewHookParams

func NewHookParams() HookParams

type Model

type Model struct {
	// Type is used to differentiate between model types.
	Type string
	// Parameters is a optional list of model's parameters.
	Parameters map[string]string
	// Pair is a asset pair for which this model returns a price.
	Pair Pair
	// Models is a list of sub models used to calculate price.
	Models []*Model
}

Model is a simplified representation of a model which is used to calculate asset pair prices. The main purpose of this structure is to help the end user to understand how prices are derived and calculated.

This structure is purely informational. The way it is used depends on a specific implementation.

type Pair

type Pair struct {
	Base  string
	Quote string
}

Pair represents an asset pair.

func NewPair

func NewPair(s string) (Pair, error)

NewPair returns a new Pair for given string. The string must be formatted as "BASE/QUOTE".

func NewPairs

func NewPairs(s ...string) ([]Pair, error)

NewPairs returns a Pair slice for given strings. Given strings must be formatted as "BASE/QUOTE".

func (Pair) Empty

func (p Pair) Empty() bool

func (Pair) Equal

func (p Pair) Equal(c Pair) bool

func (Pair) String

func (p Pair) String() string

func (*Pair) UnmarshalText added in v0.10.0

func (p *Pair) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler interface.

type PostPriceHook

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

func NewPostPriceHook

func NewPostPriceHook(
	ctx context.Context,
	clients ethereumConfig.ClientRegistry,
	params HookParams,
) (
	*PostPriceHook,
	error,
)

func (*PostPriceHook) Check

func (o *PostPriceHook) Check(prices map[Pair]*Price) error

type Price

type Price struct {
	Type       string
	Parameters map[string]string
	Pair       Pair
	Price      float64
	Bid        float64
	Ask        float64
	Volume24h  float64
	Time       time.Time
	Prices     []*Price
	Error      string
}

Price represents price for a single pair. If the Price was calculated indirectly it will also contain all prices used to calculate the price.

type PriceHook

type PriceHook interface {
	Check(map[Pair]*Price) error
}

type Provider

type Provider interface {
	// Models describes price models which are used to calculate prices.
	// If no pairs are specified, models for all pairs are returned.
	Models(pairs ...Pair) (map[Pair]*Model, error)

	// Price returns a Price for the given pair.
	Price(pair Pair) (*Price, error)

	// Prices returns prices for the given pairs. If no pairs are specified,
	// prices for all pairs are returned.
	Prices(pairs ...Pair) (map[Pair]*Price, error)

	// Pairs returns all pairs.
	Pairs() ([]Pair, error)
}

Provider provides prices for asset pairs.

Directories

Path Synopsis
TODO: check if it's possible to merge coinbase and coinbasepro
TODO: check if it's possible to merge coinbase and coinbasepro

Jump to

Keyboard shortcuts

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