From d9dc43b359b5ef33208cc8acde1c275426102eb7 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Mon, 20 Nov 2023 13:57:18 -0800 Subject: [PATCH] chore(deal-ticket): re-enable margin estimates for perps (#5317) --- .../deal-ticket/deal-ticket-fee-details.tsx | 189 ++++++++---------- 1 file changed, 87 insertions(+), 102 deletions(-) diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-fee-details.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-fee-details.tsx index e7b2cfb10f..f94a5c67dd 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-fee-details.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-fee-details.tsx @@ -1,6 +1,6 @@ import { useCallback, useState } from 'react'; import { t } from '@vegaprotocol/i18n'; -import { getAsset, getProductType, getQuoteName } from '@vegaprotocol/markets'; +import { getAsset, getQuoteName } from '@vegaprotocol/markets'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; import { useVegaWallet } from '@vegaprotocol/wallet'; @@ -151,6 +151,7 @@ export const DealTicketMarginDetails = ({ const { decimals: assetDecimals, quantum } = asset; let marginRequiredBestCase: string | undefined = undefined; let marginRequiredWorstCase: string | undefined = undefined; + if (marginEstimate) { if (currentMargins) { marginRequiredBestCase = ( @@ -286,115 +287,99 @@ export const DealTicketMarginDetails = ({ ); const quoteName = getQuoteName(market); - const productType = getProductType(market); return (
- {/* - TODO: remove this conditional check once the following PRs are deployed - and the estimatePosition query is working for perps + + +
+
+ + {t('Margin required')} + - - https://github.com/vegaprotocol/vega/pull/10119 - - https://github.com/vegaprotocol/vega/pull/10122 - */} - {productType === 'Future' && ( - <> - - +
+ -
-
- - - {t('Margin required')} - - - - -
- -
- {formatValue( - marginRequiredWorstCase, - assetDecimals, - quantum - )}{' '} - {assetSymbol || ''} -
-
-
- - } - > -
- + {formatValue( + marginRequiredWorstCase, assetDecimals, quantum - ), - assetSymbol - )} - /> - {deductionFromCollateral} - setBreakdownDialog(true) - : undefined - } - value={formatValue(marginAccountBalance, assetDecimals)} - symbol={assetSymbol} - labelDescription={MARGIN_ACCOUNT_TOOLTIP_TEXT} - formattedValue={formatValue( - marginAccountBalance, - assetDecimals, - quantum - )} - /> + )}{' '} + {assetSymbol || ''} +
+
-
-
- {projectedMargin} - - )} + + } + > +
+ + {deductionFromCollateral} + setBreakdownDialog(true) + : undefined + } + value={formatValue(marginAccountBalance, assetDecimals)} + symbol={assetSymbol} + labelDescription={MARGIN_ACCOUNT_TOOLTIP_TEXT} + formattedValue={formatValue( + marginAccountBalance, + assetDecimals, + quantum + )} + /> +
+ + + {projectedMargin}