diff --git a/src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActions.tsx b/src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActions.tsx index 82ae9ad3e6..ec1f99bf81 100644 --- a/src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActions.tsx +++ b/src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActions.tsx @@ -3,7 +3,6 @@ import { Dispatch } from 'react'; import { TrackAnalyticsHandlers } from '../../analytics/useTrackAnalytics'; import { ProtocolSwapParams, ProtocolSwapState, SwapProvider, SwapState } from '../../types'; import { SwapActionsViaCoW } from '../SwapActions/SwapActionsViaCoW'; -import { SwapActionsViaParaswap } from '../SwapActions/SwapActionsViaParaswap'; import { CollateralSwapActionsViaCowAdapters } from './CollateralSwapActionsViaCoWAdapters'; import { CollateralSwapActionsViaParaswapAdapters } from './CollateralSwapActionsViaParaswapAdapters'; @@ -41,25 +40,16 @@ export const CollateralSwapActions = ({ ); } case SwapProvider.PARASWAP: - if (state.useFlashloan) { - return ( - - ); - } else { - // Essentially traditional aTokens swap - return ( - - ); - } + // Paraswap can't swap aTokens directly, so always use the adapter. It runs swapAndDeposit + // (no flashloan) or a flashloan based on state.useFlashloan, which useFlowSelector sets from + // the health-factor impact. + return ( + + ); } }; diff --git a/src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActionsViaParaswapAdapters.tsx b/src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActionsViaParaswapAdapters.tsx index c8567ed466..c7d0a53247 100644 --- a/src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActionsViaParaswapAdapters.tsx +++ b/src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActionsViaParaswapAdapters.tsx @@ -139,7 +139,7 @@ export const CollateralSwapActionsViaParaswapAdapters = ({ symbol: state.sourceToken.symbol, blocked: areActionsBlocked(state), isMaxSelected: isMaxSelected, - useFlashLoan: true, + useFlashLoan: state.useFlashloan ?? false, swapCallData: swapCallData, augustus: augustus, signature: signatureParams?.splitedSignature, diff --git a/src/components/transactions/Swap/hooks/useSwapQuote.ts b/src/components/transactions/Swap/hooks/useSwapQuote.ts index 414ac20386..56d3427863 100644 --- a/src/components/transactions/Swap/hooks/useSwapQuote.ts +++ b/src/components/transactions/Swap/hooks/useSwapQuote.ts @@ -48,12 +48,14 @@ const getTokenSelectionForQuote = ( const destTokenObj = invertedQuoteRoute ? state.sourceToken : state.destinationToken; // Quote tokens must match what the order will post on, otherwise CoW's per-pair volume-fee policy and gas estimate apply to a different pair than the order and the cushion computed in useSwapOrderAmounts comes out short. Read provider from the active query arg, not state.provider, which lags during provider transitions. + // Paraswap collateral swaps go through the adapter (swapAndDeposit or flashloan), which operates on the underlying tokens, so quote the underlying. Quoting the aToken depends on Paraswap pricing it correctly, which it doesn't for every chain (e.g. Sonic aUSDC comes back as 18 decimals / $0). const usesAddressToSwap = state.useFlashloan === false && (provider === SwapProvider.COW_PROTOCOL || (provider === SwapProvider.PARASWAP && state.swapType !== SwapType.WithdrawAndSwap && - state.swapType !== SwapType.RepayWithCollateral)); + state.swapType !== SwapType.RepayWithCollateral && + state.swapType !== SwapType.CollateralSwap)); const srcToken = usesAddressToSwap ? srcTokenObj.addressToSwap : srcTokenObj.underlyingAddress; const destToken = usesAddressToSwap ? destTokenObj.addressToSwap : destTokenObj.underlyingAddress;