dia

package
v1.4.513-rc-5 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: GPL-2.0 Imports: 18 Imported by: 56

Documentation

Index

Constants

View Source
const (
	ArthswapExchange                   = "Arthswap"
	DiffusionExchange                  = "Diffusion"
	OmniDexExchange                    = "OmniDex"
	NetswapExchange                    = "Netswap"
	TethysExchange                     = "Tethys"
	HermesExchange                     = "Hermes"
	AnyswapExchange                    = "Anyswap"
	BalancerExchange                   = "Balancer"
	BalancerV2Exchange                 = "BalancerV2"
	BalancerV2ExchangeArbitrum         = "BalancerV2-Arbitrum"
	BalancerV2ExchangePolygon          = "BalancerV2-Polygon"
	BeetsExchange                      = "Beets"
	KrakenExchange                     = "Kraken"
	BitfinexExchange                   = "Bitfinex"
	BitforexExchange                   = "Bitforex"
	BinanceExchange                    = "Binance"
	Binance2Exchange                   = "Binance2"
	BinanceExchangeUS                  = "BinanceUS"
	BitstampExchange                   = "Bitstamp"
	CryptoDotComExchange               = "Crypto.com"
	FTXExchange                        = "FTX"
	Opyn                               = "OPYN"
	Premia                             = "Premia"
	BitBayExchange                     = "BitBay"
	CoinBaseExchange                   = "CoinBase"
	HitBTCExchange                     = "HitBTC"
	HuckleberryExchange                = "Huckleberry"
	TraderJoeExchange                  = "TraderJoe"
	TraderJoeExchangeV2_1              = "TraderJoeV2.1"
	TraderJoeExchangeV2_1Arbitrum      = "TraderJoeV2.1-Arbitrum"
	TraderJoeExchangeV2_1Avalanche     = "TraderJoeV2.1-Avalanche"
	TraderJoeExchangeV2_1BNB           = "TraderJoeV2.1-BNB"
	PangolinExchange                   = "Pangolin"
	PlatypusExchange                   = "PlatypusFinance"
	SimexExchange                      = "Simex"
	OKExExchange                       = "OKEx"
	HuobiExchange                      = "Huobi"
	LBankExchange                      = "LBank"
	GateIOExchange                     = "GateIO"
	ZBExchange                         = "ZB"
	QuoineExchange                     = "Quoine"
	UnknownExchange                    = "Unknown"
	BlockSizeSeconds                   = 120
	FilterKing                         = "MAIR120"
	BancorExchange                     = "Bancor"
	UniswapExchange                    = "Uniswap"
	UniswapExchangeV3                  = "UniswapV3"
	UniswapExchangeV3Polygon           = "UniswapV3-polygon"
	UniswapExchangeV3Arbitrum          = "UniswapV3-Arbitrum"
	LoopringExchange                   = "Loopring"
	CamelotExchange                    = "Camelot"
	CamelotExchangeV3                  = "CamelotV3"
	CurveFIExchange                    = "Curvefi"
	CurveFIExchangeFantom              = "Curvefi-Fantom"
	CurveFIExchangeMoonbeam            = "Curvefi-Moonbeam"
	CurveFIExchangePolygon             = "Curvefi-Polygon"
	CurveFIExchangeArbitrum            = "Curvefi-Arbitrum"
	MakerExchange                      = "Maker"
	KuCoinExchange                     = "KuCoin"
	SushiSwapExchange                  = "SushiSwap"
	SushiSwapExchangeArbitrum          = "SushiSwap-arbitrum"
	SushiSwapExchangePolygon           = "SushiSwap-polygon"
	SushiSwapExchangeFantom            = "SushiSwap-fantom"
	PanCakeSwap                        = "PanCakeSwap"
	PanCakeSwapExchangeV3              = "PanCakeSwapV3"
	ApeswapExchange                    = "Apeswap"
	BiswapExchange                     = "Biswap"
	DforceExchange                     = "Dforce"
	ZeroxExchange                      = "0x"
	KyberExchange                      = "Kyber"
	BitMartExchange                    = "BitMart"
	BitMaxExchange                     = "Bitmax"
	MEXCExchange                       = "MEXC"
	BKEXExchange                       = "BKEX"
	BKEX2Exchange                      = "BKEX2"
	CREX24Exchange                     = "CREX24"
	STEXExchange                       = "STEX"
	Deribit                            = "Deribit"
	DfynNetwork                        = "DFYN"
	UbeswapExchange                    = "Ubeswap"
	SpookyswapExchange                 = "Spookyswap"
	SpiritswapExchange                 = "Spiritswap"
	QuickswapExchange                  = "Quickswap"
	SerumExchange                      = "Serum"
	OrcaExchange                       = "Orca"
	SolarbeamExchange                  = "Solarbeam"
	TrisolarisExchange                 = "Trisolaris"
	ByBitExchange                      = "ByBit"
	BitMexExchange                     = "BitMex"
	MultiChain                         = "MultiChain"
	StellaswapExchange                 = "Stellaswap"
	WanswapExchange                    = "Wanswap"
	OsmosisExchange                    = "Osmosis"
	ZenlinkswapExchange                = "Zenlink"
	ZenlinkswapExchangeBifrostPolkadot = "Zenlink-bifrost-polkadot"
	VelodromeExchange                  = "Velodrome"
	MaverickExchange                   = "Maverick"
	MaverickExchangeZKSync             = "Maverick-zksync"
	MaverickExchangeBNB                = "Maverick-bnb"
	PearlfiExchangeTestnet             = "Pearlfi-Testnet"
	PearlfiExchange                    = "Pearlfi"
	RamsesV1Exchange                   = "RamsesV1"
	RamsesV2Exchange                   = "RamsesV2"
	NileV1Exchange                     = "NileV1"
	NileV2Exchange                     = "NileV2"
	ThenaExchange                      = "Thena"
	ThenaV3Exchange                    = "ThenaV3"
	AyinExchange                       = "Ayin"
)
View Source
const (
	CryptoPunks              = "CryptopunkMarket"
	CryptoKitties            = "CryptoKitties"
	Topshot                  = "Topshot"
	X2Y2                     = "X2Y2"
	Opensea                  = "OpenSea"
	OpenseaBAYC              = "OpenseaBAYC"
	OpenseaSeaport           = "OpenseaSeaport"
	BlurV1                   = "BlurV1"
	LooksRare                = "LooksRare"
	TofuNFTAstar             = "TofuNFT-Astar"
	TofuNFTBinanceSmartChain = "TofuNFT-BinanceSmartChain"
	MagicEden                = "MagicEden"
)
View Source
const (
	SCRAPER_TYPE_ASSETCOLLECTOR   = "assetcollector"
	SCRAPER_TYPE_LIQUIDITYSCRAPER = "liquidityscraper"
	INDEX_TYPE_BLOCKNUMBER        = "blocknumber"
	INDEX_TYPE_INDEX              = "index"
)
View Source
const (
	Diadata                                 = "diadata.org"
	PROOF_OF_STAKE    VerificationMechanism = "pos"
	PROOF_OF_WORK     VerificationMechanism = "pow"
	BITCOIN                                 = "Bitcoin"
	ETHEREUM                                = "Ethereum"
	BINANCESMARTCHAIN                       = "BinanceSmartChain"
	POLYGON                                 = "Polygon"
	CELO                                    = "Celo"
	FANTOM                                  = "Fantom"
	NEAR                                    = "NEAR"
	AURORA                                  = "Aurora"
	SOLANA                                  = "Solana"
	FLOW                                    = "Flow"
	MOONRIVER                               = "Moonriver"
	MOONBEAM                                = "Moonbeam"
	AVALANCHE                               = "Avalanche"
	ARBITRUM                                = "Arbitrum"
	ASTAR                                   = "Astar"
	SHIDEN                                  = "Shiden"
	METIS                                   = "Metis"
	KILT                                    = "Kilt"
	FETCH                                   = "Fetch"
	FUSE                                    = "Fuse"
	TELOS                                   = "Telos"
	EVMOS                                   = "Evmos"
	KUSAMA                                  = "Kusama"
	ACALA                                   = "Acala"
	POLKADOT                                = "Polkadot"
	WANCHAIN                                = "Wanchain"
	OSMOSIS                                 = "Osmosis"
	FIAT                                    = "Fiat"
	BIFROST                                 = "Bifrost"
	BIFROST_POLKADOT                        = "Bifrost-polkadot"
	UNREAL_TESTNET                          = "Unreal-Testnet"
	UNREAL                                  = "Unreal"
	LINEA                                   = "Linea"
	OPTIMISM                                = "Optimism"
	ALEPHIUM                                = "Alephium"
)
View Source
const BaseUrl string = "https://api.diadata.org/"

Variables

View Source
var CRYPTO_ZERO_UNIX_TIME = time.Unix(1230768000, 0)

Functions

func ContainsExchangePair added in v1.2.0

func ContainsExchangePair(pairs []ExchangePair, pair ExchangePair) bool

ContainsExchangePair returns true iff @pair is contained in pairs. Here, equality refers to the unique identifier (exchange,foreignName).

func GetAllSymbolsFromPairs added in v1.2.0

func GetAllSymbolsFromPairs(pairs []ExchangePair) ([]string, error)

GetAllSymbolsFromPairs returns a unique list of symbols which constitute @pairs.

func GetPairSymbols added in v1.2.0

func GetPairSymbols(pair ExchangePair) ([]string, error)

GetPairSymbols returns the two symbol tickers of @pair.

func GetSymbolsList

func GetSymbolsList(url string) ([]string, error)

TODO remove URL

Types

type Asset added in v1.2.0

type Asset struct {
	Symbol     string `json:"Symbol"`
	Name       string `json:"Name"`
	Address    string `json:"Address"`
	Decimals   uint8  `json:"Decimals"`
	Blockchain string `json:"Blockchain"`
}

Asset is the data type for all assets, ranging from fiat to crypto.

func GetAllAssetsFromPairs added in v1.2.0

func GetAllAssetsFromPairs(pairs []ExchangePair) (assets []Asset)

GetAllAssetsFromPairs returns the unique slice of assets underlying the exchange pairs @pairs.

func (*Asset) Identifier added in v1.4.159

func (asset *Asset) Identifier() string

func (*Asset) MarshalBinary added in v1.2.0

func (a *Asset) MarshalBinary() ([]byte, error)

MarshalBinary is a custom marshaller for Asset type

func (*Asset) UnmarshalBinary added in v1.2.0

func (a *Asset) UnmarshalBinary(data []byte) error

UnmarshalBinary is a custom unmarshaller for Asset type

type AssetLiquidity added in v1.4.68

type AssetLiquidity struct {
	Asset     Asset   `json:"Asset"`
	Volume    float64 `json:"Liquidity"`
	VolumeUSD float64 `json:"LiquidityUSD"`
	Index     uint8   `json:"Index"`
}

type AssetList added in v1.4.488

type AssetList struct {
	AssetName   string
	CustomName  string
	Symbol      string
	Methodology string
	Price       float64
	ListName    string

	Exchanges []ExchangeList
}

func (AssetList) String added in v1.4.490

func (a AssetList) String() string

type AssetVolume added in v1.4.2

type AssetVolume struct {
	Asset     Asset   `json:"Asset"`
	Volume    float64 `json:"Volume"`
	VolumeUSD float64 `json:"VolumeUSD"`
	Index     uint8   `json:"Index"`
}

type BlockChain

type BlockChain struct {
	Name string `json:"Name"`
	// Genesis date is a Unix timestamp
	GenesisDate int64 `json:"GenesisDate"`
	NativeToken Asset `json:"NativeToken"`
	// Verificationmechanism is in short notation, such as pos for proof-of-stake
	VerificationMechanism VerificationMechanism `json:"VerificationMechanism"`
	// ChainID refers to EVM based chains and is thereby optional.
	ChainID string `json:"ChainID"`
}

BlockChain is the type for blockchains. Uniquely defined by its @Name.

func (*BlockChain) MarshalBinary added in v1.2.0

func (bc *BlockChain) MarshalBinary() ([]byte, error)

MarshalBinary is a custom marshaller for BlockChain type

func (*BlockChain) UnmarshalBinary added in v1.2.0

func (bc *BlockChain) UnmarshalBinary(data []byte) error

UnmarshalBinary is a custom unmarshaller for BlockChain type

type BlockData added in v1.2.0

type BlockData struct {
	// Name of the blockchain, as found for instance in dia.ETHEREUM
	BlockchainName string
	// In order to keep it general, BlockNumber is a string
	BlockNumber int64
	Data        map[string]interface{}
}

BlockData stores information on a specific block in a given blockchain.

type ChainConfig added in v1.4.2

type ChainConfig struct {
	RestURL string `json:"RestURL"`
	WSURL   string `json:"WSURL"`
	ChainID string `json:"ChainID"`
}

type Client

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

func NewClient

func NewClient(config *ConfigApi) *Client

func NewClientWithUrl

func NewClientWithUrl(config *ConfigApi, url string) *Client

func (*Client) DoRequest

func (c *Client) DoRequest(req *http.Request, refresh bool) ([]byte, error)

func (*Client) SendSupply

func (c *Client) SendSupply(s *Supply) error

func (*Client) SendSupplyWithForceOption

func (c *Client) SendSupplyWithForceOption(s *Supply, force bool) error

type ConfigApi

type ConfigApi struct {
	ApiKey    string
	SecretKey string
}

func GetConfig

func GetConfig(exchange string) (*ConfigApi, error)

func GetConfigApi

func GetConfigApi() *ConfigApi

func GetConfigFromEnv added in v1.2.0

func GetConfigFromEnv(exchange string) (*ConfigApi, error)

type ConfigConnector

type ConfigConnector struct {
	Coins []ExchangePair
}

type EthereumBlockData added in v1.2.0

type EthereumBlockData struct {
	GasLimit    uint64             `json:"GasLimit"`
	GasUsed     uint64             `json:"GasUsed"`
	Difficulty  *big.Int           `json:"Difficulty"`
	Time        uint64             `json:"Time"`
	Size        common.StorageSize `json:"Size"`
	Number      uint64             `json:"Number"`
	MixDigest   common.Hash        `json:"MixDigest"`
	Nonce       uint64             `json:"Nonce"`
	Coinbase    common.Address     `json:"Coinbase"`
	Root        common.Hash        `json:"Root"`
	ParentHash  common.Hash        `json:"ParentHash"`
	TxHash      common.Hash        `json:"TxHash"`
	ReceiptHash common.Hash        `json:"ReceiptHash"`
	UncleHash   common.Hash        `json:"UncleHash"`
	Extra       []byte             `json:"Extra"`
}

type Exchange

type Exchange struct {
	Name          string     `json:"Name"`
	Centralized   bool       `json:"Centralized"`
	Bridge        bool       `json:"Bridge"`
	Contract      string     `json:"Contract"`
	BlockChain    BlockChain `json:"BlockChain"`
	RestAPI       string     `json:"RestAPI"`
	WsAPI         string     `json:"WsAPI"`
	PairsAPI      string     `json:"PairsAPI"`
	WatchdogDelay int        `json:"WatchdogDelay"`
	ScraperActive bool       `json:"ScraperActive"`
}

type ExchangeList added in v1.4.488

type ExchangeList struct {
	Name  string
	Pairs []string
}

func (ExchangeList) String added in v1.4.490

func (e ExchangeList) String() string

type ExchangePair added in v1.2.0

type ExchangePair struct {
	Symbol         string `json:"Symbol"`
	ForeignName    string `json:"ForeignName"`
	Exchange       string `json:"EXchange"`
	Verified       bool   `json:"Verified"`
	UnderlyingPair Pair   `json:"UnderlyingPair"`
}

ExchangePair is the container for a pair as used by exchanges. Across exchanges, these pairs cannot be uniquely mapped on asset pairs.

func MergeExchangePairs added in v1.2.0

func MergeExchangePairs(pairs1, pairs2 []ExchangePair) []ExchangePair

MergeExchangePairs appends @pairs2 to @pairs1 without repetition.

func (*ExchangePair) MarshalBinary added in v1.2.0

func (ep *ExchangePair) MarshalBinary() ([]byte, error)

MarshalBinary is a custom marshaller for ExchangePair type

func (*ExchangePair) UnmarshalBinary added in v1.2.0

func (ep *ExchangePair) UnmarshalBinary(data []byte) error

UnmarshalBinary is a custom unmarshaller for ExchangePair type

type ExchangeVolume added in v1.4.2

type ExchangeVolume struct {
	Exchange string  `json:"Exchange"`
	Volume   float64 `json:"Volume"`
}

type ExchangeVolumesList added in v1.4.2

type ExchangeVolumesList struct {
	Volumes   []ExchangeVolume `json:"Volumes"`
	Timestamp time.Time        `json:"Timestamp"`
}

type ExchangepairSelection added in v1.4.305

type ExchangepairSelection struct {
	Exchange           Exchange
	Pairs              []Pair
	Pools              []Pool
	LiquidityThreshold float64
}

type FeedSelection added in v1.4.305

type FeedSelection struct {
	Asset              Asset
	Exchangepairs      []ExchangepairSelection
	LiquidityThreshold float64
}

type FeedSelectionAggregated added in v1.4.429

type FeedSelectionAggregated struct {
	Exchange         string
	Quotetoken       Asset
	Basetoken        Asset
	Pooladdress      string
	PoolLiquidityUSD float64
	TradesCount      int32
	Volume           float64
	LastPrice        float64
	Starttime        time.Time
	Endtime          time.Time
	StatusMessage    string
	StatusCode       int32
}

type FeedUpdates added in v1.4.435

type FeedUpdates struct {
	Day         time.Time `json:"Day"`
	UpdateCount int32     `json:"UpdateCount"`
	GasUsed     float64   `json:"GasUsed"`
}

type FilterPoint

type FilterPoint struct {
	Asset      Asset
	Value      float64
	Name       string
	Time       time.Time
	Max        float64
	Min        float64
	FirstTrade Trade
	LastTrade  Trade
}

FilterPoint contains the resulting value of a filter applied to an asset.

type FilterPointExtended added in v1.4.310

type FilterPointExtended struct {
	FilterPoint FilterPoint
	// Pools and pairs of the filter point's underlying trades.
	Pools         []Pool
	Pairs         []ExchangePair
	TradesCount   int32
	StatusMessage string
	StatusCode    int32
}

type FilterPointMetadata added in v1.4.2

type FilterPointMetadata struct {
	Max float64
	Min float64
}

func NewFilterPointMetadata added in v1.4.2

func NewFilterPointMetadata() *FilterPointMetadata

func (*FilterPointMetadata) AddPoint added in v1.4.2

func (fp *FilterPointMetadata) AddPoint(value float64)

type FiltersBlock

type FiltersBlock struct {
	BlockHash        string
	FiltersBlockData FiltersBlockData
}

func (*FiltersBlock) MarshalBinary

func (e *FiltersBlock) MarshalBinary() ([]byte, error)

MarshalBinary -

func (*FiltersBlock) UnmarshalBinary

func (e *FiltersBlock) UnmarshalBinary(data []byte) error

UnmarshalBinary -

type FiltersBlockData

type FiltersBlockData struct {
	TradesBlockHash string
	BeginTime       time.Time
	EndTime         time.Time
	FilterPoints    []FilterPoint
	FiltersNumber   int
}

type IndexBlock

type IndexBlock struct {
	BlockHash      string         `json:"BlockHash"`
	IndexBlockData IndexBlockData `json:"IndexBlockData"`
}

func (IndexBlock) Hash

func (ib IndexBlock) Hash() string

func (*IndexBlock) MarshalBinary

func (e *IndexBlock) MarshalBinary() ([]byte, error)

MarshalBinary -

func (*IndexBlock) UnmarshalBinary

func (e *IndexBlock) UnmarshalBinary(data []byte) error

UnmarshalBinary -

type IndexBlockData

type IndexBlockData struct {
	FiltersBlockHash    string         `json:"FiltersBlockHash"`
	SuppliesBlockHash   string         `json:"SuppliesBlockHash"`
	VolatilityBlockHash string         `json:"VolatilityBlockHash"`
	IndexElements       []IndexElement `json:"IndexElements"`
	IndexElementsNumber int            `json:"IndexElementsNumber"`
	Time                time.Time      `json:"Time"`
	IndexValue          float64        `json:"IndexValue"`
	ValueTokenette      float64        `json:"ValueTokenette"`
	ValueToken          float64        `json:"ValueToken"`
	USDPerPointsOfIndex float64        `json:"USDPerPointsOfIndex"`
}

type IndexElement

type IndexElement struct {
	Name            string
	Symbol          string
	Percentage      float64
	FilteredPoint   FilterPoint
	Supply          Supply
	VolatilityRatio VolatilityRatio
}

type NFT

type NFT struct {
	NFTClass       NFTClass  `json:"NFTClass"`
	TokenID        string    `json:"TokenID"`
	CreationTime   time.Time `json:"CreationTme"`
	CreatorAddress string    `json:"CreatorAddress"`
	URI            string    `json:"URI"`
	// @Attributes is a collection of attributes from on- and off-chain
	// TO DO: Should we split up into two fields?
	Attributes NFTAttributes `json:"Attributes"`
}

NFT is the container for a specific NFT defined by the pair (address,tokenID).

func (*NFT) MarshalBinary

func (n *NFT) MarshalBinary() ([]byte, error)

MarshalBinary for NFT

func (*NFT) UnmarshalBinary

func (n *NFT) UnmarshalBinary(data []byte) error

UnmarshalBinary for NFT

type NFTAttributes

type NFTAttributes map[string]interface{}

NFTAttributes can be stored as jasonb in postgres: https://www.alexedwards.net/blog/using-postgresql-jsonb

func (*NFTAttributes) Scan

func (a *NFTAttributes) Scan(value interface{}) error

func (NFTAttributes) Value

func (a NFTAttributes) Value() (driver.Value, error)

type NFTBid added in v1.2.0

type NFTBid struct {
	NFT              NFT       `json:"NFT"`
	Value            *big.Int  `json:"Value"`
	FromAddress      string    `json:"FromAddress"`
	CurrencySymbol   string    `json:"CurrencySymbol"`
	CurrencyAddress  string    `json:"CurrencyAddress"`
	CurrencyDecimals int32     `json:"CurrencyDecimals"`
	BlockNumber      uint64    `json:"BlockNumber"`
	BlockPosition    uint64    `json:"BlockPosition"`
	Timestamp        time.Time `json:"Timestamp"`
	TxHash           string    `json:"TxHash"`
	Exchange         string    `json:"Exchange"`
}

func (*NFTBid) MarshalBinary added in v1.2.0

func (nb *NFTBid) MarshalBinary() ([]byte, error)

MarshalBinary for NFTBid

func (*NFTBid) UnmarshalBinary added in v1.2.0

func (nb *NFTBid) UnmarshalBinary(data []byte) error

UnmarshalBinary for NFTBid

type NFTClass

type NFTClass struct {
	Address      string `json:"Address"`
	Symbol       string `json:"Symbol"`
	Name         string `json:"Name"`
	Blockchain   string `json:"Blockchain"`
	ContractType string `json:"ContractType"`
	Category     string `json:"Category"`
}

NFTClass is the container for a nft class defined by a contract (address) on a blockchain.

func (*NFTClass) MarshalBinary

func (nc *NFTClass) MarshalBinary() ([]byte, error)

MarshalBinary for NFTClass

func (*NFTClass) UnmarshalBinary

func (nc *NFTClass) UnmarshalBinary(data []byte) error

UnmarshalBinary for NFTClass

type NFTExchange added in v1.4.7

type NFTExchange struct {
	Name          string     `json:"Name"`
	Centralized   bool       `json:"Centralized"`
	Contract      string     `json:"Contract"`
	BlockChain    BlockChain `json:"BlockChain"`
	RestAPI       string     `json:"RestAPI"`
	WsAPI         string     `json:"WsAPI"`
	WatchdogDelay int        `json:"WatchdogDelay"`
}

type NFTExchangeStats added in v1.4.2

type NFTExchangeStats struct {
	Exchange  string
	NumTrades uint64
	Volume    float64
}

type NFTOffer added in v1.2.0

type NFTOffer struct {
	NFT NFT `json:"NFT"`
	// Start and EndValue are for auction types. Otherwise, use StartValue
	// and leave EndValue blank.
	StartValue *big.Int `json:"StartValue"`
	EndValue   *big.Int `json:"EndValue"`
	// Duration of the offer/auction measured in seconds
	Duration    time.Duration `json:"Duration"`
	FromAddress string        `json:"FromAddress"`
	// Type of offer can be auction, simple offer,...
	AuctionType string `json:"AuctionType"`

	CurrencySymbol   string `json:"CurrencySymbol"`
	CurrencyAddress  string `json:"CurrencyAddress"`
	CurrencyDecimals int32  `json:"CurrencyDecimals"`

	BlockNumber   uint64    `json:"BlockNumber"`
	BlockPosition uint64    `json:"BlockPosition"`
	Timestamp     time.Time `json:"Timestamp"`
	TxHash        string    `json:"TxHash"`
	Exchange      string    `json:"Exchange"`
}

func (*NFTOffer) MarshalBinary added in v1.2.0

func (no *NFTOffer) MarshalBinary() ([]byte, error)

MarshalBinary for NFTOffer

func (*NFTOffer) UnmarshalBinary added in v1.2.0

func (no *NFTOffer) UnmarshalBinary(data []byte) error

UnmarshalBinary for NFTOffer

type NFTTrade

type NFTTrade struct {
	NFT         NFT       `json:"NFT"`
	Price       *big.Int  `json:"Price"`
	PriceUSD    float64   `json:"PriceUSD"`
	FromAddress string    `json:"FromAddress"`
	ToAddress   string    `json:"ToAddress"`
	Currency    Asset     `json:"Currency"`
	BundleSale  bool      `json:"BundleSale"`
	BlockNumber uint64    `json:"BlockNumber"`
	Timestamp   time.Time `json:"Timestamp"`
	TxHash      string    `json:"TxHash"`
	Exchange    string    `json:"Exchange"`
}

func (*NFTTrade) MarshalBinary

func (ns *NFTTrade) MarshalBinary() ([]byte, error)

MarshalBinary for NFTTrade

func (*NFTTrade) UnmarshalBinary

func (ns *NFTTrade) UnmarshalBinary(data []byte) error

UnmarshalBinary for NFTTrade

type OracleConfig added in v1.4.117

type OracleConfig struct {
	Symbols            []string
	FeederID           string
	Address            string
	FeederAddress      string
	Owner              string
	ChainID            string
	Active             bool
	Frequency          string
	SleepSeconds       string
	DeviationPermille  string
	BlockchainNode     string
	MandatoryFrequency string
	CreatedDate        time.Time
	LastUpdate         time.Time
	Deleted            bool
	FeederSelection    string
	Expired            bool
	ExpiredDate        time.Time
	ExpiringDate       time.Time
	LastOracleUpdate   time.Time
}

func (*OracleConfig) MarshalBinary added in v1.4.439

func (e *OracleConfig) MarshalBinary() ([]byte, error)

func (*OracleConfig) UnmarshalBinary added in v1.4.439

func (e *OracleConfig) UnmarshalBinary(data []byte) error

UnmarshalBinary -

type OracleUpdate added in v1.4.272

type OracleUpdate struct {
	OracleAddress     string
	TransactionHash   string
	TransactionCost   string
	AssetKey          string
	AssetPrice        string
	UpdateBlock       uint64
	UpdateFrom        string
	FromBalance       string
	GasCost           string
	GasUsed           float64
	ChainID           string
	UpdateTime        time.Time
	CreationBlock     uint64
	CreationBlockTime time.Time
}

type Pair

type Pair struct {
	QuoteToken Asset `json:"QuoteToken"`
	BaseToken  Asset `json:"BaseToken"`
}

Pair substitues the old dia.Pair. It includes the new asset type.

func (*Pair) ForeignName

func (p *Pair) ForeignName() string

ForeignName returns the foreign name of the pair @p, i.e. the string Quotetoken-Basetoken

func (*Pair) Identifier added in v1.4.131

func (p *Pair) Identifier() string

func (*Pair) PairExchangeIdentifier added in v1.4.131

func (p *Pair) PairExchangeIdentifier(exchange string) string

type PairVolume added in v1.4.2

type PairVolume struct {
	Pair        Pair    `json:"Pair"`
	PoolAddress string  `json:"Pooladdress"`
	Volume      float64 `json:"Volume"`
	TradesCount int64   `json:"TradesCount"`
}

type Pairs

type Pairs []ExchangePair

func (*Pairs) MarshalBinary

func (e *Pairs) MarshalBinary() ([]byte, error)

MarshalBinary -

func (*Pairs) UnmarshalBinary

func (e *Pairs) UnmarshalBinary(data []byte) error

UnmarshalBinary -

type Pool added in v1.4.2

type Pool struct {
	Exchange     Exchange
	Blockchain   BlockChain
	Address      string
	Assetvolumes []AssetVolume
	Time         time.Time
}

Pool is the container for liquidity pools on DEXes.

func (*Pool) GetPoolLiquidityUSD added in v1.4.306

func (p *Pool) GetPoolLiquidityUSD() (totalLiquidity float64, lowerBound bool)

GetPoolLiquidityUSD returns the total USD liquidity if available. @lowerBound is true in case USD liquidity is not available for all pool assets.

func (*Pool) SufficientNativeBalance added in v1.4.292

func (p *Pool) SufficientNativeBalance(threshold float64) bool

SufficientNativeBalance returns true if all pool assets have at least @threshold liquidity.

type SuppliesBlock

type SuppliesBlock struct {
	BlockHash string            `json:"BlockHash"`
	BlockData SuppliesBlockData `json:"BlockData"`
}

func (*SuppliesBlock) MarshalBinary

func (e *SuppliesBlock) MarshalBinary() ([]byte, error)

MarshalBinary -

func (*SuppliesBlock) UnmarshalBinary

func (e *SuppliesBlock) UnmarshalBinary(data []byte) error

UnmarshalBinary -

type SuppliesBlockData

type SuppliesBlockData struct {
	Time     time.Time `json:"Time"`
	Supplies []Supply  `json:"Supplies"`
}

type Supply

type Supply struct {
	Asset             Asset     `json:"Asset"`
	Supply            float64   `json:"Supply"`
	CirculatingSupply float64   `json:"CirculatingSupply"`
	Source            string    `json:"Source"`
	Time              time.Time `json:"Time"`
}

func GetSupply

func GetSupply(symbol string) (*Supply, error)

func (*Supply) MarshalBinary

func (e *Supply) MarshalBinary() ([]byte, error)

MarshalBinary -

func (*Supply) UnmarshalBinary

func (e *Supply) UnmarshalBinary(data []byte) error

UnmarshalBinary -

type Symbols

type Symbols struct {
	Symbols []string
}

type SynthAssetSupply added in v1.4.2

type SynthAssetSupply struct {
	Asset            Asset   // Synthetic asset under consideration.
	AssetUnderlying  Asset   // Asset underlying the synth asset.
	Supply           float64 // Supply of the synthetic asset.
	LockedUnderlying float64 // Amount of underlying asset locked in the contract.
	NumMint          int64   // Total number of synth asset mint events (optional).
	NumRedeem        int64   // Total number of underlying asset redeem events (optional).
	BlockNumber      uint64
	Time             time.Time
	ColleteralRatio  float64
	Protocol         string
	TotalDebt        float64
}

SynthAssetSupply is a container for data on synthetic assets such as aUSDC. https://etherscan.io/address/0xbcca60bb61934080951369a648fb03df4f96263c

type TopAsset added in v1.4.2

type TopAsset struct {
	Asset          Asset               `json:"Asset"`
	Volume         float64             `json:"Volume"`
	Price          float64             `json:"Price"`
	PriceYesterday float64             `json:"PriceYesterday"`
	Source         map[string][]string `json:"Source"`
}

type Trade

type Trade struct {
	// TO DO: Deprecated fields. Delete as soon as token-to-type branch is deployed.
	Symbol string `json:"Symbol"`
	Pair   string `json:"Pair"`
	// Final fields for trade
	QuoteToken        Asset     `json:"QuoteToken"`
	BaseToken         Asset     `json:"BaseToken"`
	Price             float64   `json:"Price"`
	Volume            float64   `json:"Volume"` // Quantity of bought/sold units of Quote token. Negative if result of Market order Sell
	Time              time.Time `json:"Time"`
	PoolAddress       string    `json:"PoolAddress"`
	ForeignTradeID    string    `json:"ForeignTradeID"`
	EstimatedUSDPrice float64   `json:"EstimatedUSDPrice"` // will be filled by the TradesBlockService
	Source            string    `json:"Source"`
	VerifiedPair      bool      `json:"VerifiedPair"` // will be filled by the pairDiscoveryService
}

Trade remark: In a pair A-B, we call A the Quote token and B the Base token

func SwapTrade

func SwapTrade(t Trade) (Trade, error)

SwapTrade swaps base and quote token of a trade and inverts the price accordingly

func (*Trade) GetBaseToken added in v1.2.0

func (t *Trade) GetBaseToken() string

GetBaseToken returns the base token of a trading pair TO DO (20/11/2020): This method is no longer needed once we switch to new Token/Trade structs

func (*Trade) IdentifyDuplicateFull added in v1.4.136

func (t *Trade) IdentifyDuplicateFull(falseDuplicateTrades *timedmap.TimedMap, memory time.Duration) (discardTrade bool)

IdentifyDuplicateFull returns true in case a trade is fully identical to one stored in the timed map @falseDuplicateTrades.

func (*Trade) IdentifyDuplicateTagset added in v1.4.136

func (t *Trade) IdentifyDuplicateTagset(duplicateTrades *timedmap.TimedMap, memory time.Duration)

IdentifyDuplicateTagset identifies trades with identical timestamps and tagsets and add a Nanosecond to the timestamp in order for the trade not to be overwritten in Influx.

func (*Trade) MarshalBinary

func (e *Trade) MarshalBinary() ([]byte, error)

MarshalBinary -

func (*Trade) NormalizeSymbols added in v1.4.320

func (t *Trade) NormalizeSymbols(upperCase bool, pairSplitter string) error

NormalizeSymbols normalizes @t.Symbol and @t.Pair in a trade struct to upper case letters like so A@pairSplitterB. For instance, btcusdt will be BTC-USDT.

func (*Trade) TradeIdentifierFull added in v1.4.136

func (t *Trade) TradeIdentifierFull() string

TradeIdentifierFull returns an identifier with respect to all fields of a trade.

func (*Trade) TradeIdentifierTagset added in v1.4.136

func (t *Trade) TradeIdentifierTagset() string

TradeIdentifierTagset returns an identifier with respect to the tagset of a trade in Influx. In other words, a trade with this same tagset is overwritten in Influx trades table.

func (*Trade) UnmarshalBinary

func (e *Trade) UnmarshalBinary(data []byte) error

UnmarshalBinary -

func (*Trade) VolumeUSD added in v1.4.316

func (t *Trade) VolumeUSD() float64

type TradesBlock

type TradesBlock struct {
	BlockHash       string
	TradesBlockData TradesBlockData
}

func (*TradesBlock) MarshalBinary

func (e *TradesBlock) MarshalBinary() ([]byte, error)

MarshalBinary -

func (*TradesBlock) UnmarshalBinary

func (e *TradesBlock) UnmarshalBinary(data []byte) error

UnmarshalBinary -

type TradesBlockData

type TradesBlockData struct {
	BeginTime    time.Time
	EndTime      time.Time
	TradesNumber int
	Trades       []Trade
}

type VerificationMechanism

type VerificationMechanism string

type VolatilityRatio

type VolatilityRatio struct {
	Symbol    string
	Threehold float64
	DaysAbove int64
	DaysBelow int64
	Time      time.Time
	Selected  bool
}

Directories

Path Synopsis
db
nft
scraper
service

Jump to

Keyboard shortcuts

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