diff --git a/src/hooks/useMarketsData.ts b/src/hooks/useMarketsData.ts index 522ae54de..d8bea2b7e 100644 --- a/src/hooks/useMarketsData.ts +++ b/src/hooks/useMarketsData.ts @@ -145,6 +145,8 @@ export const useMarketsData = ({ const markets = useMemo(() => { const listOfMarkets = Object.values(allPerpetualMarkets) .filter(isTruthy) + // temporarily filter out markets with empty/0 oracle price + .filter((m) => isTruthy(m.oraclePrice)) // temporary filterout TRUMPWIN until the backend is working .filter( (m) => m.assetId !== 'TRUMPWIN' || featureFlags[StatsigFlags.ffShowPredictionMarketsUi] diff --git a/src/views/forms/TradeForm.tsx b/src/views/forms/TradeForm.tsx index 7ab6b84b1..ebef61991 100644 --- a/src/views/forms/TradeForm.tsx +++ b/src/views/forms/TradeForm.tsx @@ -46,9 +46,14 @@ import { getTradeFormInputs, useTradeFormData, } from '@/state/inputsSelectors'; -import { getCurrentMarketConfig } from '@/state/perpetualsSelectors'; +import { + getCurrentMarketConfig, + getCurrentMarketId, + getCurrentMarketOraclePrice, +} from '@/state/perpetualsSelectors'; import abacusStateManager from '@/lib/abacus'; +import { isTruthy } from '@/lib/isTruthy'; import { getSelectedOrderSide, getTradeInputAlert } from '@/lib/tradeData'; import { CanvasOrderbook } from '../CanvasOrderbook/CanvasOrderbook'; @@ -92,6 +97,9 @@ export const TradeForm = ({ const { tickSizeDecimals, stepSizeDecimals } = useAppSelector(getCurrentMarketConfig, shallowEqual) ?? {}; + const oraclePrice = useAppSelector(getCurrentMarketOraclePrice); + const currentMarketId = useAppSelector(getCurrentMarketId); + const tradeFormInputValues = useAppSelector(getTradeFormInputs, shallowEqual); const currentTradeData = useAppSelector(getInputTradeData, shallowEqual); @@ -323,6 +331,15 @@ export const TradeForm = ({ /> ); + // prevent real trading if null/zero oracle price or we are out of sync with abacus somehow + if (!isTruthy(oraclePrice) || currentMarketId !== marketId) { + return ( +
+ {stringGetter({ key: STRING_KEYS.SOMETHING_WENT_WRONG })} +
+ ); + } + return ( <$TradeForm onSubmit={onSubmit} className={className}> {currentStep && currentStep !== MobilePlaceOrderSteps.EditOrder ? (