Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -75,12 +75,14 @@ async def get_wallet_base_balances(addresses):
|
|
| 75 |
df.drop(columns=['address','decimals'],inplace=True)
|
| 76 |
|
| 77 |
df = df[df['symbol'].isin(['VICE', 'ETH', 'USDT', 'USDC'])]
|
|
|
|
|
|
|
| 78 |
df= df[['symbol','tokenBalance','value']]
|
| 79 |
df = df.rename(columns={'tokenBalance':'amount','value':'usd_value'})
|
| 80 |
|
| 81 |
df = df.groupby("symbol", as_index=False).sum()
|
| 82 |
|
| 83 |
-
return df, df['usd_value'].sum(), eth_price, base_price
|
| 84 |
|
| 85 |
async def fetch_lp():
|
| 86 |
url = "https://public.zapper.xyz/graphql"
|
|
@@ -213,8 +215,12 @@ async def fetch_lp():
|
|
| 213 |
|
| 214 |
|
| 215 |
async def get_all_dfs():
|
| 216 |
-
|
| 217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
symbols = {"VICE":base_price,"WETH":eth_price}
|
| 219 |
lp_df = await fetch_lp()
|
| 220 |
if not lp_df.empty:
|
|
@@ -224,18 +230,20 @@ async def get_all_dfs():
|
|
| 224 |
for col in ['amount','usd_value']:
|
| 225 |
df[col] = pd.to_numeric(df[col], errors='coerce')
|
| 226 |
df[col] = df[col].apply(lambda x: f"{x:,.2f}")
|
| 227 |
-
return df,lp_df
|
| 228 |
|
| 229 |
with gr.Blocks() as demo:
|
| 230 |
gr.Markdown("## VICE Balances & PnL")
|
| 231 |
|
|
|
|
| 232 |
df1_out = gr.Dataframe(label="Current Balances")
|
| 233 |
-
|
| 234 |
-
|
|
|
|
| 235 |
demo.load(
|
| 236 |
fn= get_all_dfs,
|
| 237 |
inputs = [],
|
| 238 |
-
outputs=[df1_out,df2_out]
|
| 239 |
)
|
| 240 |
|
| 241 |
|
|
|
|
| 75 |
df.drop(columns=['address','decimals'],inplace=True)
|
| 76 |
|
| 77 |
df = df[df['symbol'].isin(['VICE', 'ETH', 'USDT', 'USDC'])]
|
| 78 |
+
df_lp_only = df[df['address'] == '0x45e7035499bc860dA0b5666A93B97AFc51F3cD3F']
|
| 79 |
+
df_lp_only = df_lp_only[['symbol','tokenBalance','value']]
|
| 80 |
df= df[['symbol','tokenBalance','value']]
|
| 81 |
df = df.rename(columns={'tokenBalance':'amount','value':'usd_value'})
|
| 82 |
|
| 83 |
df = df.groupby("symbol", as_index=False).sum()
|
| 84 |
|
| 85 |
+
return df, df['usd_value'].sum(), eth_price, base_price, df_lp_only
|
| 86 |
|
| 87 |
async def fetch_lp():
|
| 88 |
url = "https://public.zapper.xyz/graphql"
|
|
|
|
| 215 |
|
| 216 |
|
| 217 |
async def get_all_dfs():
|
| 218 |
+
starting_df = pd.DataFrame({
|
| 219 |
+
"symbol": ["ETH", "VICE"],
|
| 220 |
+
"amount": [23.77, 11066328.78],
|
| 221 |
+
"usd_value": [111264.43, 448971.41]
|
| 222 |
+
})
|
| 223 |
+
df, total, eth_price, base_price, df_lp_only = await get_wallet_base_balances(base_addresses)
|
| 224 |
symbols = {"VICE":base_price,"WETH":eth_price}
|
| 225 |
lp_df = await fetch_lp()
|
| 226 |
if not lp_df.empty:
|
|
|
|
| 230 |
for col in ['amount','usd_value']:
|
| 231 |
df[col] = pd.to_numeric(df[col], errors='coerce')
|
| 232 |
df[col] = df[col].apply(lambda x: f"{x:,.2f}")
|
| 233 |
+
return starting_df,df,lp_df,df_lp_only
|
| 234 |
|
| 235 |
with gr.Blocks() as demo:
|
| 236 |
gr.Markdown("## VICE Balances & PnL")
|
| 237 |
|
| 238 |
+
df0_out = gr.Dataframe(label="Starting Balances")
|
| 239 |
df1_out = gr.Dataframe(label="Current Balances")
|
| 240 |
+
df3_out = gr.Dataframe(label="LP Wallet Balances")
|
| 241 |
+
df2_out = gr.Dataframe(label="LP Position Balances")
|
| 242 |
+
|
| 243 |
demo.load(
|
| 244 |
fn= get_all_dfs,
|
| 245 |
inputs = [],
|
| 246 |
+
outputs=[df0_out,df1_out,df2_out,df3_out]
|
| 247 |
)
|
| 248 |
|
| 249 |
|