update srm fees

This commit is contained in:
Tyler Shipe 2021-12-08 12:27:48 -05:00
parent ee4b5f3b2d
commit 714de8e34f
3 changed files with 45 additions and 3 deletions

View File

@ -75,7 +75,13 @@ const FeeDiscountsTable = () => {
</div> </div>
</div> </div>
<div className="text-th-fgd-3 text-normal"> <div className="text-th-fgd-3 text-normal">
{rates ? percentFormat.format(rates.takerWithRebate) : null} {rates
? new Intl.NumberFormat(undefined, {
style: 'percent',
minimumFractionDigits: 2,
maximumFractionDigits: 3,
}).format(rates.takerWithRebate)
: null}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1063,7 +1063,7 @@ export default function AdvancedTradeForm({
<span className="hidden md:block md:px-1">|</span> <span className="hidden md:block md:px-1">|</span>
<div> <div>
{' '} {' '}
{t('taker-fee')}: {takerFee * 100}% {t('taker-fee')}: {(takerFee * 100).toFixed(3)}%
</div> </div>
</div> </div>
)} )}

View File

@ -8,10 +8,46 @@ import {
MSRM_DECIMALS, MSRM_DECIMALS,
SRM_DECIMALS, SRM_DECIMALS,
} from '@project-serum/serum/lib/token-instructions' } from '@project-serum/serum/lib/token-instructions'
import { getFeeTier, getFeeRates } from '@project-serum/serum'
import { parseTokenAccountData } from '../utils/tokens' import { parseTokenAccountData } from '../utils/tokens'
import { useEffect } from 'react' 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 useSrmAccount = () => {
const mangoGroup = useMangoStore((s) => s.selectedMangoGroup.current) const mangoGroup = useMangoStore((s) => s.selectedMangoGroup.current)
const connection = useMangoStore((s) => s.connection.current) const connection = useMangoStore((s) => s.connection.current)