prices

package
v0.0.0-...-ce1b770 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPriceNotFound = fmt.Errorf("price not found")
View Source
var (
	ErrTokenNotFound = errors.New("token not found")
)

Functions

This section is empty.

Types

type Controller

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

func NewController

func NewController(priceService *PriceService, logger *zap.Logger) *Controller

func (*Controller) FindByCoingeckoID

func (c *Controller) FindByCoingeckoID(ctx *fiber.Ctx) error

func (*Controller) FindByToken

func (c *Controller) FindByToken(ctx *fiber.Ctx) error

type Price

type Price struct {
	CoingeckoID string    `json:"coingeckoId"`
	Symbol      string    `json:"symbol"`
	Price       string    `json:"price"`
	Datetime    time.Time `json:"dateTime"`
}

type PriceDb

type PriceDb struct {
	ID          string    `bson:"_id" json:"id"`
	CoingeckoID string    `bson:"coingeckoId" json:"coingeckoId"`
	Price       string    `bson:"price" json:"price"`
	Datetime    time.Time `bson:"dateTime" json:"dateTime"`
	UpdatedAt   time.Time `bson:"updatedAt" json:"updatedAt"`
}

type PriceRepository

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

func NewPriceRepository

func NewPriceRepository(db *mongo.Database, logger *zap.Logger) *PriceRepository

NewPriceRepository creates a new price repository.

func (*PriceRepository) Find

func (p *PriceRepository) Find(ctx context.Context, coingeckoID string, dateTime time.Time) (*PriceDb, error)

Find finds a price.

func (*PriceRepository) Upsert

func (p *PriceRepository) Upsert(ctx context.Context, coingeckoID string, price decimal.Decimal, dateTime time.Time) error

Upsert upserts a price.

type PriceService

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

PriceService provides an interface to interact with prices.

func NewPriceService

func NewPriceService(priceRepository *PriceRepository,
	tokenProvider *domain.TokenProvider,
	notionalCache wormscanNotionalCache.NotionalLocalCacheReadable,
	logger *zap.Logger) *PriceService

NewPriceService creates a new price service.

func (*PriceService) GetPrice

func (s *PriceService) GetPrice(ctx context.Context, tokenChainID sdk.ChainID, tokenAddress string, datetime time.Time) (*Price, error)

GetPrice returns the price of a token at a given datetime.

func (*PriceService) GetPriceByCoingeckoID

func (s *PriceService) GetPriceByCoingeckoID(ctx context.Context, coingeckoID string, datetime time.Time) (*Price, error)

func (*PriceService) GetPriceBySymbol

func (s *PriceService) GetPriceBySymbol(ctx context.Context, token *domain.TokenMetadata, datetime time.Time, log *zap.Logger) (*priceSymbol, error)

Jump to

Keyboard shortcuts

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