From 837c63cd282810257cc2e41256dcd48af76241e8 Mon Sep 17 00:00:00 2001 From: soulBit Date: Wed, 6 Jul 2022 16:21:58 +0100 Subject: [PATCH] Fix/limit order maintenance (#2311) * fix: checkMaintenances hook * feat: show maintenance message when margin limit locked --- src/app/hooks/useMaintenance.ts | 4 ++-- .../MarginTradePage/components/TradeForm/index.tsx | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/hooks/useMaintenance.ts b/src/app/hooks/useMaintenance.ts index fac2bf444..218d8a16a 100644 --- a/src/app/hooks/useMaintenance.ts +++ b/src/app/hooks/useMaintenance.ts @@ -78,14 +78,14 @@ export function useMaintenance() { ); const checkMaintenances = useCallback((): MaintenanceResult => { - return Object.keys(States).reduce( + return Object.keys(maintenanceStates).reduce( (res, curr) => Object.assign(res, { [curr]: checkMaintenance(curr as States), }), {} as MaintenanceResult, ); - }, [checkMaintenance]); + }, [checkMaintenance, maintenanceStates]); return useMemo(() => ({ checkMaintenance, checkMaintenances, States }), [ checkMaintenance, diff --git a/src/app/pages/MarginTradePage/components/TradeForm/index.tsx b/src/app/pages/MarginTradePage/components/TradeForm/index.tsx index 6746c5016..27c6951bd 100644 --- a/src/app/pages/MarginTradePage/components/TradeForm/index.tsx +++ b/src/app/pages/MarginTradePage/components/TradeForm/index.tsx @@ -210,6 +210,13 @@ export const TradeForm: React.FC = ({ pairType }) => { ], ); + const underMaintenance = useMemo( + () => + openTradesLocked || + (orderType === OrderType.LIMIT && openLimitTradeLocked), + [openTradesLocked, openLimitTradeLocked, orderType], + ); + useEffect(() => { getPriceAmm(pair.shortAsset, pair.longAsset, toWei('0.01')) .then(response => bignumber(response).mul(100)) @@ -381,7 +388,7 @@ export const TradeForm: React.FC = ({ pairType }) => { )} - {!openTradesLocked && ( + {!underMaintenance && ( <> = ({ pairType }) => { )} - {openTradesLocked && ( + {underMaintenance && (