Skip to content

Commit

Permalink
Merge pull request #298 from mithraiclabs/bugfix/improve-mark-price-fail
Browse files Browse the repository at this point in the history
Improve failure state for mark price fetch
  • Loading branch information
evanpipta authored May 2, 2021
2 parents 9d0c73b + 83ad0b1 commit ddf4209
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/pages/Markets/Markets.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ const Markets = () => {
alignItems="center"
>
<Box>
{uAsset && uAsset.tokenSymbol && markPrice && (
{!!uAsset?.tokenSymbol && !!markPrice && (
<>
{uAsset?.tokenSymbol} Market Price: $
{markPrice && markPrice.toFixed(precision)}
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/useBonfidaMarkPrice.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const useBonfidaMarkPrice = ({ uAsset, qAsset }) => {
const { pushNotification } = useNotifications()

useEffect(() => {
setMarkPrice(0)
let timer
if (uAsset?.tokenSymbol && qAsset?.tokenSymbol) {
const fetchPrice = async () => {
Expand All @@ -22,6 +23,9 @@ export const useBonfidaMarkPrice = ({ uAsset, qAsset }) => {
setMarkPrice(0)
}
} catch (err) {
// Stop polling on failure to prevent error messages from popping up repeatedly
clearInterval(timer)
setMarkPrice(0)
pushNotification({
severity: 'error',
message: `Couldn't load market price for ${uAsset?.tokenSymbol}`,
Expand Down

0 comments on commit ddf4209

Please sign in to comment.