-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
77 lines (62 loc) · 2.77 KB
/
settings.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
import json
import os
from logging import Formatter, StreamHandler, getLogger
from logging.handlers import TimedRotatingFileHandler
from decouple import config
from web3 import HTTPProvider, Web3
from web3.middleware import geth_poa_middleware
# MONITOR
# ------------------------------------------------------------------------------
MONITOR_SLEEP_BETWEEN_CALL = config("MONITOR_SLEEP_BETWEEN_CALL", default=2.0, cast=float)
# WEB3
# ------------------------------------------------------------------------------
WEB3_MAINNET = Web3(HTTPProvider(config("WEB3_PROVIDER_HTTPS_MAINNET"), request_kwargs={"timeout": 180}))
WEB3_GOERLI = Web3(HTTPProvider(config("WEB3_PROVIDER_HTTPS_GOERLI"), request_kwargs={"timeout": 180}))
WEB3_GOERLI.middleware_onion.inject(geth_poa_middleware, layer=0)
# Repo location on system
REPO = config("SHERLOCK_CORE_PATH")
SHERLOCK_SHER_ADDRESS = config("SHERLOCK_SHER_ADDRESS")
with open(os.path.join(REPO, "artifacts", "contracts", "SherToken.sol", "SherToken.json")) as json_data:
SHERLOCK_SHER_ABI = json.load(json_data)["abi"]
SHERLOCK_DIST_MANAGER_ADDRESS = config("SHERLOCK_DIST_MANAGER_ADDRESS")
SHERLOCK_PROTOCOL_MANAGER_ADDRESS = config("SHERLOCK_PROTOCOL_MANAGER_ADDRESS")
with open(
os.path.join(
REPO, "artifacts", "contracts", "managers", "SherlockProtocolManager.sol", "SherlockProtocolManager.json"
)
) as json_data:
SHERLOCK_PROTOCOL_MANAGER_ABI = json.load(json_data)["abi"]
# DISCORD
# ------------------------------------------------------------------------------
DISCORD_BOT_TOKEN = config("DISCORD_BOT_TOKEN")
# TELEGRAM
# ------------------------------------------------------------------------------
TELEGRAM_BOT_TOKEN = config("TELEGRAM_BOT_TOKEN")
TELEGRAM_CHANNEL = config("TELEGRAM_CHANNEL", cast=int)
# LOGGING
# ------------------------------------------------------------------------------
logger = getLogger()
logger.setLevel("DEBUG")
# Create custom formatter
verbose_formatter = Formatter(
(
"[%(asctime)s] %(levelname)-7s "
"%(module)s %(name)s "
"{%(filename)s:%(lineno)d} %(process)d %(thread)d - %(message)s"
)
)
# Redirect INFO+ logs to console and output.log
file_handler = TimedRotatingFileHandler(filename="output.log", when="midnight", utc=True)
file_handler.setLevel("INFO")
file_handler.setFormatter(verbose_formatter)
console_handler = StreamHandler()
console_handler.setLevel("INFO")
console_handler.setFormatter(verbose_formatter)
# Redirect DEBUG+ logs to separate file
debug_file_handler = TimedRotatingFileHandler(filename="debug_output.log", when="midnight", utc=True)
debug_file_handler.setLevel("DEBUG")
debug_file_handler.setFormatter(verbose_formatter)
logger.handlers = []
logger.addHandler(console_handler)
logger.addHandler(file_handler)
logger.addHandler(debug_file_handler)