import { ReactElement, useMemo } from 'react' import { CircularProgress } from 'components/CircularProgress' import Text from 'components/Text' import { Tooltip } from 'components/Tooltip' import { BN } from 'utils/helpers' interface Props { health: number healthFactor: number children: ReactElement } function HealthTooltipContent({ health, healthFactor }: { health: number; healthFactor: number }) { const healthStatus = useMemo(() => { if (health > 30) return 'Healthy' if (health > 10) return 'Attention' if (health > 0 && health <= 10) return 'Close to Liquidation' return 'Liquidation Risk' }, [health]) if (healthFactor === 0) return (
Loading...
) return (
Health: {health}% ({healthStatus}) Health Factor: {BN(healthFactor).toPrecision(4)} {health > 0 && health <= 10 && ( A small price movement can cause your account to be become liquidatable! )} {health === 0 && ( Your account is unhealthy and can be liquidated! )}
) } export default function HealthTooltip(props: Props) { const { health, healthFactor, children } = props return ( } > {children} ) }