2021-06-07 15:06:00 -07:00
|
|
|
import { percentFormat } from '../utils/index'
|
|
|
|
import useSrmAccount from '../hooks/useSrmAccount'
|
2021-10-18 13:38:03 -07:00
|
|
|
import {
|
|
|
|
MSRM_DECIMALS,
|
|
|
|
SRM_DECIMALS,
|
|
|
|
} from '@project-serum/serum/lib/token-instructions'
|
2021-06-12 10:46:06 -07:00
|
|
|
import Tooltip from './Tooltip'
|
|
|
|
import { InformationCircleIcon } from '@heroicons/react/outline'
|
2021-10-18 13:38:03 -07:00
|
|
|
import Button from './Button'
|
|
|
|
import useMangoStore from '../stores/useMangoStore'
|
|
|
|
import { ZERO_BN } from '@blockworks-foundation/mango-client'
|
|
|
|
import DepositMsrmModal from './DepositMsrmModal'
|
|
|
|
import WithdrawMsrmModal from './WithdrawMsrmModal'
|
|
|
|
import { useState } from 'react'
|
2021-06-07 15:06:00 -07:00
|
|
|
|
|
|
|
const FeeDiscountsTable = () => {
|
2021-10-18 13:38:03 -07:00
|
|
|
const mangoAccount = useMangoStore((s) => s.selectedMangoAccount.current)
|
|
|
|
const { totalSrm, totalMsrm, rates } = useSrmAccount()
|
|
|
|
const [showDeposit, setShowDeposit] = useState(false)
|
|
|
|
const [showWithdraw, setShowWithdraw] = useState(false)
|
2021-06-07 15:06:00 -07:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
2021-10-18 13:38:03 -07:00
|
|
|
className={`flex justify-center bg-th-bkg-1 py-6 mt-6 rounded-md divide-x divide-gray-500`}
|
2021-06-07 15:06:00 -07:00
|
|
|
>
|
2021-10-18 13:38:03 -07:00
|
|
|
<div className="pr-10">
|
|
|
|
<div className="text-center text-lg">Serum Spot Fees</div>
|
|
|
|
<div
|
|
|
|
className={`flex flex-col sm:flex-row justify-between text-th-fgd-4 text-center mt-4`}
|
|
|
|
>
|
|
|
|
<div className="px-4">
|
|
|
|
<div>{totalMsrm > 0 ? 'MSRM' : 'SRM'} Deposits</div>
|
|
|
|
<div className="text-th-fgd-3 text-normal">
|
|
|
|
{totalMsrm > 0
|
|
|
|
? totalMsrm.toLocaleString(undefined, {
|
|
|
|
maximumFractionDigits: MSRM_DECIMALS,
|
|
|
|
})
|
|
|
|
: totalSrm.toLocaleString(undefined, {
|
|
|
|
maximumFractionDigits: SRM_DECIMALS,
|
|
|
|
})}
|
|
|
|
</div>
|
2021-06-07 15:06:00 -07:00
|
|
|
</div>
|
2021-10-18 13:38:03 -07:00
|
|
|
<div className="px-4 mt-4 sm:mt-0">
|
|
|
|
<div>Maker Fee</div>
|
|
|
|
<div className="text-th-fgd-3 text-normal">
|
|
|
|
{rates ? percentFormat.format(rates.maker) : null}
|
|
|
|
</div>
|
2021-06-07 15:06:00 -07:00
|
|
|
</div>
|
2021-10-18 13:38:03 -07:00
|
|
|
<div className="px-4 mt-4 sm:mt-0">
|
2021-06-12 10:46:06 -07:00
|
|
|
<div className="flex items-center">
|
2021-10-18 13:38:03 -07:00
|
|
|
<div>Taker Fee</div>
|
|
|
|
<div className="flex items-center">
|
|
|
|
<Tooltip
|
|
|
|
content={`20% of net fees on Serum go to the GUI host. Mango rebates this fee to you. The taker fee before the GUI rebate is ${percentFormat.format(
|
|
|
|
rates.taker
|
|
|
|
)}`}
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<InformationCircleIcon
|
|
|
|
className={`h-5 w-5 ml-2 text-th-fgd-4 cursor-help`}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="text-th-fgd-3 text-normal">
|
|
|
|
{rates ? percentFormat.format(rates.takerWithRebate) : null}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{mangoAccount ? (
|
|
|
|
<div className="flex justify-center mt-6">
|
|
|
|
<Button onClick={() => setShowDeposit(true)}>Deposit MSRM</Button>
|
|
|
|
{mangoAccount.msrmAmount.gt(ZERO_BN) ? (
|
|
|
|
<Button onClick={() => setShowWithdraw(true)} className="ml-2">
|
|
|
|
Withdraw MSRM
|
|
|
|
</Button>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
<div className="pl-10">
|
|
|
|
<div className="text-center text-lg">Mango Perp Fees</div>
|
|
|
|
<div
|
|
|
|
className={`flex flex-col sm:flex-row justify-between text-th-fgd-4 text-center mt-4`}
|
|
|
|
>
|
|
|
|
<div className="px-4 mt-4 sm:mt-0">
|
|
|
|
<div>Maker Fee</div>
|
|
|
|
<div className="text-th-fgd-3 text-normal">
|
|
|
|
{percentFormat.format(0.0)}
|
2021-06-12 10:46:06 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-10-18 13:38:03 -07:00
|
|
|
<div className="px-4 mt-4 sm:mt-0">
|
|
|
|
<div className="flex items-center">
|
|
|
|
<div>Taker Fee</div>
|
|
|
|
</div>
|
|
|
|
<div className="text-th-fgd-3 text-normal">
|
|
|
|
{percentFormat.format(0.0005)}
|
|
|
|
</div>
|
2021-06-07 15:06:00 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-10-18 13:38:03 -07:00
|
|
|
{showDeposit ? (
|
|
|
|
<DepositMsrmModal
|
|
|
|
isOpen={showDeposit}
|
|
|
|
onClose={() => setShowDeposit(false)}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
{showWithdraw ? (
|
|
|
|
<WithdrawMsrmModal
|
|
|
|
isOpen={showWithdraw}
|
|
|
|
onClose={() => setShowWithdraw(false)}
|
|
|
|
/>
|
|
|
|
) : null}
|
2021-06-07 15:06:00 -07:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FeeDiscountsTable
|