add check that market is loaded

This commit is contained in:
tjs 2022-03-11 13:37:52 -05:00
parent 7974161a67
commit 98a60b6f67
1 changed files with 10 additions and 5 deletions

View File

@ -38,16 +38,21 @@ const parsedPerpEvent = (mangoAccountPk: PublicKey, event) => {
const side = maker ? reverseSide(event.takerSide) : event.takerSide
const allMarkets = useMangoStore.getState().selectedMangoGroup.markets
const market = allMarkets[event.address]
const sizeDecimalCount = getDecimalCount(market.minOrderSize)
const roundedSize = (
Math.floor(event.quantity / market.minOrderSize) * market.minOrderSize
).toFixed(sizeDecimalCount)
let size = event.quantity
if (market) {
const sizeDecimalCount = getDecimalCount(market.minOrderSize)
const roundedSize = (
Math.floor(event.quantity / market.minOrderSize) * market.minOrderSize
).toFixed(sizeDecimalCount)
size = roundedSize
}
return {
...event,
key: orderId?.toString(),
liquidity: maker ? 'Maker' : 'Taker',
size: roundedSize,
size: size,
price: event.price,
value,
feeCost: (feeRate * value).toFixed(4),