-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
132 lines (103 loc) · 4.91 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
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
#!/usr/bin/env python3.10
from config import *
row_data = {}
etherfi_headers = {
'authority': 'app.ether.fi',
'accept': '*/*',
'accept-language': 'en-US,en;q=0.9',
'origin': 'https://app.ether.fi',
'referer': 'https://app.ether.fi/portfolio',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
}
async def sleep(sleep_from: int, sleep_to: int):
delay = random.randint(sleep_from, sleep_to)
logger.info(f"💤 Sleep {delay} s.")
for _ in range(delay):
await asyncio.sleep(1)
async def get_proxy(wallet):
if 'proxy' in row_data[wallet]:
if len(row_data[wallet]['proxy']) > 0:
return f"http://{row_data[wallet]['proxy']}"
else:
return None
else:
return None
async def get_info(session, wallet, retry = 0):
proxy = await get_proxy(wallet)
max_retry = 3
try:
get_etherfi_url = f'https://app.ether.fi/api/portfolio/v3/{wallet}'
async with session.get(get_etherfi_url, headers=etherfi_headers, ssl=False, proxy=proxy, timeout=10) as resp:
resp_json = await resp.json(content_type=None)
if ('s3Points' in resp_json):
loyaltyPoints = resp_json['s3Points']
if ('totalEigenlayerPoints' in resp_json):
eigenlayerPoints = resp_json['totalEigenlayerPoints']
row_data[wallet]['etherfi']['loyaltyPoints'] = loyaltyPoints
row_data[wallet]['etherfi']['eigenlayerPoints'] = eigenlayerPoints
dailyStreak = resp_json['dailyStreak']
row_data[wallet]['etherfi']['dailyCollector'].update(dailyStreak)
except Exception as error:
logger.error(f'{wallet} | error : {error}')
retry += 1
if retry < max_retry:
logger.warning(f'{wallet} : retry {retry}/{max_retry}')
time_sleep = 3
await asyncio.sleep(time_sleep)
return await get_info(session, wallet, retry)
else:
raise(f'{wallet} | error : {error}')
async def process_daily_collector(session, wallet):
try:
proxy = await get_proxy(wallet)
process_etherfi_url = f'https://app.ether.fi/api/dailyStreak/updateStreak'
payload = {'account': f'{wallet}'}
async with session.post(process_etherfi_url, data=json.dumps(payload), headers = etherfi_headers, ssl=False, proxy=proxy, timeout=10) as resp:
resp_json = await resp.json(content_type=None)
if resp_json['message'] == 'Streak updated successfully':
logger.success(f'{wallet} : {resp_json["message"]}')
else:
logger.error(f'{wallet} : {resp_json["message"]}')
except Exception as error:
logger.error(f'{wallet} | error : {error}')
async def main(wallet):
async with aiohttp.ClientSession() as session:
await get_info(session, wallet)
cooldownActive = row_data[wallet]['etherfi']['dailyCollector']['cooldownActive']
dailyStreak = row_data[wallet]['etherfi']['dailyCollector']['dailyStreak']
nextCheckinPoints = row_data[wallet]['etherfi']['dailyCollector']['nextCheckinPoints']
loyaltyPoints = row_data[wallet]['etherfi']['loyaltyPoints']
eigenlayerPoints = row_data[wallet]['etherfi']['eigenlayerPoints']
if cooldownActive == False:
logger.success(f'{wallet} : Do collect')
logger.success(f'S3 Points = {loyaltyPoints} : eigenlayerPoints = {eigenlayerPoints}')
logger.success(f'DailyStreak = {dailyStreak} : Next checking points = {nextCheckinPoints} : Cooldown Active = {cooldownActive}')
await process_daily_collector(session, wallet)
else:
logger.warning(f'{wallet} : Nothing to collect')
logger.warning(f'S3 Points = {loyaltyPoints} : eigenlayerPoints = {eigenlayerPoints}')
logger.success(f'DailyStreak = {dailyStreak} : Next checking points = {nextCheckinPoints} : Cooldown Active = {cooldownActive}')
async def run():
for wallet in WALLETS:
row_data.update({wallet: {
}})
walletIndex = WALLETS.index(wallet)
if len(PROXIES) >= walletIndex + 1:
proxy = PROXIES[walletIndex]
row_data[wallet].update({'proxy': proxy})
row_data[wallet].update({'etherfi': {'loyaltyPoints': {}, 'eigenlayerPoints': {}, 'dailyCollector':{}}})
while True:
try:
for wallet in WALLETS:
await main(wallet)
await sleep(SLEEP_FROM, SLEEP_TO)
except asyncio.TimeoutError:
pass
except Exception as error:
logger.error(f'{wallet} | error : {error}')
logger.info(f'💤 CYCLE Sleep')
await sleep(CYCLE_SLEEP_FROM, CYCLE_SLEEP_TO)
if __name__ == "__main__":
cprint('ether.fi Daily Collector', 'green')
loop = asyncio.get_event_loop()
loop.run_until_complete(run())