currency

package
v1.10.21-0...-6a6bd8a Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound        = errors.New("record not found")
	ErrInvalidRange    = errors.New("the provided range is not valid")
	ErrInvalidInterval = errors.New("the provided interval is not valid")
	ErrExists          = errors.New("record exists")
)

Functions

This section is empty.

Types

type ExchangeRateRecord

type ExchangeRateRecord struct {
	Id     uint64
	Time   time.Time
	Rate   float64
	Symbol string
}

type MetadataRecord

type MetadataRecord struct {
	Id uint64

	Name        string
	Symbol      string
	Description string
	ImageUrl    string

	Seed string

	Authority string

	Mint     string
	MintBump uint8
	Decimals uint8

	CurrencyConfig     string
	CurrencyConfigBump uint8

	LiquidityPool     string
	LiquidityPoolBump uint8

	VaultMint     string
	VaultMintBump uint8

	VaultCore     string
	VaultCoreBump uint8

	FeesMint  string
	BuyFeeBps uint16

	FeesCore   string
	SellFeeBps uint16

	Alt string

	CreatedBy string
	CreatedAt time.Time
}

func (*MetadataRecord) Clone

func (m *MetadataRecord) Clone() *MetadataRecord

func (*MetadataRecord) CopyTo

func (m *MetadataRecord) CopyTo(dst *MetadataRecord)

func (*MetadataRecord) Validate

func (m *MetadataRecord) Validate() error

type MultiRateRecord

type MultiRateRecord struct {
	Time  time.Time
	Rates map[string]float64
}

type ReserveRecord

type ReserveRecord struct {
	Id                uint64
	Mint              string
	SupplyFromBonding uint64
	CoreMintLocked    uint64
	Time              time.Time
}

func (*ReserveRecord) Clone

func (m *ReserveRecord) Clone() *ReserveRecord

func (*ReserveRecord) CopyTo

func (m *ReserveRecord) CopyTo(dst *ReserveRecord)

func (*ReserveRecord) Validate

func (m *ReserveRecord) Validate() error

type Store

type Store interface {
	// PutExchangeRates puts exchange rate records for the core mint into the store.
	PutExchangeRates(ctx context.Context, record *MultiRateRecord) error

	// GetExchangeRate gets price information given a certain time and currency symbol
	// for the core mint. If the exact time is not available, the most recent data prior
	// to the requested date within the same day will get returned, if available.
	//
	// ErrNotFound is returned if no price data was found for the provided Timestamp.
	GetExchangeRate(ctx context.Context, symbol string, t time.Time) (*ExchangeRateRecord, error)

	// GetAllExchangeRates gets price information given a certain time for the core mint.
	// If the exact time is not available, the most recent data prior to the requested date
	// within the same day will get returned, if available.
	//
	// ErrNotFound is returned if no price data was found for the provided Timestamp.
	GetAllExchangeRates(ctx context.Context, t time.Time) (*MultiRateRecord, error)

	// GetExchangeRatesInRange gets the price information for a range of time given a currency
	// symbol and interval for the core mint. The start and end timestamps are provided along
	// with the interval. If the raw data is not available at the sampling frequency requested,
	// it will be linearly interpolated between available points.
	//
	// ErrNotFound is returned if the symbol or the exchange rates for the symbol cannot be found
	// ErrInvalidRange is returned if the range is not valid
	// ErrInvalidInterval is returned if the interval is not valid
	GetExchangeRatesInRange(ctx context.Context, symbol string, interval query.Interval, start time.Time, end time.Time, ordering query.Ordering) ([]*ExchangeRateRecord, error)

	// PutMetadata puts currency creator metadata into the store
	PutMetadata(ctx context.Context, record *MetadataRecord) error

	// GetMetadata gets currency creator mint metadata by the mint address
	GetMetadata(ctx context.Context, mint string) (*MetadataRecord, error)

	// PutReserveRecord puts a currency creator mint reserve records into the store.
	PutReserveRecord(ctx context.Context, record *ReserveRecord) error

	// GetReserveAtTime gets reserve state for a given currency creator mint at a point
	// in time. If the exact time is not available, the most recent data prior to the
	// requested date within the same day will get returned, if available.
	//
	// ErrNotFound is returned if no reserve data was found for the provided Timestamp.
	GetReserveAtTime(ctx context.Context, mint string, t time.Time) (*ReserveRecord, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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