-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
46 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
import os
import pandas as pd
from config import BLACK_LIST, NUMBER_OF_JAILS_FOR_KICKOFF, DELEGATOR_ADDRESS
from src.calculations import calculate_endorsement
from src.get_data import get_validators
from src.tx import get_unsigned_delegation_txs
from src.utils import clean_up_validators_set
def get_result_table() -> pd.DataFrame:
"""
1. Gets validators info
2. Sorts validators by staked tokens descending and ranks them in validator_rank column
3. Drops validators by clean_up_validators_set definition
4. Returns dataframe with calculated endorsement
:return:
"""
validators_df = get_validators()
validators_df['validator_rank'] = validators_df['staked'].rank(ascending=False)
validators_df = clean_up_validators_set(validators_df, NUMBER_OF_JAILS_FOR_KICKOFF, BLACK_LIST)
return calculate_endorsement(validators_df)
def processor() -> None:
"""
Processes delegation strategy.
1. Gets result table
2. Saves results to ./delegation_strategy.csv
3. Sort by total ascending for transactions generated from less to high values
5. Removes ./txs folder if exists
6. Creates ./txs folder
7. Save unsigned .json transactions in the ./txs folder
"""
validators_df = get_result_table()
validators_df.to_csv('./delegation_strategy.csv', index=False)
validators_df = validators_df.sort_values(by=['total']).reset_index(drop=True)
try:
os.mkdir('./txs')
except OSError:
pass
get_unsigned_delegation_txs(DELEGATOR_ADDRESS, validators_df)
if __name__ == '__main__':
processor()