wagmiwiz / uniswap-v1-rewrite

Gaining more Solidity knowledge by rewriting Uni V1 (vyper) to Solidity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

An exercise in making a Solidity version of Uni V1, cuz why not

Approach

  1. Look at the Python unit tests and convert them line by line (e.g. https://github.com/Uniswap/uniswap-v1/blob/master/tests/exchange/test_liquidity_pool.py)
  2. Make them pass by writing solidity contract functions
  3. Start with add/remove liquidity, then move onto swapping etc

To run

npm install
npx hardhat test

Learnings so far

  • Vyper feels safer than Solidity (by design!) but lack of inheritance is annoying, esp with common things like ERC20 implementations
    • As an example, Vyper version implements token transferring explicitly, whilst for Solidity I just used OpenZeppelin's + mint()
  • Hardhat is awesome, if only it was easy to integrate into IDE for simpler debugging (need to find if someone did this)
  • Its surprising how simple Uni V1 code actually is, expected it to be far more complicated. Hadn't realised that UNI token was essentially what is now the LP token.

About

Gaining more Solidity knowledge by rewriting Uni V1 (vyper) to Solidity


Languages

Language:JavaScript 57.4%Language:Solidity 42.6%