Spaces:
Runtime error
Runtime error
jiarongqiu commited on
Commit ·
6456be6
1
Parent(s): 2e7cd56
add tvl
Browse files- service/api.py +12 -0
- service/scheduler.py +3 -1
service/api.py
CHANGED
|
@@ -93,5 +93,17 @@ class API():
|
|
| 93 |
except Exception as e:
|
| 94 |
print(e)
|
| 95 |
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
api = API()
|
|
|
|
| 93 |
except Exception as e:
|
| 94 |
print(e)
|
| 95 |
return data
|
| 96 |
+
|
| 97 |
+
def get_filecoin_tvl(self):
|
| 98 |
+
data = None
|
| 99 |
+
try:
|
| 100 |
+
url="https://api.llama.fi/v2/chains"
|
| 101 |
+
res=requests.get(url=url)
|
| 102 |
+
data = json.loads(res.text)
|
| 103 |
+
data = [e for e in data if e['name'] =='Filecoin'][0]['tvl']
|
| 104 |
+
data = f"{data:,.1f}"
|
| 105 |
+
except Exception as e:
|
| 106 |
+
print(e)
|
| 107 |
+
return data
|
| 108 |
|
| 109 |
api = API()
|
service/scheduler.py
CHANGED
|
@@ -20,10 +20,12 @@ class Scheduler:
|
|
| 20 |
def update_filecoin_stat(self):
|
| 21 |
price = api.get_filecoin_price()
|
| 22 |
deposit = api.get_filecoin_deposit()
|
|
|
|
| 23 |
text = """
|
| 24 |
The price of filecoin(FIL) is currently ${} USD.
|
| 25 |
The Total DeFi Net Deposits of filecoin(FIL) is {} FIL.
|
| 26 |
-
|
|
|
|
| 27 |
vector_store.upsert(text,"dataset_1")
|
| 28 |
|
| 29 |
|
|
|
|
| 20 |
def update_filecoin_stat(self):
|
| 21 |
price = api.get_filecoin_price()
|
| 22 |
deposit = api.get_filecoin_deposit()
|
| 23 |
+
tvl = api.get_filecoin_tvl()
|
| 24 |
text = """
|
| 25 |
The price of filecoin(FIL) is currently ${} USD.
|
| 26 |
The Total DeFi Net Deposits of filecoin(FIL) is {} FIL.
|
| 27 |
+
The Total Value Locked(TVL) of filecoin(FIL) is ${} USD.
|
| 28 |
+
""".format(price,deposit,tvl)
|
| 29 |
vector_store.upsert(text,"dataset_1")
|
| 30 |
|
| 31 |
|