forked from pegnet/pegnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfixedusd.go
44 lines (34 loc) · 946 Bytes
/
fixedusd.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
package polling
import (
"time"
"github.com/zpatrick/go-config"
)
// FixedUSDDataSource is the datasource for USD.
// USD is always 1 USD = 1USD.
type FixedUSDDataSource struct {
config *config.Config
}
func NewFixedUSDDataSource(config *config.Config) (*FixedUSDDataSource, error) {
s := new(FixedUSDDataSource)
s.config = config
return s, nil
}
func (d *FixedUSDDataSource) Name() string {
return "FixedUSD"
}
func (d *FixedUSDDataSource) Url() string {
return "na"
}
func (d *FixedUSDDataSource) SupportedPegs() []string {
return []string{"USD"}
}
func (d *FixedUSDDataSource) FetchPegPrices() (peg PegAssets, err error) {
peg = make(map[string]PegItem)
timestamp := time.Now()
// The USD price is always 1
peg["USD"] = PegItem{Value: 1, WhenUnix: timestamp.Unix(), When: timestamp}
return
}
func (d *FixedUSDDataSource) FetchPegPrice(peg string) (i PegItem, err error) {
return FetchPegPrice(peg, d.FetchPegPrices)
}