Skip to content

Commit d3d5f6a

Browse files
grothemMareskoYdefispartan
authored
chore: update paraswap adapters (#1683)
* chore: new paraswap adapters for testing * chore: remove usdt warning * chore: update address book package * fix: state subscription * fix: removing changes for USDT warning * fix: tusd coverage * fix: optimism e-mode test * chore: update sdk versions * chore: exclude direct routes and udpate import locations * chore: use address book for gho config --------- Co-authored-by: Nikita Boakrev <right2maresko@gmail.com> Co-authored-by: defispartan <andrew@aave.com>
1 parent abc8077 commit d3d5f6a

13 files changed

Lines changed: 57 additions & 76 deletions

File tree

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"dependencies": {
3535
"@aave/contract-helpers": "1.18.2",
3636
"@aave/math-utils": "1.18.2",
37-
"@bgd-labs/aave-address-book": "^1.26.2",
37+
"@bgd-labs/aave-address-book": "^1.29.0",
3838
"@emotion/cache": "11.10.3",
3939
"@emotion/react": "11.10.4",
4040
"@emotion/server": "latest",
@@ -44,7 +44,7 @@
4444
"@lingui/react": "^3.14.0",
4545
"@mui/icons-material": "^5.10.14",
4646
"@mui/material": "^5.10.9",
47-
"@paraswap/sdk": "5.6.0-alpha.3",
47+
"@paraswap/sdk": "6.2.1",
4848
"@tanstack/react-query": "^4.28.0",
4949
"@visx/axis": "^2.14.0",
5050
"@visx/curve": "^2.1.0",
@@ -78,7 +78,6 @@
7878
"lowdb": "^3.0.0",
7979
"mixpanel-browser": "^2.45.0",
8080
"next": "12.1.1",
81-
"paraswap-core": "^1.0.2",
8281
"react": "latest",
8382
"react-cookie-consent": "^8.0.1",
8483
"react-dom": "latest",

src/components/Warnings/USDTParaswapWarning.tsx

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/components/transactions/Repay/CollateralRepayActions.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ export const CollateralRepayActions = ({
5454
buildTxFn,
5555
...props
5656
}: CollateralRepayBaseProps & { buildTxFn: () => Promise<SwapTransactionParams> }) => {
57-
const { paraswapRepayWithCollateral, currentMarketData } = useRootStore();
57+
const [paraswapRepayWithCollateral, currentMarketData] = useRootStore((state) => [
58+
state.paraswapRepayWithCollateral,
59+
state.currentMarketData,
60+
]);
5861

5962
const { approval, action, loadingTxns, approvalTxState, mainTxState, requiresApproval } =
6063
useParaSwapTransactionHandler({
@@ -103,7 +106,6 @@ export const CollateralRepayActions = ({
103106

104107
return (
105108
<TxActionsWrapper
106-
blocked={blocked}
107109
preparingTransactions={loadingTxns}
108110
mainTxState={mainTxState}
109111
approvalTxState={approvalTxState}

src/components/transactions/Repay/CollateralRepayModalContent.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { Box, SvgIcon, Typography } from '@mui/material';
66
import BigNumber from 'bignumber.js';
77
import { useRef, useState } from 'react';
88
import { PriceImpactTooltip } from 'src/components/infoTooltips/PriceImpactTooltip';
9-
import { Warning } from 'src/components/primitives/Warning';
10-
import { USDTParaswapWarning } from 'src/components/Warnings/USDTParaswapWarning';
119
import {
1210
ComputedReserveData,
1311
useAppDataContext,
@@ -41,7 +39,7 @@ export function CollateralRepayModalContent({
4139
}: ModalWrapperProps & { debtType: InterestRate }) {
4240
const { user, reserves, userReserves } = useAppDataContext();
4341
const { gasLimit, txError, mainTxState } = useModalContext();
44-
const { currentChainId, currentNetworkConfig, currentMarketData } = useProtocolDataContext();
42+
const { currentChainId, currentNetworkConfig } = useProtocolDataContext();
4543
const { currentAccount } = useWeb3Context();
4644

4745
// List of tokens eligble to repay with, ordered by USD value
@@ -191,10 +189,6 @@ export function CollateralRepayModalContent({
191189
}
192190

193191
const assetsBlockingWithdraw: string[] = zeroLTVBlockingWithdraw(user);
194-
const isUSDTEthMainnetV3 =
195-
currentChainId === 1 &&
196-
!!currentMarketData.v3 &&
197-
(tokenToRepayWith.symbol === 'USDT' || poolReserve.symbol === 'USDT');
198192

199193
let blockingError: ErrorType | undefined = undefined;
200194

@@ -282,12 +276,6 @@ export function CollateralRepayModalContent({
282276
</Typography>
283277
)}
284278

285-
{isUSDTEthMainnetV3 && (
286-
<Warning severity="warning" sx={{ mt: 2, mb: 0 }}>
287-
<USDTParaswapWarning />
288-
</Warning>
289-
)}
290-
291279
<TxModalDetails
292280
gasLimit={gasLimit}
293281
slippageSelector={
@@ -332,7 +320,7 @@ export function CollateralRepayModalContent({
332320
isWrongNetwork={isWrongNetwork}
333321
symbol={symbol}
334322
rateMode={debtType}
335-
blocked={blockingError !== undefined || error !== '' || isUSDTEthMainnetV3}
323+
blocked={blockingError !== undefined || error !== ''}
336324
loading={routeLoading}
337325
buildTxFn={buildTxFn}
338326
/>

src/components/transactions/Swap/SwapActions.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ export const SwapActions = ({
5050
buildTxFn,
5151
...props
5252
}: SwapBaseProps & { buildTxFn: () => Promise<SwapTransactionParams> }) => {
53-
const { swapCollateral, currentMarketData } = useRootStore();
53+
const [swapCollateral, currentMarketData] = useRootStore((state) => [
54+
state.swapCollateral,
55+
state.currentMarketData,
56+
]);
5457

5558
const { approval, action, approvalTxState, mainTxState, loadingTxns, requiresApproval } =
5659
useParaSwapTransactionHandler({
@@ -97,7 +100,6 @@ export const SwapActions = ({
97100

98101
return (
99102
<TxActionsWrapper
100-
blocked={blocked}
101103
mainTxState={mainTxState}
102104
approvalTxState={approvalTxState}
103105
isWrongNetwork={isWrongNetwork}

src/components/transactions/Swap/SwapModalContent.tsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { Warning } from 'src/components/primitives/Warning';
88
import { Asset, AssetInput } from 'src/components/transactions/AssetInput';
99
import { TxModalDetails } from 'src/components/transactions/FlowCommons/TxModalDetails';
1010
import { StETHCollateralWarning } from 'src/components/Warnings/StETHCollateralWarning';
11-
import { USDTParaswapWarning } from 'src/components/Warnings/USDTParaswapWarning';
1211
import { CollateralType } from 'src/helpers/types';
1312
import { useCollateralSwap } from 'src/hooks/paraswap/useCollateralSwap';
1413
import { getDebtCeilingData } from 'src/hooks/useAssetCaps';
@@ -41,7 +40,7 @@ export const SwapModalContent = ({
4140
isWrongNetwork,
4241
}: ModalWrapperProps) => {
4342
const { reserves, user, marketReferencePriceInUsd } = useAppDataContext();
44-
const { currentChainId, currentNetworkConfig, currentMarketData } = useProtocolDataContext();
43+
const { currentChainId, currentNetworkConfig } = useProtocolDataContext();
4544
const { currentAccount } = useWeb3Context();
4645
const { gasLimit, mainTxState: supplyTxState, txError } = useModalContext();
4746

@@ -110,11 +109,6 @@ export const SwapModalContent = ({
110109
// if the hf would drop below 1 from the hf effect a flashloan should be used to mitigate liquidation
111110
const shouldUseFlashloan = useFlashloan(user.healthFactor, hfEffectOfFromAmount);
112111

113-
const isUSDTEthMainnetV3 =
114-
currentChainId === 1 &&
115-
!!currentMarketData.v3 &&
116-
(swapTarget.reserve.symbol === 'USDT' || poolReserve.symbol === 'USDT');
117-
118112
// consider caps
119113
// we cannot check this in advance as it's based on the swap result
120114
const remainingSupplyCap = remainingCap(
@@ -294,12 +288,6 @@ export const SwapModalContent = ({
294288
</Warning>
295289
)}
296290

297-
{isUSDTEthMainnetV3 && (
298-
<Warning severity="warning" sx={{ mt: 2, mb: 0 }}>
299-
<USDTParaswapWarning />
300-
</Warning>
301-
)}
302-
303291
<TxModalDetails
304292
gasLimit={gasLimit}
305293
slippageSelector={
@@ -329,10 +317,7 @@ export const SwapModalContent = ({
329317
targetReserve={swapTarget.reserve}
330318
symbol={poolReserve.symbol}
331319
blocked={
332-
blockingError !== undefined ||
333-
error !== '' ||
334-
isUSDTEthMainnetV3 ||
335-
swapTarget.reserve.symbol === 'stETH'
320+
blockingError !== undefined || error !== '' || swapTarget.reserve.symbol === 'stETH'
336321
}
337322
useFlashLoan={shouldUseFlashloan}
338323
loading={routeLoading}

src/hooks/paraswap/common.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import {
55
constructFetchFetcher,
66
constructGetRate,
77
constructPartialSDK,
8+
ContractMethod,
9+
OptimalRate,
10+
SwapSide,
811
TransactionParams,
912
} from '@paraswap/sdk';
10-
import { RateOptions } from '@paraswap/sdk/dist/rates';
11-
import { ContractMethod, OptimalRate, SwapSide } from 'paraswap-core';
13+
import { RateOptions } from '@paraswap/sdk/dist/methods/swap/rates';
1214

1315
import { ComputedReserveData } from '../app-data-provider/useAppDataProvider';
1416

@@ -47,7 +49,7 @@ const ParaSwap = (chainId: number) => {
4749
const fetcher = constructFetchFetcher(fetch); // alternatively constructFetchFetcher
4850
return constructPartialSDK(
4951
{
50-
network: chainId,
52+
chainId,
5153
fetcher,
5254
},
5355
constructBuildTx,
@@ -151,7 +153,14 @@ export async function fetchExactInRate(
151153
};
152154

153155
if (max) {
154-
options.excludeContractMethods = [ContractMethod.simpleSwap];
156+
options.excludeContractMethods = [
157+
ContractMethod.simpleSwap,
158+
ContractMethod.directUniV3Swap,
159+
ContractMethod.directBalancerV2GivenInSwap,
160+
ContractMethod.directBalancerV2GivenOutSwap,
161+
ContractMethod.directCurveV1Swap,
162+
ContractMethod.directCurveV2Swap,
163+
];
155164
}
156165

157166
const swapper = ExactInSwapper(chainId);
@@ -237,7 +246,11 @@ export async function fetchExactOutRate(
237246
};
238247

239248
if (max) {
240-
options.excludeContractMethods = [ContractMethod.simpleBuy];
249+
options.excludeContractMethods = [
250+
ContractMethod.simpleBuy,
251+
ContractMethod.directUniV3Buy,
252+
ContractMethod.directBalancerV2GivenOutSwap,
253+
];
241254
}
242255

243256
const swapper = ExactOutSwapper(chainId);

src/hooks/paraswap/useCollateralRepaySwap.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BigNumberZeroDecimal, normalize } from '@aave/math-utils';
2-
import { OptimalRate } from 'paraswap-core';
2+
import { OptimalRate } from '@paraswap/sdk';
33
import { useCallback, useEffect, useMemo, useState } from 'react';
44

55
import {

src/hooks/paraswap/useCollateralSwap.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BigNumberZeroDecimal, normalize } from '@aave/math-utils';
2-
import { OptimalRate } from 'paraswap-core';
2+
import { OptimalRate } from '@paraswap/sdk';
33
import { useCallback, useEffect, useMemo, useState } from 'react';
44

55
import {

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.

0 commit comments

Comments
 (0)