I am trying to implement a Ropsten Testnet swap via contract. This contract swaps Testnet DAI for a token I have created. Liquidity is added and swapping via the UI works.
IUniswapV2Router02 private router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
Token public token; //address passed via constructor
ERC20 public stablecoin = ERC20(0xaD6D458402F60fD3Bd25163575031ACDce07538D); //DAI
address[] paths = [address(stablecoin), address(token)];
unction swapper (uint buyValue, uint minAmount, uint time) public {
require(msg.sender==owner, "only contract owner");
router.swapExactTokensForTokens(buyValue, minAmount, paths, address(this), time);
}
When I run the swapper function, it returns Fail with error 'UniswapV2Library: ZERO_ADDRESS'. What is wrong?