import numeral from 'numeral' import _ from 'lodash' import { useEffect, useState, useMemo } from 'react' import { LoaderIcon } from 'react-hot-toast' import { Token } from '@/utils/types' import { getPoolApyData } from '@/utils/actions/getPoolApyData' import { ApyTooltipData } from '@/components/ApyTooltipData' import { hasAllPrices } from '@/utils/hasAllPrices' import { useAppSelector } from '@/store/hooks' import { HoverTooltip } from '@/components/HoverTooltip' import { InformationCircleIcon } from '@heroicons/react/outline' const StakingPoolTokens = ({ poolTokens }: { poolTokens: Token[] }) => { if (poolTokens) return (
{poolTokens.map((token: Token) => ( ))}
) } interface StakeCardTitleProps { token: Token poolTokens: Token[] poolLabel: string lpTokenBalance: bigint } const StakeCardTitle = ({ token, poolTokens, poolLabel, lpTokenBalance, }: StakeCardTitleProps) => { const [poolApyData, setPoolApyData] = useState(null) const { synPrices, ethPrice, avaxPrice, metisPrice } = useAppSelector( (state) => state.priceData ) const prices = { synPrices, ethPrice, avaxPrice, metisPrice } useEffect(() => { if (hasAllPrices(prices)) { getPoolApyData(token.chainId, token, { synPrices, ethPrice, avaxPrice, metisPrice, }) .then((res) => { setPoolApyData(res) }) .catch((err) => { console.log('Could not get pool data', err) }) } }, [token, hasAllPrices(prices), lpTokenBalance]) const displayPoolApyData = useMemo(() => { if (!poolApyData) return null const apy = poolApyData.fullCompoundedAPY > 10000 ? 10000 : poolApyData.fullCompoundedAPY return apy ? `${numeral(apy / 100).format('0,0%')}${ poolApyData.fullCompoundedAPY > 10000 ? '+' : '' }` : `-%` }, [prices, poolApyData]) return (

{poolLabel}

{displayPoolApyData ? ( {displayPoolApyData} ) : ( )}
APY
}>
) } export default StakeCardTitle