Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
fix approve logic conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
W3stside committed Jan 19, 2022
1 parent c894868 commit 9945e7b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/custom/hooks/useApproveCallback/useApproveCallbackMod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ export function useApproveCallback({
// we might not have enough data to know whether or not we need to approve
if (!currentAllowance) return ApprovalState.UNKNOWN

// is the optionally set check amount less than current set allowance?
const isOptionalAmountLessThanAllowance = !!amountToCheckAgainstAllowance?.lessThan(currentAllowance)
// is current set allowance less than actual approving amount?
const isApprovingAmountLessThanAllowance = currentAllowance.lessThan(amountToApprove)

// Return approval state
if ((amountToCheckAgainstAllowance || currentAllowance).lessThan(amountToApprove)) {
if (isOptionalAmountLessThanAllowance || isApprovingAmountLessThanAllowance) {
return pendingApproval ? ApprovalState.PENDING : ApprovalState.NOT_APPROVED
} else {
// Enough allowance
Expand Down

0 comments on commit 9945e7b

Please sign in to comment.