diff --git a/components/MarketsTable.tsx b/components/MarketsTable.tsx index 635b2874..a3a7ade2 100644 --- a/components/MarketsTable.tsx +++ b/components/MarketsTable.tsx @@ -12,17 +12,23 @@ import { LinkButton } from './Button' import { ArrowSmDownIcon } from '@heroicons/react/solid' import { useRouter } from 'next/router' import { AreaChart, Area, XAxis, YAxis } from 'recharts' -import { InformationCircleIcon } from '@heroicons/react/outline' -import Tooltip from './Tooltip' +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) + const coingeckoPrices = useMangoStore((s) => s.coingeckoPrices.data) + const loadingCoingeckoPrices = useMangoStore((s) => s.coingeckoPrices.loading) const router = useRouter() + const { theme } = useTheme() useEffect(() => { if (coingeckoPrices.length === 0) { @@ -30,13 +36,383 @@ 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) + + return !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')} + )} + + | ++ {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}
+
+
+
+ |
+
---|
+ {last ? ( + formatUsdValue(last) + ) : ( + {t('unavailable')} + )} +
+ {isPerpMarket ? ( + funding1h ? ( +
- |
-
- |
-
- |
-
- |
- {isPerpMarket ? (
- <>
-
- |
-
- |
- >
- ) : null}
- - {t('favorite')} - | -
-
-
-
-
- {name}
-
-
-
- |
-
-
- {last ? (
- formatUsdValue(last)
- ) : (
- {t('unavailable')}
- )}
-
-
- {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}
-
-
-
- |
-
---|