From 09bbc757299a4efe8cd0725123f6574ee1aa7a87 Mon Sep 17 00:00:00 2001 From: Madalina Raicu Date: Thu, 23 Feb 2023 17:50:04 +0000 Subject: [PATCH] fix(trading): padding and wording snags --- .../app/components/markets/market-details.tsx | 5 +- libs/assets/src/lib/asset-details-dialog.tsx | 2 +- .../components/market-info/info-market.tsx | 112 ++++++++++-------- .../src/lib/format/number.spec.tsx | 11 ++ .../key-value-table/key-value-table.tsx | 2 +- 5 files changed, 79 insertions(+), 53 deletions(-) diff --git a/apps/explorer/src/app/components/markets/market-details.tsx b/apps/explorer/src/app/components/markets/market-details.tsx index 1d38f65c9..fff83a7ef 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..13a91d23f 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/market-info/src/components/market-info/info-market.tsx b/libs/market-info/src/components/market-info/info-market.tsx index adaf87513..d8a549452 100644 --- a/libs/market-info/src/components/market-info/info-market.tsx +++ b/libs/market-info/src/components/market-info/info-market.tsx @@ -145,7 +145,7 @@ export const Info = ({ market, onSelect }: InfoProps) => { }} 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,42 @@ 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), + formatNumber(trigger.horizonSecs), + ])} +

+

+ {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 +384,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..866c7a9e6 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,13 @@ describe('compactNumber', () => { } ); }); + +describe('toDecimal', () => { + it.each([ + { v: 7, o: '0.0000001' }, + { v: 8, o: '0.00000001' }, + { v: 0, o: '0' }, + ])('formats with toNumber given number correctly', ({ v, o }) => { + expect(toDecimal(v)).toStrictEqual(o); + }); +}); 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 8906d6a58..e94f5934d 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 @@ -22,7 +22,7 @@ export const KeyValueTable = ({ return ( {title && {title}} -
+
{children && React.Children.map(