import { DealTicketContainer } from '@vegaprotocol/deal-ticket'; import { MarketInfoContainer } from '@vegaprotocol/market-info'; import { OrderbookContainer } from '@vegaprotocol/market-depth'; import { ColumnKind, SelectMarketPopover } from '@vegaprotocol/market-list'; import type { OnCellClickHandler } from '@vegaprotocol/market-list'; import { OrderListContainer } from '@vegaprotocol/orders'; import { FillsContainer } from '@vegaprotocol/fills'; import { PositionsContainer } from '@vegaprotocol/positions'; import { TradesContainer } from '@vegaprotocol/trades'; import { LayoutPriority } from 'allotment'; import classNames from 'classnames'; import AutoSizer from 'react-virtualized-auto-sizer'; import { useState } from 'react'; import type { ReactNode } from 'react'; import type { Market_market } from './__generated__/Market'; import { AccountsContainer } from '@vegaprotocol/accounts'; import { DepthChartContainer } from '@vegaprotocol/market-depth'; import { CandlesChartContainer } from '@vegaprotocol/candles-chart'; import { Tab, Tabs, ResizableGrid, ResizableGridPanel, ButtonLink, PriceCellChange, Link, } from '@vegaprotocol/ui-toolkit'; import { addDecimalsFormatNumber, getDateFormat, t, } from '@vegaprotocol/react-helpers'; import { useAssetDetailsDialogStore } from '@vegaprotocol/assets'; import { useEnvironment } from '@vegaprotocol/environment'; import type { CandleClose } from '@vegaprotocol/types'; import { AuctionTrigger, AuctionTriggerMapping, MarketTradingMode, MarketTradingModeMapping, } from '@vegaprotocol/types'; import { TradingModeTooltip } from '../../components/trading-mode-tooltip'; import { Header, HeaderStat } from '../../components/header'; const TradingViews = { Candles: CandlesChartContainer, Depth: DepthChartContainer, Ticket: DealTicketContainer, Info: MarketInfoContainer, Orderbook: OrderbookContainer, Trades: TradesContainer, Positions: PositionsContainer, Orders: OrderListContainer, Collateral: AccountsContainer, Fills: FillsContainer, }; type TradingView = keyof typeof TradingViews; type ExpiryLabelProps = { market: Market_market; }; const ExpiryLabel = ({ market }: ExpiryLabelProps) => { let content = null; if (market.marketTimestamps.close === null) { content = t('Not time-based'); } else { const closeDate = new Date(market.marketTimestamps.close); const isExpired = Date.now() - closeDate.valueOf() > 0; const expiryDate = getDateFormat().format(closeDate); content = `${isExpired ? `${t('Expired')} ` : ''} ${expiryDate}`; } return
{t( 'This market expires when triggered by its oracle, not on a set date.' )}
{explorerUrl && oracleId && ( {t('View oracle specification')} )} > ); } return null; }; interface TradeMarketHeaderProps { market: Market_market; onSelect: (marketId: string) => void; } export const TradeMarketHeader = ({ market, onSelect, }: TradeMarketHeaderProps) => { const { VEGA_EXPLORER_URL } = useEnvironment(); const { open: openAssetDetailsDialog } = useAssetDetailsDialogStore(); const candlesClose: string[] = (market?.candlesConnection?.edges || []) .map((candle) => candle?.node.close) .filter((c): c is CandleClose => c !== null); const symbol = market.tradableInstrument.instrument.product?.settlementAsset?.symbol; const onCellClick: OnCellClickHandler = (e, kind, value) => { if (value && kind === ColumnKind.Asset) { openAssetDetailsDialog(value, e.target as HTMLElement); } }; return (