[Coding feedback wanted!] Uniswap clone

Since there’s no technical assignment, I created super simple AMM(Automated Market Making) Dex based on the Market Place tutorial. I would like to have some coding feedback as I may continue working on this as a capstone project.

Reference

I also created a simple ruby code to simulate the logic as solidity version is a bit hard to understand (due to having different logic of dealing with Eth and ERC20 tokens)

Flow playground

Setup

  • Deploy FlowToken as second account (0x01)
  • Deploy BaloonToken as third account (0x02)
  • Deploy Dex as forth account (0x03)
  • Run Transaction1.cdc with all accounts
  • Run Transaction2.cdc with all accounts
  • Run Transaction2.cdc with account 0x01
  • Run Script1.cdc to run a report

Todo

  • Allow anyone to deposit/withdraw liquidity
  • Refactor to combine YtoX and XtoY into a single function (as they are almost identical)
  • Add Frontend (if I get enough time)

Open Question.

  • How do I change so that it allows to list any fungible tokens?
  • Can I support both fungible and semi-fungible (NFT but each asset has equal value like unisocks) tokens?
  • Is the current xVault/yVault secure? (= can the contract owner drain the fund?)

Is there an account missing in Transaction 2, line 35?
Screen Shot 2020-08-09 at 11.34.41 AM

No, second is the owner of BaloonToken hence it already has a vault.