Skip to content

Commit

Permalink
feat: add total volume
Browse files Browse the repository at this point in the history
  • Loading branch information
deep-path committed Nov 26, 2024
1 parent 0e6bb70 commit 6f3cdd5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions screens/Trading/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,23 @@ const Trading = () => {
currentTokenCate1?.metadata?.symbol == "wNEAR" ? "NEAR" : currentTokenCate1?.metadata?.symbol
}/${currentTokenCate2?.metadata?.symbol}`;

const [volumeStats, setVolumeStats] = useState<any>({});
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 (
<LayoutBox>
{/* back */}
Expand Down Expand Up @@ -277,12 +292,12 @@ const Trading = () => {
{/* total v */}
<div className="text-sm">
<p className="text-gray-300 mb-1.5">Total Volume</p>
<span>$23.25M</span>
<span>{formatWithCommas_usd(volumeStats.totalVolume)}</span>
</div>
{/* 24h v */}
<div className="text-sm">
<p className="text-gray-300 mb-1.5">24H Volume</p>
<span>$13.25K</span>
<span>{formatWithCommas_usd(volumeStats.volume24h)}</span>
</div>
{/* long short */}
<div className="text-sm">
Expand Down

0 comments on commit 6f3cdd5

Please sign in to comment.