diff --git a/components/DayHighLow.tsx b/components/DayHighLow.tsx index b6b3b344..eb844737 100644 --- a/components/DayHighLow.tsx +++ b/components/DayHighLow.tsx @@ -1,18 +1,24 @@ +import useOraclePrice from '../hooks/useOraclePrice' import { formatUsdValue } from '../utils' import { MarketDataLoader } from './MarketDetails' interface DayHighLowProps { high: number low: number - latest: number isTableView?: boolean } -const DayHighLow = ({ high, low, latest, isTableView }: DayHighLowProps) => { +const DayHighLow = ({ high, low, isTableView }: DayHighLowProps) => { + const price = useOraclePrice() let rangePercent = 0 + let latestPrice = 0 + + if (price) { + latestPrice = price?.toNumber() + } if (high) { - rangePercent = ((latest - low) * 100) / (high - low) + rangePercent = ((latestPrice - low) * 100) / (high - low) } return ( diff --git a/components/MarketDetails.tsx b/components/MarketDetails.tsx index 87b273cd..ae85f1d9 100644 --- a/components/MarketDetails.tsx +++ b/components/MarketDetails.tsx @@ -15,11 +15,30 @@ import { useTranslation } from 'next-i18next' import SwitchMarketDropdown from './SwitchMarketDropdown' import Tooltip from './Tooltip' +const OraclePrice = () => { + const oraclePrice = useOraclePrice() + const selectedMarket = useMangoStore((s) => s.selectedMarket.current) + + const decimals = useMemo( + () => getPrecisionDigits(selectedMarket?.tickSize), + [selectedMarket] + ) + + return ( +