Better Future With Decentralized Exchange

in #money7 years ago

Understanding Decentralized Exchanges
Most of the world’s cryptocurrency trading is done through centralized exchanges such as Coinbase/GDax, Binance, Bittrex, etc. These exchanges manage a person’s capital (and private keys) and facilitate trading. In the past weeks and years there have been some high profile hacks in which a large amount of funds were stolen. It is unlikely that this problem will get solved anytime soon and I would argue that the problem will only get worse. The increase of software and hardware complexity will result in more severe security vulnerabilities such as the recent Meltdown and Spectre exploits in Intel’s CPU firmware.
Decentralized Exchanges — also known as DEX’s — are a new technology that facilitate cryptocurrency trading on a distributed ledger. These exchanges shift back control of funds and trades to the user and they eliminate the single point of failure. A secondary effect is that government taxation or fund confiscation can become nearly impossible. This can arguably have profound long term consequences to macro-economic and geopolitical landscape.
DEX technology however, is still young and there are still quite some shortcomings including certain attack vectors. In this post, we’ll examine the inner workings of a decentralized exchange.
EtherDelta and 0x
There’s a popular project out there called 0x (Zero X). The aim of the project is to provide an open protocol for decentralized exchanges on top of Ethereum. They’ve also done a token sale of the $ZRX token that’s trading at a $542M market cap currently. (Disclosure: I own some). The purpose of the token is to provide governance mechanisms in for smart contracts and protocols.
0x has some excellent ideas, open source code implementation and documentation. I’m not sure however, how 0x plans to monetize decentralized exchanges and how a $542M market cap can be sustained.
When you read the 0x white paper it is basically an eloquent description of the EtherDelta decentralized exchange. EtherDelta is one of the first decentralized exchanges that has gained some traction out there. It runs mostly on Ethereum and there is about $1.4BN USD in the most recent version of its smart contract. This is pretty phenomenal given the state of their user interface which is difficult to use for even the most tech savvy users.

The EtherDelta UI
Understanding how the EtherDelta exchange works will give us a thorough understanding of the current state of decentralized exchanges and how 0x will work. 0x at it’s essence is EtherDelta with better code and additional capabilities.
The EtherDelta Smart Contract
Ethereum smart contracts are pieces of code that can be executed on the Ethereum blockchain in a distributed and immutable fashion. The core logic of EtherDelta and Ethereum-based exchanges resides in these smart contracts. Compared to conventional programming, implementing these smart contracts is like launching a rocket. They need to be ultra secure and robust, because any bug can result in huge monetary losses.
Smart Contracts — which are typically written in a human readable language called Solidity — are compiled down to Ethereum Virtual Machine instructions. These EVM instructions are practically unreadable by humans. Some projects choose to never share the Solidity code of a smart contract in an attempt to create security by obscurity. For example, the Crypto Kitties genetic diversity smart contract is “closed source”. That said, in theory one can always piece together the original workings of a smart contract so always be weary of closed source smart contracts.
The Solidity code for the EtherDelta contract is freely available on Etherscan here. We’ll analyze the two most important areas of the contract: Funds Management & Trading Logic.
Fund Management
EtherDelta leaves control of funds completely in control of the users. That said, in order to use EtherDelta funds need to be moved into the smart contract. Funds are essentially pooled together in the smart contract, but yet it’s all done on a distributed ledger. Confusing I know. The bottom line is that at any point in time a user can withdraw or deposit funds without any third party intervention.

Sort:  

Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in:
https://hackernoon.com/understanding-decentralized-exchanges-51b70ed3fe67