# \[Coding feedback wanted!\] Uniswap clone

**URL:** https://forum.flow.com/t/coding-feedback-wanted-uniswap-clone/543
**Category:** 🏄🏻‍♀️ Cadence
**Created:** [August 8, 2020, 9:03pm UTC](https://forum.flow.com/t/coding-feedback-wanted-uniswap-clone/543 "2020-08-08T21:03:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![makoto](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/makoto/32/5_2.png) [@makoto](https://forum.flow.com/u/makoto)
#### Post date: [August 8, 2020, 9:03pm UTC](https://forum.flow.com/t/coding-feedback-wanted-uniswap-clone/543/1 "2020-08-08T21:03:43Z")

</div>

Since there’s no technical assignment, I created super simple AMM(Automated Market Making) Dex based on the [Market Place tutorial](https://docs.onflow.org/docs/quick-set-up-for-marketplace). I would like to have some coding feedback as I may continue working on this as a capstone project.

## Reference

[https://medium.com/@austin\_48503/️-minimum-viable-exchange-d84f30bd0c90](https://medium.com/@austin_48503/%EF%B8%8F-minimum-viable-exchange-d84f30bd0c90)

I also created a simple [ruby code](https://gist.github.com/makoto/e761f49ad522924e5bd9e8de97630601) 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

- [Flow playground](https://play.onflow.org/ac8f1629-2f92-4559-b456-1b5401eab111)

## 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](https://unisocks.exchange/)) tokens?
- Is the current xVault/yVault secure? (= can the contract owner drain the fund?)

---

<div class="post-metadata">

### Author: ![Mackenzie](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Mackenzie](https://forum.flow.com/u/Mackenzie)
#### Post date: [August 9, 2020, 6:34pm UTC](https://forum.flow.com/t/coding-feedback-wanted-uniswap-clone/543/2 "2020-08-09T18:34:19Z")

</div>

Is there an account missing in Transaction 2, line 35?  
 ![Screen Shot 2020-08-09 at 11.34.41 AM](https://us1.discourse-cdn.com/flex022/uploads/flow/original/1X/b4ff35f1f6b352beb24a748462fd67e007a327a8.png)

---

<div class="post-metadata">

### Author: ![makoto](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/makoto/32/5_2.png) [@makoto](https://forum.flow.com/u/makoto)
#### Post date: [August 9, 2020, 8:49pm UTC](https://forum.flow.com/t/coding-feedback-wanted-uniswap-clone/543/3 "2020-08-09T20:49:35Z")

</div>

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