history

package
v0.145.2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventBalanceHistoryUpdateStarted           walletevent.EventType = "wallet-balance-history-update-started"
	EventBalanceHistoryUpdateFinished          walletevent.EventType = "wallet-balance-history-update-finished"
	EventBalanceHistoryUpdateFinishedWithError walletevent.EventType = "wallet-balance-history-update-finished-with-error"
)

EventBalanceHistoryUpdateStarted and EventBalanceHistoryUpdateDone are used to notify the UI that balance history is being updated

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

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

func NewBalance

func NewBalance(db *BalanceDB) *Balance

type BalanceDB

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

func NewBalanceDB

func NewBalanceDB(sqlDb *sql.DB) *BalanceDB

type DataPoint

type DataPoint struct {
	Balance     *hexutil.Big
	Timestamp   uint64
	BlockNumber *hexutil.Big
}

type DataSource

type DataSource interface {
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
	BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
	ChainID() uint64
	Currency() string
	TimeNow() int64
}

DataSource used as an abstraction to fetch required data from a specific blockchain

type Exchange added in v0.131.5

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

Exchange caches conversion rates in memory on a daily basis

func NewExchange added in v0.131.5

func NewExchange(marketManager *market.Manager) *Exchange

func (*Exchange) FetchAndCacheMissingRates added in v0.131.5

func (e *Exchange) FetchAndCacheMissingRates(token tokenType, currency currencyType) error

fetchAndCacheRates fetches and in memory cache exchange rates for this and last year

func (*Exchange) GetExchangeRateForDay added in v0.131.5

func (e *Exchange) GetExchangeRateForDay(token tokenType, currency currencyType, date time.Time) (float32, error)

GetExchangeRate returns the exchange rate from token to currency in the day of the given date if none exists returns "missing <element>" error

type Service

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

func NewService

func NewService(db *sql.DB, eventFeed *event.Feed, rpcClient *statusrpc.Client, tokenManager *token.Manager, marketManager *market.Manager) *Service

func (*Service) GetBalanceHistory

func (s *Service) GetBalanceHistory(ctx context.Context, chainIDs []uint64, address common.Address, tokenSymbol string, currencySymbol string, endTimestamp int64, timeInterval TimeInterval) ([]*ValuePoint, error)

GetBalanceHistory returns token count balance

func (*Service) Start added in v0.131.5

func (s *Service) Start()

func (*Service) Stop

func (s *Service) Stop()

func (*Service) UpdateVisibleTokens

func (s *Service) UpdateVisibleTokens(symbols []string)

type TimeInterval

type TimeInterval int
const (
	BalanceHistory7Days TimeInterval = iota + 1
	BalanceHistory1Month
	BalanceHistory6Months
	BalanceHistory1Year
	BalanceHistoryAllTime
)

Specific time intervals for which balance history can be fetched

type ValuePoint added in v0.131.5

type ValuePoint struct {
	Value       float64      `json:"value"`
	Timestamp   uint64       `json:"time"`
	BlockNumber *hexutil.Big `json:"blockNumber"`
}

Jump to

Keyboard shortcuts

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