Skip to content

Commit

Permalink
Merge pull request #297 from mithraiclabs/bugfix/not-iterable-error
Browse files Browse the repository at this point in the history
Fix not iterable error
  • Loading branch information
evanpipta authored May 2, 2021
2 parents 4017649 + d35481e commit 9d0c73b
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/components/OpenOrders/OpenOrdersForMarket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useSerum from '../../hooks/useSerum'
import { useSerumOpenOrders } from '../../context/SerumOpenOrdersContext'
import { useSerumOrderbooks } from '../../context/SerumOrderbookContext'
import { useSubscribeOpenOrders, useSettleFunds } from '../../hooks/Serum'
import useNotifications from '../../hooks/useNotifications'

import { TCell } from './OpenOrderStyles'

Expand Down Expand Up @@ -35,6 +36,7 @@ const OpenOrdersForMarket: React.FC<{
const [openOrders] = useSerumOpenOrders()
const { serumMarket } = serumMarkets[serumKey] || {}
const settleFunds = useSettleFunds(serumKey)
const { pushNotification } = useNotifications()

useSubscribeOpenOrders(serumKey)

Expand All @@ -54,13 +56,22 @@ const OpenOrdersForMarket: React.FC<{
return null
}

const { bidOrderbook = [], askOrderbook = [] } = orderbooks[serumKey]
const { bidOrderbook, askOrderbook } = orderbooks[serumKey]
let actualOpenOrders

const actualOpenOrders = serumMarket.market.filterForOpenOrders(
bidOrderbook,
askOrderbook,
openOrders[serumKey].orders,
)
try {
actualOpenOrders = serumMarket.market.filterForOpenOrders(
bidOrderbook || [],
askOrderbook || [],
openOrders[serumKey]?.orders || [],
)
} catch (err) {
pushNotification({
severity: 'error',
message: `Couldn't display open orders for option market: ${uAssetSymbol}/${qAssetSymbol} ${type} @ strike ${strikePrice}`,
})
console.error(err)
}

return (
actualOpenOrders &&
Expand Down

0 comments on commit 9d0c73b

Please sign in to comment.