Skip to content

Commit

Permalink
Fix/limit order maintenance (#2311)
Browse files Browse the repository at this point in the history
* fix: checkMaintenances hook

* feat: show maintenance message when margin limit locked
  • Loading branch information
soulBit authored Jul 6, 2022
1 parent e0fd149 commit 837c63c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/app/hooks/useMaintenance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 9 additions & 2 deletions src/app/pages/MarginTradePage/components/TradeForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ export const TradeForm: React.FC<ITradeFormProps> = ({ 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))
Expand Down Expand Up @@ -381,7 +388,7 @@ export const TradeForm: React.FC<ITradeFormProps> = ({ pairType }) => {
)}
</FormGroup>

{!openTradesLocked && (
{!underMaintenance && (
<>
<LabelValuePair
label={t(translations.marginTradeForm.fields.interestAPR)}
Expand Down Expand Up @@ -444,7 +451,7 @@ export const TradeForm: React.FC<ITradeFormProps> = ({ pairType }) => {
</>
)}

{openTradesLocked && (
{underMaintenance && (
<ErrorBadge
content={
<Trans
Expand Down

0 comments on commit 837c63c

Please sign in to comment.