import type { TokenAmount } from '@lifi/sdk'; import { FormHelperText, Skeleton, Typography } from '@mui/material'; import { useTranslation } from 'react-i18next'; import { useTokenAddressBalance } from '../../hooks'; import type { FormTypeProps } from '../../stores'; import { FormKeyHelper, useFieldValues } from '../../stores'; import { formatTokenAmount, formatTokenPrice } from '../../utils'; export const PriceFormHelperText: React.FC = ({ formType }) => { const [chainId, tokenAddress] = useFieldValues( FormKeyHelper.getChainKey(formType), FormKeyHelper.getTokenKey(formType), ); const { token, isLoading } = useTokenAddressBalance(chainId, tokenAddress); return ( ); }; export const PriceFormHelperTextBase: React.FC< FormTypeProps & { isLoading?: boolean; tokenAddress?: string; token?: TokenAmount; } > = ({ formType, isLoading, tokenAddress, token }) => { const { t } = useTranslation(); const [amount] = useFieldValues(FormKeyHelper.getAmountKey(formType)); const fromAmountTokenPrice = formatTokenPrice(amount, token?.priceUSD); return ( {t(`format.currency`, { value: fromAmountTokenPrice, })} {isLoading && tokenAddress ? ( ) : token?.amount ? ( {`/ ${t(`format.number`, { value: formatTokenAmount(token.amount, token.decimals), })}`} ) : null} ); };