From e503750296c6f6bde5d61d1ba47f3780a49642e7 Mon Sep 17 00:00:00 2001 From: Martin Grabina Date: Mon, 8 Jun 2026 15:50:14 -0300 Subject: [PATCH] fix(swap): force flashloan flow for Paraswap collateral swaps A no-flashloan collateral swap routes through the simple SwapActionsViaParaswap path, which builds the tx on the aToken addresses. Paraswap can't price or trade aTokens: it doesn't list them and defaults unknown tokens to 18 decimals, so the priceRoute came back with srcDecimals=18 for a 6-decimal asset while buildTx sent 6, and Paraswap rejected it with "Source Decimals Mismatch". On Sonic, where CoW is unsupported and the provider falls back to Paraswap, this hit any collateral swap with a healthy health factor. Force the flashloan flow for Paraswap collateral swaps so they use the adapter (which unwraps to the underlying), matching the existing CoW repay/debt handling. This routes the dispatcher to CollateralSwapActionsViaParaswapAdapters and flips usesAddressToSwap off, so the quote runs on the underlying tokens too. Both sides then agree on real, priceable tokens. --- src/components/transactions/Swap/hooks/useFlowSelector.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/transactions/Swap/hooks/useFlowSelector.ts b/src/components/transactions/Swap/hooks/useFlowSelector.ts index 0330d32c5f..fe1ade6873 100644 --- a/src/components/transactions/Swap/hooks/useFlowSelector.ts +++ b/src/components/transactions/Swap/hooks/useFlowSelector.ts @@ -146,9 +146,11 @@ export const healthFactorSensibleSwapFlowSelector = ({ ? valueToBigNumber(hfAfterSwap).lt(LIQUIDATION_DANGER_THRESHOLD) : false; + // Paraswap can't price or trade aTokens, so a collateral swap can't use the simple aToken path; it must go through the flashloan adapter, which unwraps to the underlying. CoW repay/debt swaps likewise have no non-flashloan path. const forceFlashloanFlow = - state.provider === SwapProvider.COW_PROTOCOL && - (state.swapType === SwapType.RepayWithCollateral || state.swapType === SwapType.DebtSwap); + (state.provider === SwapProvider.COW_PROTOCOL && + (state.swapType === SwapType.RepayWithCollateral || state.swapType === SwapType.DebtSwap)) || + (state.provider === SwapProvider.PARASWAP && state.swapType === SwapType.CollateralSwap); const useFlashloan = forceFlashloanFlow || (extendedUser?.healthFactor !== '-1' &&