One of the questions I’ve been asked a lot by the community, as well as friends and family, is what exactly a decentralised exchange (DEX) is and how it works.

DEXs — a bulletin board analogy

You can think of a DEX as a giant bulletin board which anyone can see and add post-it notes to. These notes record who is willing to trade what tokens, and for how much Ether.

Limit Orders

Suppose you decide you want to sell 100 UTY tokens for 1 ETH. You need to let everyone know that you’re willing to make this trade, so you write the details on a post-it note, and stick it to the bulletin board for everyone to see.

Now, of course, we need to make sure that you are actually the person you’re claiming to be, so before you can put the post-it note on the board, you need to sign it — this makes sure that no one can impersonate you or sell your tokens without your knowledge.

Thats it — you’ve now advertised the fact that you’re willing to sell 100 UTY tokens for 1 ETH, and you can sit back and wait to see if anyone wants to take you up on your offer.

Of course, if the price you’ve specified is not very attractive for other people (maybe you’ve asked for too high a price, or you’re not selling many tokens) then it is possible that your post-it note will be ignored and passed over for more attractive offers on the bulletin board.

Market Orders

Now, suppose that you’re looking to buy some UTY tokens right now. You head over to the bulletin board and take a look at all of the post-it notes on the board to see who is currently willing to sell UTY tokens.

You decide which of the post-it notes (offers) most appeals, peel it off, and send it, along with the right amount of Ether, to the smart contract.

The smart contract checks that the signature is correct (matches the person who is claiming to be selling tokens) and that you’ve sent the right amount of Ether (you don’t need to buy the whole amount being offered), and if it all matches, executes the trade, sending you your tokens, and the post-it note author the corresponding amount of Ether.

The post-it note is either removed from the bulletin board (if you bought the full amount of tokens offered), or otherwise amended to show the remaining amount of tokens being sold.

Some Terminology

More commonly, the bulletin board in the above example is called the order book. The order book is simply a list of all Limit Orders — offers that users have made to buy or sell tokens at particular prices.

So someone who wants to make an order (Limit Order) is adding a new order to the order book, and someone who wants to take an order (Market Order) is pulling off a particular entry in the order, and executing a trade against it!

Behind the scenes the order book is managed through a series of micro-services running on a server that keeps check of how much of each order remains, if any, and makes the order book available to the website for people to look through.

Any actual trades where tokens and Ether change hands (Market Orders) are executed through the enclavesdex.eth smart contract.

Feedback

We would love to hear any feedback on the exchange, please contact us at any of e-mail, Telegram, Reddit, Slack!

Please note that Enclaves DEX should be used only for trading utility tokens, and any use is entirely at your own risk. Enclaves DEX is not responsible for any losses made from trading tokens, or using our smart contract. See https://enclaves.io/ for full disclaimer.