import React from 'react' import { useCoingeckoPrice, useCoingeckoTokenPrice } from '@usedapp/coingecko' import { useUniswapPrice } from '@usedapp/uniswap' import { Container, ContentBlock, ContentRow, MainContent, Section, SectionRow } from '../components/base/base' import { Label } from '../typography/Label' import { TextInline } from '../typography/Text' import { Title } from '../typography/Title' import { formatEther, parseEther } from '@ethersproject/units' const WETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' const DAI_ADDRESS = '0x6b175474e89094c44da98b954eedeac495271d0f' export function Prices() { const geckoEtherPrice = useCoingeckoPrice('ethereum', 'usd') const geckoWethPrice = useCoingeckoTokenPrice(WETH_ADDRESS, 'usd') const uniWethPrice = useUniswapPrice(WETH_ADDRESS, DAI_ADDRESS) const uniWethPriceRounded = uniWethPrice ? uniWethPrice.sub(uniWethPrice.mod(parseEther('0.01'))) : undefined return (
Coingecko {geckoEtherPrice && ( {geckoEtherPrice} )} {geckoWethPrice && ( {geckoWethPrice} )}
Uniswap {uniWethPriceRounded && ( {formatEther(uniWethPriceRounded)} )}
) }