@orderly.network/hooks 1.0.18 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3343,6 +3343,7 @@ var useWithdraw = () => {
3343
3343
  const { account: account5, state } = useAccount();
3344
3344
  const [isLoading, setIsLoading] = useState(false);
3345
3345
  const { unsettledPnL, availableBalance } = useCollateral();
3346
+ const { freeCollateral } = useCollateral();
3346
3347
  const withdraw = useCallback(
3347
3348
  (inputs) => {
3348
3349
  return account5.assetsManager.withdraw(inputs).then((res) => {
@@ -3351,14 +3352,10 @@ var useWithdraw = () => {
3351
3352
  },
3352
3353
  [state]
3353
3354
  );
3354
- const { usdc } = useHoldingStream();
3355
+ useHoldingStream();
3355
3356
  const maxAmount = useMemo(() => {
3356
- if (!usdc || !usdc.holding)
3357
- return 0;
3358
- if (unsettledPnL >= 0)
3359
- return usdc?.holding ?? 0;
3360
- return new Decimal(usdc.holding).add(unsettledPnL).toNumber();
3361
- }, [usdc, unsettledPnL]);
3357
+ return freeCollateral;
3358
+ }, [freeCollateral]);
3362
3359
  return { withdraw, isLoading, maxAmount, availableBalance, unsettledPnL };
3363
3360
  };
3364
3361
  var useDeposit = (options) => {