1

I am trying to compile UniswapSwap which inherits from UniswapV2Router02 on Remix, because i want to deploy it on Ropsten testnet so i can have fun (& learning) on swapping ETH to another token. But its not going through and giving following error :

UniswapSwap.sol:11:44: Parse Error: Expected ',' but got identifier constructor() UniswapV2Router02(address _factory, address _WETH) public { ^------^

pragma solidity =0.6.6;
import '@uniswap/v2-periphery/contracts/UniswapV2Router02.sol';
import "@openzeppelin/contracts/access/Ownable.sol";

contract Swap is UniswapV2Router02, Ownable {
   
   
 
    
   constructor() UniswapV2Router02(address _factory, address _WETH) public {
       
    }
    
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        override
        payable
        ensure(deadline)
        returns (uint[] memory amounts)
    {
        require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
        amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
        require(amounts[0] <= msg.value, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
        IWETH(WETH).deposit{value: amounts[0]}();
        assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
        _swap(amounts, path, to);
        // refund dust eth, if any
        if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]);
    }
}```


Can someone please help so i can understand the basics more, as to where I am going wrong ??

Thanks & regards

Suveett kalra
1
  • Hi Cameel, Thanks I realized my mistake !! Aug 15, 2021 at 5:03

1 Answer 1

0

This is not a valid syntax for a call to an inherited constructor. You should give it parameter values instead of repeating its parameter types and names. You probably wanted to add these parameters to your Swap constructor instead:

constructor(address _factory, address _WETH)
    UniswapV2Router02(_factory, _WETH)
    public 
{
} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.