import { useTranslation } from 'next-i18next' import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import useSrmAccount from '../hooks/useSrmAccount' import { MSRM_DECIMALS, SRM_DECIMALS, } from '@project-serum/serum/lib/token-instructions' import { percentFormat4D } from '../utils/index' import Tooltip from '../components/Tooltip' import { InformationCircleIcon } from '@heroicons/react/solid' import DepositMsrmModal from '../components/DepositMsrmModal' import WithdrawMsrmModal from '../components/WithdrawMsrmModal' import { useState } from 'react' import { LinkButton } from '../components/Button' import useMangoStore from '../stores/useMangoStore' import { msrmMints, ZERO_BN } from '@blockworks-foundation/mango-client' import useFees from '../hooks/useFees' import { useWallet } from '@solana/wallet-adapter-react' export async function getStaticProps({ locale }) { return { props: { ...(await serverSideTranslations(locale, [ 'common', 'delegate', 'profile', ])), // Will be passed to the page component as props }, } } export default function Fees() { const { t } = useTranslation('common') const { totalSrm, totalMsrm, rates } = useSrmAccount() const { takerFeeBeforeDiscount, takerFeeWithTier1Discount, takerFeeWithTier2Discount, makerFee, } = useFees() const { connected } = useWallet() const [showDeposit, setShowDeposit] = useState(false) const [showWithdraw, setShowWithdraw] = useState(false) const mangoAccount = useMangoStore((s) => s.selectedMangoAccount.current) const walletTokens = useMangoStore((s) => s.wallet.tokens) const cluster = useMangoStore.getState().connection.cluster const ownerMsrmAccount = walletTokens.find((t) => t.account.mint.equals(msrmMints[cluster]) ) return (

{t('fees')}

{t('futures')}

{t('maker-fee')}
{percentFormat4D.format(makerFee)}
{t('taker-fee')}
{percentFormat4D.format(takerFeeBeforeDiscount)}

{t('if-referred', { fee: percentFormat4D.format( takerFeeBeforeDiscount < 0 ? takerFeeBeforeDiscount + takerFeeBeforeDiscount * 0.03 : takerFeeBeforeDiscount - takerFeeBeforeDiscount * 0.03 ), })}

{percentFormat4D.format(takerFeeWithTier1Discount)} if 10k MNGO

{percentFormat4D.format(takerFeeWithTier2Discount)} if 250k MNGO

{t('serum-fees')}

{t('maker-fee')}
{rates ? percentFormat4D.format(rates.maker) : null}
{t('taker-fee')}
{rates ? new Intl.NumberFormat(undefined, { style: 'percent', minimumFractionDigits: 2, maximumFractionDigits: 3, }).format(rates.takerWithRebate) : null}
{totalMsrm > 0 ? 'MSRM' : 'SRM'} {t('deposits')} {connected && mangoAccount ? (
setShowDeposit(true)} disabled={!ownerMsrmAccount} > {t('deposit')} {mangoAccount.msrmAmount.gt(ZERO_BN) ? ( setShowWithdraw(true)}> {t('withdraw')} ) : null}
) : null}
{totalMsrm > 0 ? totalMsrm.toLocaleString(undefined, { maximumFractionDigits: MSRM_DECIMALS, }) : totalSrm.toLocaleString(undefined, { maximumFractionDigits: SRM_DECIMALS, })}

{t('other')}

{t('withdraw')}
0%
{t('borrow')}
0%
{t('lend')}
0%
{showDeposit ? ( setShowDeposit(false)} /> ) : null} {showWithdraw ? ( setShowWithdraw(false)} /> ) : null}
) }