metric

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: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VaaCountMeasurement       = "vaa_count"
	VaaVolumeMeasurement      = "vaa_volume_v2"
	VaaAllMessagesMeasurement = "vaa_count_all_messages"
)

Variables

This section is empty.

Functions

func MakePointForVaaCount

func MakePointForVaaCount(vaa *sdk.VAA) (*write.Point, error)

MakePointForVaaCount generates a data point for the VAA count measurement.

Some VAAs will not generate a measurement, so the caller must always check whether the returned point is nil.

func MakePointForVaaVolume

func MakePointForVaaVolume(params *MakePointForVaaVolumeParams) (*write.Point, error)

MakePointForVaaVolume builds the InfluxDB volume metric for a given VAA

Some VAAs will not generate a measurement, so the caller must always check whether the returned point is nil.

func UpsertTransferPrices

func UpsertTransferPrices(
	ctx context.Context,
	logger *zap.Logger,
	vaa *sdk.VAA,
	transferPrices *mongo.Collection,
	tokenPriceFunc func(tokenID, coinGeckoID string, timestamp time.Time) (decimal.Decimal, error),
	transferredToken *token.TransferredToken,
	tokenProvider *domain.TokenProvider,
) error

Types

type MakePointForVaaVolumeParams

type MakePointForVaaVolumeParams struct {

	// Vaa is the VAA for which we want to compute the volume metric
	Vaa *sdk.VAA

	// TokenPriceFunc returns the price of the given token at the specified timestamp.
	TokenPriceFunc func(tokenID string, timestamp time.Time) (decimal.Decimal, error)

	// Logger is an optional parameter, in case the caller wants additional visibility.
	Logger *zap.Logger

	// Metrics is in case the caller wants additional visibility.
	Metrics metrics.Metrics

	// TransferredToken is the token that was transferred in the VAA.
	TransferredToken *token.TransferredToken

	// TokenProvider is used to obtain token metadata.
	TokenProvider *domain.TokenProvider
}

MakePointForVaaVolumeParams contains input parameters for the function `MakePointForVaaVolume`

type Metric

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

Metric definition.

func New

func New(
	ctx context.Context,
	db *mongo.Database,
	influxCli influxdb2.Client,
	organization string,
	bucketInifite string,
	bucket30Days string,
	bucket24Hours string,
	notionalCache wormscanNotionalCache.NotionalLocalCacheReadable,
	metrics metrics.Metrics,
	getTransferredTokenByVaa token.GetTransferredTokenByVaa,
	tokenProvider *domain.TokenProvider,
	logger *zap.Logger,
) (*Metric, error)

New create a new *Metric.

func (*Metric) Close

func (m *Metric) Close()

Close influx client.

func (*Metric) Push

func (m *Metric) Push(ctx context.Context, params *Params) error

Push implement MetricPushFunc definition.

type MetricPushFunc

type MetricPushFunc func(context.Context, *Params) error

MetricPushFunc is a function to push metrics

type Params

type Params struct {
	TrackID     string
	Vaa         *vaa.VAA
	VaaIsSigned bool
}

type TransferPriceDoc

type TransferPriceDoc struct {
	// ID is the unique identifier of the VAA for which we are storing price information.
	ID string `bson:"_id"`
	// Timestamp is the timestamp of the VAA for which we are storing price information.
	Timestamp time.Time `bson:"timestamp"`
	// Symbol is the trading symbol of the token being transferred.
	Symbol string `bson:"symbol"`
	// SymbolPriceUsd is the price of the token in USD at the moment of the transfer.
	SymbolPriceUsd string `bson:"price"`
	// TokenAmount is the amount of the token being transferred.
	TokenAmount string `bson:"tokenAmount"`
	// UsdAmount is the value in USD of the token being transferred.
	UsdAmount string `bson:"usdAmount"`
	// TokenChain is the chain ID of the token being transferred.
	TokenChain uint16 `bson:"tokenChain"`
	// TokenAddress is the address of the token being transferred.
	TokenAddress string `bson:"tokenAddress"`
	// CoinGeckoID is the CoinGecko ID of the token being transferred.
	CoinGeckoID string `bson:"coinGeckoId"`
	// UpdatedAt is the timestamp the document was updated.
	UpdatedAt time.Time `bson:"updatedAt"`
}

TransferPriceDoc models a document in the `transferPrices` collection

Jump to

Keyboard shortcuts

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