fix: format volume with positionDecimalPlaces

This commit is contained in:
madalinaraicu 2022-07-14 15:19:50 +03:00
parent 0662e7b5ce
commit cdd8407404
3 changed files with 12 additions and 2 deletions

View File

@ -20,6 +20,7 @@ const MARKET_QUERY = gql`
tradingMode
state
decimalPlaces
positionDecimalPlaces
data {
market {
id

View File

@ -144,6 +144,12 @@ export interface Market_market {
* GBX (pence) 1 4 GBP 0.000001 ( 0.0001p)
*/
decimalPlaces: number;
/**
* positionDecimalPlaces indicated the number of decimal places that an integer must be shifted in order to get a correct size (uint64).
* i.e. 0 means there are no fractional orders for the market, and order sizes are always whole sizes.
* 2 means sizes given as 10^2 * desired size, e.g. a desired size of 1.23 is represented as 123 in this market.
*/
positionDecimalPlaces: number;
/**
* marketData for the given market
*/

View File

@ -11,7 +11,7 @@ import { TradesContainer } from '@vegaprotocol/trades';
import { PositionsContainer } from '@vegaprotocol/positions';
import { OrderbookContainer } from '@vegaprotocol/market-depth';
import type { Market_market } from './__generated__/Market';
import { formatNumber, t } from '@vegaprotocol/react-helpers';
import { addDecimalsFormatNumber, t } from '@vegaprotocol/react-helpers';
import { AccountsContainer } from '@vegaprotocol/accounts';
import { DepthChartContainer } from '@vegaprotocol/market-depth';
import { CandlesChartContainer } from '@vegaprotocol/candles-chart';
@ -89,7 +89,10 @@ export const TradeMarketHeader = ({
<span className={itemClassName}>Volume</span>
<span data-testid="trading-volume" className={itemValueClassName}>
{market.data && market.data.indicativeVolume !== '0'
? formatNumber(market.data.indicativeVolume)
? addDecimalsFormatNumber(
market.data.indicativeVolume,
market.positionDecimalPlaces
)
: '-'}
</span>
</div>