price

package
v0.0.0-...-7d1b45a Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const CMC_API = "https://pro-api.coinmarketcap.com/v1"

Variables

View Source
var INIT_DELAY = 10 * time.Second
View Source
var PRICE_UPDATE_PERIOD time.Duration

Functions

func CMC_Update

func CMC_Update(w *cmn.Wallet) (int, error)

func DS_Update

func DS_Update(w *cmn.Wallet) (int, error)

func GetUrl

func GetUrl(feeder string, chain_id int, tokenAddr string) string

func Init

func Init()

func Update

func Update(w *cmn.Wallet) error

Types

type BaseToken

type BaseToken struct {
	Address string `json:"address"`
	Name    string `json:"name"`
	Symbol  string `json:"symbol"`
}

type CMCMapResponse

type CMCMapResponse struct {
	Status Status   `json:"status"`
	Data   []Crypto `json:"data"`
}

CMCMapResponse holds the response from the cryptocurrency/map endpoint

type CMCQuotesResponse

type CMCQuotesResponse struct {
	Status struct {
		Timestamp    string `json:"timestamp"`
		ErrorCode    int    `json:"error_code"`
		ErrorMessage string `json:"error_message,omitempty"`
		Elapsed      int    `json:"elapsed"`
		CreditCount  int    `json:"credit_count"`
	} `json:"status"`
	Data map[string]struct {
		ID                int      `json:"id"`
		Name              string   `json:"name"`
		Symbol            string   `json:"symbol"`
		Slug              string   `json:"slug"`
		CirculatingSupply float64  `json:"circulating_supply"`
		TotalSupply       float64  `json:"total_supply"`
		MaxSupply         float64  `json:"max_supply"`
		LastUpdated       string   `json:"last_updated"`
		DateAdded         string   `json:"date_added"`
		NumMarketPairs    int      `json:"num_market_pairs"`
		Tags              []string `json:"tags"`
		Platform          struct {
			ID           int    `json:"id"`
			Name         string `json:"name"`
			Symbol       string `json:"symbol"`
			Slug         string `json:"slug"`
			TokenAddress string `json:"token_address"`
		} `json:"platform,omitempty"`
		Quote map[string]struct {
			Price            float64 `json:"price"`
			Volume24h        float64 `json:"volume_24h"`
			VolumeChange24h  float64 `json:"volume_change_24h"`
			PercentChange1h  float64 `json:"percent_change_1h"`
			PercentChange24h float64 `json:"percent_change_24h"`
			PercentChange7d  float64 `json:"percent_change_7d"`
			PercentChange30d float64 `json:"percent_change_30d"`
			PercentChange60d float64 `json:"percent_change_60d"`
			PercentChange90d float64 `json:"percent_change_90d"`
			MarketCap        float64 `json:"market_cap"`
			LastUpdated      string  `json:"last_updated"`
		} `json:"quote"`
	} `json:"data"`
}

CMCQuotesResponse holds the response from the cryptocurrency/quotes/latest endpoint

type Crypto

type Crypto struct {
	ID                  int    `json:"id"`
	Name                string `json:"name"`
	Symbol              string `json:"symbol"`
	Slug                string `json:"slug"`
	Rank                int    `json:"rank"`
	IsActive            int    `json:"is_active"`
	FirstHistoricalData string `json:"first_historical_data"`
	LastHistoricalData  string `json:"last_historical_data"`
}

Crypto holds information about each cryptocurrency

type DSPair

type DSPair struct {
	URL           string       `json:"url"`
	PairAddress   string       `json:"pairAddress"`
	BaseToken     BaseToken    `json:"baseToken"`
	QuoteToken    QuoteToken   `json:"quoteToken"`
	PriceNative   string       `json:"priceNative"`
	PriceUsd      string       `json:"priceUsd"`
	Txns          Transactions `json:"txns"`
	Volume        Volume       `json:"volume"`
	PriceChange   PriceChange  `json:"priceChange"`
	Liquidity     Liquidity    `json:"liquidity"`
	FDV           float64      `json:"fdv"`
	PairCreatedAt int64        `json:"pairCreatedAt,omitempty"`
}

type DSResponse

type DSResponse struct {
	SchemaVersion string   `json:"schemaVersion"`
	Pairs         []DSPair `json:"pairs"`
}

type Liquidity

type Liquidity struct {
	USD   float64 `json:"usd"`
	Base  float64 `json:"base"`
	Quote float64 `json:"quote"`
}

type PriceChange

type PriceChange struct {
	H24 float64 `json:"h24"`
	H6  float64 `json:"h6"`
	H1  float64 `json:"h1"`
	M5  float64 `json:"m5"`
}

type PriceInfo

type PriceInfo struct {
	PriceFeeder   string
	PairID        string
	BaseToken     string
	QuoteToken    string
	PriceUsd      float64
	PriceChange24 float64
	Liquidity     float64
	URL           string
}

func CMC_GetLatest

func CMC_GetLatest(slags []string) ([]PriceInfo, error)

func CMC_GetPriceInfoList

func CMC_GetPriceInfoList(chain_id int, tokenAddr string) ([]PriceInfo, error)

func DSGetPairs

func DSGetPairs(chain_id int, pairList string) ([]PriceInfo, error)

func DS_GetPriceInfoList

func DS_GetPriceInfoList(chain_id int, tokenAddr string) ([]PriceInfo, error)

func GetPriceInfoList

func GetPriceInfoList(chain_id int, tokenAddr string) ([]PriceInfo, error)

type QuoteToken

type QuoteToken struct {
	Symbol string `json:"symbol"`
}

type Status

type Status struct {
	Timestamp    string `json:"timestamp"`
	ErrorCode    int    `json:"error_code"`
	ErrorMessage string `json:"error_message"`
	Elapsed      int    `json:"elapsed"`
	CreditCount  int    `json:"credit_count"`
}

Status holds metadata about the response

type TransactionDetails

type TransactionDetails struct {
	Buys  int `json:"buys"`
	Sells int `json:"sells"`
}

type Transactions

type Transactions struct {
	H24 TransactionDetails `json:"h24"`
	H6  TransactionDetails `json:"h6"`
	H1  TransactionDetails `json:"h1"`
	M5  TransactionDetails `json:"m5"`
}

type Volume

type Volume struct {
	H24 float64 `json:"h24"`
	H6  float64 `json:"h6"`
	H1  float64 `json:"h1"`
	M5  float64 `json:"m5"`
}

Jump to

Keyboard shortcuts

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