oracles

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 9 Imported by: 0

README

Oracles

m := NewChainlinkMap()
address := m.ChooseOracle(Selectors{Network: chainId.AvalancheChainName, Symbol: "avax"})
fmt.Println(address)
// Output:
// 0x0A77230d17318075983913bC2145DB16C7366156

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPriceByChainlink(oracleAddr string, client bind.ContractBackend) (decimal.Decimal, error)

Get the price by chainlink oracle.

Return value already divided by decimals.

Types

type ChainlinkOracleMap added in v0.2.0

type ChainlinkOracleMap struct {
	AddressMap map[string]map[string]string
	UpdateAt   time.Time
}

Complete map of chainlink oracles.

func NewChainlinkMap added in v0.2.0

func NewChainlinkMap() *ChainlinkOracleMap

func (*ChainlinkOracleMap) ChooseOracle added in v0.2.0

func (m *ChainlinkOracleMap) ChooseOracle(selectors Selectors) string

Get the specific oracle base on selectors. Symbol must not be empty.

If oracle not found, will return "".

func (*ChainlinkOracleMap) UpdateMap added in v0.2.0

func (m *ChainlinkOracleMap) UpdateMap()

Set the map to up to date status.

type Selectors added in v0.2.0

type Selectors struct {
	Network  string // Default: "ethereum".
	Currency string // Default: "USD". Can be "ETH", "AVAX", etc.
	Symbol   string // Must not be empty.
}

Used to choose oracle from the complete map.

Jump to

Keyboard shortcuts

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