# Making your own DEX

**URL:** <https://forum.soliditylang.org/t/making-your-own-dex/181>\
**Category:** Code Wizards\
**Created:** [March 15, 2021, 10:42pm UTC](https://forum.soliditylang.org/t/making-your-own-dex/181 "2021-03-15T22:42:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cryptormaster](https://avatars.discourse-cdn.com/v4/letter/c/e9bcb4/32.png) [@cryptormaster](https://forum.soliditylang.org/u/cryptormaster)\
**Post date:** [March 15, 2021, 10:42pm UTC](https://forum.soliditylang.org/t/making-your-own-dex/181/1 "2021-03-15T22:42:16Z")

</div>

Hi everyone, i had this idea for a new liquidity pool design. I already have some Solidity programming experience. What i want to do is basically my own decentralized exchange (DEX), with a generic liquidity pool contract for Token/Token pairs, and then a factory contract that you can call to deploy a new liquidity pool contract whenever you want to add a new token/token pair. So basically something like a basic Uniswap, pretty much.

I started coding a simple liquidity pool contract, but i realized that maybe this is not the kind of thing that you should completely write yourself, because a security bug in something like a DEX can be catastrophic, and if you write everything on your own bugs are very likely…

So, my question is, what would be the best route to do this? Should i use some kind of template/standard? (I dont know of any, and i dont want to fork Uniswap)? Should i write everything myself?  
Is my liquidity pool and factory contract a good way of doing this?  
Thanks guys

---

<div class="post-metadata">

**Author:** ![Bu\_Xinren](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@Bu\_Xinren](https://forum.soliditylang.org/u/Bu_Xinren)\
**Post date:** [May 24, 2021, 12:00pm UTC](https://forum.soliditylang.org/t/making-your-own-dex/181/2 "2021-05-24T12:00:03Z")

</div>

Checkout Pankcake swap. All their code is on gitlab.

I’m wanting to do something similar. I want a token pair (my token + BNB or similar) I’ll take the BNB and invest, then distribute profits via another contract, spread across all token holders according to % holding.
