diff --git a/apps/dapp/src/components/Pages/Core/DappPages/Dashboard/hooks/use-dashboardv2-metrics.ts b/apps/dapp/src/components/Pages/Core/DappPages/Dashboard/hooks/use-dashboardv2-metrics.ts index 239257e10..bd6fd9e13 100644 --- a/apps/dapp/src/components/Pages/Core/DappPages/Dashboard/hooks/use-dashboardv2-metrics.ts +++ b/apps/dapp/src/components/Pages/Core/DappPages/Dashboard/hooks/use-dashboardv2-metrics.ts @@ -184,14 +184,22 @@ export default function useDashboardV2Metrics(dashboardData: DashboardData) { fetchGenericSubgraph( env.subgraph.templeV2, `{ - treasuryReservesVaults { - totalMarketValueUSD - treasuryPriceIndex - principalUSD - accruedInterestUSD - benchmarkedEquityUSD - } - }` + treasuryReservesVaults { + treasuryPriceIndex + principalUSD + accruedInterestUSD + } + }` + ), + // includes the external balances so has to come from the second subgraph + fetchGenericSubgraph( + env.subgraph.templeV2Balances, + `{ + treasuryReservesVaults { + totalMarketValueUSD + benchmarkedEquityUSD + } + }` ), getBenchmarkRate(), getTempleCirculatingSupply(), @@ -200,6 +208,7 @@ export default function useDashboardV2Metrics(dashboardData: DashboardData) { const [ trvSubgraphResponse, + responseExternalBalances, benchmarkRate, templeCirculatingSupply, templeSpotPrice, @@ -208,15 +217,18 @@ export default function useDashboardV2Metrics(dashboardData: DashboardData) { const trvSubgraphData = trvSubgraphResponse?.data?.treasuryReservesVaults[0]; + const externalBalancesData = + responseExternalBalances?.data?.treasuryReservesVaults[0]; + metrics = { - totalMarketValue: parseFloat(trvSubgraphData.totalMarketValueUSD), + totalMarketValue: parseFloat(externalBalancesData.totalMarketValueUSD), spotPrice: parseFloat(templeSpotPrice), treasuryPriceIndex: parseFloat(trvSubgraphData.treasuryPriceIndex), circulatingSupply: parseFloat(templeCirculatingSupply), benchmarkRate: parseFloat(benchmarkRate), principal: parseFloat(trvSubgraphData.principalUSD), accruedInterest: parseFloat(trvSubgraphData.accruedInterestUSD), - benchmarkedEquity: parseFloat(trvSubgraphData.benchmarkedEquityUSD), + benchmarkedEquity: parseFloat(externalBalancesData.benchmarkedEquityUSD), }; } catch (error) { console.info(error); diff --git a/apps/dapp/src/components/Pages/Core/NewUI/Home.tsx b/apps/dapp/src/components/Pages/Core/NewUI/Home.tsx index ac00b11b0..00b676a21 100644 --- a/apps/dapp/src/components/Pages/Core/NewUI/Home.tsx +++ b/apps/dapp/src/components/Pages/Core/NewUI/Home.tsx @@ -106,20 +106,14 @@ const Home = ({ tlc }: { tlc?: boolean }) => { useEffect(() => { const fetchMetrics = async () => { const { data: treasuryData } = await fetchGenericSubgraph( - env.subgraph.protocolMetrics, + env.subgraph.templeV2Balances, `{ - metrics { - treasuryValueUSD - } - }` - ); - const { data: arbitrumTreasuryData } = await fetchGenericSubgraph( - env.subgraph.protocolMetricsArbitrum, - `{ - metrics { - treasuryValueUSD - } - }` + treasuryReservesVaults { + principalUSD + benchmarkedEquityUSD + treasuryPriceIndex + } + }` ); const { data: ramosData } = await fetchGenericSubgraph( env.subgraph.ramos, @@ -130,20 +124,13 @@ const Home = ({ tlc }: { tlc?: boolean }) => { }` ); - const { data: tpiData } = await fetchGenericSubgraph( - env.subgraph.templeV2, - `{ - tpiOracles { - currentTpi - } - }` - ); + const treasuryMetrics = treasuryData.treasuryReservesVaults[0]; setMetrics({ price: parseFloat(ramosData.metrics[0].spotPrice), - tpi: parseFloat(tpiData.tpiOracles[0].currentTpi), + tpi: parseFloat(treasuryMetrics.treasuryPriceIndex), treasury: - parseFloat(treasuryData.metrics[0].treasuryValueUSD) + - parseFloat(arbitrumTreasuryData.metrics[0].treasuryValueUSD), + parseFloat(treasuryMetrics.principalUSD) + + parseFloat(treasuryMetrics.benchmarkedEquityUSD), }); }; fetchMetrics();