@huma-finance/widgets 0.0.51-beta.349 → 0.0.51-beta.361

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.
@@ -3363,8 +3363,8 @@ function ChooseAmount$a(_ref) {
3363
3363
  }));
3364
3364
  }, [dispatch]);
3365
3365
  const handleAction = React.useCallback(() => {
3366
- const payAmount = shared.upScale(currentAmount, decimals);
3367
- const step = shared.toBigNumber(payAmount).gt(allowance) ? WIDGET_STEP.ApproveAllowance : WIDGET_STEP.Transfer;
3366
+ const payAmount = shared.upScale(shared.toBigNumber(currentAmount), decimals);
3367
+ const step = payAmount.gt(allowance) ? WIDGET_STEP.ApproveAllowance : WIDGET_STEP.Transfer;
3368
3368
  dispatch(setStep(step));
3369
3369
  }, [allowance, currentAmount, decimals, dispatch]);
3370
3370
  return jsxRuntime.jsx(ChooseAmountModal, {
@@ -3409,7 +3409,7 @@ function Transfer$d(_ref) {
3409
3409
  const {
3410
3410
  decimals
3411
3411
  } = poolInfo.poolUnderlyingToken;
3412
- const paymentBigNumber = shared.toBigNumber(shared.upScale(paymentAmount, decimals));
3412
+ const paymentBigNumber = shared.upScale(shared.toBigNumber(paymentAmount), decimals);
3413
3413
  const handleSuccess = React.useCallback(() => {
3414
3414
  dispatch(setStep(WIDGET_STEP.Done));
3415
3415
  }, [dispatch]);
@@ -6075,8 +6075,10 @@ function LendWithdraw(_ref) {
6075
6075
  const [lenderPosition, refreshLenderPosition] = shared.useLenderPosition(poolName, poolType, chainId, account, provider);
6076
6076
  const [poolBalance, refreshPoolBalance] = shared.usePoolBalance(poolName, poolType, chainId, provider);
6077
6077
  React.useEffect(() => {
6078
- if (!step && lenderPosition && poolBalance) {
6078
+ if (!step && lenderPosition !== null && lenderPosition !== void 0 && lenderPosition.gt(0) && poolBalance !== null && poolBalance !== void 0 && poolBalance.gt(0)) {
6079
6079
  dispatch(setStep(WIDGET_STEP.CheckWithdrawable));
6080
+ } else if (!step && (lenderPosition !== null && lenderPosition !== void 0 && lenderPosition.eq(0) || poolBalance !== null && poolBalance !== void 0 && poolBalance.eq(0))) {
6081
+ dispatch(setStep(WIDGET_STEP.Error));
6080
6082
  }
6081
6083
  }, [dispatch, lenderPosition, poolBalance, step]);
6082
6084
  const handleWithdrawSuccess = React.useCallback(blockNumber => {
@@ -6093,10 +6095,10 @@ function LendWithdraw(_ref) {
6093
6095
  isOpen: true,
6094
6096
  handleClose: handleClose,
6095
6097
  handleSuccess: handleWithdrawSuccess,
6096
- children: [(!step || step === WIDGET_STEP.CheckWithdrawable) && jsxRuntime.jsx(CheckWithdrawable, {
6098
+ children: [step === WIDGET_STEP.CheckWithdrawable && jsxRuntime.jsx(CheckWithdrawable, {
6097
6099
  poolInfo: poolInfo,
6098
6100
  handleClose: handleClose
6099
- }), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$3, {
6101
+ }), step === WIDGET_STEP.ChooseAmount && lenderPosition && poolBalance && jsxRuntime.jsx(ChooseAmount$3, {
6100
6102
  poolInfo: poolInfo,
6101
6103
  lenderPosition: lenderPosition,
6102
6104
  poolBalance: poolBalance