Compare commits

...
Author SHA1 Message Date
maciek d8b5432888 fix: prevent empty call estimate position 2023-10-02 13:52:32 +02:00
2 changed files with 9 additions and 3 deletions
@@ -264,7 +264,11 @@ export const DealTicket = ({
orders,
collateralAvailable:
marginAccountBalance || generalAccountBalance ? balance : undefined,
skip: !normalizedOrder,
skip:
!normalizedOrder ||
(normalizedOrder.type !== Schema.OrderType.TYPE_MARKET &&
(!normalizedOrder.price || normalizedOrder.price === '0')) ||
normalizedOrder.size === '0',
});
const assetSymbol = getAsset(market).symbol;
@@ -30,9 +30,11 @@ export const usePositionEstimate = ({
fetchPolicy: 'no-cache',
});
useEffect(() => {
if (data) {
if (skip) {
setEstimates(undefined);
} else if (data) {
setEstimates(data);
}
}, [data]);
}, [data, skip]);
return estimates;
};