tokenprice

package
v0.0.0-...-5cda5f8 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultTokenRatio is eth_price / mnt_price, 4000 = $1800/$0.45
	DefaultTokenRatio = float64(4000)
	// TokenRatioMax token_ratio upper bounds
	TokenRatioMax = float64(100000)
	// TokenRatioMin token_ratio lower bounds
	TokenRatioMin = float64(100)

	// DefaultETHPrice is default eth_price
	// If SwitchOneDollarTokenRatio valid, use DefaultETHPrice to set token_ratio to make mnt_price is 1$
	DefaultETHPrice = float64(1800)
	// ETHPriceMax eth_price upper bounds
	ETHPriceMax = float64(1000000)
	// ETHPriceMin eth_price lower bounds
	ETHPriceMin = float64(100)

	DefaultMNTPrice = 0.45
	// MNTPriceMax mnt_price upper bounds
	MNTPriceMax = float64(100)
	// MNTPriceMin mnt_price lower bounds
	MNTPriceMin = 0.01

	// RealTokenRatioMode use eth_price / mnt_price to set token_ratio
	RealTokenRatioMode = TokenRatioMode(0)
	// OneDollarTokenRatioMode use eth_price to set token_ratio, so mnt price is 1$
	OneDollarTokenRatioMode = TokenRatioMode(1)
	// DefaultTokenRatioMode use DefaultTokenRatio to set token_ratio
	DefaultTokenRatioMode = TokenRatioMode(2)

	// token pairs, used to query token pairs price
	// ETHUSDT used to query eth/usdt price
	ETHUSDT = "ETHUSDT"
	// BITUSDT used to query bit/usdt price
	BITUSDT = "BITUSDT"
	// MNTUSDT used to query mnt/usdt price
	MNTUSDT = "MNTUSDT"
)
View Source
var (
	ContractV3Quoter = common.HexToAddress("0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6")
)

Functions

This section is empty.

Types

type Client

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

Client is an HTTP based TokenPriceClient

func NewClient

func NewClient(url, uniswapURL string, frequency uint64, tokenRatioMode uint64, tokenPairMNTMode bool) *Client

NewClient create a new Client given a remote HTTP url, update frequency and different mode_switch for token ratio tokenPairMNTMode(true/false) to choose if mnt_price is in production

func (*Client) PriceRatioWithMode

func (c *Client) PriceRatioWithMode() (float64, error)

type Item

type Item struct {
	Symbol     string `json:"symbol"`
	LastPrice  string `json:"lastPrice"`
	IndexPrice string `json:"indexPrice"`
}

type PriceResult

type PriceResult struct {
	Category string `json:"category"`
	List     []Item `json:"list"`
}

type Response

type Response struct {
	RetCode     int         `json:"retCode"`
	RetMsg      string      `json:"retMsg"`
	PriceResult PriceResult `json:"result"`
	RetExtInfo  struct{}    `json:"retExtInfo"`
	Time        int64       `json:"time"`
}

type Result

type Result struct {
	RetCode int
	Result  TokenPrice
}

type TokenPrice

type TokenPrice struct {
	Symbol string `json:"symbol"`
	Price  string `json:"price"`
}

type TokenRatioMode

type TokenRatioMode uint64

Jump to

Keyboard shortcuts

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