import { PerpMarket } from '@blockworks-foundation/mango-v4' import Change from '@components/shared/Change' import { useCoingecko } from 'hooks/useCoingecko' import useSelectedMarket from 'hooks/useSelectedMarket' import { useTranslation } from 'next-i18next' import { useMemo } from 'react' import { getDecimalCount } from 'utils/numbers' import MarketSelectDropdown from './MarketSelectDropdown' import PerpFundingRate from './PerpFundingRate' const AdvancedMarketHeader = () => { const { t } = useTranslation(['common', 'trade']) const { serumOrPerpMarket, baseSymbol, price } = useSelectedMarket() const { data: tokenPrices } = useCoingecko() const coingeckoData = useMemo(() => { return tokenPrices.find((asset) => baseSymbol === 'soETH' ? asset.symbol === 'ETH' : asset.symbol === baseSymbol ) }, [baseSymbol, tokenPrices]) const change = useMemo(() => { return coingeckoData ? ((coingeckoData.prices[coingeckoData.prices.length - 1][1] - coingeckoData.prices[0][1]) / coingeckoData.prices[0][1]) * 100 : 0 }, [coingeckoData]) return (
{t('trade:oracle-price')}
{price ? ( `$${price.toFixed( getDecimalCount(serumOrPerpMarket?.tickSize || 0.01) )}` ) : ( )}
{t('rolling-change')}
{serumOrPerpMarket instanceof PerpMarket ? (
{t('trade:funding-rate')}
) : null}
) } export default AdvancedMarketHeader