-
Notifications
You must be signed in to change notification settings - Fork 7
/
worker.go
42 lines (34 loc) · 801 Bytes
/
worker.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
package main
import (
"context"
"fmt"
"github.com/ethereum/go-ethereum/core/types"
)
func (arb *arbBot) blockNotifications() error {
headers := make(chan *types.Header)
sub, err := arb.ethClient.SubscribeNewHead(context.Background(), headers)
if err != nil {
return err
}
go func() {
for {
select {
case err := <-sub.Err():
fmt.Println(err)
case <-headers:
// Update all marjets reserves.
for _, market := range arb.markets {
err := market.UpdateReserves(arb.bundleExecutor)
if err != nil {
fmt.Println("error updating market reserve:", err)
}
}
// fmt.Println("Updated reserves")
// Find arb opportunites
arb.cma.EvaluateMarkets(arb.markets, arb.tokens)
// fmt.Println("Evaluated markets")
}
}
}()
return nil
}