Skip to content

Commit

Permalink
Update price shock cached to show slot
Browse files Browse the repository at this point in the history
  • Loading branch information
SinaKhalili committed Nov 25, 2024
1 parent 5521d3b commit 1d5ab02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 5 additions & 4 deletions backend/scripts/generate_ucache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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={
Expand Down
6 changes: 6 additions & 0 deletions src/page/price_shock_cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit 1d5ab02

Please sign in to comment.