pricegetter

package
v0.0.3-RC8 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Start price getter client
	Start(ctx context.Context)
	// GetEthToMaticPrice getting eth to matic price
	GetEthToMaticPrice(ctx context.Context) (*big.Float, error)
}

Client for the pricegetter

func NewClient

func NewClient(cfg Config) (Client, error)

NewClient inits price getter client

type Config

type Config struct {
	// Type is price getter type
	Type Type `mapstructure:"Type"`

	// PriceProvider config
	PriceProvider priceprovider.Config `mapstructure:"PriceProvider"`

	// UpdateFrequency is price updating frequency, used only for the async type
	UpdateFrequency types.Duration `mapstructure:"UpdateFrequency"`

	// DefaultPrice is used only for the default type
	DefaultPrice TokenPrice `mapstructure:"DefaultPrice"`
}

Config represents the configuration of the pricegetter

type TokenPrice

type TokenPrice struct {
	*big.Float `validate:"required"`
}

TokenPrice is a wrapper type that parses token amount to big float

func (*TokenPrice) UnmarshalText

func (t *TokenPrice) UnmarshalText(data []byte) error

UnmarshalText unmarshal token amount from float string to big int

type Type

type Type string

Type for the pricegetter

const (
	// SyncType synchronous request to price provider
	SyncType Type = "sync"
	// AsyncType update price every n second
	AsyncType Type = "async"
	// DefaultType get default price from the config
	DefaultType Type = "default"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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