From 406cf228106ba40976b9751a154d494a50433c5c Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Thu, 20 Jul 2023 12:52:13 +0100 Subject: [PATCH] chore(trading): remove user pnl from closed market list (#4312) --- .../src/integration/closed-markets.cy.ts | 6 -- .../client-pages/markets/closed.spec.tsx | 68 +------------------ apps/trading/client-pages/markets/closed.tsx | 39 +---------- 3 files changed, 5 insertions(+), 108 deletions(-) diff --git a/apps/trading-e2e/src/integration/closed-markets.cy.ts b/apps/trading-e2e/src/integration/closed-markets.cy.ts index e0c870671..3de17a42b 100644 --- a/apps/trading-e2e/src/integration/closed-markets.cy.ts +++ b/apps/trading-e2e/src/integration/closed-markets.cy.ts @@ -351,12 +351,6 @@ describe('Closed markets', { tags: '@smoke' }, () => { ) ); - // 6001-MARK-017 - cy.get(rowSelector) - .first() - .find('[col-id="realisedPNL"]') - .should('have.text', '-'); - // 6001-MARK-018 cy.get(rowSelector) .first() diff --git a/apps/trading/client-pages/markets/closed.spec.tsx b/apps/trading/client-pages/markets/closed.spec.tsx index b96a1c3d6..d6d5eec80 100644 --- a/apps/trading/client-pages/markets/closed.spec.tsx +++ b/apps/trading/client-pages/markets/closed.spec.tsx @@ -2,7 +2,6 @@ import { act, render, screen, within, waitFor } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; import { Closed } from './closed'; import { MarketStateMapping, PropertyKeyType } from '@vegaprotocol/types'; -import { PositionStatus } from '@vegaprotocol/types'; import { MarketState } from '@vegaprotocol/types'; import { subDays } from 'date-fns'; import type { MockedResponse } from '@apollo/client/testing'; @@ -19,11 +18,6 @@ import { } from '@vegaprotocol/markets'; import type { VegaWalletContextShape } from '@vegaprotocol/wallet'; import { VegaWalletContext } from '@vegaprotocol/wallet'; -import type { - PositionsQuery, - PositionFieldsFragment, -} from '@vegaprotocol/positions'; -import { PositionsDocument } from '@vegaprotocol/positions'; import { addDecimalsFormatNumber } from '@vegaprotocol/utils'; import { createMarketFragment, @@ -161,45 +155,6 @@ describe('Closed', () => { }, }; - // Create mock position - const createPosition = (): PositionFieldsFragment => { - return { - __typename: 'Position' as const, - realisedPNL: '1000', - unrealisedPNL: '2000', - openVolume: '3000', - averageEntryPrice: '100', - updatedAt: new Date().toISOString(), - positionStatus: PositionStatus.POSITION_STATUS_UNSPECIFIED, - lossSocializationAmount: '1000', - market: { - __typename: 'Market', - id: marketId, - }, - party: { - __typename: 'Party', - id: pubKey, - }, - }; - }; - const position = createPosition(); - const positionsMock: MockedResponse = { - request: { - query: PositionsDocument, - variables: { - partyIds: [pubKey], - }, - }, - result: { - data: { - positions: { - __typename: 'PositionConnection', - edges: [{ __typename: 'PositionEdge', node: position }], - }, - }, - }, - }; - beforeAll(() => { originalNow = Date.now; Date.now = jest.fn().mockReturnValue(mockNowTimestamp); @@ -214,12 +169,7 @@ describe('Closed', () => { render( { 'Best offer', 'Mark price', 'Settlement price', - 'Realised PNL', 'Settlement asset', '', // actions row ]; @@ -266,7 +215,6 @@ describe('Closed', () => { addDecimalsFormatNumber(marketsData!.markPrice, market.decimalPlaces), /* eslint-enable @typescript-eslint/no-non-null-assertion */ addDecimalsFormatNumber(property.value, market.decimalPlaces), - addDecimalsFormatNumber(position.realisedPNL, market.decimalPlaces), market.tradableInstrument.instrument.product.settlementAsset.symbol, '', // actions row ]; @@ -327,12 +275,7 @@ describe('Closed', () => { render( { render( { - const { pubKey } = useVegaWallet(); - const { - data: marketData, - error, - reload, - } = useDataProvider({ + const { data: marketData, error } = useDataProvider({ dataProvider: closedMarketsWithDataProvider, variables: undefined, }); - const { data: positionData } = usePositionsQuery({ - variables: { - partyIds: pubKey ? [pubKey] : [], - }, - skip: !pubKey, - }); // find a position for each market and add the realised pnl to // a normalized object const rowData = compact(marketData).map((market) => { - const position = positionData?.positions?.edges?.find((edge) => { - return edge.node.market.id === market.id; - }); - const instrument = market.tradableInstrument.instrument; const spec = @@ -115,7 +97,6 @@ export const Closed = () => { tradingTerminationOracleId: instrument.product.dataSourceSpecForTradingTermination.id, settlementAsset: instrument.product.settlementAsset, - realisedPNL: position?.node.realisedPNL, successorMarketID: market.successorMarketID, }; @@ -123,7 +104,7 @@ export const Closed = () => { }); return (
- +
); }; @@ -153,11 +134,9 @@ export const SuccessorMarketRenderer = ({ const ClosedMarketsDataGrid = ({ rowData, error, - reload, }: { rowData: Row[]; error: Error | undefined; - reload: () => void; }) => { const openAssetDialog = useAssetDetailsDialogStore((store) => store.open); const colDefs = useMemo(() => { @@ -289,25 +268,11 @@ const ClosedMarketsDataGrid = ({ /> ), }, - { - headerName: t('Realised PNL'), - field: 'realisedPNL', - cellClass: 'font-mono ag-right-aligned-cell', - type: 'numericColumn', - valueFormatter: ({ - value, - data, - }: VegaValueFormatterParams) => { - if (!value || !data) return '-'; - return addDecimalsFormatNumber(value, data.decimalPlaces); - }, - }, { headerName: t('Settlement asset'), field: 'settlementAsset', cellRenderer: ({ value, - data, }: VegaValueFormatterParams) => (