4
4
"context"
5
5
"encoding/hex"
6
6
"math/big"
7
+ "strconv"
7
8
"strings"
8
9
"time"
9
10
@@ -16,16 +17,17 @@ import (
16
17
)
17
18
18
19
type VelarLiquidityScraper struct {
19
- logger * logrus.Entry
20
- api * stackshelper.StacksClient
21
- velarClient * velarhelper.VelarClient
22
- poolChannel chan dia.Pool
23
- doneChannel chan bool
24
- blockchain string
25
- exchangeName string
26
- relDB * models.RelDB
27
- datastore * models.DB
28
- handlerType string
20
+ logger * logrus.Entry
21
+ api * stackshelper.StacksClient
22
+ velarClient * velarhelper.VelarClient
23
+ poolChannel chan dia.Pool
24
+ doneChannel chan bool
25
+ blockchain string
26
+ exchangeName string
27
+ sleepTimeMilliseconds int
28
+ relDB * models.RelDB
29
+ datastore * models.DB
30
+ handlerType string
29
31
}
30
32
31
33
// NewVelarLiquidityScraper returns a new VelarLiquidityScraper initialized with default values.
@@ -54,16 +56,21 @@ func NewVelarLiquidityScraper(exchange dia.Exchange, relDB *models.RelDB, datast
54
56
isDebug ,
55
57
)
56
58
59
+ sleepTime , err := strconv .Atoi (utils .Getenv ("SLEEP_TIME_MILLISECONDS" , "1000" ))
60
+ if err != nil {
61
+ log .Error ("parse SLEEP_TIME_MILLISECONDS: " , err )
62
+ }
57
63
s := & VelarLiquidityScraper {
58
- poolChannel : make (chan dia.Pool ),
59
- doneChannel : make (chan bool ),
60
- exchangeName : exchange .Name ,
61
- blockchain : exchange .BlockChain .Name ,
62
- api : stacksClient ,
63
- velarClient : velarClient ,
64
- relDB : relDB ,
65
- datastore : datastore ,
66
- handlerType : "liquidity" ,
64
+ poolChannel : make (chan dia.Pool ),
65
+ doneChannel : make (chan bool ),
66
+ exchangeName : exchange .Name ,
67
+ blockchain : exchange .BlockChain .Name ,
68
+ sleepTimeMilliseconds : sleepTime ,
69
+ api : stacksClient ,
70
+ velarClient : velarClient ,
71
+ relDB : relDB ,
72
+ datastore : datastore ,
73
+ handlerType : "liquidity" ,
67
74
}
68
75
69
76
s .logger = logrus .
@@ -85,6 +92,8 @@ func (s *VelarLiquidityScraper) fetchPools() {
85
92
}
86
93
87
94
for _ , t := range tickers {
95
+ time .Sleep (time .Duration (s .sleepTimeMilliseconds ) * time .Millisecond )
96
+
88
97
balances , err := s .fetchPoolBalances (t .PoolID )
89
98
if err != nil {
90
99
s .logger .WithError (err ).Error ("failed to fetch velar pool balances" )
0 commit comments