import { MangoAccount, MangoGroup } from '@blockworks-foundation/mango-client' import { ArrowSmDownIcon, ArrowSmUpIcon, HeartIcon, UsersIcon, } from '@heroicons/react/outline' import { useWallet } from '@solana/wallet-adapter-react' import { useTranslation } from 'next-i18next' import useMangoStore from 'stores/useMangoStore' import { abbreviateAddress } from 'utils' import Tooltip from './Tooltip' export const numberCurrencyCompacter = Intl.NumberFormat('en-us', { notation: 'compact', style: 'currency', currency: 'USD', maximumFractionDigits: 2, }) const MangoAccountCard = ({ mangoAccount, pnl, }: { mangoAccount: MangoAccount pnl?: number }) => { const { t } = useTranslation('common') const mangoGroup = useMangoStore((s) => s.selectedMangoGroup.current) const { publicKey } = useWallet() return (

{pnl ? ( {mangoAccount?.name || abbreviateAddress(mangoAccount.publicKey)} ) : ( {mangoAccount?.name || abbreviateAddress(mangoAccount.publicKey)} )} {publicKey && !mangoAccount?.owner.equals(publicKey) ? ( ) : ( '' )}

{mangoGroup && (
)}
) } export default MangoAccountCard const AccountInfo = ({ mangoGroup, mangoAccount, pnl, }: { mangoGroup: MangoGroup mangoAccount: MangoAccount pnl?: number }) => { const mangoCache = useMangoStore((s) => s.selectedMangoGroup.cache) if (!mangoCache) { return null } const accountEquity = mangoAccount.computeValue(mangoGroup, mangoCache) const health = mangoAccount.getHealthRatio(mangoGroup, mangoCache, 'Maint') return (
{numberCurrencyCompacter.format(accountEquity.toNumber())} | {pnl ? ( {pnl < 0 ? ( ) : ( )} {numberCurrencyCompacter.format(pnl)} ) : ( {Number(health) > 100 ? '>100' : health.toFixed(0)}% )}
) }