Documentation ¶
Index ¶
- Constants
- Variables
- func ExpDecay(x float64) (float64, float64)
- func InitPSRs() error
- func LinearDecay(x float64) (float64, float64)
- func ManualEntry(apis []*IndexTracker, at time.Time) (apiOracle.PriceInfo, float64)
- func Mean(vals []apiOracle.PriceInfo) apiOracle.PriceInfo
- func MeanAt(apis []*IndexTracker, at time.Time) (apiOracle.PriceInfo, float64)
- func Median(values []apiOracle.PriceInfo) apiOracle.PriceInfo
- func MedianAt(apis []*IndexTracker, at time.Time) (apiOracle.PriceInfo, float64)
- func MedianAtEOD(apis []*IndexTracker, at time.Time) (apiOracle.PriceInfo, float64)
- func NoDecay(x float64) (float64, float64)
- func PSRValueForTime(requestID int, at time.Time) (float64, float64)
- func UpdatePSRs(ctx context.Context, updatedSymbols []string) error
- func VolumeWeightedAvg(vals []apiOracle.PriceInfo) apiOracle.PriceInfo
- type Ampl
- type BalanceTracker
- type ChainedPrice
- type CurrentVariablesTracker
- type DataSource
- type DisputeTracker
- type FetchRequest
- type GasPriceModel
- type GasTracker
- type IndexProcessor
- type IndexTracker
- type JSONapi
- type JSONfile
- type NewCurrentVariablesTracker
- type Runner
- type SingleSymbol
- type TimeOutTracker
- type TimedSwitch
- type Tracker
- type TributeTracker
- type ValueCheckResult
- type ValueGenerator
Constants ¶
const GWEI = 1000000000
GWEI constant is the multiplier from Wei
Variables ¶
var PSRs = map[int]ValueGenerator{ 1: &TimedSwitch{ before: &SingleSymbol{symbol: "ETH/USD", granularity: 1000, transform: MedianAt}, after: &SingleSymbol{symbol: "ETH/USD", granularity: 1000000, transform: MedianAt}, at: switchTime, }, 2: &TimedSwitch{ before: &SingleSymbol{symbol: "BTC/USD", granularity: 1000, transform: MedianAt}, after: &SingleSymbol{symbol: "BTC/USD", granularity: 1000000, transform: MedianAt}, at: switchTime, }, 3: &TimedSwitch{ before: &SingleSymbol{symbol: "BNB/USD", granularity: 1000, transform: MedianAt}, after: &SingleSymbol{symbol: "BNB/USD", granularity: 1000000, transform: MedianAt}, at: switchTime, }, 4: &TimedSwitch{ before: &SingleSymbol{symbol: "BTC/USD", granularity: 100000, transform: MedianAt}, after: &SingleSymbol{symbol: "BTC/USD", granularity: 1000000, transform: TimeWeightedAvg(24*time.Hour, ExpDecay)}, at: switchTime, }, 5: &SingleSymbol{symbol: "ETH/BTC", granularity: 1000000, transform: MedianAt}, 6: &SingleSymbol{symbol: "BNB/BTC", granularity: 1000000, transform: MedianAt}, 7: &SingleSymbol{symbol: "BNB/ETH", granularity: 1000000, transform: MedianAt}, 8: &TimedSwitch{ before: &SingleSymbol{symbol: "ETH/USD", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "ETH/USD", granularity: 1000000, transform: TimeWeightedAvg(24*time.Hour, ExpDecay)}, at: switchTime, }, 9: &TimedSwitch{ before: &SingleSymbol{symbol: "LINK/BTC", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "ETH/USD", granularity: 1000000, transform: MedianAtEOD}, at: switchTime, }, 10: &TimedSwitch{ before: &SingleSymbol{symbol: "ETC/ETH", granularity: 1000000, transform: MedianAt}, after: &Ampl{granularity: 1000000}, at: switchTime, }, 11: &SingleSymbol{symbol: "ZEC/ETH", granularity: 1000000, transform: MedianAt}, 12: &SingleSymbol{symbol: "TRX/ETH", granularity: 1000000, transform: MedianAt}, 13: &TimedSwitch{ before: &SingleSymbol{symbol: "XRP/BTC", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "XRP/USD", granularity: 1000000, transform: MedianAt}, at: switchTime, }, 14: &SingleSymbol{symbol: "XMR/ETH", granularity: 1000000, transform: MedianAt}, 15: &TimedSwitch{ before: &SingleSymbol{symbol: "XLM/BTC", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "ATOM/USD", granularity: 1000000, transform: MedianAt}, at: switchTime, }, 16: &SingleSymbol{symbol: "LTC/USD", granularity: 1000000, transform: MedianAt}, 17: &SingleSymbol{symbol: "WAVES/BTC", granularity: 1000000, transform: MedianAt}, 18: &SingleSymbol{symbol: "REP/BTC", granularity: 1000000, transform: MedianAt}, 19: &SingleSymbol{symbol: "TUSD/ETH", granularity: 1000000, transform: MedianAt}, 20: &SingleSymbol{symbol: "EOS/USD", granularity: 1000000, transform: MedianAt}, 21: &SingleSymbol{symbol: "IOTA/USD", granularity: 1000000, transform: MedianAt}, 22: &SingleSymbol{symbol: "ETC/USD", granularity: 1000000, transform: MedianAt}, 23: &SingleSymbol{symbol: "ETH/PAX", granularity: 1000000, transform: MedianAt}, 24: &TimedSwitch{ before: &SingleSymbol{symbol: "ETH/USD", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "ETH/BTC", granularity: 1000000, transform: TimeWeightedAvg(1*time.Hour, NoDecay)}, at: switchTime, }, 25: &SingleSymbol{symbol: "USDC/USDT", granularity: 1000000, transform: MedianAt}, 26: &TimedSwitch{ before: &SingleSymbol{symbol: "RCN/BTC", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "XTZ/USD", granularity: 1000000, transform: MedianAt}, at: switchTime, }, 27: &SingleSymbol{symbol: "LINK/USD", granularity: 1000000, transform: MedianAt}, 28: &SingleSymbol{symbol: "ZRX/BNB", granularity: 1000000, transform: MedianAt}, 29: &SingleSymbol{symbol: "ZEC/USD", granularity: 1000000, transform: MedianAt}, 30: &TimedSwitch{ before: &SingleSymbol{symbol: "DASH/BNB", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "XAU/USD", granularity: 1000000, transform: MedianAt}, at: switchTime, }, 31: &SingleSymbol{symbol: "MATIC/USD", granularity: 1000000, transform: MedianAt}, 32: &SingleSymbol{symbol: "BAT/USD", granularity: 1000000, transform: MedianAt}, 33: &SingleSymbol{symbol: "ALGO/USD", granularity: 1000000, transform: MedianAt}, 34: &SingleSymbol{symbol: "ZRX/USD", granularity: 1000000, transform: MedianAt}, 35: &SingleSymbol{symbol: "COS/USD", granularity: 1000000, transform: MedianAt}, 36: &SingleSymbol{symbol: "BCH/USD", granularity: 1000000, transform: MedianAt}, 37: &SingleSymbol{symbol: "REP/USD", granularity: 1000000, transform: MedianAt}, 38: &SingleSymbol{symbol: "GNO/USD", granularity: 1000000, transform: MedianAt}, 39: &SingleSymbol{symbol: "DAI/USD", granularity: 1000000, transform: MedianAt}, 40: &SingleSymbol{symbol: "STEEM/BTC", granularity: 1000000, transform: MedianAt}, 41: &TimedSwitch{ before: &SingleSymbol{symbol: "LINK/USD", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "USPCE", granularity: 1000, transform: ManualEntry}, at: switchTime, }, 42: &TimedSwitch{ before: &SingleSymbol{symbol: "WAN/BTC", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "BTC/USD", granularity: 1000000, transform: MedianAtEOD}, at: switchTime, }, 43: &TimedSwitch{ before: &SingleSymbol{symbol: "GNT/ETH", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "TRB/ETH", granularity: 1000000, transform: MedianAt}, at: switchTime, }, 44: &TimedSwitch{ before: &SingleSymbol{symbol: "BTC/USD", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "BTC/USD", granularity: 1000000, transform: TimeWeightedAvg(1*time.Hour, NoDecay)}, at: switchTime, }, 45: &TimedSwitch{ before: &SingleSymbol{symbol: "BTC/USD", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "TRB/USD", granularity: 1000000, transform: MedianAtEOD}, at: switchTime, }, 46: &TimedSwitch{ before: &SingleSymbol{symbol: "ETH/USD", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "ETH/USD", granularity: 1000000, transform: TimeWeightedAvg(1*time.Hour, NoDecay)}, at: switchTime, }, 47: &TimedSwitch{ before: &SingleSymbol{symbol: "LTC/USD", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "BSV/USD", granularity: 1000000, transform: MedianAt}, at: switchTime, }, 48: &SingleSymbol{symbol: "MAKER/USD", granularity: 1000000, transform: MedianAt}, 49: &TimedSwitch{ before: &SingleSymbol{symbol: "EOS/USD", granularity: 1000000, transform: MedianAt}, after: &SingleSymbol{symbol: "BCH/USD", granularity: 1000000, transform: TimeWeightedAvg(24*time.Hour, NoDecay)}, at: switchTime, }, 50: &SingleSymbol{symbol: "TRB/USD", granularity: 1000000, transform: MedianAt}, 51: &SingleSymbol{symbol: "XMR/USD", granularity: 1000000, transform: MedianAt}, 52: &SingleSymbol{symbol: "XFT/USD", granularity: 1000000, transform: MedianAt}, 53: &SingleSymbol{symbol: "BTCDOMINANCE", granularity: 1000000, transform: MedianAt}, }
Functions ¶
func ExpDecay ¶
these weight functions map values of x between 0 (brand new) and 1 (old) to weights between 0 and 1 also returns the integral of the weight over the range [0,1] weights the oldest data (1) as being 1/3 as important (1/e)
func ManualEntry ¶
func MedianAtEOD ¶
Types ¶
type BalanceTracker ¶
type BalanceTracker struct { }
BalanceTracker concrete tracker type
func (*BalanceTracker) Exec ¶
func (b *BalanceTracker) Exec(ctx context.Context) error
Exec implementation for tracker
func (*BalanceTracker) String ¶
func (b *BalanceTracker) String() string
type ChainedPrice ¶
type ChainedPrice struct {
// contains filtered or unexported fields
}
ChainedPrice computes a pair that doesn't exist by using multiple symbols
type CurrentVariablesTracker ¶
type CurrentVariablesTracker struct { }
CurrentVariablesTracker concrete tracker type
func (*CurrentVariablesTracker) Exec ¶
func (b *CurrentVariablesTracker) Exec(ctx context.Context) error
Exec implementation for tracker
func (*CurrentVariablesTracker) String ¶
func (b *CurrentVariablesTracker) String() string
type DataSource ¶
type DisputeTracker ¶
type DisputeTracker struct { }
DisputeTracker struct
func (*DisputeTracker) Exec ¶
func (b *DisputeTracker) Exec(ctx context.Context) error
Exec - Places the Dispute Status in the database
func (*DisputeTracker) String ¶
func (b *DisputeTracker) String() string
type FetchRequest ¶
type FetchRequest struct {
// contains filtered or unexported fields
}
FetchRequest holds info for a request TODO: add mock fetch
type GasPriceModel ¶
type GasPriceModel struct { Fast float32 `json:"fast"` Fastest float32 `json:"fastest"` Average float32 `json:"average"` }
GasPriceModel is what ETHGasStation returns from queries. Not all fields are filled in
type GasTracker ¶
type GasTracker struct { }
GasTracker is the struct that maintains the latest gasprices. note the prices are actually stored in the DB
func (*GasTracker) Exec ¶
func (b *GasTracker) Exec(ctx context.Context) error
Exec queries EthGasStation for the current Gas Prices
func (*GasTracker) String ¶
func (b *GasTracker) String() string
type IndexProcessor ¶
a function to consolidate the recorded API values to a single value
func AmpleChained ¶
func AmpleChained(chainedPair string) IndexProcessor
compute the average ampl price over a 24 hour period using a chained price feed
func TimeWeightedAvg ¶
func VolumeWeightedAPIs ¶
func VolumeWeightedAPIs(processor IndexProcessor) IndexProcessor
type IndexTracker ¶
type IndexTracker struct { Name string Identifier string Symbols []string Source DataSource Args [][]string }
func (*IndexTracker) String ¶
func (i *IndexTracker) String() string
type JSONapi ¶
type JSONapi struct {
Request *FetchRequest
}
type NewCurrentVariablesTracker ¶
type NewCurrentVariablesTracker struct { }
CurrentVariablesTracker concrete tracker type
func (*NewCurrentVariablesTracker) Exec ¶
func (b *NewCurrentVariablesTracker) Exec(ctx context.Context) error
Exec implementation for tracker
func (*NewCurrentVariablesTracker) String ¶
func (b *NewCurrentVariablesTracker) String() string
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner will execute all configured trackers
type SingleSymbol ¶
type SingleSymbol struct {
// contains filtered or unexported fields
}
func (SingleSymbol) Require ¶
func (s SingleSymbol) Require(at time.Time) map[string]IndexProcessor
type TimeOutTracker ¶
type TimeOutTracker struct { }
TimeOutTracker struct
func (*TimeOutTracker) Exec ¶
func (b *TimeOutTracker) Exec(ctx context.Context) error
Exec - Places the Dispute Status in the database
func (*TimeOutTracker) String ¶
func (b *TimeOutTracker) String() string
type TimedSwitch ¶
type TimedSwitch struct {
// contains filtered or unexported fields
}
func (*TimedSwitch) Require ¶
func (t *TimedSwitch) Require(at time.Time) map[string]IndexProcessor
type Tracker ¶
type Tracker interface { //Exec will be run as a go function. The given context will be a KeyValue context containing //the client to use for tracking ops. Exec(ctx context.Context) error String() string }
Tracker is the primary interface for the various tracking options
func BuildIndexTrackers ¶
BuildIndexTrackers creates and initializes a new tracker instance
type TributeTracker ¶
type TributeTracker struct { }
func (*TributeTracker) String ¶
func (b *TributeTracker) String() string
type ValueCheckResult ¶
type ValueCheckResult struct {
High, Low float64
WithinRange bool
Datapoints []float64
Times []time.Time
}
ValueCheckResult holds the details regarding the disputed value
func CheckValueAtTime ¶
CheckValueAtTime queries for the details regarding the disputed value
type ValueGenerator ¶
type ValueGenerator interface { //PSRs report what they require to produce a value with this Require(time.Time) map[string]IndexProcessor //return the best estimate of a value at a given time, and the confidence // if confidence == 0, the value has no meaning ValueAt(map[string]apiOracle.PriceInfo, time.Time) float64 }