history

package
v0.173.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MPL-2.0 Imports: 28 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

func TimeIntervalDurationSecs added in v0.168.1

func TimeIntervalDurationSecs(timeInterval TimeInterval) uint64

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
}

func (*DataPoint) String added in v0.168.1

func (d *DataPoint) String() string

String returns a string representation of the data point

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, accountsDB *accounts.Database, eventFeed *event.Feed, rpcClient *statusrpc.Client, tokenManager *token.Manager, marketManager *market.Manager, balanceCache balance.CacheIface) *Service

func (*Service) GetBalanceHistory

func (s *Service) GetBalanceHistory(ctx context.Context, chainIDs []uint64, addresses []common.Address, tokenSymbol string, currencySymbol string, fromTimestamp uint64) ([]*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()

type TimeInterval

type TimeInterval int

Specific time intervals for which balance history can be fetched

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

type TransfersLoadedCb added in v0.168.1

type TransfersLoadedCb func(chainID uint64, addresses []common.Address, block *big.Int)

type ValuePoint added in v0.131.5

type ValuePoint struct {
	Value     float64 `json:"value"`
	Timestamp uint64  `json:"time"`
}

type Watcher added in v0.168.1

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

Watcher executes a given callback whenever an account gets added/removed

func NewWatcher added in v0.168.1

func NewWatcher(feed *event.Feed, callback TransfersLoadedCb) *Watcher

func (*Watcher) Start added in v0.168.1

func (w *Watcher) Start()

func (*Watcher) Stop added in v0.168.1

func (w *Watcher) Stop()

Jump to

Keyboard shortcuts

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