HOOK use-underlying-price
useUnderlyingPrice
Subscribes to the underlying asset's perp price with candleSnapshot history. Returns { prices, currentPrice } ready for LivePriceChart. Handles history prefetch + live WS updates + deduplication.
Install
$
npx shadcn@latest add https://ui.purrdict.xyz/r/use-underlying-price.json Signature
useUnderlyingPrice(symbol: string, opts?) Returns
{ prices, currentPrice, isLoading } Usage
import { useUnderlyingPrice } from "@/hooks/hip4/use-underlying-price"
// Feeds LivePriceChart with underlying asset perp price
const { prices, currentPrice } = useUnderlyingPrice("BTC", {
historyMinutes: 60,
})
<LivePriceChart
symbol="BTC"
prices={prices}
currentPrice={currentPrice}
targetPrice={market.targetPrice}
/> Dependencies
npm packages
Registry components