Skip to content

Commit

Permalink
Improved approval checks
Browse files Browse the repository at this point in the history
  • Loading branch information
uncoolzero committed Jun 25, 2023
1 parent c2e20c9 commit 0f42a0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion projects/ui/src/components/Field/Actions/Sow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ const SowForm: FC<
claimBeansState: values.claimableBeans,
});

/// Checks
const shouldApprove =
values.balanceFrom === BalanceFrom.EXTERNAL ||
values.balanceFrom === BalanceFrom.TOTAL && values.tokens[0].amount?.gt(balances[tokenIn.address].internal);

const handleSetBalanceFrom = useCallback(
(_balanceFrom: BalanceFrom) => {
setFieldValue('balanceFrom', _balanceFrom);
Expand Down Expand Up @@ -354,7 +359,7 @@ const SowForm: FC<
size="large"
disabled={!isSubmittable || isSubmitting}
contract={sdk.contracts.beanstalk}
tokens={values.tokens}
tokens={shouldApprove ? values.tokens : []}
mode="auto"
>
Sow
Expand Down
2 changes: 1 addition & 1 deletion projects/ui/src/components/Swap/Actions/Transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const TransferForm: FC<
/// Checks
const shouldApprove =
fromMode === FarmFromMode.EXTERNAL ||
fromMode === FarmFromMode.INTERNAL_EXTERNAL;
fromMode === FarmFromMode.INTERNAL_EXTERNAL && amount?.gt(balances[tokenIn.address]?.internal);

const amountsCheck = amount?.gt(0);
const enoughBalanceCheck = amount
Expand Down

0 comments on commit 0f42a0b

Please sign in to comment.