繁体   English   中英

测试网上的 Uniswap 'INSUFFICIENT_LIQUIDITY'

[英]Uniswap 'INSUFFICIENT_LIQUIDITY' on testnet

我正在尝试估算在 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;
    }
}

当我在 remix ide 上运行getEstimatedETHforToken(amount)时,出现错误:

execution reverted: UniswapV2Library: INSUFFICIENT_LIQUIDITY

我怀疑我的 DAI 稳定币地址有误,但这是 uniswap 网站上的地址,我应该使用哪个地址?

在测试网上似乎没有很好的代币使用。 刚刚在本教程中使用ganache-cli和 infura 分叉了主网,它工作得很好。

暂无
暂无

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

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