rates

package
v1.14.10 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitCalculator

func InitCalculator(source ratesSource) *calculator

Types

type Asset

type Asset struct {
	Account      ton.AccountID
	Decimals     int
	Reserve      float64
	HoldersCount int
}

Asset represents an asset used in jetton price calculations within pools

type Assets

type Assets struct {
	Assets   []Asset
	IsStable bool
}

Assets represents a collection of assets in a pool

type LpAsset

type LpAsset struct {
	Account     ton.AccountID
	Decimals    int
	TotalSupply *big.Int // The total supply of the liquidity provider asset
	Assets      []Asset  // A slice of Asset included in the liquidity pool
}

LpAsset represents a liquidity provider asset that holds a collection of assets in a pool

type Market

type Market struct {
	ID       int64
	Name     string // Name of the service used for price calculation
	UsdPrice float64
	URL      string
	// Converter for calculating the TON to USD price
	TonPriceConverter func(closer io.ReadCloser) (float64, error)
	// Converter for calculating fiat prices
	FiatPriceConverter func(closer io.ReadCloser) (map[string]float64, error)
	// Converter for calculating jetton prices within pools
	PoolResponseConverter func(closer io.ReadCloser) ([]Assets, []LpAsset, error)
	DateUpdate            time.Time
}

type Mock

type Mock struct {
	// TonApiToken the token for TonApi to increase HTTP limits is obtained from https://tonconsole.com/tonapi
	TonApiToken string
	// URL to the CSV file from the analytics service https://tonconsole.com/analytics (data is sourced from the TonApi analytics database)
	StonV1FiResultUrl, StonV2FiResultUrl string
	// URL to the CSV file from the analytics service https://tonconsole.com/analytics (data is sourced from the TonApi analytics database)
	DedustResultUrl string
}

func (*Mock) GetCurrentMarketsTonPrice

func (m *Mock) GetCurrentMarketsTonPrice() ([]Market, error)

GetCurrentMarketsTonPrice shows the TON to USD price on different markets

func (*Mock) GetCurrentRates

func (m *Mock) GetCurrentRates() (map[string]float64, error)

func (Mock) GetMarketsTonPrice

func (m Mock) GetMarketsTonPrice() ([]Market, error)

func (Mock) GetRates

func (m Mock) GetRates(date int64) (map[string]float64, error)

GetRates cannot request data for a specific date in the open source version It will always return data for the current day

func (Mock) GetRatesChart

func (m Mock) GetRatesChart(token string, currency string, pointsCount int, startDate *int64, endDate *int64) ([]Point, error)

GetRatesChart cannot be used to request charts for jettons in the open source version To use this method, you must save today's data from GetRates and then override the method

type Point

type Point struct {
	Timestamp int64
	Price     float64
}

Jump to

Keyboard shortcuts

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