I want to write a system that will exchange any ERC20 for any other ERC20 registered in the system using Uniswap I already wrote a contract for Ether swap in DAI and back with UniswapRouterV2 My question is how to create a new pair ERC20 and ERC20(may be ERC20 -> WETH -> ERC20), add liquidity to it and implement a new exchange.

1 Answer 1


For create a new pair, you need to add liquidity to this specific pool. In your case, you have two options:

  • Manually: Go to Uniswap dapp, click on Pool -> More -> Create a new pool -> Insert your token address and second token address and click on Add your liquidity.
  • With coding: in this alternative, you can use createPair() inside IUniswapV2Factory that allow you to create a new pair between your token and another token. When you created this pair, you must to add liquidity inside its liquidity pool for allow other users to be able to swap your token inside liquidity pool. You can use addLiquidity() method inside IUniswapV2Router02 increase your liquidity inside the liquidity pool that you created previous. More information about this two method here: addLiquidity() and createPair().

In the end, for implementing a new exchange, you can use swapExactTokensForTokensSupportingFeeOnTransferTokens() method (here more information about this method) inside IUniswapV2Router02 that it'll allows a user to swap your token inside your smart contract code.

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.