fetcher

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ETH_TO_WEI = 1000000000000000000
	MIN_ETH    = 0.1
	KEY        = "kybersecret"
)
View Source
const (
	TIME_TO_DELETE  = 18000
	API_KEY_TRACKER = "jHGlaMKcGn5cCBxQCGwusS4VcnH0C6tN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	Endpoint string `json:"endPoint"`
	Type     string `json:"type"`
	Apikey   string `json:"api_key"`
}

type Ethereum

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

func NewEthereum

func NewEthereum(network string, networkAbiStr string, tradeTopic string, wrapper string, wrapperAbiStr string, averageBlockTime int64) (*Ethereum, error)

func (*Ethereum) EncodeKyberEnable

func (self *Ethereum) EncodeKyberEnable() (string, error)

func (*Ethereum) EncodeMaxGasPrice

func (self *Ethereum) EncodeMaxGasPrice() (string, error)

func (*Ethereum) EncodeRateData

func (self *Ethereum) EncodeRateData(source, dest string, quantity *big.Int) (string, error)

func (*Ethereum) EncodeRateDataWrapper

func (self *Ethereum) EncodeRateDataWrapper(source, dest []string, quantity []*big.Int) (string, error)

func (*Ethereum) ExtractEnabled

func (self *Ethereum) ExtractEnabled(result string) (bool, error)

func (*Ethereum) ExtractMaxGasPrice

func (self *Ethereum) ExtractMaxGasPrice(result string) (string, error)

func (*Ethereum) ExtractRateData

func (self *Ethereum) ExtractRateData(result string, sourceSymbol, destSymbol string) (ethereum.Rate, error)

func (*Ethereum) ExtractRateDataWrapper

func (self *Ethereum) ExtractRateDataWrapper(result string, sourceArr, destAddr []string) ([]ethereum.Rate, error)

func (*Ethereum) Gettimestamp

func (self *Ethereum) Gettimestamp(block string, latestBlock string, averageBlockTime int64) (string, error)

func (*Ethereum) IsSmallAmount

func (self *Ethereum) IsSmallAmount(eventRaw ethereum.EventRaw) (bool, error)

func (*Ethereum) ReadEvents

func (self *Ethereum) ReadEvents(listEventAddr *[]ethereum.EventRaw, typeFetch string, latestBlock string) (*[]ethereum.EventHistory, error)

func (*Ethereum) ReadEventsWithBlockNumber

func (self *Ethereum) ReadEventsWithBlockNumber(eventRaw *[]ethereum.EventRaw, latestBlock string) (*[]ethereum.EventHistory, error)

func (*Ethereum) ReadEventsWithTimeStamp

func (self *Ethereum) ReadEventsWithTimeStamp(eventRaw *[]ethereum.EventRaw) (*[]ethereum.EventHistory, error)

type Fetcher

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

func NewFetcher

func NewFetcher(kyberENV string) (*Fetcher, error)

func (*Fetcher) CheckKyberEnable

func (self *Fetcher) CheckKyberEnable() (bool, error)

func (*Fetcher) CheckStatus added in v1.1.2

func (self *Fetcher) CheckStatus(listToken, listFailed []ethereum.Token) []ethereum.Token

func (*Fetcher) FetchRate7dData

func (self *Fetcher) FetchRate7dData() (map[string]*ethereum.Rates, error)

func (*Fetcher) FetchUserInfo

func (self *Fetcher) FetchUserInfo(address string) (*common.UserInfo, error)

func (*Fetcher) GetArrToken added in v1.1.2

func (self *Fetcher) GetArrToken() []ethereum.Token

func (*Fetcher) GetGasPrice

func (self *Fetcher) GetGasPrice() (*ethereum.GasPrice, error)

func (*Fetcher) GetGeneralInfoTokens

func (self *Fetcher) GetGeneralInfoTokens() map[string]*ethereum.TokenGeneralInfo

func (*Fetcher) GetLatestBlock

func (self *Fetcher) GetLatestBlock() (string, error)

func (*Fetcher) GetListToken

func (self *Fetcher) GetListToken() map[string]ethereum.Token

GetListToken return map token with key is token ID

func (*Fetcher) GetListTokenAPI

func (self *Fetcher) GetListTokenAPI() []ethereum.TokenAPI

api to get config token

func (*Fetcher) GetMapBadToken added in v1.1.2

func (self *Fetcher) GetMapBadToken() map[string]ethereum.Token

func (*Fetcher) GetMapGoodToken added in v1.1.2

func (self *Fetcher) GetMapGoodToken() map[string]ethereum.Token

func (*Fetcher) GetMaxGasPrice

func (self *Fetcher) GetMaxGasPrice() (string, error)

func (*Fetcher) GetNumTokens

func (self *Fetcher) GetNumTokens() int

func (*Fetcher) GetRate

func (self *Fetcher) GetRate(currentRate []ethereum.Rate, isNewRate bool, mapToken map[string]ethereum.Token, fallback bool) ([]ethereum.Rate, error)

GetRate get full rate of list token

func (*Fetcher) GetRateBuy added in v1.1.2

func (self *Fetcher) GetRateBuy(mapToken map[string]ethereum.Token) ([]ethereum.Rate, error)

GetRateBuy return rate fr

func (*Fetcher) GetRateUsdEther

func (self *Fetcher) GetRateUsdEther() (string, error)

func (*Fetcher) GetStepRate

func (self *Fetcher) GetStepRate() ([]ethereum.StepRate, error)

func (*Fetcher) GetTokenBySymbol

func (self *Fetcher) GetTokenBySymbol(symbol string) (*ethereum.Token, error)

func (*Fetcher) TryUpdateListToken

func (self *Fetcher) TryUpdateListToken() error

func (*Fetcher) UpdateListStatusToken added in v1.1.2

func (self *Fetcher) UpdateListStatusToken(mapGoodToken, mapBadToken map[string]ethereum.Token)

func (*Fetcher) UpdateListToken

func (self *Fetcher) UpdateListToken() error

type FetcherInterface

type FetcherInterface interface {
	EthCall(string, string) (string, error)
	GetLatestBlock() (string, error)

	GetTypeName() string

	GetRate(string, string) (string, error)
}

func NewFetcherIns

func NewFetcherIns(typeName string, endpoint string, apiKey string) (FetcherInterface, error)

type GasStation

type GasStation struct {
	Fast     float64 `json:"fast"`
	Standard float64 `json:"average"`
	Low      float64 `json:"safeLow"`
}

type HTTPFetcher

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

func NewHTTPFetcher

func NewHTTPFetcher(tradingAPIEndpoint, gasStationEndpoint, apiEndpoint string) *HTTPFetcher

func (*HTTPFetcher) GetGasPrice

func (self *HTTPFetcher) GetGasPrice() (*ethereum.GasPrice, error)

func (*HTTPFetcher) GetListToken

func (self *HTTPFetcher) GetListToken() ([]ethereum.Token, error)

func (*HTTPFetcher) GetRate7dData

func (self *HTTPFetcher) GetRate7dData() (map[string]*ethereum.Rates, error)

func (*HTTPFetcher) GetRateUsdEther

func (self *HTTPFetcher) GetRateUsdEther() (string, error)

GetRateUsdEther get usd from api

func (*HTTPFetcher) GetUserInfo

func (self *HTTPFetcher) GetUserInfo(url string) (*common.UserInfo, error)

type InfoData

type InfoData struct {
	ApiUsd         string              `json:"api_usd"`
	CoinMarket     []string            `json:"coin_market"`
	TokenAPI       []ethereum.TokenAPI `json:"tokens"`
	CanDeleteToken []string            `json:"can_delete"`

	Tokens       map[string]ethereum.Token
	BackupTokens map[string]ethereum.Token

	RateCache []string `json:"rate_cache"`

	//ServerLog ServerLog        `json:"server_logs"`
	Connections []Connection `json:"connections"`

	Network    string `json:"network"`
	NetworkAbi string
	TradeTopic string `json:"trade_topic"`

	Wapper     string `json:"wrapper"`
	WrapperAbi string
	EthAdress  string
	EthSymbol  string

	AverageBlockTime int64 `json:"averageBlockTime"`

	GasStationEndpoint string `json:"gasstation_endpoint"`
	APIEndpoint        string `json:"api_endpoint"`
	ConfigEndpoint     string `json:"config_endpoint"`
	UserStatsEndpoint  string `json:"user_stats_endpoint"`
	// contains filtered or unexported fields
}

func (*InfoData) GetArrToken added in v1.1.2

func (self *InfoData) GetArrToken() []ethereum.Token

func (*InfoData) GetListToken

func (self *InfoData) GetListToken() map[string]ethereum.Token

func (*InfoData) GetMapBadToken added in v1.1.2

func (self *InfoData) GetMapBadToken() map[string]ethereum.Token

func (*InfoData) GetMapGoodToken added in v1.1.2

func (self *InfoData) GetMapGoodToken() map[string]ethereum.Token

func (*InfoData) GetTokenAPI

func (self *InfoData) GetTokenAPI() []ethereum.TokenAPI

func (*InfoData) UpdateByBackupToken

func (self *InfoData) UpdateByBackupToken()

func (*InfoData) UpdateListStatusToken added in v1.1.2

func (self *InfoData) UpdateListStatusToken(mapGoodToken, mapBadToken map[string]ethereum.Token)

func (*InfoData) UpdateListToken

func (self *InfoData) UpdateListToken(tokens, mapGoodTokens map[string]ethereum.Token, arrToken []ethereum.Token)

type LogData

type LogData struct {
	Source           common.Address `json:"source"`
	Dest             common.Address `json:"dest"`
	ActualSrcAmount  *big.Int       `json:"actualSrcAmount"`
	ActualDestAmount *big.Int       `json:"actualDestAmount"`
}

type MarketFetcherInterface

type MarketFetcherInterface interface {
	GetRateUsdEther() (string, error)
	GetGeneralInfo(string) (*ethereum.TokenGeneralInfo, error)
}

func NewMarketFetcherInterface

func NewMarketFetcherInterface() MarketFetcherInterface

type RateNetwork

type RateNetwork struct {
	ExpectedRate *big.Int `json:"expectedRate"`
	SlippageRate *big.Int `json:"slippageRate"`
}

type RateUSD

type RateUSD struct {
	Symbol   string `json:"symbol"`
	PriceUsd string `json:"price_usd"`
}

type RateWrapper

type RateWrapper struct {
	ExpectedRate []*big.Int `json:"expectedRate"`
	SlippageRate []*big.Int `json:"slippageRate"`
}

type TokenPrice

type TokenPrice struct {
	Data []struct {
		Symbol string  `json:"symbol"`
		Price  float64 `json:"price"`
	} `json:"data"`
	Error      bool   `json:"error"`
	TimeUpdate uint64 `json:"timeUpdated"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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