diff --git a/apps/trading-e2e/src/integration/market-info.cy.ts b/apps/trading-e2e/src/integration/market-info.cy.ts index 49f259db9..f6b38be3f 100644 --- a/apps/trading-e2e/src/integration/market-info.cy.ts +++ b/apps/trading-e2e/src/integration/market-info.cy.ts @@ -81,8 +81,8 @@ describe('market info is displayed', { tags: '@smoke' }, () => { 'Contract address', '0x0158031158Bb4dF2AD02eAA31e8963E84EA978a4' ); - validateMarketDataRow(8, 'Withdrawal threshold', '0.00050'); - validateMarketDataRow(9, 'Lifetime limit', '1,230.00000'); + validateMarketDataRow(8, 'Withdrawal threshold', '0.0005'); + validateMarketDataRow(9, 'Lifetime limit', '1,230'); }); it('metadata displayed', () => { @@ -184,7 +184,7 @@ describe('market info is displayed', { tags: '@smoke' }, () => { .and('contain', '/governance/market-0'); cy.getByTestId(externalLink) .eq(1) - .should('have.text', 'Propose a change to this market') + .should('have.text', 'Propose a change to market') .and('have.attr', 'href') .and('contain', '/governance/propose/update-market'); }); diff --git a/apps/trading-e2e/src/integration/trading-accounts.cy.ts b/apps/trading-e2e/src/integration/trading-accounts.cy.ts index 2b13d38b6..f66cfce08 100644 --- a/apps/trading-e2e/src/integration/trading-accounts.cy.ts +++ b/apps/trading-e2e/src/integration/trading-accounts.cy.ts @@ -28,6 +28,6 @@ describe('accounts', { tags: '@smoke' }, () => { cy.getByTestId('tab-accounts') .get(tradingAccountRowId) .find('[col-id="deposited"]') - .should('have.text', '1,000.00000'); + .should('have.text', '1,000'); }); }); diff --git a/apps/trading/components/select-market/select-market-columns.tsx b/apps/trading/components/select-market/select-market-columns.tsx index d3fae575e..2a9480e78 100644 --- a/apps/trading/components/select-market/select-market-columns.tsx +++ b/apps/trading/components/select-market/select-market-columns.tsx @@ -554,7 +554,13 @@ export const columnsPositionMarkets = ( { kind: ColumnKind.Position, value: ( -

{openVolume}

+

+ {openVolume && + addDecimalsNormalizeNumber( + openVolume, + market.positionDecimalPlaces + )} +

), className: `${cellClassNames} hidden xxl:table-cell font-mono`, onlyOnDetailed: true, diff --git a/libs/accounts/src/lib/accounts-table.spec.tsx b/libs/accounts/src/lib/accounts-table.spec.tsx index c55070156..46ef9c6e0 100644 --- a/libs/accounts/src/lib/accounts-table.spec.tsx +++ b/libs/accounts/src/lib/accounts-table.spec.tsx @@ -55,8 +55,8 @@ describe('AccountsTable', () => { const cells = await screen.findAllByRole('gridcell'); const expectedValues = [ 'tBTC', - '1,256.00000', - '1,256.00001,256.0000', + '1,256', + '1,2561,256', 'Breakdown', 'Deposit', ]; diff --git a/libs/accounts/src/lib/accounts-table.tsx b/libs/accounts/src/lib/accounts-table.tsx index 04b774c95..58f093db9 100644 --- a/libs/accounts/src/lib/accounts-table.tsx +++ b/libs/accounts/src/lib/accounts-table.tsx @@ -2,7 +2,7 @@ import { forwardRef, useState } from 'react'; import type { ValueFormatterParams } from 'ag-grid-community'; import type { Asset } from '@vegaprotocol/assets'; import { - addDecimalsFormatNumber, + addDecimalsNormalizeNumber, isNumeric, t, } from '@vegaprotocol/react-helpers'; @@ -38,8 +38,8 @@ export const progressBarValueFormatter = ({ const max = BigInt(data.deposited); const range = max > min ? max : min; return { - low: addDecimalsFormatNumber(min.toString(), data.asset.decimals, 4), - high: addDecimalsFormatNumber(mid.toString(), data.asset.decimals, 4), + low: addDecimalsNormalizeNumber(min.toString(), data.asset.decimals, 4), + high: addDecimalsNormalizeNumber(mid.toString(), data.asset.decimals, 4), value: range ? Number((min * BigInt(100)) / range) : 0, intent: Intent.Warning, }; @@ -125,7 +125,7 @@ export const AccountTable = forwardRef( data && data.asset && isNumeric(value) && - addDecimalsFormatNumber(value, data.asset.decimals) + addDecimalsNormalizeNumber(value, data.asset.decimals) } maxWidth={300} /> diff --git a/libs/accounts/src/lib/breakdown-table.spec.tsx b/libs/accounts/src/lib/breakdown-table.spec.tsx index 169188212..b9647bb37 100644 --- a/libs/accounts/src/lib/breakdown-table.spec.tsx +++ b/libs/accounts/src/lib/breakdown-table.spec.tsx @@ -51,9 +51,9 @@ describe('BreakdownTable', () => { const expectedValues = [ 'Margin', 'BTCUSD Monthly (30 Jun 2022)', - '1,256.00001,256.0000', - '1,256.00000', - '1,256.00000', + '1,2561,256', + '1,256', + '1,256', ]; cells.forEach((cell, i) => { expect(cell).toHaveTextContent(expectedValues[i]); diff --git a/libs/assets/src/lib/asset-details-dialog.spec.tsx b/libs/assets/src/lib/asset-details-dialog.spec.tsx index e7bb5ab36..f223f6822 100644 --- a/libs/assets/src/lib/asset-details-dialog.spec.tsx +++ b/libs/assets/src/lib/asset-details-dialog.spec.tsx @@ -83,8 +83,8 @@ describe('AssetDetailsDialog', () => { { key: AssetDetail.QUANTUM, value: '1' }, { key: AssetDetail.STATUS, value: 'Enabled' }, { key: AssetDetail.CONTRACT_ADDRESS, value: '0x123' }, - { key: AssetDetail.WITHDRAWAL_THRESHOLD, value: '0.050' }, - { key: AssetDetail.LIFETIME_LIMIT, value: '123,000.000' }, + { key: AssetDetail.WITHDRAWAL_THRESHOLD, value: '0.05' }, + { key: AssetDetail.LIFETIME_LIMIT, value: '123,000' }, { key: AssetDetail.INFRASTRUCTURE_FEE_ACCOUNT_BALANCE, value: '0.001', @@ -115,10 +115,10 @@ describe('AssetDetailsDialog', () => { { key: AssetDetail.DECIMALS, value: '5' }, { key: AssetDetail.QUANTUM, value: '1' }, { key: AssetDetail.STATUS, value: 'Enabled' }, - { key: AssetDetail.MAX_FAUCET_AMOUNT_MINT, value: '50,000.00000' }, + { key: AssetDetail.MAX_FAUCET_AMOUNT_MINT, value: '50,000' }, { key: AssetDetail.INFRASTRUCTURE_FEE_ACCOUNT_BALANCE, - value: '0.00000', + value: '0', }, ], ], @@ -132,10 +132,10 @@ describe('AssetDetailsDialog', () => { { key: AssetDetail.DECIMALS, value: '5' }, { key: AssetDetail.QUANTUM, value: '1' }, { key: AssetDetail.STATUS, value: 'Pending listing' }, - { key: AssetDetail.MAX_FAUCET_AMOUNT_MINT, value: '50,000.00000' }, + { key: AssetDetail.MAX_FAUCET_AMOUNT_MINT, value: '50,000' }, { key: AssetDetail.INFRASTRUCTURE_FEE_ACCOUNT_BALANCE, - value: '0.00000', + value: '0', }, ], ], @@ -149,10 +149,10 @@ describe('AssetDetailsDialog', () => { { key: AssetDetail.DECIMALS, value: '5' }, { key: AssetDetail.QUANTUM, value: '1' }, { key: AssetDetail.STATUS, value: 'Proposed' }, - { key: AssetDetail.MAX_FAUCET_AMOUNT_MINT, value: '50,000.00000' }, + { key: AssetDetail.MAX_FAUCET_AMOUNT_MINT, value: '50,000' }, { key: AssetDetail.INFRASTRUCTURE_FEE_ACCOUNT_BALANCE, - value: '0.00000', + value: '0', }, ], ], @@ -166,10 +166,10 @@ describe('AssetDetailsDialog', () => { { key: AssetDetail.DECIMALS, value: '5' }, { key: AssetDetail.QUANTUM, value: '1' }, { key: AssetDetail.STATUS, value: 'Rejected' }, - { key: AssetDetail.MAX_FAUCET_AMOUNT_MINT, value: '50,000.00000' }, + { key: AssetDetail.MAX_FAUCET_AMOUNT_MINT, value: '50,000' }, { key: AssetDetail.INFRASTRUCTURE_FEE_ACCOUNT_BALANCE, - value: '0.00000', + value: '0', }, ], ], diff --git a/libs/assets/src/lib/asset-details-table.spec.tsx b/libs/assets/src/lib/asset-details-table.spec.tsx index 656ea6552..17896214a 100644 --- a/libs/assets/src/lib/asset-details-table.spec.tsx +++ b/libs/assets/src/lib/asset-details-table.spec.tsx @@ -23,8 +23,8 @@ describe('AssetDetailsTable', () => { { key: AssetDetail.QUANTUM, value: '1' }, { key: AssetDetail.STATUS, value: 'Enabled' }, { key: AssetDetail.CONTRACT_ADDRESS, value: '0x123' }, - { key: AssetDetail.WITHDRAWAL_THRESHOLD, value: '0.050' }, - { key: AssetDetail.LIFETIME_LIMIT, value: '123,000.000' }, + { key: AssetDetail.WITHDRAWAL_THRESHOLD, value: '0.05' }, + { key: AssetDetail.LIFETIME_LIMIT, value: '123,000' }, { key: AssetDetail.INFRASTRUCTURE_FEE_ACCOUNT_BALANCE, value: '0.001', @@ -56,10 +56,10 @@ describe('AssetDetailsTable', () => { { key: AssetDetail.DECIMALS, value: '5' }, { key: AssetDetail.QUANTUM, value: '1' }, { key: AssetDetail.STATUS, value: 'Enabled' }, - { key: AssetDetail.MAX_FAUCET_AMOUNT_MINT, value: '50,000.00000' }, + { key: AssetDetail.MAX_FAUCET_AMOUNT_MINT, value: '50,000' }, { key: AssetDetail.INFRASTRUCTURE_FEE_ACCOUNT_BALANCE, - value: '0.00000', + value: '0', }, ], ], diff --git a/libs/assets/src/lib/asset-details-table.tsx b/libs/assets/src/lib/asset-details-table.tsx index e12fa31a7..9c8e347de 100644 --- a/libs/assets/src/lib/asset-details-table.tsx +++ b/libs/assets/src/lib/asset-details-table.tsx @@ -1,4 +1,4 @@ -import { addDecimalsFormatNumber, t } from '@vegaprotocol/react-helpers'; +import { addDecimalsNormalizeNumber, t } from '@vegaprotocol/react-helpers'; import type { Schema } from '@vegaprotocol/types'; import type { KeyValueTableRowProps } from '@vegaprotocol/ui-toolkit'; import { @@ -43,7 +43,7 @@ type Mapping = { [key in string]: { value: string; tooltip: string } }; const num = (asset: Asset, n: string | undefined | null) => { if (typeof n === 'undefined' || n == null) return ''; - return addDecimalsFormatNumber(n, asset.decimals); + return addDecimalsNormalizeNumber(n, asset.decimals); }; export const rows: Rows = [ diff --git a/libs/market-info/src/components/market-info/info-key-value-table.tsx b/libs/market-info/src/components/market-info/info-key-value-table.tsx index 17114f0ce..97a19cd13 100644 --- a/libs/market-info/src/components/market-info/info-key-value-table.tsx +++ b/libs/market-info/src/components/market-info/info-key-value-table.tsx @@ -1,5 +1,5 @@ import { - addDecimalsFormatNumber, + addDecimalsNormalizeNumber, formatNumber, formatNumberPercentage, t, @@ -40,8 +40,9 @@ const Row = ({ return value; } if (decimalPlaces) { - return `${parseFloat( - addDecimalsFormatNumber(value, decimalPlaces) + return `${addDecimalsNormalizeNumber( + value, + decimalPlaces )} ${assetSymbol}`; } if (asPercentage) { diff --git a/libs/market-info/src/components/market-info/info-market.tsx b/libs/market-info/src/components/market-info/info-market.tsx index e3ef4082c..a3e17a713 100644 --- a/libs/market-info/src/components/market-info/info-market.tsx +++ b/libs/market-info/src/components/market-info/info-market.tsx @@ -391,7 +391,7 @@ export const Info = ({ market, onSelect }: InfoProps) => { '' } > - {t('Propose a change to this market')} + {t('Propose a change to market')} ), diff --git a/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx b/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx index dfc36d530..2668d2e46 100644 --- a/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx +++ b/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx @@ -1,10 +1,10 @@ import { t, - addDecimalsFormatNumber, toDecimal, Size, getDateTimeFormat, addDecimal, + addDecimalsNormalizeNumber, } from '@vegaprotocol/react-helpers'; import { Schema } from '@vegaprotocol/types'; import { @@ -57,22 +57,25 @@ export const OrderEditDialog = ({ title={t('Edit order')} icon={} > -
+
{order.market && ( -
+

{t(`Market`)}

{t(`${order.market.tradableInstrument.instrument.name}`)}

)} {order.type === Schema.OrderType.TYPE_LIMIT && order.market && ( -
-

{t(`Current price`)}

+
+

{t(`Price`)}

- {addDecimalsFormatNumber(order.price, order.market.decimalPlaces)} + {addDecimalsNormalizeNumber( + order.price, + order.market.decimalPlaces + )}

)} -
+

{t(`Size`)}

{order.market && ( diff --git a/libs/positions/src/lib/close-position-dialog/requested.spec.tsx b/libs/positions/src/lib/close-position-dialog/requested.spec.tsx index c91c22af5..7bcec0946 100644 --- a/libs/positions/src/lib/close-position-dialog/requested.spec.tsx +++ b/libs/positions/src/lib/close-position-dialog/requested.spec.tsx @@ -77,7 +77,7 @@ describe('Close position dialog - Request', () => { ); const closingOrderRow = closingOrderTable.getAllByRole('row'); expect(closingOrderRow[0].children[0]).toHaveTextContent('test market'); - expect(closingOrderRow[0].children[1]).toHaveTextContent('+0.10'); + expect(closingOrderRow[0].children[1]).toHaveTextContent('+0.1'); expect(closingOrderRow[0].children[2]).toHaveTextContent('~1.00 SYM'); // orders @@ -87,13 +87,13 @@ describe('Close position dialog - Request', () => { ); const orderRows = ordersTable.getAllByRole('row'); expect(orderRows).toHaveLength(orders.length); - expect(orderRows[0].children[0]).toHaveTextContent('+2.00'); + expect(orderRows[0].children[0]).toHaveTextContent('+2'); expect(orderRows[0].children[1]).toHaveTextContent('9.99 SYM'); expect(orderRows[0].children[2]).toHaveTextContent( "Good 'til Cancelled (GTC)" ); - expect(orderRows[1].children[0]).toHaveTextContent('-3.00'); + expect(orderRows[1].children[0]).toHaveTextContent('-3'); expect(orderRows[1].children[1]).toHaveTextContent('8.88 SYM'); expect(orderRows[1].children[2]).toHaveTextContent( "Good 'til Cancelled (GTC)" diff --git a/libs/react-helpers/src/lib/grid/size.tsx b/libs/react-helpers/src/lib/grid/size.tsx index 522740d47..66dd62ac9 100644 --- a/libs/react-helpers/src/lib/grid/size.tsx +++ b/libs/react-helpers/src/lib/grid/size.tsx @@ -1,7 +1,7 @@ import { Schema } from '@vegaprotocol/types'; import type { ICellRendererParams } from 'ag-grid-community'; import classNames from 'classnames'; -import { addDecimalsFormatNumber } from '../format'; +import { addDecimalsNormalizeNumber } from '../format'; export const Size = ({ value, @@ -26,7 +26,7 @@ export const Size = ({ : side === Schema.Side.SIDE_SELL ? '-' : ''} - {addDecimalsFormatNumber(value, positionDecimalPlaces)} + {addDecimalsNormalizeNumber(value, positionDecimalPlaces)} ); };