-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
94 lines (79 loc) · 2.25 KB
/
main.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
package main
import (
"fmt"
"os"
"yam-api/source"
"yam-api/source/config"
"yam-api/source/routes"
"yam-api/source/utils/log"
"yam-api/source/utils/mongodb"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/robfig/cron"
)
func run() error {
fmt.Println("Starting yam server...")
conf, confError := config.Load("./config/prod.yaml")
if confError != nil {
fmt.Print(confError)
}
geth, gethError := ethclient.Dial(conf.Eth.Url.Http)
if gethError != nil {
fmt.Print(gethError)
}
mongodb.Connect()
// /// @notice Asset Index scheduler
// storeAssetIndexCron := cron.New()
// storeAssetIndexCron.AddFunc("@every 5m", func() {
// values := routes.FetchAssetIndex("apr21", "USTONKS-0421")
// mongodb.InsertAssetIndex(values)
// values = routes.FetchAssetIndex("jun21", "USTONKS-0621")
// mongodb.InsertAssetIndex(values)
// values = routes.FetchAssetIndex("sep21", "USTONKS-0921")
// mongodb.InsertAssetIndex(values)
// })
// storeAssetIndexCron.Start()
// // TODO: Merge with Asset Index scheduler
// /// @notice Punk Index scheduler
// calculatePunkIndexCron := cron.New()
// calculatePunkIndexCron.AddFunc("@every 5m", func() {
// values := routes.CalculatePunkIndex(geth)
// mongodb.InsertPunkIndex(values)
// })
// calculatePunkIndexCron.Start()
/// @notice YAM APR scheduler
getAprYamCron := cron.New()
getAprYamCron.AddFunc("@every 5m", func() {
val := routes.CalculateAprYam(geth)
routes.StoreAprYam(val)
})
getAprYamCron.Start()
/// @notice Degenerative APR scheduler
/*getAprDegenerativeCron := cron.New()
getAprDegenerativeCron.AddFunc("@every 5m", func() {
val := routes.CalculateAprDegenerative(geth)
routes.StoreAprDegenerative(val)
})
getAprDegenerativeCron.Start()*/
/// @notice TVL scheduler
getTvlCron := cron.New()
getTvlCron.AddFunc("@every 5m", func() {
val := routes.CalculateTvl(geth)
routes.StoreTvl(val)
})
getTvlCron.Start()
/// @notice Treasury scheduler
getTreasuryCron := cron.New()
getTreasuryCron.AddFunc("@every 5m", func() {
val := routes.GetTreasury(geth)
routes.StoreTreasury(val)
})
getTreasuryCron.Start()
routes := routes.Initialize(conf, geth)
return source.Serve(conf, routes)
}
func main() {
if err := run(); err != nil {
log.Error("error :", err)
os.Exit(1)
}
}