From 4eb6e09bd49f8d78b9c628c9855cd8ef2eb88020 Mon Sep 17 00:00:00 2001
From: "m.ray" <16125548+MadalinaRaicu@users.noreply.github.com>
Date: Mon, 27 Feb 2023 13:04:13 -0500
Subject: [PATCH] fix(trading): condense deal ticket & market info price range
snags (#3012)
---
.../app/components/markets/market-details.tsx | 5 +-
libs/assets/src/lib/asset-details-dialog.tsx | 2 +-
.../deal-ticket/deal-ticket-button.tsx | 2 +-
.../deal-ticket/deal-ticket-fee-details.tsx | 2 +-
.../deal-ticket/deal-ticket-limit-amount.tsx | 2 +-
.../deal-ticket/deal-ticket-market-amount.tsx | 4 +-
.../components/deal-ticket/deal-ticket.tsx | 12 +-
.../components/market-info/info-market.tsx | 110 ++++++++++--------
.../src/lib/format/number.spec.tsx | 18 +++
.../src/components/form-group/form-group.tsx | 2 +-
.../key-value-table/key-value-table.tsx | 6 +-
11 files changed, 96 insertions(+), 69 deletions(-)
diff --git a/apps/explorer/src/app/components/markets/market-details.tsx b/apps/explorer/src/app/components/markets/market-details.tsx
index 405f354a9..2b642a6d3 100644
--- a/apps/explorer/src/app/components/markets/market-details.tsx
+++ b/apps/explorer/src/app/components/markets/market-details.tsx
@@ -184,9 +184,8 @@ export const MarketDetails = ({
content: (
<>
- {`For liquidity orders count towards a commitment they have to be
- within either the liquidity or price monitoring bounds (whichever is
- tighter).`}
+ {`For liquidity orders to count towards a commitment, they must be
+ within the liquidity monitoring bounds.`}
{`The liquidity price range is a ${liquidityPriceRange} difference from the mid
diff --git a/libs/assets/src/lib/asset-details-dialog.tsx b/libs/assets/src/lib/asset-details-dialog.tsx
index 4c581df8f..a45789b3a 100644
--- a/libs/assets/src/lib/asset-details-dialog.tsx
+++ b/libs/assets/src/lib/asset-details-dialog.tsx
@@ -98,7 +98,7 @@ export const AssetDetailsDialog = ({
}}
>
{content}
-
+
{t(
'There is 1 unit of the settlement asset (%s) to every 1 quote unit.',
[assetSymbol]
diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-button.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-button.tsx
index 5960612bd..1eae3d5a6 100644
--- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-button.tsx
+++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-button.tsx
@@ -12,7 +12,7 @@ export const DealTicketButton = ({ disabled, variant }: Props) => {
const { pubKey, isReadOnly } = useVegaWallet();
const isDisabled = !pubKey || isReadOnly || disabled;
return (
-
+
{details.map(({ label, value, labelDescription, symbol }) => (
diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-limit-amount.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-limit-amount.tsx
index f990b2a26..31136e5c2 100644
--- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-limit-amount.tsx
+++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-limit-amount.tsx
@@ -38,7 +38,7 @@ export const DealTicketLimitAmount = ({
};
return (
-
+
+
-
Size
+
{t('Size')}
{isMarketInAuction(marketData.marketTradingMode) && (
diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx
index ac7848783..0b0aaefa0 100644
--- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx
+++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx
@@ -307,7 +307,7 @@ const SummaryMessage = memo(
);
if (isReadOnly) {
return (
-
+
{
'You need to connect your own wallet to start trading on this market'
@@ -318,7 +318,7 @@ const SummaryMessage = memo(
}
if (!pubKey) {
return (
-
+
+
+
{errorMessage}
@@ -368,7 +368,7 @@ const SummaryMessage = memo(
// balance render the margin warning, but still allow submission
if (balanceError) {
return (
-
+
;
);
@@ -383,7 +383,7 @@ const SummaryMessage = memo(
].includes(marketData.marketTradingMode)
) {
return (
-
+
{
}}
decimalPlaces={market.decimalPlaces}
/>
-
+
{t(
'There is 1 unit of the settlement asset (%s) to every 1 quote unit (%s).',
[assetSymbol, quoteUnit]
@@ -249,7 +249,7 @@ export const Info = ({ market, onSelect }: InfoProps) => {
dtClassName="text-black dark:text-white text-ui !px-0 !font-normal"
ddClassName="text-black dark:text-white text-ui !px-0 !font-normal max-w-full"
/>
-
+
{t(
'There is 1 unit of the settlement asset (%s) to every 1 quote unit (%s).',
[assetSymbol, quoteUnit]
@@ -309,27 +309,40 @@ export const Info = ({ market, onSelect }: InfoProps) => {
),
},
...(market.priceMonitoringSettings?.parameters?.triggers || []).map(
- (trigger, i) => ({
- title: t(`Price monitoring trigger ${i + 1}`),
- content: ,
- })
+ (trigger, i) => {
+ const bounds = market.data?.priceMonitoringBounds?.[i];
+ return {
+ title: t(`Price monitoring bounds ${i + 1}`),
+ content: (
+
+
+
+ {t('%s% probability of trading', [
+ formatNumber(trigger.probability * 100),
+ ])}
+
+
+ {t('Within %s seconds', [formatNumber(trigger.horizonSecs)])}
+
+
+
+ {bounds && (
+
+ )}
+
+
+ ),
+ };
+ }
),
- ...(market.data?.priceMonitoringBounds || []).map((trigger, i) => ({
- title: t(`Price monitoring bound ${i + 1}`),
- content: (
- <>
-
-
- >
- ),
- })),
{
title: t('Liquidity monitoring parameters'),
content: (
@@ -369,37 +382,38 @@ export const Info = ({ market, onSelect }: InfoProps) => {
content: (
<>
- {`For liquidity orders count towards a commitment they have to be
- within either the liquidity or price monitoring bounds (whichever is
- tighter).`}
+ {`For liquidity orders to count towards a commitment, they must be
+ within the liquidity monitoring bounds.`}
{`The liquidity price range is a ${liquidityPriceRange} difference from the mid
price.`}
-
+
+
+
>
),
},
diff --git a/libs/react-helpers/src/lib/format/number.spec.tsx b/libs/react-helpers/src/lib/format/number.spec.tsx
index 0dccbc44b..21a6bdb4d 100644
--- a/libs/react-helpers/src/lib/format/number.spec.tsx
+++ b/libs/react-helpers/src/lib/format/number.spec.tsx
@@ -6,6 +6,7 @@ import {
formatNumber,
formatNumberPercentage,
isNumeric,
+ toDecimal,
toNumberParts,
} from './number';
@@ -197,3 +198,20 @@ describe('compactNumber', () => {
}
);
});
+
+describe('toDecimal', () => {
+ it.each([
+ { v: 0, o: '1' },
+ { v: 1, o: '0.1' },
+ { v: 2, o: '0.01' },
+ { v: 3, o: '0.001' },
+ { v: 4, o: '0.0001' },
+ { v: 5, o: '0.00001' },
+ { v: 6, o: '0.000001' },
+ { v: 7, o: '0.0000001' },
+ { v: 8, o: '0.00000001' },
+ { v: 9, o: '0.000000001' },
+ ])('formats with toNumber given number correctly', ({ v, o }) => {
+ expect(toDecimal(v)).toStrictEqual(o);
+ });
+});
diff --git a/libs/ui-toolkit/src/components/form-group/form-group.tsx b/libs/ui-toolkit/src/components/form-group/form-group.tsx
index 0ad57fc65..1242aea9f 100644
--- a/libs/ui-toolkit/src/components/form-group/form-group.tsx
+++ b/libs/ui-toolkit/src/components/form-group/form-group.tsx
@@ -20,7 +20,7 @@ export const FormGroup = ({
labelAlign = 'left',
hideLabel = false,
}: FormGroupProps) => {
- const wrapperClasses = classNames('relative mb-6', className);
+ const wrapperClasses = classNames('relative mb-2', className);
const labelClasses = classNames('block mb-2 text-sm', {
'text-right': labelAlign === 'right',
'sr-only': hideLabel,
diff --git a/libs/ui-toolkit/src/components/key-value-table/key-value-table.tsx b/libs/ui-toolkit/src/components/key-value-table/key-value-table.tsx
index 639cbaf57..c46a3183d 100644
--- a/libs/ui-toolkit/src/components/key-value-table/key-value-table.tsx
+++ b/libs/ui-toolkit/src/components/key-value-table/key-value-table.tsx
@@ -24,11 +24,7 @@ export const KeyValueTable = ({
return (
{title && {title} }
-
+
{children &&
React.Children.map(