diff --git a/src/abacus-ts/selectors/assets.ts b/src/abacus-ts/selectors/assets.ts index 9a9e38026..e06f45854 100644 --- a/src/abacus-ts/selectors/assets.ts +++ b/src/abacus-ts/selectors/assets.ts @@ -7,12 +7,12 @@ import { getAssetFromMarketId } from '@/lib/assetUtils'; import { transformAssetsInfo } from '../calculators/assets'; import { selectRawAssetsData } from './base'; -export const createSelectAllAssetsInfo = createSelector([selectRawAssetsData], (assets) => +export const selectAllAssetsInfo = createSelector([selectRawAssetsData], (assets) => transformAssetsInfo(assets) ); -export const createSelectCurrentMarketAssetInfo = createSelector( - [getCurrentMarketId, createSelectAllAssetsInfo], +export const selectCurrentMarketAssetInfo = createSelector( + [getCurrentMarketId, selectAllAssetsInfo], (currentMarket, assets) => { const assetId = getAssetFromMarketId(currentMarket ?? ''); return assets?.[assetId]; diff --git a/src/abacus-ts/selectors/markets.ts b/src/abacus-ts/selectors/markets.ts index 310ba5707..0accba780 100644 --- a/src/abacus-ts/selectors/markets.ts +++ b/src/abacus-ts/selectors/markets.ts @@ -4,11 +4,11 @@ import { createAppSelector } from '@/state/appTypes'; import { calculateAllMarkets } from '../calculators/markets'; import { selectRawMarketsData } from './base'; -export const createSelectAllMarketsInfo = createAppSelector([selectRawMarketsData], (markets) => +export const selectAllMarketsInfo = createAppSelector([selectRawMarketsData], (markets) => calculateAllMarkets(markets) ); -export const createSelectCurrentMarketInfo = createAppSelector( - [createSelectAllMarketsInfo, (state: RootState) => state.perpetuals.currentMarketId], +export const selectCurrentMarketInfo = createAppSelector( + [selectAllMarketsInfo, (state: RootState) => state.perpetuals.currentMarketId], (markets, currentMarketId) => (currentMarketId ? markets?.[currentMarketId] : undefined) ); diff --git a/src/views/MarketDetails/CurrentMarketDetails.tsx b/src/views/MarketDetails/CurrentMarketDetails.tsx index 41917e2b7..0e47e0987 100644 --- a/src/views/MarketDetails/CurrentMarketDetails.tsx +++ b/src/views/MarketDetails/CurrentMarketDetails.tsx @@ -1,5 +1,5 @@ -import { createSelectCurrentMarketAssetInfo } from '@/abacus-ts/selectors/assets'; -import { createSelectCurrentMarketInfo } from '@/abacus-ts/selectors/markets'; +import { selectCurrentMarketAssetInfo } from '@/abacus-ts/selectors/assets'; +import { selectCurrentMarketInfo } from '@/abacus-ts/selectors/markets'; import { IndexerPerpetualMarketType } from '@/types/indexer/indexerApiGen'; import BigNumber from 'bignumber.js'; import { shallowEqual } from 'react-redux'; @@ -22,8 +22,8 @@ import { MarketDetails } from './MarketDetails'; export const CurrentMarketDetails = () => { const stringGetter = useStringGetter(); - const currentMarketData = useAppSelector(createSelectCurrentMarketInfo, shallowEqual); - const asset = useAppSelector(createSelectCurrentMarketAssetInfo); + const currentMarketData = useAppSelector(selectCurrentMarketInfo, shallowEqual); + const asset = useAppSelector(selectCurrentMarketAssetInfo); const { displayableAsset,