diff --git a/src/PriceBox.tsx b/src/PriceBox.tsx index 933d046..1598276 100644 --- a/src/PriceBox.tsx +++ b/src/PriceBox.tsx @@ -45,7 +45,7 @@ const PriceBox: React.FC = () => { readData(); }, [ethFeed, gasFeed]); - const [latestPrice, timestamp] = useMemo(() => { + const [latestPrice, latestPriceTimestamp] = useMemo(() => { if (!latestPriceData) { return [undefined, undefined]; } @@ -59,27 +59,32 @@ const PriceBox: React.FC = () => { return [formattedPrice, timestamp]; }, [latestPriceData]); - const latestGasPrice = useMemo(() => { + const [latestGasPrice, latestGasPriceTimestamp] = useMemo(() => { if (!latestGasData) { - return undefined; + return [undefined, undefined]; } - return formatValue(latestGasData.answer, 9); + + const formattedGas = formatValue(latestGasData.answer, 9); + const timestamp = new Date(latestGasData.updatedAt * 1000); + return [formattedGas, timestamp]; }, [latestGasData]); return ( <> {latestPriceData && ( -
- +
+ Eth: ${latestPrice} {latestGasData && ( <> | - + {latestGasPrice} Gwei