From f7c5683fbc366a8c60e25f25a03415f257670a1c Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Thu, 19 Mar 2026 11:47:00 +0000 Subject: [PATCH 1/2] [#355] Fix blank token price and TVL on writer dashboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Price display depended on decimals from the TVL query (no fallback), so if getTokenTVL was slow or failed, both price and TVL showed "—". Default decimals to 18 (matching ClaimRoyalties and getTokenPrice) so price renders independently of the TVL query. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/WriterTradingStats.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/WriterTradingStats.tsx b/src/components/WriterTradingStats.tsx index 369cb6e7..507f8397 100644 --- a/src/components/WriterTradingStats.tsx +++ b/src/components/WriterTradingStats.tsx @@ -35,7 +35,7 @@ export function WriterTradingStats({ storyline }: WriterTradingStatsProps) { enabled: !!tokenAddress, }); - const decimals = tvlData?.decimals; + const decimals = tvlData?.decimals ?? 18; return (
@@ -44,7 +44,7 @@ export function WriterTradingStats({ storyline }: WriterTradingStatsProps) { Token Price - {price !== undefined && decimals !== undefined ? `${formatUnits(BigInt(price), decimals)} ${RESERVE_LABEL}` : "—"} + {price !== undefined ? `${formatUnits(BigInt(price), decimals)} ${RESERVE_LABEL}` : "—"}
From f8b046507448262cfeda0194bfa0b83b28a762f9 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Thu, 19 Mar 2026 11:49:56 +0000 Subject: [PATCH 2/2] [#355] Combine price+TVL into single query with retry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address T2a review: TVL still showed "—" when getTokenTVL failed independently. Now both values are fetched atomically in one query with retry:2 and refetchInterval:30s. TVL falls back to "0" when getTokenTVL returns null but price succeeds. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/WriterTradingStats.tsx | 44 ++++++++++++++------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/components/WriterTradingStats.tsx b/src/components/WriterTradingStats.tsx index 507f8397..621f9c1f 100644 --- a/src/components/WriterTradingStats.tsx +++ b/src/components/WriterTradingStats.tsx @@ -13,30 +13,32 @@ interface WriterTradingStatsProps { export function WriterTradingStats({ storyline }: WriterTradingStatsProps) { const tokenAddress = storyline.token_address as Address; - // Fetch token price - const { data: price } = useQuery({ - queryKey: ["writer-price", tokenAddress], + + // Fetch price + TVL together so they succeed/fail atomically + const { data } = useQuery({ + queryKey: ["writer-stats", tokenAddress], queryFn: async () => { - const result = await publicClient.readContract({ - address: MCV2_BOND, - abi: mcv2BondAbi, - functionName: "priceForNextMint", - args: [tokenAddress], - }); - return result; + const [priceRaw, tvlData] = await Promise.all([ + publicClient.readContract({ + address: MCV2_BOND, + abi: mcv2BondAbi, + functionName: "priceForNextMint", + args: [tokenAddress], + }), + getTokenTVL(tokenAddress), + ]); + const decimals = tvlData?.decimals ?? 18; + return { + price: formatUnits(BigInt(priceRaw), decimals), + tvl: tvlData?.tvl ?? formatUnits(BigInt(0), decimals), + decimals, + }; }, enabled: !!tokenAddress, + retry: 2, + refetchInterval: 30000, }); - // Fetch TVL via getTokenTVL (uses correct reserve token decimals) - const { data: tvlData } = useQuery({ - queryKey: ["writer-tvl", tokenAddress], - queryFn: () => getTokenTVL(tokenAddress), - enabled: !!tokenAddress, - }); - - const decimals = tvlData?.decimals ?? 18; - return (
@@ -44,7 +46,7 @@ export function WriterTradingStats({ storyline }: WriterTradingStatsProps) { Token Price - {price !== undefined ? `${formatUnits(BigInt(price), decimals)} ${RESERVE_LABEL}` : "—"} + {data ? `${data.price} ${RESERVE_LABEL}` : "—"}
@@ -52,7 +54,7 @@ export function WriterTradingStats({ storyline }: WriterTradingStatsProps) { TVL - {tvlData ? `${tvlData.tvl} ${RESERVE_LABEL}` : "—"} + {data ? `${data.tvl} ${RESERVE_LABEL}` : "—"}