From 1d5ab02c633360aec82dc4a6b983f2935a972da4 Mon Sep 17 00:00:00 2001 From: sina <20732540+SinaKhalili@users.noreply.github.com> Date: Mon, 25 Nov 2024 14:06:05 -0800 Subject: [PATCH] Update price shock cached to show slot --- backend/scripts/generate_ucache.py | 9 +++++---- src/page/price_shock_cached.py | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/backend/scripts/generate_ucache.py b/backend/scripts/generate_ucache.py index 16443e2..7fc8087 100644 --- a/backend/scripts/generate_ucache.py +++ b/backend/scripts/generate_ucache.py @@ -53,6 +53,7 @@ def __init__(self, path: str, query_params: dict): async def mock_call_next(request): if endpoint == "price-shock/usermap": content = await _get_price_shock( + state.last_oracle_slot, state.vat, state.dc, oracle_distortion=query_params["oracle_distortion"], @@ -126,10 +127,10 @@ async def main(): await state.close() endpoints = [ - Endpoint( - endpoint="asset-liability/matrix", - params={"mode": 0, "perp_market_index": 0}, - ), + # Endpoint( + # endpoint="asset-liability/matrix", + # params={"mode": 0, "perp_market_index": 0}, + # ), Endpoint( endpoint="price-shock/usermap", params={ diff --git a/src/page/price_shock_cached.py b/src/page/price_shock_cached.py index dbbcb02..fc48ee9 100644 --- a/src/page/price_shock_cached.py +++ b/src/page/price_shock_cached.py @@ -14,6 +14,8 @@ from solana.rpc.async_api import AsyncClient import streamlit as st +from utils import get_current_slot + class UserLeveragesResponse(TypedDict): leverages_none: list[Any] @@ -154,6 +156,10 @@ def price_shock_cached_page(): st.write("Check again in one minute!") st.stop() + current_slot = get_current_slot() + st.info( + f"This data is for slot {result['slot']}, which is now {int(current_slot) - int(result['slot'])} slots old" + ) fig = price_shock_plot(result, oracle_distort) st.plotly_chart(fig) oracle_down_max = pd.DataFrame(result["leverages_down"][-1])