utils

package
v0.0.0-...-989067b Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CoinGeckoCoins map[string][]CoinGeckoCoin
View Source
var DefaultLimiter = rate.NewLimiter(rate.Every(time.Second), 3)
View Source
var DefaultRateLimitClient = NewRateLimitClient(DefaultLimiter)

Functions

func CalcNotionalAmount

func CalcNotionalAmount(amount *big.Int, decimals uint8, price float64) *big.Float

func FetchCoinGeckoCoins

func FetchCoinGeckoCoins()

func FetchCoinGeckoPrice

func FetchCoinGeckoPrice(coinId string, timestamp time.Time) (float64, error)

func FetchTokenPrices

func FetchTokenPrices(ctx context.Context, coinIds []string) (map[string]float64, error)

Types

type CoinGeckoCoin

type CoinGeckoCoin struct {
	Id     string `json:"id"`
	Symbol string `json:"symbol"`
	Name   string `json:"name"`
}

func FetchCoinGeckoCoin

func FetchCoinGeckoCoin(chainId vaa.ChainID, symbol, name string) *CoinGeckoCoin

type CoinGeckoCoinPrices

type CoinGeckoCoinPrices map[string]Price

type CoinGeckoErrorRes

type CoinGeckoErrorRes struct {
	Error string `json:"error"`
}

type CoinGeckoMarket

type CoinGeckoMarket [2]float64

type CoinGeckoMarketRes

type CoinGeckoMarketRes struct {
	Prices []CoinGeckoMarket `json:"prices"`
}

type Price

type Price struct {
	USD float64 `json:"usd"`
}

type RateLimitClient

type RateLimitClient struct {
	Ratelimiter *rate.Limiter
	// contains filtered or unexported fields
}

func NewRateLimitClient

func NewRateLimitClient(limiter *rate.Limiter) *RateLimitClient

func (*RateLimitClient) Do

Jump to

Keyboard shortcuts

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