Skip to content

Commit 5415de0

Browse files
committed
nit
1 parent 1ec1f46 commit 5415de0

15 files changed

+46
-20
lines changed

src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActionsViaCoWAdapters.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export const CollateralSwapActionsViaCowAdapters = ({
131131
setState,
132132
allowPermit: !disablePermitDueToActiveOrder, // CoW Adapters do support permit but avoid nonce reuse
133133
trackingHandlers,
134+
swapType: state.swapType,
134135
});
135136

136137
// Use centralized gas estimation

src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActionsViaParaswapAdapters.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const CollateralSwapActionsViaParaswapAdapters = ({
6464
spender: currentMarketData.addresses.SWAP_COLLATERAL_ADAPTER,
6565
setState,
6666
trackingHandlers,
67+
swapType: state.swapType,
6768
});
6869

6970
// Use centralized gas estimation

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export const DebtSwapActionsViaCoW = ({
137137
allowPermit: !disablePermitDueToActiveOrder, // avoid nonce reuse if active order present
138138
type: 'delegation', // Debt swap uses delegation
139139
trackingHandlers,
140+
swapType: state.swapType,
140141
});
141142

142143
// Use centralized gas estimation

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export const DebtSwapActionsViaParaswap = ({
8383
margin: 0.25,
8484
type: 'delegation',
8585
trackingHandlers,
86+
swapType: state.swapType,
8687
});
8788

8889
// Use centralized gas estimation

src/components/transactions/Swap/actions/RepayWithCollateral/RepayWithCollateralActionsViaCoW.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export const RepayWithCollateralActionsViaCoW = ({
135135
setState,
136136
allowPermit: !disablePermitDueToActiveOrder, // avoid nonce reuse if active order present
137137
trackingHandlers,
138+
swapType: state.swapType,
138139
});
139140

140141
// Use centralized gas estimation

src/components/transactions/Swap/actions/RepayWithCollateral/RepayWithCollateralActionsViaParaswap.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const RepayWithCollateralActionsViaParaswap = ({
8686
spender: currentMarketData.addresses.REPAY_WITH_COLLATERAL_ADAPTER,
8787
setState,
8888
trackingHandlers,
89+
swapType: state.swapType,
8990
});
9091

9192
// Use centralized gas estimation

src/components/transactions/Swap/actions/SwapActions/SwapActionsViaCoW.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export const SwapActionsViaCoW = ({
100100
setState,
101101
allowPermit: !disablePermitDueToActiveOrder,
102102
trackingHandlers,
103+
swapType: state.swapType,
103104
});
104105

105106
// Use centralized gas estimation

src/components/transactions/Swap/actions/SwapActions/SwapActionsViaParaswap.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const SwapActionsViaParaswap = ({
6060
: undefined,
6161
setState,
6262
trackingHandlers,
63+
swapType: state.swapType,
6364
});
6465

6566
// Use centralized gas estimation

src/components/transactions/Swap/actions/WithdrawAndSwap/WithdrawAndSwapActionsViaParaswap.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const WithdrawAndSwapActionsViaParaswap = ({
6363
spender: currentMarketData.addresses.WITHDRAW_SWITCH_ADAPTER,
6464
setState,
6565
trackingHandlers,
66+
swapType: state.swapType,
6667
});
6768

6869
// Use centralized gas estimation

src/components/transactions/Swap/actions/approval/useSwapTokenApproval.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { useShallow } from 'zustand/shallow';
1717

1818
import { TrackAnalyticsHandlers } from '../../analytics/useTrackAnalytics';
1919
import { isNativeToken } from '../../helpers/cow';
20-
import { SwapState } from '../../types';
20+
import { SwapState, SwapType } from '../../types';
2121

2222
export type SwapTokenApprovalParams = {
2323
chainId: number;
@@ -31,6 +31,7 @@ export type SwapTokenApprovalParams = {
3131
margin?: number;
3232
type?: 'approval' | 'delegation';
3333
trackingHandlers?: TrackAnalyticsHandlers;
34+
swapType: SwapType;
3435
};
3536

3637
export type SignatureLike = {
@@ -90,6 +91,7 @@ export const useSwapTokenApproval = ({
9091
margin = 0,
9192
type = 'approval',
9293
trackingHandlers,
94+
swapType,
9395
}: SwapTokenApprovalParams) => {
9496
const [approvedAmount, setApprovedAmount] = useState<string | undefined>();
9597
const [approvedAddress, setApprovedAddress] = useState<string | undefined>();
@@ -170,7 +172,10 @@ export const useSwapTokenApproval = ({
170172
const currentApproved = calculateSignedAmount(approvedAmount?.toString() || '0', decimals, 0);
171173

172174
let needsApprovalReset = false;
173-
if (needsUSDTApprovalReset(symbol, chainId, currentApproved, amountToApprove)) {
175+
if (
176+
needsUSDTApprovalReset(symbol, chainId, currentApproved, amountToApprove) &&
177+
swapType == SwapType.Swap
178+
) {
174179
needsApprovalReset = true;
175180
setRequiresApprovalReset(true);
176181
} else {

0 commit comments

Comments
 (0)