From c0652e963d92c8612bae37cdadc627a9cb1a1bc5 Mon Sep 17 00:00:00 2001 From: mulan xia Date: Fri, 26 Apr 2024 15:24:46 -0400 Subject: [PATCH 1/8] update flags --- package.json | 2 +- pnpm-lock.yaml | 8 +-- public/configs/env.json | 60 ++++++++++++++----- public/configs/v1/env.json | 60 ++++++++++++++----- src/hooks/useEnvFeatures.ts | 2 + src/lib/orders.ts | 10 ++-- src/lib/testFlags.ts | 8 --- src/state/accountCalculators.ts | 6 +- src/state/accountSelectors.ts | 55 +++++++++-------- src/views/dialogs/PreferencesDialog.tsx | 5 +- .../TriggersForm/AdvancedTriggersOptions.tsx | 7 +-- src/views/tables/PositionsTable.tsx | 18 ++++-- .../PositionsTable/PositionsActionsCell.tsx | 6 +- .../PositionsTable/PositionsTriggersCell.tsx | 11 ++-- 14 files changed, 166 insertions(+), 92 deletions(-) diff --git a/package.json b/package.json index 60a1832a3..54e180216 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@cosmjs/tendermint-rpc": "^0.32.1", "@dydxprotocol/v4-abacus": "^1.6.48", "@dydxprotocol/v4-client-js": "^1.1.7", - "@dydxprotocol/v4-localization": "^1.1.71", + "@dydxprotocol/v4-localization": "^1.1.72", "@ethersproject/providers": "^5.7.2", "@js-joda/core": "^5.5.3", "@privy-io/react-auth": "^1.59.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 72870980f..3998009fa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,8 +36,8 @@ dependencies: specifier: ^1.1.7 version: 1.1.7 '@dydxprotocol/v4-localization': - specifier: ^1.1.71 - version: 1.1.71 + specifier: ^1.1.72 + version: 1.1.73 '@ethersproject/providers': specifier: ^5.7.2 version: 5.7.2 @@ -1623,8 +1623,8 @@ packages: - utf-8-validate dev: false - /@dydxprotocol/v4-localization@1.1.71: - resolution: {integrity: sha512-7VBiqmzoiQ8zWmlEsDAp7hQD2CPytyS70HmsC0lEkHhHXE+0wRKkFUybxCLG00y9Qof0P6AdPfMyX2jWGNDXkA==} + /@dydxprotocol/v4-localization@1.1.73: + resolution: {integrity: sha512-504ldIA1hvjgt3WbBgMK3qMdfd8L1fIknw04tjCVMwxP/5wtRrnuRipFThKMyIUNmgNf4jOyBzb8PzBN4+HJMQ==} dev: false /@dydxprotocol/v4-proto@5.0.0-dev.0: diff --git a/public/configs/env.json b/public/configs/env.json index f8ad38d6a..17a3a53cc 100644 --- a/public/configs/env.json +++ b/public/configs/env.json @@ -129,7 +129,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-dev-2": { @@ -216,7 +218,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-dev-4": { @@ -304,7 +308,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-dev-5": { @@ -391,7 +397,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-staging": { @@ -480,7 +488,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-staging-forced-update": { @@ -567,7 +577,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-staging-west": { @@ -656,7 +668,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet": { @@ -749,7 +763,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet-dydx": { @@ -839,7 +855,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet-nodefleet": { @@ -929,7 +947,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet-kingnodes": { @@ -1019,7 +1039,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet-liquify": { @@ -1109,7 +1131,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet-polkachu": { @@ -1190,7 +1214,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet-bware": { @@ -1280,7 +1306,9 @@ "featureFlags": { "reduceOnlySupported": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-mainnet": { @@ -1369,7 +1397,9 @@ }, "featureFlags": { "reduceOnlySupported": false, - "withdrawalSafetyEnabled": false + "withdrawalSafetyEnabled": false, + "isSlTpEnabled": false, + "isSlTpLimitOrdersEnabled": false } } } diff --git a/public/configs/v1/env.json b/public/configs/v1/env.json index a3834bc47..829872d3c 100644 --- a/public/configs/v1/env.json +++ b/public/configs/v1/env.json @@ -271,7 +271,9 @@ "usePessimisticCollateralCheck": false, "useOptimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-dev-2": { @@ -300,7 +302,9 @@ "usePessimisticCollateralCheck": false, "useOptimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-dev-4": { @@ -330,7 +334,9 @@ "usePessimisticCollateralCheck": false, "useOptimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-dev-5": { @@ -359,7 +365,9 @@ "usePessimisticCollateralCheck": false, "useOptimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-staging": { @@ -389,7 +397,9 @@ "usePessimisticCollateralCheck": false, "useOptimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-staging-forced-update": { @@ -426,7 +436,9 @@ "usePessimisticCollateralCheck": false, "useOptimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-staging-west": { @@ -456,7 +468,9 @@ "usePessimisticCollateralCheck": false, "useOptimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet": { @@ -490,7 +504,9 @@ "usePessimisticCollateralCheck": false, "useOptimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet-dydx": { @@ -519,7 +535,9 @@ "reduceOnlySupported": true, "usePessimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet-nodefleet": { @@ -549,7 +567,9 @@ "usePessimisticCollateralCheck": false, "useOptimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet-kingnodes": { @@ -578,7 +598,9 @@ "reduceOnlySupported": true, "usePessimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet-liquify": { @@ -608,7 +630,9 @@ "usePessimisticCollateralCheck": false, "useOptimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet-polkachu": { @@ -638,7 +662,9 @@ "usePessimisticCollateralCheck": false, "useOptimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-testnet-bware": { @@ -668,7 +694,9 @@ "usePessimisticCollateralCheck": false, "useOptimisticCollateralCheck": true, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": true, + "isSlTpLimitOrdersEnabled": false } }, "dydxprotocol-mainnet": { @@ -698,7 +726,9 @@ "usePessimisticCollateralCheck": true, "useOptimisticCollateralCheck": false, "withdrawalSafetyEnabled": true, - "CCTPWithdrawalOnly": true + "CCTPWithdrawalOnly": true, + "isSlTpEnabled": false, + "isSlTpLimitOrdersEnabled": false } } } diff --git a/src/hooks/useEnvFeatures.ts b/src/hooks/useEnvFeatures.ts index 8b68f4d84..5ba48f343 100644 --- a/src/hooks/useEnvFeatures.ts +++ b/src/hooks/useEnvFeatures.ts @@ -8,6 +8,8 @@ export interface EnvironmentFeatures { reduceOnlySupported: boolean; withdrawalSafetyEnabled: boolean; CCTPWithdrawalOnly: boolean; + isSlTpEnabled: boolean; + isSlTpLimitOrdersEnabled: boolean; } export const useEnvFeatures = (): EnvironmentFeatures => { diff --git a/src/lib/orders.ts b/src/lib/orders.ts index da7ce85c6..3614edeb9 100644 --- a/src/lib/orders.ts +++ b/src/lib/orders.ts @@ -19,8 +19,6 @@ import { IconName } from '@/components/Icon'; import { convertAbacusOrderSide } from '@/lib/abacus/conversions'; import { MustBigNumber } from '@/lib/numbers'; -import { testFlags } from './testFlags'; - export const getStatusIconInfo = ({ status, totalFilled, @@ -95,15 +93,15 @@ export const isLimitOrderType = (type?: AbacusOrderTypes) => ({ ordinal }) => ordinal === type.ordinal ); -export const isStopLossOrder = (order: SubaccountOrder) => { - const validOrderTypes = testFlags.enableConditionalLimitOrders +export const isStopLossOrder = (order: SubaccountOrder, isSlTpLimitOrdersEnabled: boolean) => { + const validOrderTypes = isSlTpLimitOrdersEnabled ? [AbacusOrderType.stopLimit, AbacusOrderType.stopMarket] : [AbacusOrderType.stopMarket]; return validOrderTypes.some(({ ordinal }) => ordinal === order.type.ordinal) && order.reduceOnly; }; -export const isTakeProfitOrder = (order: SubaccountOrder) => { - const validOrderTypes = testFlags.enableConditionalLimitOrders +export const isTakeProfitOrder = (order: SubaccountOrder, isSlTpLimitOrdersEnabled: boolean) => { + const validOrderTypes = isSlTpLimitOrdersEnabled ? [AbacusOrderType.takeProfitLimit, AbacusOrderType.takeProfitMarket] : [AbacusOrderType.takeProfitMarket]; return validOrderTypes.some(({ ordinal }) => ordinal === order.type.ordinal) && order.reduceOnly; diff --git a/src/lib/testFlags.ts b/src/lib/testFlags.ts index ab6bd614e..74b323d19 100644 --- a/src/lib/testFlags.ts +++ b/src/lib/testFlags.ts @@ -32,14 +32,6 @@ class TestFlags { return this.queryParams.address; } - get configureSlTpFromPositionsTable() { - return !!this.queryParams.sltp; - } - - get enableConditionalLimitOrders() { - return !!this.queryParams.sltplimit; - } - get isolatedMargin() { return !!this.queryParams.isolatedmargin; } diff --git a/src/state/accountCalculators.ts b/src/state/accountCalculators.ts index f9526b8c2..2693a2d61 100644 --- a/src/state/accountCalculators.ts +++ b/src/state/accountCalculators.ts @@ -2,6 +2,8 @@ import { createSelector } from 'reselect'; import { OnboardingState, OnboardingSteps } from '@/constants/account'; +import { useEnvFeatures } from '@/hooks/useEnvFeatures'; + import { getOnboardingGuards, getOnboardingState, @@ -9,8 +11,6 @@ import { getUncommittedOrderClientIds, } from '@/state/accountSelectors'; -import { testFlags } from '@/lib/testFlags'; - export const calculateOnboardingStep = createSelector( [getOnboardingState, getOnboardingGuards], (onboardingState: OnboardingState, onboardingGuards: ReturnType) => { @@ -92,7 +92,7 @@ export const calculateIsAccountLoading = createSelector( */ export const calculateShouldRenderTriggersInPositionsTable = createSelector( [calculateIsAccountViewOnly], - (isAccountViewOnly: boolean) => !isAccountViewOnly && testFlags.configureSlTpFromPositionsTable + (isAccountViewOnly: boolean) => !isAccountViewOnly && useEnvFeatures().isSlTpEnabled ); /** diff --git a/src/state/accountSelectors.ts b/src/state/accountSelectors.ts index 1010292b5..57a21151f 100644 --- a/src/state/accountSelectors.ts +++ b/src/state/accountSelectors.ts @@ -179,32 +179,39 @@ export const getMarketSubaccountOpenOrders = ( * @param state * @returns list of conditional orders that have not been filled or cancelled for all subaccount positions */ -export const getSubaccountConditionalOrders = createSelector( - [getMarketSubaccountOpenOrders, getOpenPositions], - (openOrdersByMarketId, positions) => { - const stopLossOrders: SubaccountOrder[] = []; - const takeProfitOrders: SubaccountOrder[] = []; - - positions?.forEach((position) => { - const orderSideForConditionalOrder = - position?.side?.current === AbacusPositionSide.LONG - ? AbacusOrderSide.sell - : AbacusOrderSide.buy; - - const conditionalOrders = openOrdersByMarketId[position.id]; - - conditionalOrders?.forEach((order: SubaccountOrder) => { - if (order.side === orderSideForConditionalOrder && isStopLossOrder(order)) { - stopLossOrders.push(order); - } else if (order.side === orderSideForConditionalOrder && isTakeProfitOrder(order)) { - takeProfitOrders.push(order); - } +export const getSubaccountConditionalOrders = (isSlTpLimitOrdersEnabled: boolean) => + createSelector( + [getMarketSubaccountOpenOrders, getOpenPositions], + (openOrdersByMarketId, positions) => { + const stopLossOrders: SubaccountOrder[] = []; + const takeProfitOrders: SubaccountOrder[] = []; + + positions?.forEach((position) => { + const orderSideForConditionalOrder = + position?.side?.current === AbacusPositionSide.LONG + ? AbacusOrderSide.sell + : AbacusOrderSide.buy; + + const conditionalOrders = openOrdersByMarketId[position.id]; + + conditionalOrders?.forEach((order: SubaccountOrder) => { + if ( + order.side === orderSideForConditionalOrder && + isStopLossOrder(order, isSlTpLimitOrdersEnabled) + ) { + stopLossOrders.push(order); + } else if ( + order.side === orderSideForConditionalOrder && + isTakeProfitOrder(order, isSlTpLimitOrdersEnabled) + ) { + takeProfitOrders.push(order); + } + }); }); - }); - return { stopLossOrders, takeProfitOrders }; - } -); + return { stopLossOrders, takeProfitOrders }; + } + ); /** * @param state diff --git a/src/views/dialogs/PreferencesDialog.tsx b/src/views/dialogs/PreferencesDialog.tsx index c2626df43..4a716e171 100644 --- a/src/views/dialogs/PreferencesDialog.tsx +++ b/src/views/dialogs/PreferencesDialog.tsx @@ -7,6 +7,7 @@ import { STRING_KEYS } from '@/constants/localization'; import { NotificationType } from '@/constants/notifications'; import { useStringGetter } from '@/hooks'; +import { useEnvFeatures } from '@/hooks'; import { useNotifications } from '@/hooks/useNotifications'; import { ComboboxDialogMenu } from '@/components/ComboboxDialogMenu'; @@ -16,11 +17,11 @@ import { OtherPreference, setDefaultToAllMarketsInPositionsOrdersFills } from '@ import { getDefaultToAllMarketsInPositionsOrdersFills } from '@/state/configsSelectors'; import { isTruthy } from '@/lib/isTruthy'; -import { testFlags } from '@/lib/testFlags'; export const usePreferenceMenu = () => { const dispatch = useDispatch(); const stringGetter = useStringGetter(); + const { isSlTpEnabled } = useEnvFeatures(); // Notifications const { notificationPreferences, setNotificationPreferences } = useNotifications(); @@ -69,7 +70,7 @@ export const usePreferenceMenu = () => { ), onSelect: () => toggleNotifPreference(NotificationType.SquidTransfer), }, - testFlags.configureSlTpFromPositionsTable && { + isSlTpEnabled && { value: NotificationType.TriggerOrder, label: stringGetter({ key: STRING_KEYS.TAKE_PROFIT_STOP_LOSS }), slotAfter: ( diff --git a/src/views/forms/TriggersForm/AdvancedTriggersOptions.tsx b/src/views/forms/TriggersForm/AdvancedTriggersOptions.tsx index 3013e0c4a..c83a99d72 100644 --- a/src/views/forms/TriggersForm/AdvancedTriggersOptions.tsx +++ b/src/views/forms/TriggersForm/AdvancedTriggersOptions.tsx @@ -2,14 +2,12 @@ import styled, { AnyStyledComponent } from 'styled-components'; import { STRING_KEYS } from '@/constants/localization'; -import { useStringGetter } from '@/hooks'; +import { useEnvFeatures, useStringGetter } from '@/hooks'; import { layoutMixins } from '@/styles/layoutMixins'; import { HorizontalSeparatorFiller } from '@/components/Separator'; -import { testFlags } from '@/lib/testFlags'; - import { LimitPriceInputs } from './LimitPriceInputs'; import { OrderSizeInput } from './OrderSizeInput'; @@ -42,6 +40,7 @@ export const AdvancedTriggersOptions = ({ className, }: ElementProps & StyleProps) => { const stringGetter = useStringGetter(); + const { isSlTpLimitOrdersEnabled } = useEnvFeatures(); return ( @@ -58,7 +57,7 @@ export const AdvancedTriggersOptions = ({ positionSize={positionSize} stepSizeDecimals={stepSizeDecimals} /> - {testFlags.enableConditionalLimitOrders && ( + {isSlTpLimitOrdersEnabled && ( void; }) => ({ width, @@ -331,7 +336,9 @@ const getPositionsTableColumnDef = ({ }, [PositionsTableColumnKey.Actions]: { columnKey: 'actions', - label: stringGetter({ key: STRING_KEYS.ACTION }), // TODO: CT-639 + label: stringGetter({ + key: shouldRenderTriggers ? STRING_KEYS.ACTIONS : STRING_KEYS.ACTION, + }), isActionable: true, allowsSorting: false, hideOnBreakpoint: MediaQueryKeys.isTablet, @@ -379,17 +386,19 @@ export const PositionsTable = ({ }: ElementProps & StyleProps) => { const stringGetter = useStringGetter(); const navigate = useNavigate(); + const { isSlTpLimitOrdersEnabled } = useEnvFeatures(); const isAccountViewOnly = useSelector(calculateIsAccountViewOnly); const perpetualMarkets = useSelector(getPerpetualMarkets, shallowEqual) || {}; const assets = useSelector(getAssets, shallowEqual) || {}; + const shouldRenderTriggers = useSelector(calculateShouldRenderTriggersInPositionsTable); const openPositions = useSelector(getExistingOpenPositions, shallowEqual) || []; const marketPosition = openPositions.find((position) => position.id == currentMarket); const positions = currentMarket ? (marketPosition ? [marketPosition] : []) : openPositions; const { stopLossOrders: allStopLossOrders, takeProfitOrders: allTakeProfitOrders } = useSelector( - getSubaccountConditionalOrders, + getSubaccountConditionalOrders(isSlTpLimitOrdersEnabled), { equalityFn: (oldVal, newVal) => { return ( @@ -436,6 +445,7 @@ export const PositionsTable = ({ width: columnWidths?.[key], isAccountViewOnly, showClosePositionAction, + shouldRenderTriggers, navigateToOrders, }) )} diff --git a/src/views/tables/PositionsTable/PositionsActionsCell.tsx b/src/views/tables/PositionsTable/PositionsActionsCell.tsx index c4b12c675..719f4421b 100644 --- a/src/views/tables/PositionsTable/PositionsActionsCell.tsx +++ b/src/views/tables/PositionsTable/PositionsActionsCell.tsx @@ -7,6 +7,8 @@ import { ButtonShape } from '@/constants/buttons'; import { DialogTypes, TradeBoxDialogTypes } from '@/constants/dialogs'; import { AppRoute } from '@/constants/routes'; +import { useEnvFeatures } from '@/hooks'; + import { IconName } from '@/components/Icon'; import { IconButton } from '@/components/IconButton'; import { ActionsTableCell } from '@/components/Table'; @@ -16,7 +18,6 @@ import { getActiveTradeBoxDialog } from '@/state/dialogsSelectors'; import { getCurrentMarketId } from '@/state/perpetualsSelectors'; import abacusStateManager from '@/lib/abacus'; -import { testFlags } from '@/lib/testFlags'; type ElementProps = { marketId: string; @@ -39,6 +40,7 @@ export const PositionsActionsCell = ({ }: ElementProps) => { const dispatch = useDispatch(); const navigate = useNavigate(); + const { isSlTpEnabled } = useEnvFeatures(); const currentMarketId = useSelector(getCurrentMarketId); const activeTradeBoxDialog = useSelector(getActiveTradeBoxDialog); @@ -61,7 +63,7 @@ export const PositionsActionsCell = ({ return ( - {testFlags.configureSlTpFromPositionsTable && ( + {isSlTpEnabled && ( diff --git a/src/views/tables/PositionsTable/PositionsTriggersCell.tsx b/src/views/tables/PositionsTable/PositionsTriggersCell.tsx index f7bef9f6d..acbd73e18 100644 --- a/src/views/tables/PositionsTable/PositionsTriggersCell.tsx +++ b/src/views/tables/PositionsTable/PositionsTriggersCell.tsx @@ -11,7 +11,7 @@ import { ButtonAction, ButtonSize } from '@/constants/buttons'; import { DialogTypes } from '@/constants/dialogs'; import { STRING_KEYS } from '@/constants/localization'; -import { useStringGetter } from '@/hooks'; +import { useEnvFeatures, useStringGetter } from '@/hooks'; import { layoutMixins } from '@/styles/layoutMixins'; @@ -51,11 +51,12 @@ export const PositionsTriggersCell = ({ }: ElementProps) => { const stringGetter = useStringGetter(); const dispatch = useDispatch(); + const { isSlTpLimitOrdersEnabled } = useEnvFeatures(); const onViewOrders = isDisabled ? null : () => onViewOrdersClick(marketId); const showLiquidationWarning = (order: SubaccountOrder) => { - if (!isStopLossOrder(order) || !liquidationPrice) { + if (!isStopLossOrder(order, isSlTpLimitOrdersEnabled) || !liquidationPrice) { return false; } return ( @@ -148,7 +149,9 @@ export const PositionsTriggersCell = ({ align="end" side="top" hovercard={ - isStopLossOrder(order) ? 'partial-close-stop-loss' : 'partial-close-take-profit' + isStopLossOrder(order, isSlTpLimitOrdersEnabled) + ? 'partial-close-stop-loss' + : 'partial-close-take-profit' } slotButton={