import { useEffect, useMemo } from 'react' import Link from 'next/link' import { formatUsdValue, perpContractPrecision, usdFormatter } from '../utils' import { Table, Td, Th, TrBody, TrHead } from './TableElements' import { useViewport } from '../hooks/useViewport' import { breakpoints } from './TradePageGrid' import { useTranslation } from 'next-i18next' import useMangoStore from '../stores/useMangoStore' import { FavoriteMarketButton } from './TradeNavMenu' import { useSortableData } from '../hooks/useSortableData' import { LinkButton } from './Button' import { ArrowSmDownIcon } from '@heroicons/react/solid' import { useRouter } from 'next/router' import { AreaChart, Area, XAxis, YAxis } from 'recharts' import { useTheme } from 'next-themes' const MarketsTable = ({ isPerpMarket, markets, }: { isPerpMarket?: boolean markets: any[] }) => { const { t } = useTranslation('common') const { width } = useViewport() const isMobile = width ? width < breakpoints.md : false const actions = useMangoStore((s) => s.actions) const coingeckoPrices = useMangoStore((s) => s.coingeckoPrices.data) const loadingCoingeckoPrices = useMangoStore((s) => s.coingeckoPrices.loading) const router = useRouter() useEffect(() => { if (coingeckoPrices.length === 0) { actions.fetchCoingeckoPrices() } }, [coingeckoPrices]) const { items, requestSort, sortConfig } = useSortableData(markets) return !isMobile ? (
|
|
|
|
{isPerpMarket ? (
<>
|
|
>
) : null}
{t('favorite')} |
|
{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 ? (