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;
}
}
当我 运行 getEstimatedETHforToken(amount)
混音 ide 时,我收到错误:
execution reverted: UniswapV2Library: INSUFFICIENT_LIQUIDITY
我怀疑我的 DAI 稳定币地址有误,但这是 uniswap 网站上的地址,我应该使用哪个?
似乎没有在测试网上使用好的令牌。刚刚使用 ganache-cli
和 infura 使用 this tutorial 分叉了主网,它工作得很好。
我正在尝试估算在 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;
}
}
当我 运行 getEstimatedETHforToken(amount)
混音 ide 时,我收到错误:
execution reverted: UniswapV2Library: INSUFFICIENT_LIQUIDITY
我怀疑我的 DAI 稳定币地址有误,但这是 uniswap 网站上的地址,我应该使用哪个?
似乎没有在测试网上使用好的令牌。刚刚使用 ganache-cli
和 infura 使用 this tutorial 分叉了主网,它工作得很好。