import { percentFormat } from '../utils/index' import useSrmAccount from '../hooks/useSrmAccount' import { MSRM_DECIMALS, SRM_DECIMALS, } from '@project-serum/serum/lib/token-instructions' import Tooltip from './Tooltip' import { InformationCircleIcon } from '@heroicons/react/outline' import { useTranslation } from 'next-i18next' import Button from './Button' import useMangoStore from '../stores/useMangoStore' import { msrmMints, ZERO_BN } from '@blockworks-foundation/mango-client' import DepositMsrmModal from './DepositMsrmModal' import WithdrawMsrmModal from './WithdrawMsrmModal' import { useState } from 'react' const FeeDiscountsTable = () => { const { t } = useTranslation('common') const mangoAccount = useMangoStore((s) => s.selectedMangoAccount.current) const connected = useMangoStore((s) => s.wallet.connected) const walletTokens = useMangoStore((s) => s.wallet.tokens) const { totalSrm, totalMsrm, rates } = useSrmAccount() const [showDeposit, setShowDeposit] = useState(false) const [showWithdraw, setShowWithdraw] = useState(false) const cluster = useMangoStore.getState().connection.cluster const ownerMsrmAccount = walletTokens.find((t) => t.account.mint.equals(msrmMints[cluster]) ) return (
{t('serum-fees')}
{totalMsrm > 0 ? 'MSRM' : 'SRM'} {t('deposits')}
{totalMsrm > 0 ? totalMsrm.toLocaleString(undefined, { maximumFractionDigits: MSRM_DECIMALS, }) : totalSrm.toLocaleString(undefined, { maximumFractionDigits: SRM_DECIMALS, })}
{t('maker-fee')}
{rates ? percentFormat.format(rates.maker) : null}
{t('taker-fee')}
{rates ? new Intl.NumberFormat(undefined, { style: 'percent', minimumFractionDigits: 2, maximumFractionDigits: 3, }).format(rates.takerWithRebate) : null}
{connected && mangoAccount ? (
{mangoAccount.msrmAmount.gt(ZERO_BN) ? ( ) : null}
) : null}
{showDeposit ? ( setShowDeposit(false)} /> ) : null} {showWithdraw ? ( setShowWithdraw(false)} /> ) : null}
) } export default FeeDiscountsTable