From 5e5ec0e470fdd526f88ae0efedac3b54ea3af030 Mon Sep 17 00:00:00 2001 From: Madalina Raicu Date: Tue, 7 Nov 2023 17:09:02 +0000 Subject: [PATCH] feat(trading): close position stopped and IOC behaviour update --- .../src/components/deal-ticket/deal-ticket.tsx | 2 +- .../src/lib/components/order-list/order-list.tsx | 12 ++++++++++++ libs/web3/src/lib/use-vega-transaction-toasts.tsx | 13 +++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) 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 786486b16..2090fa604 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx @@ -685,7 +685,7 @@ export const DealTicket = ({ subLabel={`${formatValue( normalizedOrder.size, market.positionDecimalPlaces - )} ${baseQuote} @ ${ + )} ${baseQuote || ''} @ ${ type === Schema.OrderType.TYPE_MARKET ? 'market' : `${formatValue( diff --git a/libs/orders/src/lib/components/order-list/order-list.tsx b/libs/orders/src/lib/components/order-list/order-list.tsx index b952f36b8..1e8018e97 100644 --- a/libs/orders/src/lib/components/order-list/order-list.tsx +++ b/libs/orders/src/lib/components/order-list/order-list.tsx @@ -1,4 +1,5 @@ import { + MAXGOINT64, addDecimalsFormatNumber, getDateTimeFormat, isNumeric, @@ -144,11 +145,22 @@ export const OrderListTable = memo< if (!data?.market || !isNumeric(data.size)) { return '-'; } + const prefix = data ? data.side === Schema.Side.SIDE_BUY ? '+' : '-' : ''; + + if ( + data.size === MAXGOINT64 && + data.timeInForce === + Schema.OrderTimeInForce.TIME_IN_FORCE_IOC && + data.reduceOnly + ) { + return t('MAX'); + } + return ( prefix + addDecimalsFormatNumber( diff --git a/libs/web3/src/lib/use-vega-transaction-toasts.tsx b/libs/web3/src/lib/use-vega-transaction-toasts.tsx index af322445f..502f51b70 100644 --- a/libs/web3/src/lib/use-vega-transaction-toasts.tsx +++ b/libs/web3/src/lib/use-vega-transaction-toasts.tsx @@ -41,6 +41,7 @@ import { toBigNum, truncateByChars, formatTrigger, + MAXGOINT64, } from '@vegaprotocol/utils'; import { t } from '@vegaprotocol/i18n'; import { useAssetsMapProvider } from '@vegaprotocol/assets'; @@ -953,7 +954,19 @@ export const getVegaTransactionContentIntent = (tx: VegaStoredTxState) => { isWithdrawTransaction(tx.body) && Intent.Warning; + // Toast for an IOC should go green when it is stopped, + // because stopping an IOC once all available volume has filled is the correct behaviour (it is immediate or cancel), + // this behaviour should apply to all IOC, not just those created due to "Close position" + const intentForClosedPosition = + tx.order && + tx.order.status === Schema.OrderStatus.STATUS_STOPPED && + tx.order.timeInForce === Schema.OrderTimeInForce.TIME_IN_FORCE_IOC && + tx.order.size === MAXGOINT64 && + // isClosePositionTransaction(tx) && + Intent.Success; + const intent = + intentForClosedPosition || intentForRejectedOrder || intentForCompletedWithdrawal || intentMap[tx.status];