Skip to content

Commit a589dd2

Browse files
committed
fix: fixed conflict merging main
2 parents 6af7b22 + aca6602 commit a589dd2

File tree

13 files changed

+66
-44
lines changed

13 files changed

+66
-44
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@
3737
"@amplitude/analytics-browser": "^2.13.0",
3838
"@bgd-labs/aave-address-book": "^4.36.3",
3939
"@cowprotocol/cow-sdk": "7.1.1",
40-
"@cowprotocol/sdk-app-data": "4.1.6",
41-
"@cowprotocol/sdk-flash-loans": "1.5.2",
42-
"@cowprotocol/sdk-viem-adapter": "0.2.0",
40+
"@cowprotocol/sdk-flash-loans": "1.5.3",
41+
"@cowprotocol/sdk-ethers-v5-adapter": "0.2.0",
4342
"@emotion/cache": "11.10.3",
4443
"@emotion/react": "11.10.4",
4544
"@emotion/server": "latest",

src/components/transactions/Swap/constants/cow.constants.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,10 @@ export const COW_UNSUPPORTED_ASSETS: Partial<
7777
[SupportedChainId.BASE]: 'ALL', // Base is not supported
7878
},
7979
[SwapType.CollateralSwap]: {
80-
[SupportedChainId.ARBITRUM_ONE]: 'ALL',
81-
[SupportedChainId.AVALANCHE]: 'ALL',
82-
[SupportedChainId.BNB]: 'ALL',
83-
[SupportedChainId.GNOSIS_CHAIN]: 'ALL',
8480
[SupportedChainId.MAINNET]: 'ALL',
81+
[SupportedChainId.BNB]: 'ALL',
8582
[SupportedChainId.POLYGON]: 'ALL',
8683
[SupportedChainId.SEPOLIA]: 'ALL',
87-
// Base is supported
8884
},
8985
[SwapType.RepayWithCollateral]: {
9086
[SupportedChainId.ARBITRUM_ONE]: 'ALL',

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Dispatch, useEffect } from 'react';
2+
import { useZeroLTVBlockingWithdraw } from 'src/hooks/useZeroLTVBlockingWithdraw';
23

34
import { useModalContext } from '../../../../hooks/useModal';
45
import { TrackAnalyticsHandlers } from '../analytics/useTrackAnalytics';
@@ -35,6 +36,7 @@ export const SwapErrors = ({
3536
trackingHandlers: TrackAnalyticsHandlers;
3637
}) => {
3738
const { txError } = useModalContext();
39+
const assetsBlockingWithdraw = useZeroLTVBlockingWithdraw();
3840

3941
useEffect(() => {
4042
if (txError) {
@@ -78,7 +80,7 @@ export const SwapErrors = ({
7880
);
7981
}
8082

81-
if (hasZeroLTVBlocking(state, [])) {
83+
if (hasZeroLTVBlocking(state, assetsBlockingWithdraw)) {
8284
return (
8385
<ZeroLTVBlockingGuard
8486
state={state}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export const ZeroLTVBlockingError = ({ sx }: { sx?: SxProps }) => {
77
<Warning severity="error" sx={{ mt: 4, ...sx }} icon={false}>
88
<Typography variant="caption">
99
<Trans>
10-
You have assets with zero LTV that are blocking this operation. Please disable them as
11-
collateral first.
10+
You have assets with zero LTV that are blocking this operation. Please withdraw them or
11+
disable them as collateral first.
1212
</Trans>
1313
</Typography>
1414
</Warning>

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ import { ActionsBlockedReason, SwapError, SwapState, SwapType } from '../../type
66
import { ZeroLTVBlockingError } from './ZeroLTVBlockingError';
77

88
export const hasZeroLTVBlocking = (state: SwapState, blockingAssets: string[]) => {
9-
return (
10-
blockingAssets.length > 0 &&
11-
!blockingAssets.includes(state.sourceToken.symbol) &&
12-
state.swapType !== SwapType.RepayWithCollateral
13-
);
9+
// Never block RepayWithCollateral
10+
if (state.swapType === SwapType.RepayWithCollateral) {
11+
return false;
12+
}
13+
// For CollateralSwap, block if the user has any zero-LTV collateral enabled
14+
if (state.swapType === SwapType.CollateralSwap) {
15+
return blockingAssets.length > 0;
16+
}
17+
// For other swap types, block if there are zero-LTV assets enabled
18+
// and the source token is not one of those (existing behavior)
19+
return blockingAssets.length > 0 && !blockingAssets.includes(state.sourceToken.symbol);
1420
};
1521

1622
export const ZeroLTVBlockingGuard = ({
@@ -38,7 +44,7 @@ export const ZeroLTVBlockingGuard = ({
3844
const blockingError: SwapError = {
3945
rawError: new Error('ZeroLTVBlockingError'),
4046
message:
41-
'You have assets with zero LTV that are blocking this operation. Please disable them as collateral first.',
47+
'You have assets with zero LTV that are blocking this operation. Please withdraw them or disable them as collateral first.',
4248
actionBlocked: true,
4349
};
4450
setState({
@@ -61,7 +67,7 @@ export const ZeroLTVBlockingGuard = ({
6167
});
6268
}
6369
}
64-
}, [assetsBlockingWithdraw, state.sourceToken.symbol]);
70+
}, [assetsBlockingWithdraw, state.sourceToken.symbol, state.swapType]);
6571

6672
if (hasZeroLTVBlocking(state, assetsBlockingWithdraw)) {
6773
return <ZeroLTVBlockingError sx={{ mb: !isSwapFlowSelected ? 0 : 4, ...sx }} />;

src/components/transactions/Swap/helpers/cow/env.helpers.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { CowEnv, setGlobalAdapter, TradingSdk } from '@cowprotocol/cow-sdk';
2+
import { EthersV5Adapter } from '@cowprotocol/sdk-ethers-v5-adapter';
23
import { AaveCollateralSwapSdk } from '@cowprotocol/sdk-flash-loans';
3-
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter';
4+
import { ethers } from 'ethers';
45
import { wagmiConfig } from 'src/ui-config/wagmiConfig';
5-
import { getPublicClient, getWalletClient } from 'wagmi/actions';
6+
import { getProvider } from 'src/utils/marketsAndNetworksConfig';
7+
import { getWalletClient } from 'wagmi/actions';
68

79
import { ADAPTER_FACTORY, HOOK_ADAPTER_PER_TYPE } from '../../constants/cow.constants';
810
import { APP_CODE_PER_SWAP_TYPE } from '../../constants/shared.constants';
@@ -40,16 +42,33 @@ export const getCowFlashLoanSdk = async (chainId: number) => {
4042
return new AaveCollateralSwapSdk({
4143
hookAdapterPerType: HOOK_ADAPTER_PER_TYPE,
4244
aaveAdapterFactory: ADAPTER_FACTORY,
45+
hooksGasLimit: {
46+
pre: BigInt(300000),
47+
post: BigInt(700000),
48+
},
4349
});
4450
};
4551

4652
export const getCowAdapter = async (chainId: number) => {
4753
const walletClient = await getWalletClient(wagmiConfig, { chainId });
48-
const publicClient = getPublicClient(wagmiConfig, { chainId });
49-
50-
if (!publicClient || !walletClient) {
54+
if (!walletClient) {
5155
throw new Error('Wallet not connected');
5256
}
5357

54-
return new ViemAdapter({ provider: publicClient, walletClient });
58+
const eip1193Provider =
59+
walletClient.transport?.value || (typeof window !== 'undefined' ? window.ethereum : undefined);
60+
61+
if (!eip1193Provider) {
62+
throw new Error('No EIP-1193 provider available for signer');
63+
}
64+
65+
const web3Provider = new ethers.providers.Web3Provider(eip1193Provider, 'any');
66+
const signer = web3Provider.getSigner();
67+
68+
const provider = getProvider(chainId); // Use RPC proxy
69+
70+
return new EthersV5Adapter({
71+
provider,
72+
signer,
73+
});
5574
};

src/locales/el/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/locales/en/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/locales/en/messages.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,10 @@ msgstr "Costs & Fees"
12511251
msgid "deposited"
12521252
msgstr "deposited"
12531253

1254+
#: src/components/transactions/Swap/errors/shared/ZeroLTVBlockingError.tsx
1255+
msgid "You have assets with zero LTV that are blocking this operation. Please withdraw them or disable them as collateral first."
1256+
msgstr "You have assets with zero LTV that are blocking this operation. Please withdraw them or disable them as collateral first."
1257+
12541258
#: src/components/incentives/MeritIncentivesTooltipContent.tsx
12551259
#: src/components/incentives/MeritIncentivesTooltipContent.tsx
12561260
#: src/components/incentives/MerklIncentivesTooltipContent.tsx
@@ -3280,10 +3284,6 @@ msgstr "Cooldown to unstake"
32803284
msgid "User does not have outstanding variable rate debt on this reserve"
32813285
msgstr "User does not have outstanding variable rate debt on this reserve"
32823286

3283-
#: src/components/transactions/Swap/errors/shared/ZeroLTVBlockingError.tsx
3284-
msgid "You have assets with zero LTV that are blocking this operation. Please disable them as collateral first."
3285-
msgstr "You have assets with zero LTV that are blocking this operation. Please disable them as collateral first."
3286-
32873287
#: src/modules/faucet/FaucetAssetsList.tsx
32883288
msgid "Test Assets"
32893289
msgstr "Test Assets"

src/locales/es/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)