uniswap对接addLiquidity 显示false Transaction mined but execution failed

我在编写一个sol文件,已经导入了uniswapfactroy和uniswapexchange的接口文件,接下来新建一个util文件完成addLiquidity ,代码如下:

pragma solidity 0.6.0;

import "./UniswapInterface.sol";
import "./IERC20.sol";

/**
 * @title The Utils of Uniswap
 * @author Tao
 */
contract UniswapUtils {
    // ropsten testnet
    address public constant UNISWAP_FACTORY_ADDRESS = 0x9c83dCE8CA20E9aAF9D3efc003b2ea62aBC08351;
    // TAO address
    address public constant DAI_ADDRESS = 0x6DFEcD45BbAA2b0032B25F91Ee8D48C8FBbFB4b1;

    /**
     * @dev Get UniswapExchange
     * @param _tokenAddress the address token contract
     * @return the address of UniswapExchange
     */ 
    function getUniswapExchange(address _tokenAddress)
        public
        view
        returns (address)
    {
        return
            IUniswapFactory(UNISWAP_FACTORY_ADDRESS).getExchange(_tokenAddress);
    }

    function test0() public returns(address)
    {
        return IUniswapFactory(UNISWAP_FACTORY_ADDRESS).createExchange(DAI_ADDRESS);
    }

    function test1()public view returns(address)
    {
        IUniswapExchange uniswapExchange=IUniswapExchange(getUniswapExchange(DAI_ADDRESS));
        return uniswapExchange.tokenAddress();
    }

    function test2() public payable returns(uint256)
    {
        IUniswapExchange uniswapExchange=IUniswapExchange(getUniswapExchange(DAI_ADDRESS));
        IERC20(DAI_ADDRESS).approve(address(uniswapExchange), 100);
        IERC20(DAI_ADDRESS).transferFrom(msg.sender, address(this), 100);
        uniswapExchange.addLiquidity.value(msg.value)(
            100,
            100,
            now + 120
            );
}

但是一直无法添加流动性,报错信息如下: https://ropsten.etherscan.io/tx/0x4a8f3840075889fe3f5cdd0fdb05085cc177fe879b99ab77fa8c8fd221bf9fc8

请先 登录 后评论

3 个回答

Tiny熊
  擅长:智能合约,以太坊
请先 登录 后评论
Tao
请先 登录 后评论
smartDev
请先 登录 后评论
  • 3 关注
  • 0 收藏,8030 浏览
  • Tao 提出于 2020-05-19 13:15