-
Notifications
You must be signed in to change notification settings - Fork 0
/
observation.go
98 lines (75 loc) · 2.31 KB
/
observation.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package v3
import (
"math/big"
"github.com/smartcontractkit/libocr/commontypes"
"github.com/smartcontractkit/chainlink-data-streams/mercury"
)
type PAO interface {
mercury.PAO
GetBid() (*big.Int, bool)
GetAsk() (*big.Int, bool)
GetMaxFinalizedTimestamp() (int64, bool)
GetLinkFee() (*big.Int, bool)
GetNativeFee() (*big.Int, bool)
}
var _ PAO = parsedAttributedObservation{}
type parsedAttributedObservation struct {
Timestamp uint32
Observer commontypes.OracleID
BenchmarkPrice *big.Int
Bid *big.Int
Ask *big.Int
PricesValid bool
MaxFinalizedTimestamp int64
MaxFinalizedTimestampValid bool
LinkFee *big.Int
LinkFeeValid bool
NativeFee *big.Int
NativeFeeValid bool
}
func NewParsedAttributedObservation(ts uint32, observer commontypes.OracleID,
bp *big.Int, bid *big.Int, ask *big.Int, pricesValid bool, mfts int64,
mftsValid bool, linkFee *big.Int, linkFeeValid bool, nativeFee *big.Int, nativeFeeValid bool) PAO {
return parsedAttributedObservation{
Timestamp: ts,
Observer: observer,
BenchmarkPrice: bp,
Bid: bid,
Ask: ask,
PricesValid: pricesValid,
MaxFinalizedTimestamp: mfts,
MaxFinalizedTimestampValid: mftsValid,
LinkFee: linkFee,
LinkFeeValid: linkFeeValid,
NativeFee: nativeFee,
NativeFeeValid: nativeFeeValid,
}
}
func (pao parsedAttributedObservation) GetTimestamp() uint32 {
return pao.Timestamp
}
func (pao parsedAttributedObservation) GetObserver() commontypes.OracleID {
return pao.Observer
}
func (pao parsedAttributedObservation) GetBenchmarkPrice() (*big.Int, bool) {
return pao.BenchmarkPrice, pao.PricesValid
}
func (pao parsedAttributedObservation) GetBid() (*big.Int, bool) {
return pao.Bid, pao.PricesValid
}
func (pao parsedAttributedObservation) GetAsk() (*big.Int, bool) {
return pao.Ask, pao.PricesValid
}
func (pao parsedAttributedObservation) GetMaxFinalizedTimestamp() (int64, bool) {
if pao.MaxFinalizedTimestamp < -1 {
// values below -1 are not valid
return 0, false
}
return pao.MaxFinalizedTimestamp, pao.MaxFinalizedTimestampValid
}
func (pao parsedAttributedObservation) GetLinkFee() (*big.Int, bool) {
return pao.LinkFee, pao.LinkFeeValid
}
func (pao parsedAttributedObservation) GetNativeFee() (*big.Int, bool) {
return pao.NativeFee, pao.NativeFeeValid
}