diff --git a/centrifuge-app/src/components/Charts/PoolPerformanceChart.tsx b/centrifuge-app/src/components/Charts/PoolPerformanceChart.tsx index b9b7de7ae3..b13701ade7 100644 --- a/centrifuge-app/src/components/Charts/PoolPerformanceChart.tsx +++ b/centrifuge-app/src/components/Charts/PoolPerformanceChart.tsx @@ -103,7 +103,9 @@ function PoolPerformanceChart() { // querying chain for more accurate data, since data for today from subquery is not necessarily up to date const todayAssetValue = pool?.nav.total.toDecimal().toNumber() || 0 - const todayPrice = pool?.tranches ? pool?.tranches[pool.tranches.length - 1].tokenPrice : null + const todayPrice = pool?.tranches + ? formatBalance(pool?.tranches[pool.tranches.length - 1].tokenPrice || 0, pool?.currency.symbol, 5, 5) + : null const today = { nav: todayAssetValue, @@ -121,6 +123,15 @@ function PoolPerformanceChart() { return 45 } + const isToday = (date: Date) => { + const today = new Date() + return ( + date.getDate() === today.getDate() && + date.getMonth() === today.getMonth() && + date.getFullYear() === today.getFullYear() + ) + } + return ( @@ -216,9 +227,11 @@ function PoolPerformanceChart() { {name === 'nav' && typeof value === 'number' - ? formatBalance(value, 'USD' || '') + ? formatBalance(value, 'USD') : typeof value === 'number' - ? formatBalance(value, 'USD' || '', 6) + ? isToday(payload[0].payload.day) + ? todayPrice + : formatBalance(value, pool.currency.symbol || '', 5, 5) : '-'}