diff --git a/components/FeeDiscountsTable.tsx b/components/FeeDiscountsTable.tsx index dbc2ee09..c44f4e08 100644 --- a/components/FeeDiscountsTable.tsx +++ b/components/FeeDiscountsTable.tsx @@ -75,7 +75,13 @@ const FeeDiscountsTable = () => {
- {rates ? percentFormat.format(rates.takerWithRebate) : null} + {rates + ? new Intl.NumberFormat(undefined, { + style: 'percent', + minimumFractionDigits: 2, + maximumFractionDigits: 3, + }).format(rates.takerWithRebate) + : null}
diff --git a/components/trade_form/AdvancedTradeForm.tsx b/components/trade_form/AdvancedTradeForm.tsx index 712697b1..344a01a8 100644 --- a/components/trade_form/AdvancedTradeForm.tsx +++ b/components/trade_form/AdvancedTradeForm.tsx @@ -1063,7 +1063,7 @@ export default function AdvancedTradeForm({ |
{' '} - {t('taker-fee')}: {takerFee * 100}% + {t('taker-fee')}: {(takerFee * 100).toFixed(3)}%
)} diff --git a/hooks/useSrmAccount.tsx b/hooks/useSrmAccount.tsx index 3fed52fd..53fa0489 100644 --- a/hooks/useSrmAccount.tsx +++ b/hooks/useSrmAccount.tsx @@ -8,10 +8,46 @@ import { MSRM_DECIMALS, SRM_DECIMALS, } from '@project-serum/serum/lib/token-instructions' -import { getFeeTier, getFeeRates } from '@project-serum/serum' import { parseTokenAccountData } from '../utils/tokens' import { useEffect } from 'react' +export function getFeeRates(feeTier: number): { taker: number; maker: number } { + if (feeTier === 1) { + return { taker: 0.00039, maker: 0 } + } else if (feeTier === 2) { + return { taker: 0.00038, maker: 0 } + } else if (feeTier === 3) { + return { taker: 0.00036, maker: 0 } + } else if (feeTier === 4) { + return { taker: 0.00034, maker: 0 } + } else if (feeTier === 5) { + return { taker: 0.00032, maker: 0 } + } else if (feeTier === 6) { + // MSRM + return { taker: 0.0003, maker: 0 } + } + // Base + return { taker: 0.0004, maker: 0 } +} + +export function getFeeTier(msrmBalance: number, srmBalance: number): number { + if (msrmBalance >= 1) { + return 6 + } else if (srmBalance >= 1_000_000) { + return 5 + } else if (srmBalance >= 100_000) { + return 4 + } else if (srmBalance >= 10_000) { + return 3 + } else if (srmBalance >= 1_000) { + return 2 + } else if (srmBalance >= 100) { + return 1 + } else { + return 0 + } +} + const useSrmAccount = () => { const mangoGroup = useMangoStore((s) => s.selectedMangoGroup.current) const connection = useMangoStore((s) => s.connection.current)