简体   繁体   English

测试网上的 Uniswap 'INSUFFICIENT_LIQUIDITY'

[英]Uniswap 'INSUFFICIENT_LIQUIDITY' on testnet

I'm trying to get estimated eth needed to perform a swap on ropsten.我正在尝试估算在 ropsten 上执行交换所需的 eth。

interface IUniswap {
            
        function WETH() external pure returns (address);
        
        function getAmountsOut(
            uint amountIn, 
            address[] calldata path)
            external
            view 
            returns (uint[] memory amounts);        
}


contract UniswapController {
    address internal constant UNISWAP_ROUTER_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;

    IUniswap public uniswapRouter;

    address private UNISWAP_DAI_ADDRESS = 0x6B175474E89094C44Da98b954EedeAC495271d0F;

    constructor() public {
        uniswapRouter = IUniswap(UNISWAP_ROUTER_ADDRESS);
    }

    function getEstimatedETHforToken(uint daiAmount) public view returns (uint[] memory) {
        return uniswapRouter.getAmountsOut(daiAmount, getPathForETHtoDAI());

    }
    
    function getWETH() public view returns(address) {
        return uniswapRouter.WETH();
    }
    
    function getPathForETHtoDAI() public view returns (address[] memory) {
        address[] memory path = new address[](2);
        
        path[0] = uniswapRouter.WETH();
        path[1] = UNISWAP_DAI_ADDRESS;
    
        return path;
    }
}

When I run getEstimatedETHforToken(amount) on remix ide, I get the error:当我在 remix ide 上运行getEstimatedETHforToken(amount)时,出现错误:

execution reverted: UniswapV2Library: INSUFFICIENT_LIQUIDITY

I suspect I have the wrong DAI stablecoin address, but this is the address on uniswap's site, which one should I use?我怀疑我的 DAI 稳定币地址有误,但这是 uniswap 网站上的地址,我应该使用哪个地址?

There doesn't seem to be good tokens use on testnets.在测试网上似乎没有很好的代币使用。 Just forked the mainnet using ganache-cli and infura with this tutorial and it worked just fine.刚刚在本教程中使用ganache-cli和 infura 分叉了主网,它工作得很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM