chore: add tick size to info panel, move determine func to utils

This commit is contained in:
asiaznik 2024-03-06 14:13:44 +01:00
parent 513cebbcfc
commit 08b31ea43e
No known key found for this signature in database
GPG Key ID: 4D5C8972A02C52C2
10 changed files with 20 additions and 9 deletions

View File

@ -1,7 +1,7 @@
import { Controller, type Control } from 'react-hook-form';
import type { Market } from '@vegaprotocol/markets';
import type { OrderFormValues } from '../../hooks/use-form-values';
import { toDecimal, useValidateAmount } from '@vegaprotocol/utils';
import { determinePriceStep, useValidateAmount } from '@vegaprotocol/utils';
import {
TradingFormGroup,
TradingInputError,
@ -12,7 +12,6 @@ import {
Pill,
} from '@vegaprotocol/ui-toolkit';
import { useT } from '../../use-t';
import { determinePriceStep } from '../../utils/step';
export interface DealTicketPriceTakeProfitStopLossProps {
control: Control<OrderFormValues>;

View File

@ -9,7 +9,7 @@ import {
Tooltip,
} from '@vegaprotocol/ui-toolkit';
import { useT } from '../../use-t';
import { determineSizeStep } from '../../utils/step';
import { determineSizeStep } from '@vegaprotocol/utils';
export interface DealTicketSizeIcebergProps {
control: Control<OrderFormValues>;

View File

@ -58,7 +58,7 @@ import { KeyValue } from './key-value';
import { useDataProvider } from '@vegaprotocol/data-provider';
import { stopOrdersProvider } from '@vegaprotocol/orders';
import { useT } from '../../use-t';
import { determinePriceStep, determineSizeStep } from '../../utils/step';
import { determinePriceStep, determineSizeStep } from '@vegaprotocol/utils';
export interface StopOrderProps {
market: Market;

View File

@ -81,7 +81,7 @@ import { DocsLinks } from '@vegaprotocol/environment';
import { useT } from '../../use-t';
import { DealTicketPriceTakeProfitStopLoss } from './deal-ticket-price-tp-sl';
import uniqueId from 'lodash/uniqueId';
import { determinePriceStep, determineSizeStep } from '../../utils/step';
import { determinePriceStep, determineSizeStep } from '@vegaprotocol/utils';
export const REDUCE_ONLY_TOOLTIP =
'"Reduce only" will ensure that this order will not increase the size of an open position. When the order is matched, it will only trade enough volume to bring your open volume towards 0 but never change the direction of your position. If applied to a limit order that is not instantly filled, the order will be stopped.';

View File

@ -20,5 +20,11 @@
"jest.config.ts",
"__mocks__"
],
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
"include": [
"**/*.js",
"**/*.jsx",
"**/*.ts",
"**/*.tsx",
"../utils/src/lib/step.ts"
]
}

View File

@ -139,6 +139,7 @@ query MarketInfo($marketId: ID!) {
id
decimalPlaces
positionDecimalPlaces
tickSize
state
tradingMode
linearSlippageFactor

File diff suppressed because one or more lines are too long

View File

@ -23,6 +23,7 @@ import {
} from '@vegaprotocol/ui-toolkit';
import {
addDecimalsFormatNumber,
determinePriceStep,
formatNumber,
formatNumberPercentage,
getDateTimeFormat,
@ -320,6 +321,7 @@ export const KeyDetailsInfoPanel = ({
marketDecimalPlaces: market.decimalPlaces,
positionDecimalPlaces: market.positionDecimalPlaces,
settlementAssetDecimalPlaces: assetDecimals,
tickSize: determinePriceStep(market),
}
: {
name: market.tradableInstrument.instrument.name,
@ -330,6 +332,7 @@ export const KeyDetailsInfoPanel = ({
marketDecimalPlaces: market.decimalPlaces,
positionDecimalPlaces: market.positionDecimalPlaces,
settlementAssetDecimalPlaces: assetDecimals,
tickSize: determinePriceStep(market),
}
}
parentData={

View File

@ -16,3 +16,4 @@ export * from './lib/validate';
export * from './lib/resolve-network-name';
export * from './lib/is-test-env';
export * from './lib/constants';
export * from './lib/step';

View File

@ -1,5 +1,5 @@
import type { Market } from '@vegaprotocol/markets';
import { toBigNum, toDecimal } from '@vegaprotocol/utils';
import type { Market } from '@vegaprotocol/types';
import { toBigNum, toDecimal } from './format';
export const determinePriceStep = (
market: Pick<Market, 'decimalPlaces' | 'tickSize'>