Compare commits

...
Author SHA1 Message Date
Madalina Raicu 970193fde9 chore: remove liquidation price (est) for now 2022-11-17 06:48:14 -05:00
Madalina Raicu 38439b2562 fix: add other dp to summary row data 2022-11-17 06:28:27 -05:00
Madalina Raicu 1bd8c65031 fix: fix positions unit tests 2022-11-17 05:41:21 -05:00
Madalina Raicu 805467d6fa fix: normalize values 2022-11-17 05:31:56 -05:00
Madalina Raicu de61f89fb9 fix: update decimals on position notional size 2022-11-17 05:10:56 -05:00
Madalina Raicu 1436e97434 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-11-16 16:48:09 -05:00
Madalina Raicu 3d793128e7 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-11-16 10:54:05 -05:00
Madalina Raicu 4fa3aac079 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-11-15 05:41:37 -05:00
Madalina Raicu 41ca079814 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-11-13 20:04:39 -05:00
Madalina Raicu 38c76f24a3 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-11-11 16:35:08 +00:00
Madalina Raicu ab1308316f Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-11-11 10:44:16 +00:00
Madalina Raicu 3f3c0e18ab Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-11-08 16:14:53 +00:00
Madalina Raicu 29e7a9de03 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-11-08 10:11:34 +00:00
Madalina Raicu 8b4d8895fc Merge branches 'develop' and 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-11-07 10:28:44 +00:00
Madalina Raicu 36b2f9a5a9 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-11-06 12:56:19 +00:00
Madalina Raicu 962f5041ec Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-11-04 11:56:17 +00:00
Madalina Raicu 2c881cf35e Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-11-02 16:25:45 +00:00
Madalina Raicu 94c6bdf234 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-11-01 11:26:55 +00:00
Madalina Raicu 0855d3bae6 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-10-28 11:03:07 +01:00
Madalina Raicu 2fcee815e5 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-10-27 15:01:57 +01:00
Madalina Raicu 3aab601180 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-10-26 15:35:12 +01:00
Madalina Raicu 8561c1d0bc Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-10-26 10:34:30 +01:00
Madalina Raicu e0f5f43777 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-10-25 08:00:09 +01:00
Madalina Raicu 81ff3ceff0 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-10-23 00:38:55 +01:00
Madalina Raicu 5f9287a220 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-10-21 16:20:36 +01:00
Madalina Raicu 76827b239a Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-10-18 13:25:22 +01:00
Madalina Raicu 464b964cba Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-10-12 15:42:39 +01:00
Madalina Raicu 2c0287be32 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-10-10 09:28:15 +01:00
Madalina Raicu 0f60018ab4 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-10-07 16:36:10 +01:00
Madalina Raicu 934d75643f Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-10-05 21:24:40 +01:00
Madalina Raicu 1eb8565739 Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into develop 2022-10-05 17:36:48 +01:00
4 changed files with 21 additions and 48 deletions
@@ -41,11 +41,6 @@ describe('positions', { tags: '@smoke' }, () => {
cy.getByTestId('flash-cell').each(($prices) => {
cy.wrap($prices).invoke('text').should('not.be.empty');
});
cy.get('[col-id="liquidationPrice"]')
.should('contain.text', '85,093.38') // entry price
.should('contain.text', '0.00'); // liquidation price
cy.get('[col-id="currentLeverage"]').should('contain.text', '0.8');
cy.get('[col-id="marginAccountBalance"]') // margin allocated
@@ -92,7 +92,7 @@ it('add color and sign to amount, displays positive notional value', async () =>
expect(cells[2].classList.contains('text-vega-green-dark')).toBeTruthy();
expect(cells[2].classList.contains('text-vega-red-dark')).toBeFalsy();
expect(cells[2].textContent).toEqual('+100');
expect(cells[1].textContent).toEqual('123.00');
expect(cells[1].textContent).toEqual('1,230');
await act(async () => {
result.rerender(
<PositionsTable rowData={[{ ...singleRow, openVolume: '-100' }]} />
@@ -102,7 +102,7 @@ it('add color and sign to amount, displays positive notional value', async () =>
expect(cells[2].classList.contains('text-vega-green-dark')).toBeFalsy();
expect(cells[2].classList.contains('text-vega-red-dark')).toBeTruthy();
expect(cells[2].textContent?.startsWith('-100')).toBeTruthy();
expect(cells[1].textContent).toEqual('123.00');
expect(cells[1].textContent).toEqual('1,230');
});
it('displays mark price', async () => {
@@ -172,7 +172,7 @@ it('displays allocated margin', async () => {
});
const cells = screen.getAllByRole('gridcell');
const cell = cells[8];
expect(cell.textContent).toEqual('123,456.00');
expect(cell.textContent).toEqual('123,456');
});
it('displays realised and unrealised PNL', async () => {
+16 -40
View File
@@ -14,7 +14,7 @@ import type {
import { EmptyCell, ProgressBarCell } from '@vegaprotocol/ui-toolkit';
import {
PriceFlashCell,
addDecimalsFormatNumber,
addDecimalsNormalizeNumber,
volumePrefix,
t,
toBigNum,
@@ -72,11 +72,11 @@ export const AmountCell = ({ valueFormatted }: AmountCellProps) => {
className={classNames('text-right', signedNumberCssClass(openVolume))}
>
{volumePrefix(
addDecimalsFormatNumber(openVolume, positionDecimalPlaces)
addDecimalsNormalizeNumber(openVolume, positionDecimalPlaces)
)}
</div>
<div className="text-right">
{addDecimalsFormatNumber(notional, marketDecimalPlaces)}
{addDecimalsNormalizeNumber(notional, marketDecimalPlaces)}
</div>
</div>
) : null;
@@ -116,8 +116,8 @@ const progressBarValueFormatter = ({
const mid = BigInt(data.markPrice);
const range = max - min;
return {
low: addDecimalsFormatNumber(min.toString(), data.marketDecimalPlaces),
high: addDecimalsFormatNumber(max.toString(), data.marketDecimalPlaces),
low: addDecimalsNormalizeNumber(min.toString(), data.marketDecimalPlaces),
high: addDecimalsNormalizeNumber(max.toString(), data.marketDecimalPlaces),
value: range ? Number(((mid - min) * BigInt(100)) / range) : 0,
intent: data.lowMarginLevel ? Intent.Warning : undefined,
};
@@ -173,14 +173,17 @@ export const PositionsTable = forwardRef<AgGridReact, Props>(
}: VegaValueGetterParams<Position, 'notional'>) => {
return data?.notional === undefined
? undefined
: toBigNum(data?.notional, data.decimals).toNumber();
: toBigNum(data?.notional, data.marketDecimalPlaces).toNumber();
}}
valueFormatter={({
data,
}: VegaValueFormatterParams<Position, 'notional'>) => {
return !data
? undefined
: addDecimalsFormatNumber(data.notional, data.decimals);
: addDecimalsNormalizeNumber(
data.notional,
data.marketDecimalPlaces
);
}}
/>
<AgGridColumn
@@ -205,7 +208,7 @@ export const PositionsTable = forwardRef<AgGridReact, Props>(
return data?.openVolume === undefined
? undefined
: volumePrefix(
addDecimalsFormatNumber(
addDecimalsNormalizeNumber(
data.openVolume,
data.positionDecimalPlaces
)
@@ -246,7 +249,7 @@ export const PositionsTable = forwardRef<AgGridReact, Props>(
) {
return '-';
}
return addDecimalsFormatNumber(
return addDecimalsNormalizeNumber(
data.markPrice,
data.marketDecimalPlaces
);
@@ -284,39 +287,12 @@ export const PositionsTable = forwardRef<AgGridReact, Props>(
if (!data || node?.rowPinned) {
return undefined;
}
return addDecimalsFormatNumber(
return addDecimalsNormalizeNumber(
data.averageEntryPrice,
data.marketDecimalPlaces
);
}}
/>
<AgGridColumn
headerName={t('Liquidation price (est)')}
field="liquidationPrice"
flex={2}
headerTooltip={t(
'Liquidation prices are based on the amount of collateral you have available, the risk of your position and the liquidity on the order book. They can change rapidly based on the profit and loss of your positions and any changes to collateral from opening/closing other positions and making deposits/withdrawals.'
)}
filter="agNumberColumnFilter"
valueGetter={({
data,
}: VegaValueGetterParams<Position, 'liquidationPrice'>) => {
return !data
? undefined
: toBigNum(
data?.liquidationPrice,
data.marketDecimalPlaces
).toNumber();
}}
cellRendererSelector={(
params: ICellRendererParams
): CellRendererSelectorResult => {
return {
component: params.node.rowPinned ? EmptyCell : ProgressBarCell,
};
}}
valueFormatter={progressBarValueFormatter}
/>
<AgGridColumn
headerName={t('Leverage')}
field="currentLeverage"
@@ -363,7 +339,7 @@ export const PositionsTable = forwardRef<AgGridReact, Props>(
if (!data || node?.rowPinned) {
return undefined;
}
return addDecimalsFormatNumber(
return addDecimalsNormalizeNumber(
data.marginAccountBalance,
data.decimals
);
@@ -387,7 +363,7 @@ export const PositionsTable = forwardRef<AgGridReact, Props>(
}: VegaValueFormatterParams<Position, 'realisedPNL'>) => {
return !data
? undefined
: addDecimalsFormatNumber(data.realisedPNL, data.decimals);
: addDecimalsNormalizeNumber(data.realisedPNL, data.decimals);
}}
cellRenderer="PriceFlashCell"
headerTooltip={t(
@@ -412,7 +388,7 @@ export const PositionsTable = forwardRef<AgGridReact, Props>(
}: VegaValueFormatterParams<Position, 'unrealisedPNL'>) =>
!data
? undefined
: addDecimalsFormatNumber(data.unrealisedPNL, data.decimals)
: addDecimalsNormalizeNumber(data.unrealisedPNL, data.decimals)
}
cellRenderer="PriceFlashCell"
headerTooltip={t(
@@ -33,6 +33,8 @@ export const getSummaryRowData = (positions: Position[]) => {
realisedPNL: summaryRow.realisedPNL.toString(),
unrealisedPNL: summaryRow.unrealisedPNL.toString(),
decimals,
marketDecimalPlaces: positions[0]?.marketDecimalPlaces || 0,
positionDecimalPlaces: positions[0]?.positionDecimalPlaces || 0,
};
};