diff --git a/package.json b/package.json index 54ac478832..ffcd8cd540 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@lingui/react": "^3.14.0", "@mui/icons-material": "^5.10.14", "@mui/material": "^5.10.9", - "@paraswap/sdk": "6.2.2", + "@paraswap/sdk": "6.2.4", "@tanstack/react-query": "^4.28.0", "@visx/axis": "^2.14.0", "@visx/curve": "^2.1.0", diff --git a/src/components/transactions/Switch/SwitchActions.tsx b/src/components/transactions/Switch/SwitchActions.tsx index 652761042b..d38db0ec57 100644 --- a/src/components/transactions/Switch/SwitchActions.tsx +++ b/src/components/transactions/Switch/SwitchActions.tsx @@ -117,6 +117,7 @@ export const SwitchActions = ({ maxSlippage: Number(slippage) * 10000, permit: signatureParams && signatureParams.signature, deadline: signatureParams && signatureParams.deadline, + partner: 'aave-widget', }); tx.chainId = chainId; const txWithGasEstimation = await estimateGasLimit(tx, chainId); diff --git a/src/components/transactions/Switch/SwitchModalContent.tsx b/src/components/transactions/Switch/SwitchModalContent.tsx index 1d4aafae4a..dba8ccba93 100644 --- a/src/components/transactions/Switch/SwitchModalContent.tsx +++ b/src/components/transactions/Switch/SwitchModalContent.tsx @@ -105,6 +105,9 @@ export const SwitchModalContent = ({ destToken: selectedOutputReserve.underlyingAsset, destDecimals: selectedOutputReserve.decimals, user, + options: { + partner: 'aave-widget', + }, }); if (sellRates && switchTxState.success) { diff --git a/src/hooks/paraswap/common.ts b/src/hooks/paraswap/common.ts index 259cce8aab..cd860fade1 100644 --- a/src/hooks/paraswap/common.ts +++ b/src/hooks/paraswap/common.ts @@ -78,7 +78,7 @@ export const getParaswap = (chainId: ChainId) => { throw new Error('chain not supported'); }; -const getFeeClaimerAddress = (chainId: ChainId) => { +export const getFeeClaimerAddress = (chainId: ChainId) => { if (ChainId.base === chainId) return MiscBase.PARASWAP_FEE_CLAIMER; return MiscEthereum.PARASWAP_FEE_CLAIMER; @@ -350,7 +350,7 @@ export const ExactInSwapper = (chainId: ChainId) => { priceRoute: route, userAddress: user, partnerAddress: FEE_CLAIMER_ADDRESS, - positiveSlippageToUser: false, + takeSurplus: true, }, { ignoreChecks: true } ); @@ -423,7 +423,7 @@ const ExactOutSwapper = (chainId: ChainId) => { priceRoute: route, userAddress: user, partnerAddress: FEE_CLAIMER_ADDRESS, - positiveSlippageToUser: false, + takeSurplus: true, srcDecimals, destDecimals, }, diff --git a/src/hooks/paraswap/useParaswapRates.ts b/src/hooks/paraswap/useParaswapRates.ts index 3a285d8433..0f575e15f7 100644 --- a/src/hooks/paraswap/useParaswapRates.ts +++ b/src/hooks/paraswap/useParaswapRates.ts @@ -1,9 +1,10 @@ import { OptimalRate, SwapSide } from '@paraswap/sdk'; +import { RateOptions } from '@paraswap/sdk/dist/methods/swap/rates'; import { useMutation, useQuery } from '@tanstack/react-query'; import { BigNumber, constants, PopulatedTransaction } from 'ethers'; import { QueryKeys } from 'src/ui-config/queries'; -import { getParaswap } from './common'; +import { getFeeClaimerAddress, getParaswap } from './common'; type ParaSwapSellRatesParams = { amount: string; @@ -13,6 +14,7 @@ type ParaSwapSellRatesParams = { destDecimals: number; chainId: number; user: string; + options?: RateOptions; }; export const useParaswapSellRates = ({ @@ -23,6 +25,7 @@ export const useParaswapSellRates = ({ destToken, destDecimals, user, + options = {}, }: ParaSwapSellRatesParams) => { return useQuery({ queryFn: () => { @@ -35,6 +38,10 @@ export const useParaswapSellRates = ({ destDecimals, userAddress: user ? user : constants.AddressZero, side: SwapSide.SELL, + options: { + ...options, + excludeDEXS: ['ParaSwapPool', 'ParaSwapLimitOrders'], + }, }); }, queryKey: [QueryKeys.PARASWAP_RATES, chainId, amount, srcToken, destToken, user], @@ -54,9 +61,11 @@ type UseParaswapSellTxParams = { maxSlippage: number; permit?: string; deadline?: string; + partner?: string; }; export const useParaswapSellTxParams = (chainId: number) => { + const FEE_CLAIMER_ADDRESS = getFeeClaimerAddress(chainId); return useMutation({ mutationFn: async ({ srcToken, @@ -68,6 +77,7 @@ export const useParaswapSellTxParams = (chainId: number) => { maxSlippage, permit, deadline, + partner, }: UseParaswapSellTxParams) => { const paraswap = getParaswap(chainId); const response = await paraswap.buildTx( @@ -80,7 +90,9 @@ export const useParaswapSellTxParams = (chainId: number) => { userAddress: user, priceRoute: route, slippage: maxSlippage, - positiveSlippageToUser: true, + takeSurplus: true, + partner, + partnerAddress: FEE_CLAIMER_ADDRESS, permit, deadline, }, diff --git a/yarn.lock b/yarn.lock index 77a310fac6..259a8d8664 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2799,10 +2799,10 @@ resolved "https://registry.yarnpkg.com/@paraswap/core/-/core-1.1.0.tgz#5ec7415be69dc657a9d82b0fde4e20f632cca1b6" integrity sha512-ecnX8ezlhYWFwolZxYEz+K+RfLr8xaxQqiJKlxJ8Yf00tXTGxDGn6/Acy00t4+9Kv0apewd7++J33eJt9yNfwg== -"@paraswap/sdk@6.2.2": - version "6.2.2" - resolved "https://registry.yarnpkg.com/@paraswap/sdk/-/sdk-6.2.2.tgz#c34eef61ab4cb8e0ad284f2259a25b9a61b4bb9a" - integrity sha512-W0sAIf/T4zAmI7Yp4TcAuQr68NtaopeuYOWop20piAGoko4K9eLY4DYwWgkXf9fw9bAeeGofwP+GYJJC8Q24xg== +"@paraswap/sdk@6.2.4": + version "6.2.4" + resolved "https://registry.yarnpkg.com/@paraswap/sdk/-/sdk-6.2.4.tgz#df6cf7c6acf04b40c4efd678d1aa7326e5e8d219" + integrity sha512-Ow7MArOXYeE0xrAYclCxPUyBCsPlk+Jm3k1+jsxXF0jUQgucSXZ4yfFzA/nxlRd6xjpoljX5V05Nir1nOAINsQ== dependencies: "@paraswap/core" "1.1.0" bignumber.js "^9.0.2"