Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

337
Views
¿Cómo intercambiar tokens de Uniswap en el contrato mismo? ValueError: estimación de gas fallida: 'ejecución revertida'

Estoy buscando realizar un intercambio Uniswap V3 de WMATIC a USDC. Escribí e implementé mi contacto en Polygon Mumbai Testnet usando brownie-eth.

Sin embargo, al llamar a la función de intercambio en el contrato, aparece el siguiente error:

ValueError: estimación de gas fallida: 'ejecución revertida'. Es probable que esta transacción se revierta. Si desea transmitir, debe establecer el límite de gas manualmente.

No puedo localizar exactamente qué causa que el intercambio falle. Debería haber WMATIC más que suficiente en el contrato para ejecutar el intercambio: https://mumbai.polygonscan.com/address/0xED85D87Ddf25036d8ea1F03005900f5524D65a26

 pragma solidity ^0.8.0; import {TokenSwap} from "./uniswap.sol"; import {ISwapRouter} from '../interfaces/ISwapRouter.sol'; import {TransferHelper} from '../contracts/uniswap/TransferHelper.sol'; contract swapTest { address public immutable tokenIn = 0xb685400156cF3CBE8725958DeAA61436727A30c3; address public immutable tokenOut = 0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747; uint public immutable amount = 0.01*(1 ether); // Uniswap Config address private constant SWAP_ROUTER = 0xE592427A0AEce92De3Edee1F18E0157C05861564; ISwapRouter public immutable swapRouter = ISwapRouter(SWAP_ROUTER); uint24 public constant poolFee = 3000; // Safely transfer tokens function swapExactInputSingle() public returns (uint256 amountOut) { TransferHelper.safeApprove(tokenIn, SWAP_ROUTER, amount); ISwapRouter.ExactInputSingleParams memory params = ISwapRouter .ExactInputSingleParams({ tokenIn: tokenIn, tokenOut: tokenOut, fee: 3000, recipient: address(this), deadline: block.timestamp, amountIn: amount, amountOutMinimum: 0, sqrtPriceLimitX96: 0 }); amountOut = swapRouter.exactInputSingle(params); } }

Me gustaría que el intercambio se realice en el contrato en sí (sin tener que aprobar el contrato para gastar el saldo de la billetera y que el remitente reciba el intercambio). Por eso cambié el destinatario para que sea la dirección (esto) , y no incluye una función de transferencia segura.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!