utils

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BINANCESMARTCHAIN = "BinanceSmartChain"
	BITCOIN           = "Bitcoin"
	ETHEREUM          = "Ethereum"
)

Variables

This section is empty.

Functions

func Average

func Average(samples []float64) (average float64)

func AvgDistances

func AvgDistances(samples []float64) (distSlice []float64)

AvgDistances returns a slice. The i-th entry of @distSlice is the average distance from all other entries normalized by the 2-norm of @samples.

func ContainsAddress

func ContainsAddress(addresses []common.Address, address common.Address) (contains bool)

func GetBalanceOf

func GetBalanceOf(tokenAddress common.Address, walletAddress common.Address, client *ethclient.Client) (*big.Int, error)

func GetPath

func GetPath(configPath string, exchange string) string

func GetPriceFromDiaAPI

func GetPriceFromDiaAPI(address string, blockchain string) (float64, error)

func GetRequest

func GetRequest(url string) ([]byte, int, error)

GetRequest performs a get request on @url and returns the response body as a slice of byte data.

func Getenv

func Getenv(key, fallback string) string

func MakeEthClient added in v0.1.10

func MakeEthClient(mainNode string, backupNode string) (conn *ethclient.Client, err error)

func Median

func Median(samples []float64) (median float64)

func Norm

func Norm(samples []float64) float64

func RemoveOutliers

func RemoveOutliers(samples []float64, threshold float64) (cleanedSamples []float64, indices []int)

RemoveOutliers removes outliers from @samples which have an average distance to the rest larger than @threshold. Distance is normalized by the 2-norm. The removal process is iteratively and returns as soon as no distance is larger than threshold or len(@cleanedSamples)=2. @indices is the slice of indices which were originally in samples, so @samples[@indices]=@cleanedSamples.

Types

type TokenCaller

type TokenCaller struct {
	Contract *bind.BoundContract // Generic contract wrapper for the low level calls
}

TokenCaller is an auto generated read-only Go binding around an Ethereum contract.

func NewTokenCaller

func NewTokenCaller(address common.Address, caller bind.ContractCaller) (*TokenCaller, error)

NewTokenCaller creates a new read-only instance of token, bound to a specific deployed contract.

Jump to

Keyboard shortcuts

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