/
infrastructure.go
71 lines (58 loc) · 1.65 KB
/
infrastructure.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
package main
import (
"time"
"github.com/anonutopia/gowaves"
)
type InfrastructureMonitor struct{}
func (im *InfrastructureMonitor) start() {
go func() {
for {
im.checkSponsoredFees()
im.checkNodeAHRK()
im.checkNodeAINTAHRK()
// im.checkAINTOrders()
time.Sleep(time.Minute * 15)
}
}()
}
func (im *InfrastructureMonitor) checkSponsoredFees() {
gowaves.WNC.Host = WavesNodeURL
abr, err := gowaves.WNC.AddressesBalance(FeeAddress)
if err == nil && abr.Balance < int(SatInBTC) {
logTelegram("Fee address WAVES balance is too small.")
} else if err != nil {
logTelegram("Error checking fee balance.")
}
}
func (im *InfrastructureMonitor) checkNodeAHRK() {
gowaves.WNC.Host = WavesNodeURL
abr, err := gowaves.WNC.AssetsBalance(AHRKAddress, AHRKId)
if err == nil && int(abr.Balance) < 20000*int(AHRKDec) {
logTelegram("AHRK balance on AHRK node is too small.")
} else if err != nil {
logTelegram("Error checking AHRK node balance.")
}
}
func (im *InfrastructureMonitor) checkNodeAINTAHRK() {
gowaves.WNC.Host = WavesNodeURL
abr, err := gowaves.WNC.AssetsBalance(AINTAddress, AHRKId)
if err == nil && int(abr.Balance) < 1000*int(AHRKDec) {
logTelegram("AHRK balance on AINT node is too small.")
} else if err != nil {
logTelegram("Error checking AINT node balance.")
}
}
func (im *InfrastructureMonitor) checkAINTOrders() {
opr, err := gowaves.WMC.OrderbookPair(AINTId, "WAVES", 10)
if err == nil {
if len(opr.Asks) < 2 {
logTelegram("There are not enough AINT orders on DEX.")
}
} else {
logTelegram("Error checking AINT orders.")
}
}
func initInfrastructureMonitor() {
im := &InfrastructureMonitor{}
im.start()
}