-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
67 lines (56 loc) · 1.41 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
package main
import (
"log"
"os"
"strconv"
"time"
"uniswapv3simulator/onlinestrategy"
"uniswapv3simulator/swaputils"
)
func parseArgs(args []string) (filePath string, feeTier float64, tickSpacing uint32, concentrationController uint32, err error) {
filePath = os.Args[1]
feeTier, err = strconv.ParseFloat(os.Args[2], 64)
if err != nil {
return
}
tickSpacing64, err := strconv.ParseUint(os.Args[3], 0, 32)
if err != nil {
return
}
tickSpacing = uint32(tickSpacing64)
concentrationController64, err := strconv.ParseUint(os.Args[4], 0, 32)
if err != nil {
return
}
concentrationController = uint32(concentrationController64)
return
}
func main() {
filePath, feeTier, tickSpacing, concentrationController, err := parseArgs(os.Args)
if err != nil {
log.Fatal(err)
}
swaps, err := swaputils.ReadSwapsFile(filePath)
if err != nil {
log.Fatal(err)
}
if len(swaps) <= 0 {
log.Fatal("No swaps provided")
}
strategy := onlinestrategy.OnlineStrategy{
UninvestedToken0: 0.5,
UninvestedToken1: 0.5 * swaps[0].Price,
ActiveRange: onlinestrategy.Range{TickSpacing: tickSpacing},
LastSwap: swaps[0],
Strategy: &onlinestrategy.StaticStrategy{
ConcentrationController: concentrationController,
Duration: time.Hour,
LastDeposit: time.Unix(0, 0),
},
FeeTier: feeTier,
}
err = strategy.PrintResults(swaps)
if err != nil {
log.Fatal(err)
}
}