Skip to content

Commit d39f8ce

Browse files
authored
fix swaps (#2770)
1 parent 85a5271 commit d39f8ce

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

src/components/transactions/Swap/actions/DebtSwap/DebtSwapActionsViaParaswap.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ export const DebtSwapActionsViaParaswap = ({
103103
throw new Error('No swap rate found');
104104
}
105105

106-
if (!signatureParams) {
107-
throw new Error('Signature params not found');
108-
}
109-
110106
const inferredKind = state.swapRate.optimalRateData.side === 'SELL' ? 'sell' : 'buy';
111107

112108
// CallData for ParaswapRoute, which is inversed to the actual swap (dest -> src)
@@ -133,11 +129,15 @@ export const DebtSwapActionsViaParaswap = ({
133129
isMaxSelected: state.isMaxSelected,
134130
txCalldata: swapCallData,
135131
augustus: augustus,
136-
signatureParams: {
137-
signature: signatureParams.signature,
138-
deadline: signatureParams.deadline,
139-
amount: signatureParams.amount,
140-
},
132+
...(signatureParams != undefined
133+
? {
134+
signatureParams: {
135+
signature: signatureParams.signature,
136+
deadline: signatureParams.deadline,
137+
amount: signatureParams.amount,
138+
},
139+
}
140+
: {}),
141141
isWrongNetwork: state.isWrongNetwork,
142142
});
143143

src/components/transactions/Swap/errors/SwapErrors.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { Dispatch, useEffect } from 'react';
22

33
import { useModalContext } from '../../../../hooks/useModal';
44
import { TrackAnalyticsHandlers } from '../analytics/useTrackAnalytics';
5-
import { SwapError, SwapParams, SwapState } from '../types';
5+
import { SwapError, SwapParams, SwapState, SwapType } from '../types';
66
import { ActionsBlockedReason, isProtocolSwapState } from '../types/state.types';
77
import { errorToConsole } from './shared/console.helpers';
88
import {
@@ -108,7 +108,11 @@ export const SwapErrors = ({
108108
);
109109
}
110110

111-
if (isProtocolSwapState(state) && hasInsufficientLiquidity(state)) {
111+
if (
112+
isProtocolSwapState(state) &&
113+
hasInsufficientLiquidity(state) &&
114+
state.swapType !== SwapType.RepayWithCollateral
115+
) {
112116
return (
113117
<InsufficientLiquidityBlockingGuard
114118
state={state}

src/components/transactions/Swap/errors/shared/InsufficientLiquidityBlockingGuard.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ import { BigNumber } from 'bignumber.js';
44
import { ethers } from 'ethers';
55
import { Dispatch, useEffect } from 'react';
66

7-
import { ActionsBlockedReason, ProtocolSwapState, SwapError, SwapState } from '../../types';
7+
import {
8+
ActionsBlockedReason,
9+
ProtocolSwapState,
10+
SwapError,
11+
SwapState,
12+
SwapType,
13+
} from '../../types';
814
import { isProtocolSwapState } from '../../types/state.types';
915
import { InsufficientLiquidityBlockingError } from './InsufficientLiquidityBlockingError';
1016

1117
export const hasInsufficientLiquidity = (state: SwapState) => {
12-
if (!isProtocolSwapState(state)) return false;
18+
if (!isProtocolSwapState(state) || state.swapType === SwapType.RepayWithCollateral) return false;
1319
const reserve = state.isInvertedSwap
1420
? state.sourceReserve?.reserve
1521
: state.destinationReserve?.reserve;

src/components/transactions/Swap/hooks/useSwapQuote.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ const useMultiProviderSwapQuoteQuery = ({
439439
})(),
440440
retry: 0,
441441
throwOnError: false,
442-
refetchOnWindowFocus: (query) => (query.state.error ? false : true),
443442
refetchInterval: (() => {
444443
const isInsufficientBalance = hasInsufficientBalance(state);
445444
const isFlashloanDisabled = hasFlashLoanDisabled(state);

0 commit comments

Comments
 (0)