From 6f3cdd5c3eb5ad162b593abb432cc6a93ff7ff0f Mon Sep 17 00:00:00 2001 From: deep-path <476044723@qq.com> Date: Tue, 26 Nov 2024 17:46:29 +0800 Subject: [PATCH] feat: add total volume --- screens/Trading/index.tsx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/screens/Trading/index.tsx b/screens/Trading/index.tsx index 34917fd5..7f428469 100644 --- a/screens/Trading/index.tsx +++ b/screens/Trading/index.tsx @@ -168,8 +168,23 @@ const Trading = () => { currentTokenCate1?.metadata?.symbol == "wNEAR" ? "NEAR" : currentTokenCate1?.metadata?.symbol }/${currentTokenCate2?.metadata?.symbol}`; + const [volumeStats, setVolumeStats] = useState({}); + useEffect(() => { + const fetchVolumeStats = async () => { + try { + const response = await DataSource.shared.getMarginTradingVolumeStatistics(); + setVolumeStats({ + totalVolume: response.totalVolume || 0, + volume24h: response.volume24h || 0, + }); + } catch (error) { + console.error("Failed to fetch volume statistics:", error); + } + }; + + fetchVolumeStats(); + }, []); // - console.log(marginAccountList); return ( {/* back */} @@ -277,12 +292,12 @@ const Trading = () => { {/* total v */}

Total Volume

- $23.25M + {formatWithCommas_usd(volumeStats.totalVolume)}
{/* 24h v */}

24H Volume

- $13.25K + {formatWithCommas_usd(volumeStats.volume24h)}
{/* long short */}