import { ZERO_I80F48 } from '@blockworks-foundation/mango-client' import { HeartIcon } from '@heroicons/react/outline' import useMangoStore from '../stores/useMangoStore' import FloatingElement from './FloatingElement' import { ElementTitle } from './styles' import Tooltip from './Tooltip' export default function MarginInfo() { const connected = useMangoStore((s) => s.wallet.connected) const mangoGroup = useMangoStore((s) => s.selectedMangoGroup.current) const mangoCache = useMangoStore((s) => s.selectedMangoGroup.cache) const mangoAccount = useMangoStore((s) => s.selectedMangoAccount.current) const maintHealth = mangoAccount ? mangoAccount.getHealthRatio(mangoGroup, mangoCache, 'Maint') : 100 const equity = mangoAccount ? mangoAccount.computeValue(mangoGroup, mangoCache) : ZERO_I80F48 // const leverage = // mangoAccount && equity.gt(ZERO_I80F48) // ? mangoAccount.getLiabsVal(mangoGroup, mangoCache).div(equity) // : 0.0 return (
Account
Equity
${equity.toFixed(2)}
{/*
Leverage
{leverage.toFixed(2)}x
*/}
Total Assets Value
$ {mangoAccount ? mangoAccount.getAssetsVal(mangoGroup, mangoCache).toFixed(2) : 0}
Total Liabilities Value
$ {mangoAccount ? mangoAccount.getLiabsVal(mangoGroup, mangoCache).toFixed(2) : 0}
Maint Health
{mangoAccount ? mangoAccount .getHealth(mangoGroup, mangoCache, 'Maint') .toFixed(2) : 0}
Init Health
{mangoAccount ? mangoAccount .getHealth(mangoGroup, mangoCache, 'Init') .toFixed(2) : 0}
{/*
Init Ratio
{mangoAccount ? mangoAccount .getHealthRatio(mangoGroup, mangoCache, 'Init') .toFixed(2) : 100.0} %
*/}
{maintHealth.toFixed(2)}%
50 ? 'bg-th-green' : maintHealth <= 50 && maintHealth > 24 ? 'bg-th-orange' : 'bg-th-red' }`} >
) }