From 6e25f5c57f909dc371d932a382d1cc8cf30e0fba Mon Sep 17 00:00:00 2001 From: devtealeaf Date: Thu, 30 Jan 2025 14:39:37 +0200 Subject: [PATCH] upd: sGEM1 price --- src/modules/Users/index.tsx | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/modules/Users/index.tsx b/src/modules/Users/index.tsx index b39583cf..36c0af8a 100644 --- a/src/modules/Users/index.tsx +++ b/src/modules/Users/index.tsx @@ -18,7 +18,7 @@ import { import { findAllValidPeriods } from "./functions"; -import { account, apiData } from "@store"; +import { account, apiData, assetsPrices } from "@store"; import { contests } from "@stabilitydao/stability"; @@ -42,6 +42,7 @@ import type { UserRewards } from "@stabilitydao/stability/out/api.types"; const Users = (): JSX.Element => { const $apiData: ApiMainReply | undefined = useStore(apiData); + const $assetsPrices = useStore(assetsPrices); const $account = useStore(account); // const activeContestInfo = contests?.[currentPeriod]; @@ -54,6 +55,7 @@ const Users = (): JSX.Element => { points: "0", gems: "900k", }); + const [gemPrice, setGemPrice] = useState("-"); const [contestsToClaim, setContestsToClaim] = useState([]); @@ -92,6 +94,19 @@ const Users = (): JSX.Element => { } }; + const getSGEMPrice = async () => { + const sonicPrices = $assetsPrices["146"]; + + if (sonicPrices) { + const _sGEM1Price = + Number( + sonicPrices[sGEM1?.toLowerCase() as keyof typeof sonicPrices]?.price + ).toFixed(3) ?? "0.010"; + + setGemPrice(_sGEM1Price); + } + }; + const getRewardsTotalSupply = async () => { if ($apiData?.leaderboards?.absolute.length) { const pointsTotalSupply = $apiData?.leaderboards?.absolute.reduce( @@ -270,9 +285,13 @@ const Users = (): JSX.Element => { initTableData(); }, [activeContest, allContests]); + useEffect(() => { + getSGEMPrice(); + }, [$assetsPrices]); + useEffect(() => { getRewardsTotalSupply(); - }, [$apiData?.leaderboards?.absolute]); + }, [$apiData]); useEffect(() => { if ($account) { @@ -334,7 +353,7 @@ const Users = (): JSX.Element => {
- Price: 0.01 USDc + Price: ${gemPrice} Balance: {userBalance.gems}