@@ -17,6 +17,9 @@ import KeyDetailPageErrorBoundary from '@/components/common/KeyDetailPageErrorBo
1717import { ApiError } from '@/services/api.service' ;
1818import { useKeyHolders } from '@/hooks/useKeyHolders' ;
1919import { useNavigationTiming } from '@/hooks/useNavigationTiming' ;
20+ import { useKeyTwap } from '@/hooks/useKeyTwap' ;
21+ import Skeleton from '@/components/ui/skeleton' ;
22+ import { Tooltip } from '@/components/ui/tooltip' ;
2023
2124function CreatorDetailPageContent ( ) {
2225 const { id } = useParams < { id : string } > ( ) ;
@@ -35,6 +38,7 @@ function CreatorDetailPageContent() {
3538 isFetchingNextPage,
3639 fetchNextPage,
3740 } = useKeyHolders ( id || '' ) ;
41+ const { data : twap , isLoading : isTwapLoading } = useKeyTwap ( id || '' ) ;
3842
3943 // Track stale data indicator
4044 const { shouldShowBadge, handleRefetch } = useCreatorProfileStaleIndicator (
@@ -100,6 +104,9 @@ function CreatorDetailPageContent() {
100104 supply : ( index + 1 ) * 20 ,
101105 priceXLM : priceStroops / 10_000_000 ,
102106 } ) ) ;
107+ const spotPrice = resolveCreatorKeyPriceStroops ( creator ) ;
108+ const twapPrice = twap ?. priceStroops ?? null ;
109+ const twapDelta = twapPrice != null && spotPrice != null ? twapPrice - spotPrice : null ;
103110
104111 const defaultHolders = [
105112 { id : 'h1' , displayName : 'Early Adopter' , keyCount : 25 , stakedQuantity : 18 } ,
@@ -152,6 +159,25 @@ function CreatorDetailPageContent() {
152159 < CreatorProfileStatRow items = { statItems } />
153160 </ div >
154161
162+ < div className = "rounded-2xl border border-white/10 bg-white/[0.03] px-5 py-4" data-testid = "twap-price" >
163+ { isTwapLoading ? (
164+ < div aria-label = "Loading 24 hour TWAP" role = "status" > < Skeleton className = "h-3 w-24" /> < Skeleton className = "mt-2 h-6 w-32" /> </ div >
165+ ) : twapPrice != null ? (
166+ < div className = "flex items-center justify-between gap-4" >
167+ < div >
168+ < div className = "flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-white/55" >
169+ < span > TWAP (24h)</ span >
170+ < Tooltip content = "Time-weighted average key price over the last 24 hours." >
171+ < button type = "button" aria-label = "What is 24 hour TWAP?" className = "text-white/50" > ⓘ</ button >
172+ </ Tooltip >
173+ </ div >
174+ < div className = "mt-1 text-xl font-bold text-white" > { formatDisplayKeyPrice ( twapPrice ) } </ div >
175+ </ div >
176+ { twapDelta != null && < span className = { twapDelta >= 0 ? 'text-sm font-semibold text-emerald-400' : 'text-sm font-semibold text-rose-400' } > { twapDelta >= 0 ? '▲' : '▼' } { formatDisplayKeyPrice ( Math . abs ( twapDelta ) ) } vs spot</ span > }
177+ </ div >
178+ ) : null }
179+ </ div >
180+
155181 { /* Staking Rewards */ }
156182 < StakingRewardsSection
157183 { ...stakingStats }
0 commit comments