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 PrepareEthTransaction(ctx context.Context) (*bind.TransactOpts, error)
- 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 TallyVotesTracker
- type TimeOutTracker
- type TimedSwitch
- type TokenTracker
- type Tracker
- type ValueCheckResult
- type ValueGenerator
Constants ¶
const GWEI = 1000000000
GWEI constant is the multiplier from Wei
Variables ¶
var PSRs = map[int]ValueGenerator{ 1: &SingleSymbol{symbol: "ZAP/USD", granularity: 1000000, transform: MedianAt}, 2: &SingleSymbol{symbol: "BTC/USD", granularity: 1000000, transform: MedianAt}, 3: &SingleSymbol{symbol: "ETH/USD", granularity: 1000000, transform: MedianAt}, 4: &SingleSymbol{symbol: "LTC/USD", granularity: 1000000, transform: MedianAt}, 5: &SingleSymbol{symbol: "XRP/USD", granularity: 1000000, transform: MedianAt}, 6: &SingleSymbol{symbol: "BNB/USD", granularity: 1000000, transform: MedianAt}, 7: &SingleSymbol{symbol: "DOGE/USD", granularity: 1000000, transform: MedianAt}, 8: &SingleSymbol{symbol: "BCH/USD", granularity: 1000000, transform: MedianAt}, 9: &SingleSymbol{symbol: "BSV/USD", granularity: 1000000, transform: MedianAt}, 10: &SingleSymbol{symbol: "EOS/USD", granularity: 1000000, transform: MedianAt}, 11: &SingleSymbol{symbol: "ETC/USD", granularity: 1000000, transform: MedianAt}, 12: &SingleSymbol{symbol: "ADA/USD", granularity: 1000000, transform: MedianAt}, 13: &SingleSymbol{symbol: "DOT/USD", granularity: 1000000, transform: MedianAt}, 14: &SingleSymbol{symbol: "UNI/USD", granularity: 1000000, transform: MedianAt}, 15: &SingleSymbol{symbol: "LINK/USD", granularity: 1000000, transform: MedianAt}, 16: &SingleSymbol{symbol: "XCD/USD", granularity: 1000000, transform: MedianAt}, 17: &SingleSymbol{symbol: "TTD/USD", granularity: 1000000, transform: MedianAt}, 18: &SingleSymbol{symbol: "JMD/USD", granularity: 1000000, transform: MedianAt}, 19: &SingleSymbol{symbol: "BBD/USD", granularity: 1000000, transform: MedianAt}, 20: &SingleSymbol{symbol: "KYD/USD", granularity: 1000000, transform: MedianAt}, 21: &SingleSymbol{symbol: "BSD/USD", granularity: 1000000, transform: MedianAt}, 22: &SingleSymbol{symbol: "BZD/USD", granularity: 1000000, transform: MedianAt}, 23: &SingleSymbol{symbol: "HTG/USD", granularity: 1000000, transform: MedianAt}, 24: &SingleSymbol{symbol: "SRD/USD", granularity: 1000000, transform: MedianAt}, 25: &SingleSymbol{symbol: "BMD/USD", granularity: 1000000, transform: MedianAt}, 26: &SingleSymbol{symbol: "AUD/USD", granularity: 1000000, transform: MedianAt}, 27: &SingleSymbol{symbol: "GBP/USD", granularity: 1000000, transform: MedianAt}, 28: &SingleSymbol{symbol: "CAD/USD", granularity: 1000000, transform: MedianAt}, 29: &SingleSymbol{symbol: "DKK/USD", granularity: 1000000, transform: MedianAt}, 30: &SingleSymbol{symbol: "EUR/USD", granularity: 1000000, transform: MedianAt}, 31: &SingleSymbol{symbol: "HKD/USD", granularity: 1000000, transform: MedianAt}, 32: &SingleSymbol{symbol: "JPY/USD", granularity: 1000000, transform: MedianAt}, 33: &SingleSymbol{symbol: "NZD/USD", granularity: 1000000, transform: MedianAt}, 34: &SingleSymbol{symbol: "NOK/USD", granularity: 1000000, transform: MedianAt}, 35: &SingleSymbol{symbol: "ZAR/USD", granularity: 1000000, transform: MedianAt}, 36: &SingleSymbol{symbol: "SEK/USD", granularity: 1000000, transform: MedianAt}, 37: &SingleSymbol{symbol: "CHF/USD", granularity: 1000000, transform: MedianAt}, 38: &SingleSymbol{symbol: "TRY/USD", granularity: 1000000, transform: MedianAt}, 39: &SingleSymbol{symbol: "AED/USD", granularity: 1000000, transform: MedianAt}, 40: &SingleSymbol{symbol: "CNY/USD", granularity: 1000000, transform: MedianAt}, 41: &SingleSymbol{symbol: "THB/USD", granularity: 1000000, transform: MedianAt}, 42: &SingleSymbol{symbol: "INR/USD", granularity: 1000000, transform: MedianAt}, 43: &SingleSymbol{symbol: "SGD/USD", granularity: 1000000, transform: MedianAt}, 44: &SingleSymbol{symbol: "RUB/USD", granularity: 1000000, transform: MedianAt}, 45: &SingleSymbol{symbol: "KRW/USD", 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 ¶
func PrepareEthTransaction ¶
func PrepareEthTransaction(ctx context.Context) (*bind.TransactOpts, error)
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
Returns the BalanceTracker name
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
Returns the CurrentVariablesTracker name
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 TallyVotesTracker ¶
type TallyVotesTracker struct {
// contains filtered or unexported fields
}
func (*TallyVotesTracker) String ¶
func (b *TallyVotesTracker) String() string
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 TokenTracker ¶
type TokenTracker struct { }
func (*TokenTracker) String ¶
func (b *TokenTracker) String() string
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 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 }