import { useCallback, useState } from 'react' import Link from 'next/link' import { Menu } from '@headlessui/react' import { DotsHorizontalIcon } from '@heroicons/react/outline' import FloatingElement from './FloatingElement' import { ElementTitle } from './styles' import useMangoStore from '../stores/useMangoStore' // import useMarketList from '../hooks/useMarketList' import { abbreviateAddress, i80f48ToPercent, // floorToDecimal, tokenPrecision, } from '../utils/index' import DepositModal from './DepositModal' import WithdrawModal from './WithdrawModal' // import BorrowModal from './BorrowModal' import Button from './Button' import Tooltip from './Tooltip' import { QUOTE_INDEX } from '@blockworks-foundation/mango-client/lib/src/MangoGroup' // import AccountsModal from './AccountsModal' export default function MarginBalances() { const selectedMangoGroup = useMangoStore((s) => s.selectedMangoGroup.current) const selectedMangoGroupConfig = useMangoStore( (s) => s.selectedMangoGroup.config ) const selectedMangoGroupCache = useMangoStore( (s) => s.selectedMangoGroup.cache ) const selectedMangoAccount = useMangoStore( (s) => s.selectedMangoAccount.current ) const loadingMangoAccount = useMangoStore( (s) => s.selectedMangoAccount.initialLoad ) const connected = useMangoStore((s) => s.wallet.connected) // const { symbols } = useMarketList() const [showDepositModal, setShowDepositModal] = useState(false) const [showWithdrawModal, setShowWithdrawModal] = useState(false) // const [showBorrowModal, setShowBorrowModal] = useState(false) // const [showAccountsModal, setShowAccountsModal] = useState(false) const handleCloseDeposit = useCallback(() => { setShowDepositModal(false) }, []) const handleCloseWithdraw = useCallback(() => { setShowWithdrawModal(false) }, []) // const handleCloseBorrow = useCallback(() => { // setShowBorrowModal(false) // }, []) // const handleCloseAccounts = useCallback(() => { // setShowAccountsModal(false) // }, []) return ( <>
Margin Account {selectedMangoAccount ? ( {abbreviateAddress(selectedMangoAccount?.publicKey)} ) : null}
{/* */}
{selectedMangoGroup ? ( {selectedMangoGroupConfig.tokens.map(({ symbol, mintKey }) => { const tokenIndex = selectedMangoGroup.getTokenIndex(mintKey) return ( ) })}
Asset Deposits Borrows
Deposits / Borrows
{symbol} {selectedMangoAccount ? selectedMangoAccount .getUiDeposit( selectedMangoGroupCache.rootBankCache[tokenIndex], selectedMangoGroup, tokenIndex ) .toFixed(tokenPrecision[symbol]) : (0).toFixed(tokenPrecision[symbol])} {selectedMangoAccount ? selectedMangoAccount .getUiBorrow( selectedMangoGroupCache.rootBankCache[tokenIndex], selectedMangoGroup, tokenIndex ) .toFixed(tokenPrecision[symbol]) : (0).toFixed(tokenPrecision[symbol])} {i80f48ToPercent( selectedMangoGroup.getDepositRate(tokenIndex) ).toFixed(2)} % {' / '} {i80f48ToPercent( selectedMangoGroup.getBorrowRate(tokenIndex) ).toFixed(2)} %
) : null}
{showDepositModal && ( )} {showWithdrawModal && ( )} {/* {showBorrowModal && ( )} {showAccountsModal ? ( ) : null} */} ) }