Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:airswap/airswap-web into ipfs
Browse files Browse the repository at this point in the history
  • Loading branch information
dmosites committed Dec 10, 2023
2 parents 4a11170 + 4bbb045 commit 9ae5d11
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/@widgets/SwapWidget/SwapWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,13 @@ const SwapWidget: FC = () => {

const baseTokenInfo = useTokenInfo(baseToken);
const quoteTokenInfo = useTokenInfo(quoteToken);
const swapType = useSwapType(baseTokenInfo, quoteTokenInfo);
const wrappedNativeTokenInfo = useNativeWrappedToken(chainId);
const { hasSufficientAllowance, readableAllowance } = useAllowance(
baseTokenInfo,
baseAmount
);
const shouldApprove = !hasSufficientAllowance && swapType !== 'wrapOrUnwrap';

const hasApprovalPending = useApprovalPending(baseToken);
const maxAmount = useMaxAmount(baseToken);
Expand Down Expand Up @@ -270,7 +272,6 @@ const SwapWidget: FC = () => {
);
}, [allowances.swap.status, allowances.wrapper.status]);

const swapType = useSwapType(baseTokenInfo, quoteTokenInfo);
const quoteAmount =
swapType === "wrapOrUnwrap"
? baseAmount
Expand Down Expand Up @@ -790,7 +791,7 @@ const SwapWidget: FC = () => {
);
}

if (state === SwapWidgetState.review && !hasSufficientAllowance) {
if (state === SwapWidgetState.review && shouldApprove) {
return (
<Container>
<ApproveReview
Expand Down Expand Up @@ -858,7 +859,7 @@ const SwapWidget: FC = () => {
orderCompleted={
showOrderSubmitted && activeTransaction?.status === "succeeded"
}
requiresApproval={bestRfqOrder && !hasSufficientAllowance}
requiresApproval={bestRfqOrder && shouldApprove}
showViewAllQuotes={indexerOrders.length > 0}
// @ts-ignore
bestTradeOption={bestTradeOption}
Expand Down Expand Up @@ -889,7 +890,7 @@ const SwapWidget: FC = () => {
!isRequestingQuotes && (!!bestTradeOption || isWrapping)
}
hasSufficientBalance={!insufficientBalance}
needsApproval={!!baseToken && !hasSufficientAllowance}
needsApproval={!!baseToken && shouldApprove}
pairUnavailable={pairUnavailable}
onButtonClicked={(action) => handleActionButtonClick(action)}
isLoading={
Expand Down

0 comments on commit 9ae5d11

Please sign in to comment.