0

Error: VM Exception while processing transaction: reverted with reason string '1inch swap failed'this error came when I run 1inch swap functions. swap code as below

       IAggregationRouterV6.SwapDescription memory desc = IAggregationRouterV6.SwapDescription({
           srcToken: wbtcAddress,
           dstToken: usdcAddress,
           srcReceiver: payable(address(this)),
           dstReceiver: payable(address(this)),
           amount: amountIn,
           minReturnAmount: 1,  // Adjust this if needed
           flags: 0
       });

       console.log("Starting 1inch swap with V6:");
       console.log("WBTC Amount: %s", amountIn);
       console.log("WBTC Address: %s", wbtcAddress);
       console.log("USDC Address: %s", usdcAddress);

       try aggregationRouterV6.swap(address(this), desc, "") returns (uint256 returnAmount, uint256) {
           console.log("1inch swap successful, %s USDC received", returnAmount);
           return returnAmount;  // Return USDC received
       } catch (bytes memory reason) {
           console.log("1inch swap failed, reason: %s", reason.length > 0 ? string(reason) : "no reason provided");
           revert("1inch swap failed");
       }
   }

I am using 1inch aggregation router v6

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.