import { BigNumber } from '@ethersproject/bignumber' ; import { ContractName } from 'models/contract-name' ; import { useCallback , useState } from 'react' ; import { fromWad } from 'utils/formatNumber' ; import useContractReader from './ContractReader' ; export function useEtherPrice ( ) { const [ price , setPrice ] = useState < number > ( ) ; useContractReader ( { contract : ContractName . Prices , functionName : 'getETHPriceFor' , args : [ '1' ] , callback : useCallback ( ( val ? ) => setPrice ( parseFloat ( fromWad ( val ) ) ) , [ setPrice ] ) , } ) ; return price ; }