feat(trading): close position stopped and IOC behaviour update

This commit is contained in:
Madalina Raicu
2023-11-07 17:09:02 +00:00
parent 9233778e85
commit 5e5ec0e470
3 changed files with 26 additions and 1 deletions
@@ -685,7 +685,7 @@ export const DealTicket = ({
subLabel={`${formatValue(
normalizedOrder.size,
market.positionDecimalPlaces
)} ${baseQuote} @ ${
)} ${baseQuote || ''} @ ${
type === Schema.OrderType.TYPE_MARKET
? 'market'
: `${formatValue(
@@ -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(
@@ -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];