import { getAsset, tooltipMapping, useMarket, useStaticMarketData, } from '@vegaprotocol/markets'; import { Header, HeaderStat, HeaderTitle } from '../header'; import { addDecimalsFormatNumber, formatNumberPercentage, } from '@vegaprotocol/utils'; import { CopyWithTooltip, ExternalLink, Indicator, VegaIcon, VegaIconNames, truncateMiddle, } from '@vegaprotocol/ui-toolkit'; import { DocsLinks } from '@vegaprotocol/environment'; import { useCheckLiquidityStatus, usePaidFeesQuery, } from '@vegaprotocol/liquidity'; import { useParams } from 'react-router-dom'; import { useT } from '../../lib/use-t'; export const LiquidityHeader = () => { const t = useT(); const { marketId } = useParams(); const { data: market } = useMarket(marketId); const { data: marketData } = useStaticMarketData(marketId); const { data: feesPaidRes } = usePaidFeesQuery({ variables: { marketId: marketId || '' }, }); const targetStake = marketData?.targetStake; const suppliedStake = marketData?.suppliedStake; const asset = market && getAsset(market); const assetDecimalPlaces = asset?.decimals || 0; const symbol = asset?.symbol; const triggeringRatio = market?.liquidityMonitoringParameters.triggeringRatio || '1'; const { percentage, status } = useCheckLiquidityStatus({ suppliedStake: suppliedStake || 0, targetStake: targetStake || 0, triggeringRatio, }); const feesObject = feesPaidRes?.paidLiquidityFees?.edges?.find( (e) => e?.node.marketId === marketId ); return (
{market.tradableInstrument.instrument.code && t('{{instrumentCode}} liquidity provision', { instrumentCode: market.tradableInstrument.instrument.code, })} ) } >
{targetStake ? `${addDecimalsFormatNumber( targetStake, assetDecimalPlaces ?? 0 )} ${symbol}` : '-'}
{suppliedStake ? `${addDecimalsFormatNumber( suppliedStake, assetDecimalPlaces ?? 0 )} ${symbol}` : '-'}
{formatNumberPercentage(percentage, 2)}
{feesObject?.node.totalFeesPaid ? `${addDecimalsFormatNumber( feesObject?.node.totalFeesPaid, assetDecimalPlaces ?? 0 )} ${symbol}` : '-'}
{marketId && (
)} {DocsLinks ? ( {t('Providing liquidity')} ) : ( (null as React.ReactNode) )}
); };