round open orders price to tick size

This commit is contained in:
saml33 2022-11-21 20:42:18 +11:00
parent e83e26c17d
commit 6f95fc8784
1 changed files with 7 additions and 1 deletions

View File

@ -130,12 +130,14 @@ const OpenOrders = () => {
return orders.map((o) => { return orders.map((o) => {
const group = mangoStore.getState().group! const group = mangoStore.getState().group!
let market: PerpMarket | Serum3Market let market: PerpMarket | Serum3Market
let tickSize: number
let quoteSymbol let quoteSymbol
if (o instanceof PerpOrder) { if (o instanceof PerpOrder) {
market = group.getPerpMarketByMarketIndex(o.perpMarketIndex) market = group.getPerpMarketByMarketIndex(o.perpMarketIndex)
quoteSymbol = group.getFirstBankByTokenIndex( quoteSymbol = group.getFirstBankByTokenIndex(
market.settleTokenIndex market.settleTokenIndex
).name ).name
tickSize = market.tickSize
} else { } else {
market = group.getSerum3MarketByExternalMarket( market = group.getSerum3MarketByExternalMarket(
new PublicKey(marketPk) new PublicKey(marketPk)
@ -143,6 +145,9 @@ const OpenOrders = () => {
quoteSymbol = group.getFirstBankByTokenIndex( quoteSymbol = group.getFirstBankByTokenIndex(
market!.quoteTokenIndex market!.quoteTokenIndex
).name ).name
tickSize = group.getSerum3ExternalMarket(
market.serumMarketExternal
).tickSize
} }
return ( return (
<TrBody <TrBody
@ -166,7 +171,8 @@ const OpenOrders = () => {
<Td className="text-right"> <Td className="text-right">
<span className="font-mono"> <span className="font-mono">
{o.price.toLocaleString(undefined, { {o.price.toLocaleString(undefined, {
maximumFractionDigits: getDecimalCount(o.price), minimumFractionDigits: getDecimalCount(tickSize),
maximumFractionDigits: getDecimalCount(tickSize),
})}{' '} })}{' '}
<span className="font-body tracking-wide text-th-fgd-4"> <span className="font-body tracking-wide text-th-fgd-4">
{quoteSymbol} {quoteSymbol}