Trireme commited on
Commit
1fd1024
·
verified ·
1 Parent(s): b69c6a1

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -5,6 +5,7 @@ import pandas as pd
5
  import urllib
6
  import gradio as gr
7
  import os
 
8
 
9
  addresses = [
10
  "0x46dae11e3ab74C417d370FB0d467364397178f5d",
@@ -102,6 +103,14 @@ async def get_wallet_balances(addresses):
102
  return df, df['usd_value'].sum()
103
 
104
  async def get_lp_balances():
 
 
 
 
 
 
 
 
105
  url = "https://api.debank.com/user?id=0x275c7f2781db0b78228029f85735059c9bdd4f35"
106
 
107
  SCRAPE_DO_TOKEN = os.getenv('SCRAPE_DO_KEY')
@@ -122,9 +131,9 @@ async def get_lp_balances():
122
  "sec-fetch-site": "same-site",
123
  "source": "web",
124
  "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",
125
- "x-api-nonce": "n_7SRfLNLCxRMncZbfaHcmRoO2CH6XN7OvkTQxFl3f",
126
- "x-api-sign": "d4f8bab02dc4a7e52cd35c21482798366fab0a2160463fb6030ebbc752af814b",
127
- "x-api-ts": "1749544063",
128
  "x-api-ver": "v2"
129
  }
130
 
@@ -168,7 +177,7 @@ with gr.Blocks() as demo:
168
  df2_out = gr.Dataframe(label="Total Balances")
169
  txt2_out = gr.Textbox(label="Total Value")
170
 
171
- pnl_out = gr.Textbox(label="PNL (AuUM Model)")
172
 
173
  # Load from MongoDB on app load (sync function)
174
  demo.load(
 
5
  import urllib
6
  import gradio as gr
7
  import os
8
+ from pymongo import MongoClient
9
 
10
  addresses = [
11
  "0x46dae11e3ab74C417d370FB0d467364397178f5d",
 
103
  return df, df['usd_value'].sum()
104
 
105
  async def get_lp_balances():
106
+ client = MongoClient(os.getenv('MONGO_DB_URI'))
107
+ db = client["debank_tokens"]
108
+ token_collection = db["debank"]
109
+ token_list = token_collection.find_one(sort=[("timestamp", -1)])
110
+ api_nonce = token_list['x-api-nonce']
111
+ api_sign = token_list['x-api-sign']
112
+ api_ts = token_list['x-api-ts']
113
+
114
  url = "https://api.debank.com/user?id=0x275c7f2781db0b78228029f85735059c9bdd4f35"
115
 
116
  SCRAPE_DO_TOKEN = os.getenv('SCRAPE_DO_KEY')
 
131
  "sec-fetch-site": "same-site",
132
  "source": "web",
133
  "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",
134
+ "x-api-nonce": api_nonce,
135
+ "x-api-sign": api_sign,
136
+ "x-api-ts": api_ts,
137
  "x-api-ver": "v2"
138
  }
139
 
 
177
  df2_out = gr.Dataframe(label="Total Balances")
178
  txt2_out = gr.Textbox(label="Total Value")
179
 
180
+ pnl_out = gr.Textbox(label="PNL (AUM Model)")
181
 
182
  # Load from MongoDB on app load (sync function)
183
  demo.load(