-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
51 lines (39 loc) · 1.56 KB
/
main.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
import argparse
import json
import os
from datetime import datetime
from dotenv import load_dotenv
from fee_allocator.fee_allocator import FeeAllocator
from fee_allocator.utils import get_last_thursday_odd_week
parser = argparse.ArgumentParser()
parser.add_argument("--ts_now", help="Current timestamp", type=int, required=False)
parser.add_argument(
"--ts_in_the_past", help="Timestamp in the past", type=int, required=False
)
parser.add_argument(
"--output_file_name", help="Output file name", type=str, required=False
)
parser.add_argument("--fees_file_name", help="Fees file name", type=str, required=False)
ROOT = os.path.dirname(__file__)
now = datetime.utcnow()
DELTA = 6000
TS_NOW = int(now.timestamp()) - DELTA
TS_2_WEEKS_AGO = int(get_last_thursday_odd_week().timestamp())
def main() -> None:
load_dotenv()
ts_now = parser.parse_args().ts_now or TS_NOW
ts_in_the_past = parser.parse_args().ts_in_the_past or TS_2_WEEKS_AGO
print(
f"\n\n\n------\nRunning from timestamps {ts_in_the_past} to {ts_now}\n------\n\n\n"
)
fees_file_name = parser.parse_args().fees_file_name or "current_fees_collected.json"
input_fees_path = f"fee_allocator/fees_collected/{fees_file_name}"
with open(input_fees_path) as f:
input_fees = json.load(f)
fee_allocator = FeeAllocator(input_fees, (ts_in_the_past, ts_now))
fee_allocator.redistribute_fees()
fee_allocator.generate_incentives_csv()
file_name = fee_allocator.generate_bribe_csv()
fee_allocator.generate_bribe_payload(file_name)
if __name__ == "__main__":
main()