-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathcount_uni_sushi_tx.py
44 lines (42 loc) · 1.46 KB
/
count_uni_sushi_tx.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
import json
from web3.auto import w3
sync_topic = "0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"
sushi_addresses = []
uni_addresses = []
def get_tx_info(info):
receipt = info['receipt']
if len(receipt['logs']) <= 1:
return False, False
is_sushi = False
is_uni = False
for log in receipt['logs']:
if not len(log['topics']) or not log['topics'][0] == sync_topic:
continue
addr = w3.toChecksumAddress(log['address'])
if addr in sushi_addresses:
is_sushi = True
if addr in uni_addresses:
is_uni = True
if is_sushi and is_uni:
return True, True
return is_uni, is_sushi
sushi_pairs = json.load(open('data/sushi_pairs.json'))
uni_pairs = json.load(open('data/pairs.json'))
sushi_addresses = [p['id'] for p in sushi_pairs]
uni_addresses = [p['id'] for p in uni_pairs]
uni_count = 0
sushi_count = 0
with open('/data/receipts_export_new', 'r') as f:
for line in f:
info = json.loads(line)
print(int(info['receipt']['blockNumber'], 16))
is_uni, is_sushi = get_tx_info(info)
if is_uni:
uni_count += 1
with open('/data/uni_receipts', 'a') as f1:
f1.write(json.dumps(info)+'\n')
if is_sushi:
sushi_count += 1
with open('/data/sushi_receipts', 'a') as f2:
f2.write(json.dumps(info)+'\n')
print('uni:', uni_count, 'sushi:', sushi_count)