diff --git a/src/components/Swap/SwapBestTrade.tsx b/src/components/Swap/SwapBestTrade.tsx
index c626d5461..e1b6721a9 100644
--- a/src/components/Swap/SwapBestTrade.tsx
+++ b/src/components/Swap/SwapBestTrade.tsx
@@ -453,7 +453,6 @@ const SwapBestTrade: React.FC<{
isLoading: liquidityHubQuoteLoading,
error: liquidityHubQuoteError,
refetch: fetchLiquidityHubQuote,
- getLatestQuote,
} = useLiquidityHubQuote({
allowedSlippage,
inAmount: parsedAmount?.raw.toString(),
@@ -1279,6 +1278,8 @@ const SwapBestTrade: React.FC<{
}
}, [handleParaswap, onApprove, showApproveFlow]);
+ const getLatestOptimalRate = useCallback(() => optimalRate, [optimalRate]);
+
return (
diff --git a/src/components/Swap/orbs/ConfirmationModal.tsx b/src/components/Swap/orbs/ConfirmationModal.tsx
index 8e146fc95..c8eca9a7e 100644
--- a/src/components/Swap/orbs/ConfirmationModal.tsx
+++ b/src/components/Swap/orbs/ConfirmationModal.tsx
@@ -248,7 +248,7 @@ function ConfirmationContainer({
export const Error = () => {
const {
- onDismiss,
+ onDismiss: _onDismiss,
inAmount,
state: { shouldUnwrap },
} = useConfirmationContext();
@@ -256,23 +256,32 @@ export const Error = () => {
const { chainId } = useActiveWeb3React();
const nativeSymbol = ETHER[chainId].symbol;
const wSymbol = WETH[chainId].symbol;
+ const [isLoading, setIsLoading] = useState(false);
- const { execute, wrapType } = useWrapCallback(
+ const { execute, inputError } = useWrapCallback(
WETH[chainId],
ETHER[chainId],
inAmount,
);
+
const [success, setSuccess] = useState(false);
- const isLoading = wrapType === WrapType.UNWRAPPING;
const unwrap = useCallback(async () => {
try {
+ setIsLoading(true);
await execute?.();
setSuccess(true);
} catch (error) {
console.error(error);
+ } finally {
+ setIsLoading(false);
}
}, [execute]);
+ const onDismiss = useCallback(() => {
+ _onDismiss();
+ setSuccess(false);
+ }, [_onDismiss]);
+
if (success) {
return (
{
)}
- {shouldUnwrap ? (
+ {!inputError && shouldUnwrap ? (