import { Popover } from 'antd' import { useCallback, useState } from 'react' import { ExternalLinkIcon, InformationCircleIcon, } from '@heroicons/react/outline' import FloatingElement from './FloatingElement' import { ElementTitle } from './styles' import useMangoStore from '../stores/useMangoStore' import useMarketList from '../hooks/useMarketList' import { tokenPrecision } from '../utils/index' import DepositModal from './DepositModal' import WithdrawModal from './WithdrawModal' import Button from './Button' export default function MarginStats() { const selectedMangoGroup = useMangoStore((s) => s.selectedMangoGroup.current) const selectedMarginAccount = useMangoStore( (s) => s.selectedMarginAccount.current ) const connected = useMangoStore((s) => s.wallet.connected) const { symbols } = useMarketList() const [showDepositModal, setShowDepositModal] = useState(false) const [showWithdrawModal, setShowWithdrawModal] = useState(false) const handleCloseDeposit = useCallback(() => { setShowDepositModal(false) }, []) const handleCloseWithdraw = useCallback(() => { setShowWithdrawModal(false) }, []) return ( <> Margin Account } placement="topLeft" trigger="hover" >
{selectedMangoGroup ? ( {Object.entries(symbols).map(([name], i) => ( ))}
Assets Deposits Borrows Interest (APY)
{name} {selectedMarginAccount ? selectedMarginAccount .getUiDeposit(selectedMangoGroup, i) .toFixed(tokenPrecision[name]) : (0).toFixed(tokenPrecision[name])} {selectedMarginAccount ? selectedMarginAccount .getUiBorrow(selectedMangoGroup, i) .toFixed(tokenPrecision[name]) : (0).toFixed(tokenPrecision[name])} +{(selectedMangoGroup.getDepositRate(i) * 100).toFixed(2)} % {' / '} -{(selectedMangoGroup.getBorrowRate(i) * 100).toFixed(2)}%
) : null}
Settle funds in the Balances tab
{showDepositModal && ( )} {showWithdrawModal && ( )} ) } const AddressTooltip = ({ owner, marginAccount, }: { owner?: string marginAccount?: string }) => { return ( <> {owner && marginAccount ? ( <>
Margin Account:
{marginAccount}
Account Owner:
{owner}
) : ( 'Connect a wallet and deposit funds to start trading' )} ) }