-
Notifications
You must be signed in to change notification settings - Fork 0
/
trader-joe.py
41 lines (31 loc) · 1.32 KB
/
trader-joe.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
import requests
headers = {
'authority': 'api.thegraph.com',
'accept': '*/*',
'accept-language': 'en-US,en;q=0.9',
# Already added when you pass json=
# 'content-type': 'application/json',
'origin': 'https://thegraph.com',
'referer': 'https://thegraph.com/',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'sec-gpc': '1',
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36',
}
json_data = {
'query': '{\n accounts(where: {health_gt: 0, health_lt: 1.005, totalBorrowValueInUSD_gt: 1000}) {\n id\n health\n totalBorrowValueInUSD\n totalCollateralValueInUSD\n }\n}\n',
'variables': None,
}
response = requests.post('https://api.thegraph.com/subgraphs/name/traderjoe-xyz/lending', headers=headers, json=json_data)
dict = response.json()
for i in dict:
all = dict[i]["accounts"]
total = len(all)
print(f"There are {total} accounts near liquidation on Trader Joe based on our filters")
if total > 0:
print(f"Printing the first 2 results of {total}")
print(all[0]["id"], all[0]["health"], all[0]["totalBorrowValueInUSD"])
print(all[1]["id"], all[1]["health"], all[1]["totalBorrowValueInUSD"])
if total < 0:
print("No results to display")