Skip to content

Commit

Permalink
cleanup hook
Browse files Browse the repository at this point in the history
  • Loading branch information
abcrane123 committed Jun 12, 2024
1 parent 0823347 commit 4eebdfb
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/swap/hooks/useGetSwapQuote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,29 @@ async function useGetSwapQuote({
}
}
},
[fromAmount, fromToken, toAmount, toToken],
[fromAmount, fromToken, onError, onSuccess, setFromAmount, setToAmount, toAmount, toToken],
);

useEffect(() => {
/* we only want to fetch the swap quote for fromToken
reference amount if the user last changed the fromAmount */
if (fromToken && toToken && fromAmount && amountReference === 'from') {
handleGetSwapQuote('from');
}
const fetchFromQuote = async () => {
if (fromToken && toToken && fromAmount && amountReference === 'from') {
await handleGetSwapQuote('from');
}
};
fetchFromQuote();
}, [fromAmount, fromToken, handleGetSwapQuote, amountReference, toToken]);

useEffect(() => {
/* we only want to fetch the swap quote for toToken
reference amount if the user last changed the toAmount */
if (fromToken && toToken && toAmount && amountReference === 'to') {
handleGetSwapQuote('to');
}
const fetchToQuote = async () => {
if (fromToken && toToken && toAmount && amountReference === 'to') {
handleGetSwapQuote('to');
}
};
fetchToQuote();
}, [fromToken, handleGetSwapQuote, amountReference, toAmount, toToken]);
}

Expand Down

0 comments on commit 4eebdfb

Please sign in to comment.