Uniswap V1 – Creating and Interacting with a Pool Using Remix and Vyper

remixuniswapvyper

I have the project of making some educational content on the history of AMMs and to do so I’m trying to interact with Uniswap V1 contracts on Goerli. I’m quite new to all that (this exercise is also an opportunity for me to learn), so my apologies if you see rookie mistakes 🙂

What I’m trying to do is:

  1. Create a new Token on Goerli
  2. Create a Uniswap V1 pool to swap between this token and ETH
  3. Add some liquidity to that pool.

 
I managed to the first 2:
 

Note: the pool TOTO / ETH has been created by calling the createExchange function of the Uniswap V1 factory contract here: https://goerli.etherscan.io/address/0x6ce570d02d73d4c384b46135e87f8c592a8c86da#writeContract

My first issue is that I didn’t manage in Etherscan to Verify & Publish the pool’s contract (it’s in Vyper, maybe this doesn’t help), hence I cannot interact directly with the contract in Etherscan. So now I’m trying to interact with the pool contract using Remix IDE.

To do so, I first created a .ABI file in Remix with the ABI of the TOTO / ETH pool. To find the ABI, I used the one here, since the factory contract of Uniswap V1 seems to be using this template to create new pools: https://goerli.etherscan.io/address/0xf9555870C0575A4ECB47cB1587bCA162A3076d7F#code

enter image description here

enter image description here

I managed to load the ABI in Remix, but when I tried calling the addLiquidity function with these parameters:

  • min_liquidity: 0
  • max_tokens: 500000
  • deadline: 1695139366 (I generate a timestamp in the future on the website unixtimestamp dot com

And sending 1000000000000 wei in the "VALUE" field (since it’s a payable function)
 
I get this message:
 
 

enter image description here
 
I try sending the transaction, it gets mined in a block but the execution fails:

 
https://goerli.etherscan.io/tx/0xe825c8aadceb952643b4666ebb9ff22990071a9a592dd63fb83c485cfb99d856
 

 

If anyone can either:

  • Help me make that work
  • Or help me verify & publish the TOTO / ETH contract on Etherscan
  • Or both 🙂

I would be very grateful since I’m struggling with this for a while now.

Cheers!

Best Answer

I found the solution, I needed to call the approve method of the token with the address of the pool as a parameter. I then managed to add liquidity to the pool. Thanks again!

Related Topic