diff --git a/components/MarketsTable.tsx b/components/MarketsTable.tsx index 55417845..a3a7ade2 100644 --- a/components/MarketsTable.tsx +++ b/components/MarketsTable.tsx @@ -14,11 +14,16 @@ import { useRouter } from 'next/router' import { AreaChart, Area, XAxis, YAxis } from 'recharts' import { useTheme } from 'next-themes' -const MarketsTable = ({ isPerpMarket }) => { +const MarketsTable = ({ + isPerpMarket, + markets, +}: { + isPerpMarket?: boolean + markets: any[] +}) => { const { t } = useTranslation('common') const { width } = useViewport() const isMobile = width ? width < breakpoints.md : false - const marketsInfo = useMangoStore((s) => s.marketsInfo) const actions = useMangoStore((s) => s.actions) const coingeckoPrices = useMangoStore((s) => s.coingeckoPrices.data) const loadingCoingeckoPrices = useMangoStore((s) => s.coingeckoPrices.loading) @@ -31,290 +36,266 @@ const MarketsTable = ({ isPerpMarket }) => { } }, [coingeckoPrices]) - const perpMarketsInfo = useMemo( - () => - marketsInfo - .filter((mkt) => mkt?.name.includes('PERP')) - .sort((a, b) => b.volumeUsd24h - a.volumeUsd24h), - [marketsInfo] - ) + const { items, requestSort, sortConfig } = useSortableData(markets) - const spotMarketsInfo = useMemo( - () => - marketsInfo - .filter((mkt) => mkt?.name.includes('USDC')) - .sort((a, b) => b.volumeUsd24h - a.volumeUsd24h), - [marketsInfo] - ) - - const { items, requestSort, sortConfig } = useSortableData( - isPerpMarket ? perpMarketsInfo : spotMarketsInfo - ) - - return items.length > 0 ? ( - !isMobile ? ( -
- |
-
- |
-
- |
-
- |
- {isPerpMarket ? (
- <>
-
- |
-
- |
- >
- ) : null}
- - {t('favorite')} - | -
-
-
-
-
- {name}
-
-
-
- |
-
-
- {last ? (
- formatUsdValue(last)
- ) : (
- {t('unavailable')}
- )}
-
-
- {!loadingCoingeckoPrices ? (
- chartData !== undefined ? (
-
- |
-
- = 0 ? 'text-th-green' : 'text-th-red'}
- >
- {change24h || change24h === 0 ? (
- `${(change24h * 100).toFixed(2)}%`
- ) : (
- {t('unavailable')}
- )}
+ return !isMobile ? (
+
+ {!loadingCoingeckoPrices ? (
+ chartData !== undefined ? (
+
+ |
+ + = 0 ? 'text-th-green' : 'text-th-red'} + > + {change24h || change24h === 0 ? ( + `${(change24h * 100).toFixed(2)}%` + ) : ( + {t('unavailable')} + )} + + | ++ {volumeUsd24h ? ( + usdFormatter(volumeUsd24h, 0) + ) : ( + {t('unavailable')} + )} + | + {isPerpMarket ? ( + <> ++ {funding1h ? ( + <> + {`${funding1h.toFixed(4)}%`}{' '} + {`(${fundingApr}% APR)`} + > + ) : ( + {t('unavailable')} + )} + | +
+ {openInterestUsd ? (
+ <>
+ {usdFormatter(openInterestUsd, 0)}{' '}
+ {openInterest ? (
+
+ {openInterest.toLocaleString(undefined, {
+ maximumFractionDigits:
+ perpContractPrecision[baseSymbol],
+ })}{' '}
+ {baseSymbol}
+
+ ) : null}
+ >
+ ) : (
+ {t('unavailable')}
+ )}
+ |
+ >
+ ) : null}
+
+
+
+ |
+
---|