@orderly.network/ui-transfer 2.8.3-alpha.0 → 2.8.4-alpha.0

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.d.mts CHANGED
@@ -168,6 +168,7 @@ declare const useDepositFormScript: (options: DepositFormScriptOptions) => {
168
168
  targetQuantity: string;
169
169
  targetQuantityLoading: boolean;
170
170
  tokenBalances: Record<string, string>;
171
+ isLoggedIn: boolean;
171
172
  };
172
173
  type UseDepositFeeReturn = ReturnType<typeof useDepositFee>;
173
174
  declare function useDepositFee(options: {
@@ -194,7 +195,8 @@ declare const useWithdrawFormScript: (options: WithdrawFormScriptOptions) => {
194
195
  setWithdrawTo: react.Dispatch<react.SetStateAction<WithdrawTo>>;
195
196
  currentLTV: number;
196
197
  nextLTV: number;
197
- warningMessage: string | undefined;
198
+ warningMessage: string;
199
+ isLoggedIn: boolean;
198
200
  toAccountId: string;
199
201
  setToAccountId: react.Dispatch<react.SetStateAction<string>>;
200
202
  onTransfer: () => void;
@@ -222,7 +224,6 @@ declare const useWithdrawFormScript: (options: WithdrawFormScriptOptions) => {
222
224
  currentChain: CurrentChain | null;
223
225
  onChainChange: (chain: API.NetworkInfos) => Promise<void>;
224
226
  onWithdraw: () => Promise<void>;
225
- chainVaultBalance: number | null;
226
227
  fee: number;
227
228
  crossChainWithdraw: boolean;
228
229
  crossChainTrans: boolean;
@@ -233,8 +234,7 @@ declare const useWithdrawFormScript: (options: WithdrawFormScriptOptions) => {
233
234
  onSettlePnl: () => Promise<any>;
234
235
  brokerName: string;
235
236
  qtyGreaterThanMaxAmount: boolean;
236
- qtyGreaterThanVault: boolean;
237
- vaultBalanceList: API.VaultBalance[] | undefined;
237
+ vaultBalanceList: API.VaultBalance[];
238
238
  };
239
239
 
240
240
  type WithdrawFormProps = WithdrawFormScriptReturn;
@@ -436,6 +436,7 @@ type ChainSelectProps = {
436
436
  onValueChange: (chain: API.NetworkInfos) => Promise<void>;
437
437
  wrongNetwork: boolean;
438
438
  loading?: boolean;
439
+ disabled?: boolean;
439
440
  };
440
441
  declare const ChainSelect: React.FC<ChainSelectProps>;
441
442
 
package/dist/index.d.ts CHANGED
@@ -168,6 +168,7 @@ declare const useDepositFormScript: (options: DepositFormScriptOptions) => {
168
168
  targetQuantity: string;
169
169
  targetQuantityLoading: boolean;
170
170
  tokenBalances: Record<string, string>;
171
+ isLoggedIn: boolean;
171
172
  };
172
173
  type UseDepositFeeReturn = ReturnType<typeof useDepositFee>;
173
174
  declare function useDepositFee(options: {
@@ -194,7 +195,8 @@ declare const useWithdrawFormScript: (options: WithdrawFormScriptOptions) => {
194
195
  setWithdrawTo: react.Dispatch<react.SetStateAction<WithdrawTo>>;
195
196
  currentLTV: number;
196
197
  nextLTV: number;
197
- warningMessage: string | undefined;
198
+ warningMessage: string;
199
+ isLoggedIn: boolean;
198
200
  toAccountId: string;
199
201
  setToAccountId: react.Dispatch<react.SetStateAction<string>>;
200
202
  onTransfer: () => void;
@@ -222,7 +224,6 @@ declare const useWithdrawFormScript: (options: WithdrawFormScriptOptions) => {
222
224
  currentChain: CurrentChain | null;
223
225
  onChainChange: (chain: API.NetworkInfos) => Promise<void>;
224
226
  onWithdraw: () => Promise<void>;
225
- chainVaultBalance: number | null;
226
227
  fee: number;
227
228
  crossChainWithdraw: boolean;
228
229
  crossChainTrans: boolean;
@@ -233,8 +234,7 @@ declare const useWithdrawFormScript: (options: WithdrawFormScriptOptions) => {
233
234
  onSettlePnl: () => Promise<any>;
234
235
  brokerName: string;
235
236
  qtyGreaterThanMaxAmount: boolean;
236
- qtyGreaterThanVault: boolean;
237
- vaultBalanceList: API.VaultBalance[] | undefined;
237
+ vaultBalanceList: API.VaultBalance[];
238
238
  };
239
239
 
240
240
  type WithdrawFormProps = WithdrawFormScriptReturn;
@@ -436,6 +436,7 @@ type ChainSelectProps = {
436
436
  onValueChange: (chain: API.NetworkInfos) => Promise<void>;
437
437
  wrongNetwork: boolean;
438
438
  loading?: boolean;
439
+ disabled?: boolean;
439
440
  };
440
441
  declare const ChainSelect: React.FC<ChainSelectProps>;
441
442
 
package/dist/index.js CHANGED
@@ -341,7 +341,7 @@ var TransferVerticalIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
341
341
  }
342
342
  );
343
343
  var ChainSelect = (props) => {
344
- const { chains, value, wrongNetwork, loading } = props;
344
+ const { chains, value, wrongNetwork, loading, disabled } = props;
345
345
  const [open, setOpen] = react.useState(false);
346
346
  const { t } = i18n.useTranslation();
347
347
  const selectable = wrongNetwork || chains?.length > 1;
@@ -372,7 +372,7 @@ var ChainSelect = (props) => {
372
372
  intensity: 500,
373
373
  className: ui.cn(
374
374
  "oui-rounded-t-xl oui-rounded-b-sm oui-border oui-border-line",
375
- selectable ? "oui-cursor-pointer" : "oui-cursor-auto"
375
+ disabled ? "oui-cursor-not-allowed" : selectable ? "oui-cursor-pointer" : "oui-cursor-auto"
376
376
  ),
377
377
  height: 54,
378
378
  px: 3,
@@ -428,7 +428,7 @@ var ChainSelect = (props) => {
428
428
  );
429
429
  });
430
430
  return /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuRoot, { open: selectable ? open : false, onOpenChange: setOpen, children: [
431
- /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: trigger }),
431
+ /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuTrigger, { disabled, asChild: true, children: trigger }),
432
432
  /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(
433
433
  ui.DropdownMenuContent,
434
434
  {
@@ -4667,6 +4667,7 @@ var useDepositFormScript = (options2) => {
4667
4667
  quantity,
4668
4668
  maxQuantity
4669
4669
  });
4670
+ const isLoggedIn = uiConnector.useAuthGuard();
4670
4671
  const {
4671
4672
  collateralRatio: collateralRatio2,
4672
4673
  collateralContributionQuantity,
@@ -4819,7 +4820,8 @@ var useDepositFormScript = (options2) => {
4819
4820
  warningMessage,
4820
4821
  targetQuantity,
4821
4822
  targetQuantityLoading,
4822
- tokenBalances
4823
+ tokenBalances,
4824
+ isLoggedIn
4823
4825
  };
4824
4826
  };
4825
4827
  function useDepositFee(options2) {
@@ -5027,7 +5029,8 @@ var DepositForm = (props) => {
5027
5029
  value: currentChain,
5028
5030
  onValueChange: onChainChange,
5029
5031
  wrongNetwork,
5030
- loading: settingChain
5032
+ loading: settingChain,
5033
+ disabled: !props.isLoggedIn
5031
5034
  }
5032
5035
  ),
5033
5036
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -5045,7 +5048,8 @@ var DepositForm = (props) => {
5045
5048
  hintMessage,
5046
5049
  fetchBalance,
5047
5050
  tokenBalances: props.tokenBalances,
5048
- "data-testId": "oui-testid-deposit-dialog-quantity-input"
5051
+ "data-testId": "oui-testid-deposit-dialog-quantity-input",
5052
+ disabled: !props.isLoggedIn
5049
5053
  }
5050
5054
  )
5051
5055
  ] }),
@@ -5081,7 +5085,8 @@ var DepositForm = (props) => {
5081
5085
  loading: targetQuantityLoading,
5082
5086
  classNames: {
5083
5087
  root: "oui-mt-3 oui-border-transparent focus-within:oui-outline-transparent"
5084
- }
5088
+ },
5089
+ disabled: !props.isLoggedIn
5085
5090
  }
5086
5091
  ),
5087
5092
  renderContent()
@@ -5183,11 +5188,13 @@ var TextAreaInput = (props) => {
5183
5188
  "oui-border oui-border-line focus:oui-border-primary-light",
5184
5189
  status === "error" && "oui-border-danger-light focus-within:oui-border-danger-light focus:oui-border-danger-light",
5185
5190
  status === "warning" && "oui-border-warning-light focus-within:oui-border-warning-light focus:oui-border-warning-light",
5191
+ "disabled:oui-cursor-not-allowed",
5186
5192
  props.className
5187
5193
  ),
5188
5194
  rows: 1,
5189
5195
  value,
5190
- onChange: handleChange
5196
+ onChange: handleChange,
5197
+ disabled: props.disabled
5191
5198
  }
5192
5199
  ),
5193
5200
  hintMessage && message
@@ -5443,22 +5450,9 @@ var WithdrawAction = (props) => {
5443
5450
  ) });
5444
5451
  };
5445
5452
  var WithdrawWarningMessage = (props) => {
5446
- const {
5447
- chainVaultBalance,
5448
- currentChain,
5449
- crossChainTrans,
5450
- tokenName,
5451
- qtyGreaterThanMaxAmount,
5452
- qtyGreaterThanVault
5453
- } = props;
5453
+ const { crossChainTrans, qtyGreaterThanMaxAmount } = props;
5454
5454
  const { t } = i18n.useTranslation();
5455
5455
  const { state } = hooks.useAccount();
5456
- const chainName = react.useMemo(() => {
5457
- if (currentChain && currentChain.info && currentChain.info.network_infos) {
5458
- return currentChain.info.network_infos.name;
5459
- }
5460
- return void 0;
5461
- }, [currentChain]);
5462
5456
  const renderContent = () => {
5463
5457
  if (state.status === types.AccountStatusEnum.NotConnected) {
5464
5458
  return null;
@@ -5469,13 +5463,6 @@ var WithdrawWarningMessage = (props) => {
5469
5463
  if (qtyGreaterThanMaxAmount) {
5470
5464
  return t("transfer.insufficientBalance");
5471
5465
  }
5472
- if (qtyGreaterThanVault) {
5473
- return t("transfer.withdraw.vaultWarning", {
5474
- tokenName,
5475
- chainName,
5476
- balance: chainVaultBalance
5477
- });
5478
- }
5479
5466
  return props.message;
5480
5467
  };
5481
5468
  const content = renderContent();
@@ -5505,15 +5492,13 @@ var WithdrawForm = (props) => {
5505
5492
  currentChain,
5506
5493
  fee,
5507
5494
  settingChain,
5508
- chainVaultBalance,
5509
5495
  crossChainTrans,
5510
5496
  checkIsBridgeless,
5511
5497
  withdrawTo,
5512
5498
  sourceTokens,
5513
5499
  onSourceTokenChange,
5514
5500
  vaultBalanceList,
5515
- qtyGreaterThanMaxAmount,
5516
- qtyGreaterThanVault
5501
+ qtyGreaterThanMaxAmount
5517
5502
  } = props;
5518
5503
  const { t } = i18n.useTranslation();
5519
5504
  const internalWithdrawPanel = /* @__PURE__ */ jsxRuntime.jsxs(
@@ -5531,7 +5516,8 @@ var WithdrawForm = (props) => {
5531
5516
  value: props.toAccountId,
5532
5517
  onChange: props.setToAccountId,
5533
5518
  status: props.toAccountIdInputStatus,
5534
- hintMessage: props.toAccountIdHintMessage
5519
+ hintMessage: props.toAccountIdHintMessage,
5520
+ disabled: !props.isLoggedIn
5535
5521
  }
5536
5522
  ),
5537
5523
  /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { my: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 54, children: t("transfer.withdraw.accountId.tips") }) })
@@ -5558,7 +5544,8 @@ var WithdrawForm = (props) => {
5558
5544
  hintMessage: props.hintMessage,
5559
5545
  vaultBalanceList,
5560
5546
  testId: "oui-testid-withdraw-dialog-quantity-input",
5561
- displayType: "vaultBalance"
5547
+ displayType: "vaultBalance",
5548
+ disabled: !props.isLoggedIn
5562
5549
  }
5563
5550
  ) }),
5564
5551
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -5600,7 +5587,7 @@ var WithdrawForm = (props) => {
5600
5587
  ui.TabPanel,
5601
5588
  {
5602
5589
  title: t("transfer.web3Wallet.my"),
5603
- icon: /* @__PURE__ */ jsxRuntime.jsx(ui.WalletIcon, { size: "xs", name: props.walletName ?? "" }),
5590
+ icon: props.walletName ? /* @__PURE__ */ jsxRuntime.jsx(ui.WalletIcon, { size: "xs", name: props.walletName ?? "" }) : void 0,
5604
5591
  value: "wallet" /* Wallet */,
5605
5592
  children: [
5606
5593
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -5610,7 +5597,8 @@ var WithdrawForm = (props) => {
5610
5597
  value: currentChain,
5611
5598
  onValueChange: props.onChainChange,
5612
5599
  wrongNetwork: props.wrongNetwork,
5613
- loading: settingChain
5600
+ loading: settingChain,
5601
+ disabled: !props.isLoggedIn
5614
5602
  }
5615
5603
  ),
5616
5604
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -5649,11 +5637,7 @@ var WithdrawForm = (props) => {
5649
5637
  WithdrawWarningMessage,
5650
5638
  {
5651
5639
  checkIsBridgeless,
5652
- chainVaultBalance,
5653
- currentChain,
5654
5640
  crossChainTrans,
5655
- tokenName: sourceToken?.symbol,
5656
- qtyGreaterThanVault,
5657
5641
  qtyGreaterThanMaxAmount,
5658
5642
  message: props.warningMessage
5659
5643
  }
@@ -5718,6 +5702,87 @@ var useSettlePnl = (options2) => {
5718
5702
  onSettlePnl
5719
5703
  };
5720
5704
  };
5705
+ var cctpSupportedChains = [43114, 1, 137, 42161, 10, 8453, 1329];
5706
+ var cctpSupportedTokens = ["USDC"];
5707
+ var useVaultBalance = (inputs) => {
5708
+ const {
5709
+ currentChain,
5710
+ sourceToken,
5711
+ withdrawTo,
5712
+ quantity,
5713
+ qtyGreaterThanMaxAmount
5714
+ } = inputs;
5715
+ const { t } = i18n.useTranslation();
5716
+ const { data: vaultBalanceData } = hooks.useQuery(
5717
+ `/v1/public/vault_balance`,
5718
+ {
5719
+ revalidateOnMount: true,
5720
+ errorRetryCount: 3
5721
+ }
5722
+ );
5723
+ const vaultBalanceList = react.useMemo(() => {
5724
+ if (withdrawTo === "accountId" /* Account */ || !currentChain || !Array.isArray(vaultBalanceData)) {
5725
+ return [];
5726
+ }
5727
+ return vaultBalanceData.filter(
5728
+ (item) => Number.parseInt(item.chain_id) === currentChain?.id
5729
+ );
5730
+ }, [vaultBalanceData, currentChain, withdrawTo]);
5731
+ const chainVaultBalance = react.useMemo(() => {
5732
+ const vaultBalance = vaultBalanceList?.find(
5733
+ (item) => item.token === sourceToken?.symbol
5734
+ );
5735
+ return vaultBalance?.balance;
5736
+ }, [vaultBalanceList, sourceToken]);
5737
+ const qtyGreaterThanVault = react.useMemo(() => {
5738
+ if (!quantity || Number.isNaN(quantity) || !chainVaultBalance || Number.isNaN(chainVaultBalance)) {
5739
+ return false;
5740
+ }
5741
+ return new utils.Decimal(quantity).gt(chainVaultBalance);
5742
+ }, [quantity, chainVaultBalance, withdrawTo]);
5743
+ const crossChainWithdraw = react.useMemo(() => {
5744
+ const canCCTP = currentChain?.id && sourceToken?.symbol ? cctpSupportedChains.includes(currentChain?.id) && cctpSupportedTokens.includes(sourceToken?.symbol) : false;
5745
+ return qtyGreaterThanVault && canCCTP && !qtyGreaterThanMaxAmount;
5746
+ }, [qtyGreaterThanVault, qtyGreaterThanMaxAmount, currentChain, sourceToken]);
5747
+ const chainName = react.useMemo(() => {
5748
+ if (currentChain && currentChain.info && currentChain.info.network_infos) {
5749
+ return currentChain.info.network_infos.name;
5750
+ }
5751
+ return "";
5752
+ }, [currentChain]);
5753
+ const vaultBalanceMessage = react.useMemo(() => {
5754
+ if (qtyGreaterThanVault && !crossChainWithdraw && chainName) {
5755
+ return t("transfer.withdraw.vaultWarning", {
5756
+ tokenName: sourceToken?.symbol,
5757
+ chainName,
5758
+ balance: chainVaultBalance
5759
+ });
5760
+ }
5761
+ return "";
5762
+ }, [
5763
+ qtyGreaterThanVault,
5764
+ crossChainWithdraw,
5765
+ chainName,
5766
+ sourceToken,
5767
+ chainVaultBalance
5768
+ ]);
5769
+ const vaultBalanceListFilterCCTP = react.useMemo(() => {
5770
+ if (cctpSupportedChains.includes(currentChain?.id)) {
5771
+ return vaultBalanceList?.filter(
5772
+ (item) => !cctpSupportedTokens.includes(item.token)
5773
+ );
5774
+ }
5775
+ return vaultBalanceList;
5776
+ }, [vaultBalanceList, currentChain]);
5777
+ return {
5778
+ vaultBalanceList: vaultBalanceListFilterCCTP,
5779
+ // chainVaultBalance,
5780
+ // if the token is cross chain withdraw supported, the qtyGreaterThanVault will be false
5781
+ qtyGreaterThanVault: qtyGreaterThanVault && !crossChainWithdraw,
5782
+ crossChainWithdraw,
5783
+ vaultBalanceMessage
5784
+ };
5785
+ };
5721
5786
  function useWithdrawAccountId(options2) {
5722
5787
  const { token, quantity, setQuantity, close, setLoading, decimals } = options2;
5723
5788
  const { t } = i18n.useTranslation();
@@ -5932,19 +5997,13 @@ var useWithdrawFormScript = (options2) => {
5932
5997
  filter: (chain) => chain.network_infos?.bridge_enable || chain.network_infos?.bridgeless
5933
5998
  });
5934
5999
  const [linkDeviceStorage] = hooks.useLocalStorage("orderly_link_device", {});
5935
- const { data: vaultBalanceList } = hooks.useQuery(
5936
- `/v1/public/vault_balance`,
5937
- {
5938
- revalidateOnMount: true,
5939
- errorRetryCount: 3
5940
- }
5941
- );
5942
6000
  const {
5943
6001
  connectedChain,
5944
6002
  wallet,
5945
6003
  setChain: switchChain,
5946
6004
  settingChain
5947
6005
  } = hooks.useWalletConnector();
6006
+ const isLoggedIn = uiConnector.useAuthGuard();
5948
6007
  const currentChain = react.useMemo(() => {
5949
6008
  const chainId = connectedChain ? utils.praseChainIdToNumber(connectedChain.id) : Number.parseInt(linkDeviceStorage?.chainId);
5950
6009
  if (!chainId) {
@@ -5985,6 +6044,27 @@ var useWithdrawFormScript = (options2) => {
5985
6044
  token: sourceToken?.symbol,
5986
6045
  decimals: sourceToken?.token_decimal
5987
6046
  });
6047
+ const qtyGreaterThanMaxAmount = react.useMemo(() => {
6048
+ if (!quantity || Number.isNaN(quantity)) {
6049
+ return false;
6050
+ }
6051
+ if (!maxAmount || Number.isNaN(maxAmount)) {
6052
+ return true;
6053
+ }
6054
+ return new utils.Decimal(quantity).gt(maxAmount);
6055
+ }, [quantity, maxAmount]);
6056
+ const {
6057
+ vaultBalanceList,
6058
+ qtyGreaterThanVault,
6059
+ crossChainWithdraw,
6060
+ vaultBalanceMessage
6061
+ } = useVaultBalance({
6062
+ currentChain,
6063
+ sourceToken,
6064
+ withdrawTo,
6065
+ quantity,
6066
+ qtyGreaterThanMaxAmount
6067
+ });
5988
6068
  const withdrawAccountIdState = useWithdrawAccountId({
5989
6069
  token: sourceToken?.symbol,
5990
6070
  decimals: sourceToken?.token_decimal,
@@ -6035,47 +6115,6 @@ var useWithdrawFormScript = (options2) => {
6035
6115
  },
6036
6116
  [currentChain, switchChain, findByChainId, t]
6037
6117
  );
6038
- const chainVaultBalance = react.useMemo(() => {
6039
- if (!Array.isArray(vaultBalanceList) || !currentChain) {
6040
- return null;
6041
- }
6042
- const vaultBalance = vaultBalanceList.find(
6043
- (item) => Number.parseInt(item.chain_id) === currentChain?.id && item.token === sourceToken?.symbol
6044
- );
6045
- if (vaultBalance) {
6046
- return vaultBalance.balance;
6047
- }
6048
- return null;
6049
- }, [chains, currentChain, vaultBalanceList, sourceToken?.symbol]);
6050
- const qtyGreaterThanMaxAmount = react.useMemo(() => {
6051
- if (!quantity || Number.isNaN(quantity)) {
6052
- return false;
6053
- }
6054
- if (!maxAmount || Number.isNaN(maxAmount)) {
6055
- return true;
6056
- }
6057
- return new utils.Decimal(quantity).gt(maxAmount);
6058
- }, [quantity, maxAmount]);
6059
- const qtyGreaterThanVault = react.useMemo(() => {
6060
- if (withdrawTo === "accountId" /* Account */) {
6061
- return false;
6062
- }
6063
- if (!quantity || Number.isNaN(quantity)) {
6064
- return false;
6065
- }
6066
- if (!chainVaultBalance || Number.isNaN(chainVaultBalance)) {
6067
- return true;
6068
- }
6069
- return new utils.Decimal(quantity).gt(chainVaultBalance);
6070
- }, [quantity, chainVaultBalance, withdrawTo]);
6071
- const crossChainWithdraw = react.useMemo(() => {
6072
- if (chainVaultBalance !== null) {
6073
- const qtyNum = Number.parseFloat(quantity);
6074
- const value = qtyNum > chainVaultBalance && qtyNum <= maxAmount;
6075
- return value;
6076
- }
6077
- return false;
6078
- }, [quantity, maxAmount, chainVaultBalance]);
6079
6118
  const onWithdraw = async () => {
6080
6119
  if (loading) {
6081
6120
  return;
@@ -6157,7 +6196,6 @@ var useWithdrawFormScript = (options2) => {
6157
6196
  }
6158
6197
  }
6159
6198
  }, [quantity, maxAmount, unsettledPnL, crossChainTrans]);
6160
- const disabled = crossChainTrans || !quantity || Number(quantity) === 0 || ["error", "warning"].includes(inputStatus) || withdrawTo === "accountId" /* Account */ && !withdrawAccountIdState.toAccountId || qtyGreaterThanMaxAmount || qtyGreaterThanVault || !!minAmountWarningMessage;
6161
6199
  react.useEffect(() => {
6162
6200
  setCrossChainTrans(!!assetHistory?.length);
6163
6201
  }, [assetHistory?.length]);
@@ -6179,15 +6217,8 @@ var useWithdrawFormScript = (options2) => {
6179
6217
  token: sourceToken?.symbol,
6180
6218
  quantity
6181
6219
  });
6182
- const warningMessage = ltvWarningMessage || minAmountWarningMessage;
6183
- const filteredVaultBalanceList = react.useMemo(() => {
6184
- if (withdrawTo === "accountId" /* Account */) {
6185
- return [];
6186
- }
6187
- return vaultBalanceList?.filter(
6188
- (item) => Number.parseInt(item.chain_id) === currentChain?.id
6189
- );
6190
- }, [vaultBalanceList, currentChain, withdrawTo]);
6220
+ const disabled = crossChainTrans || !quantity || Number(quantity) === 0 || ["error", "warning"].includes(inputStatus) || withdrawTo === "accountId" /* Account */ && !withdrawAccountIdState.toAccountId || qtyGreaterThanMaxAmount || !!minAmountWarningMessage || qtyGreaterThanVault;
6221
+ const warningMessage = minAmountWarningMessage || ltvWarningMessage || vaultBalanceMessage;
6191
6222
  return {
6192
6223
  walletName,
6193
6224
  address,
@@ -6210,7 +6241,6 @@ var useWithdrawFormScript = (options2) => {
6210
6241
  currentChain,
6211
6242
  onChainChange,
6212
6243
  onWithdraw,
6213
- chainVaultBalance,
6214
6244
  fee,
6215
6245
  crossChainWithdraw,
6216
6246
  crossChainTrans,
@@ -6221,14 +6251,14 @@ var useWithdrawFormScript = (options2) => {
6221
6251
  onSettlePnl,
6222
6252
  brokerName,
6223
6253
  qtyGreaterThanMaxAmount,
6224
- qtyGreaterThanVault,
6225
- vaultBalanceList: filteredVaultBalanceList,
6254
+ vaultBalanceList,
6226
6255
  ...withdrawAccountIdState,
6227
6256
  withdrawTo,
6228
6257
  setWithdrawTo,
6229
6258
  currentLTV,
6230
6259
  nextLTV,
6231
- warningMessage
6260
+ warningMessage,
6261
+ isLoggedIn
6232
6262
  };
6233
6263
  };
6234
6264
  var WithdrawFormWidget = (props) => {