-
Notifications
You must be signed in to change notification settings - Fork 791
/
snapshots.go
39 lines (32 loc) · 924 Bytes
/
snapshots.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package types
import (
"gopkg.in/yaml.v2"
)
// OracleExchangeRates - array of OracleExchangeRate
type PriceSnapshots []PriceSnapshot
type (
PriceSnapshotItems []PriceSnapshotItem
OracleTwaps []OracleTwap
)
// String implements fmt.Stringer interface
func (snapshots PriceSnapshots) String() string {
out, _ := yaml.Marshal(snapshots)
return string(out)
}
// String implements fmt.Stringer interface
func (items PriceSnapshotItems) String() string {
out, _ := yaml.Marshal(items)
return string(out)
}
func NewPriceSnapshotItem(denom string, exchangeRate OracleExchangeRate) PriceSnapshotItem {
return PriceSnapshotItem{
Denom: denom,
OracleExchangeRate: exchangeRate,
}
}
func NewPriceSnapshot(priceSnapshotItems PriceSnapshotItems, snapshotTimestamp int64) PriceSnapshot {
return PriceSnapshot{
SnapshotTimestamp: snapshotTimestamp,
PriceSnapshotItems: priceSnapshotItems,
}
}