Skip to content

Commit 1ec4a0a

Browse files
committed
fix: preserve zero RWA volume fallback behavior
1 parent 7858f98 commit 1ec4a0a

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

apps/web/src/lib/tokens/rwa-stats.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,23 @@ export const fetchRwaStats = async (): Promise<RwaStats> => {
104104
volume24hUSD: sum((asset) => asset.stats?.volume24hUSD),
105105
};
106106

107-
// Guard against a partial/empty payload leaving a field at zero.
107+
// Guard against a partial/empty payload: if no relevant assets surfaced,
108+
// all derived aggregates would be zero/stale so fall back entirely.
109+
if (stats.totalAssets === 0) {
110+
return FALLBACK_STATS;
111+
}
112+
108113
return {
109114
treasuries: stats.treasuries || FALLBACK_STATS.treasuries,
110115
etfs: stats.etfs || FALLBACK_STATS.etfs,
111116
commodities: stats.commodities || FALLBACK_STATS.commodities,
112117
stocks: stats.stocks || FALLBACK_STATS.stocks,
113-
totalAssets: stats.totalAssets || FALLBACK_STATS.totalAssets,
118+
totalAssets: stats.totalAssets,
114119
totalValueUSD: stats.totalValueUSD || FALLBACK_STATS.totalValueUSD,
115-
volume24hUSD: stats.volume24hUSD || FALLBACK_STATS.volume24hUSD,
120+
volume24hUSD: stats.volume24hUSD,
116121
};
117-
} catch {
122+
} catch (err) {
123+
console.error("[fetchRwaStats] failed, using fallback stats:", err);
118124
return FALLBACK_STATS;
119125
} finally {
120126
clearTimeout(timeout);

0 commit comments

Comments
 (0)