import { IconButton } from '@components/shared/Button' import SheenLoader from '@components/shared/SheenLoader' import { ChevronLeftIcon } from '@heroicons/react/20/solid' import mangoStore from '@store/mangoStore' // import dayjs from 'dayjs' import { useTranslation } from 'next-i18next' import dynamic from 'next/dynamic' import { useMemo } from 'react' import { formatFixedDecimals } from 'utils/numbers' const DetailedAreaChart = dynamic( () => import('@components/shared/DetailedAreaChart'), { ssr: false } ) const PerpMarketDetails = ({ perpMarket, setShowPerpDetails, }: { perpMarket: string setShowPerpDetails: (x: string) => void }) => { const { t } = useTranslation(['common', 'trade']) const perpStats = mangoStore((s) => s.perpStats.data) const loadingPerpStats = mangoStore((s) => s.perpStats.loading) // const perpMarkets = mangoStore((s) => s.perpMarkets) const marketStats = useMemo(() => { if (!perpStats) return [] return perpStats.filter((stat) => stat.perp_market === perpMarket).reverse() }, [perpStats]) return (
setShowPerpDetails('')}>

{`${perpMarket} ${t('stats')}`}

{loadingPerpStats ? ( <>
) : marketStats.length ? ( <>
formatFixedDecimals(x, true)} title={t('price')} xKey="date_hour" yKey={'price'} />
Math.floor(x).toString()} title={t('trade:open-interest')} xKey="date_hour" yKey={'open_interest'} />
formatFixedDecimals(x)} title={t('hourly-funding')} xKey="date_hour" yKey={'funding_rate_hourly'} />
formatFixedDecimals(x)} title={t('instantaneous-funding')} xKey="date_hour" yKey={'instantaneous_funding_rate'} />
) : null}
) } export default PerpMarketDetails