-
Notifications
You must be signed in to change notification settings - Fork 51
/
keeper.py
182 lines (165 loc) · 5.55 KB
/
keeper.py
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
from brownie import Wei
from helpers.network import network_manager
from helpers.time_utils import days, hours, minutes
# Setts that are not tendable will automatically be skipped
# Lines can be commented out here to skip Setts
setts_to_skip = {
"eth": {
"harvest": [
"native.badger",
"native.renCrv",
"native.convexRenCrv",
"native.sbtcCrv",
"native.convexSbtcCrv",
"native.tbtcCrv",
"native.convexTbtcCrv",
"native.uniBadgerWbtc",
"harvest.renCrv",
"native.sushiWbtcEth",
"native.sushiBadgerWbtc",
"native.digg",
"native.uniDiggWbtc",
"native.sushiDiggWbtc",
"yearn.wbtc",
"experimental.sushiIBbtcWbtc",
"experimental.digg",
"native.hbtcCrv",
"native.pbtcCrv",
"native.obtcCrv",
"native.bbtcCrv",
"native.tricrypto",
"native.cvxCrv",
"native.cvx",
# "native.tricrypto2",
],
"tend": [
"native.badger",
# "native.renCrv",
"native.convexRenCrv",
# "native.sbtcCrv",
"native.convexSbtcCrv",
# "native.tbtcCrv",
"native.convexTbtcCrv",
"native.uniBadgerWbtc",
# "harvest.renCrv",
# "native.sushiWbtcEth",
# "native.sushiBadgerWbtc",
"native.digg",
"native.uniDiggWbtc",
# "native.sushiDiggWbtc",
"yearn.wbtc",
# "experimental.sushiIBbtcWbtc",
"experimental.digg",
# "native.hbtcCrv",
# "native.pbtcCrv",
# "native.obtcCrv",
# "native.bbtcCrv",
# "native.tricrypto",
"native.cvxCrv",
"native.cvx",
# "native.tricrypto2",
],
"earn": [
"native.badger",
"native.renCrv",
"native.convexRenCrv",
"native.sbtcCrv",
"native.convexSbtcCrv",
"native.tbtcCrv",
"native.convexTbtcCrv",
"native.uniBadgerWbtc",
"harvest.renCrv",
"native.sushiWbtcEth",
"native.sushiBadgerWbtc",
"native.digg",
"native.uniDiggWbtc",
"native.sushiDiggWbtc",
"yearn.wbtc",
"experimental.sushiIBbtcWbtc",
"experimental.digg",
"native.hbtcCrv",
"native.pbtcCrv",
"native.obtcCrv",
"native.bbtcCrv",
"native.tricrypto",
"native.cvxCrv",
"native.cvx",
# "native.tricrypto2",
],
},
"bsc": {
"harvest": ["native.pancakeBnbBtcB", "native.pancakeBnbBtcb", "native.test"],
"tend": [],
"earn": [],
},
}
run_intervals = {
"eth": {
"harvest": days(1),
"tend": hours(12),
"earn": minutes(60),
},
"bsc": {
"harvest": minutes(10),
"tend": minutes(15),
"earn": minutes(10),
},
}
earn_default_percentage_threshold = 0.01
btc_threshold = Wei("2 ether")
earn_threshold_value_override = {
"eth": {
"native.renCrv": btc_threshold,
"native.sbtcCrv": btc_threshold,
"native.tbtcCrv": btc_threshold,
"harvest.renCrv": btc_threshold,
"native.sushiWbtcEth": Wei("0.00000202 ether"),
"native.hbtcCrv": btc_threshold,
"native.pbtcCrv": btc_threshold,
"native.obtcCrv": btc_threshold,
"native.bbtcCrv": btc_threshold,
},
"bsc": {"native.pancakeBnbBtcb": Wei("0.0001 ether")},
}
class KeeperConfig:
def __init__(self):
self.debug = False
self.setts_to_skip = {}
self.run_intervals = run_intervals
self.earn_default_percentage_threshold = earn_default_percentage_threshold
self.earn_threshold_value_override = earn_threshold_value_override
def has_earn_threshold_override_active_chain(self, key):
chain = network_manager.get_active_network()
override = self.get_earn_threshold_override(chain, key)
if override == 0:
return False
else:
return True
def get_earn_threshold_override(self, chain, key):
if key in self.earn_threshold_value_override[chain].keys():
return self.earn_threshold_value_override[chain][key]
else:
return 0
def get_active_chain_earn_threshold_override(self, key):
chain = network_manager.get_active_network()
return self.get_earn_threshold_override(chain, key)
def get_run_interval(self, chain, action):
if chain in self.setts_to_skip.keys():
return self.run_intervals[chain][action]
else:
raise Exception("Run interval not found for {}".format(chain))
def get_skipped_setts(self, chain, action):
if chain in self.setts_to_skip.keys():
return self.setts_to_skip[chain][action]
else:
raise Exception("Setts not found for {}".format(chain))
def add_skipped_setts(self, setts_to_skip):
self.setts_to_skip = setts_to_skip
def get_active_chain_skipped_setts(self, action):
chain = network_manager.get_active_network()
return self.get_skipped_setts(chain, action)
def get_active_chain_run_interval(self, action):
chain = network_manager.get_active_network()
return self.get_run_interval(chain, action)
keeper_config = KeeperConfig()
keeper_config.add_skipped_setts(setts_to_skip)