[英]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.