This article will serve as a guide to ‘decentralized exchanges’ and will explain how they are different from centralized exchanges.
The four key functions
Transactions are among the most crucial components of the cryptocurrency market. Yet contemporary, centralized exchanges that deal in transactions present an exceptionally weak link in the general philosophy of decentralization.
There are four core functions that every exchange serves, whether centralized or decentralized:
- Capital deposits – The deposit of financial assets
- Order books – An electronic list of buy and sell orders made for specific security or financial tools that are organized by price level
- Order matching – The process in which exchanges match buy orders (or bids) with sell orders (or asks) in order to execute security trades
- Asset exchange – When asset accounts are involved in a transaction
If one wanted to construct a fully functional decentralized exchange (DEX), then each of these four functions needs to be decentralized. In a majority of exchanges, it is only the asset exchange that is decentralized. This is due to the fact that the assets are cryptocurrencies, which are set up on the blockchain with no one entity controlling them. The other three functions – especially the capital deposits – are typically centralized.
Before we move forward, allow me to explain what KYC and AML regulations are because they play a part in what we discuss next.
What are AML and KYC?
AML (Anti-Money Laundering) regulations are used as a way to “help detect and report suspicious activity including the predicate offenses to money laundering and terrorist financings, such as securities fraud and market manipulation.” One example of AML is the requirement for banks to report all transactions exceeding $10,000 in cash to federal authorities.
KYC (Know Your Client) is a standard form that is recognized and used throughout the investment industry. For instance, financial institutions are required to gather information about investors to help verify who they are and whether or not they are ‘qualified investors’. That way, investment advisors can know detailed information regarding their client’s risk tolerance, knowledge in investments, and financial position.
For more information about KYC, read one of our previous articles, “What is KYC?”
It is because of these two regulations that exchanges are often required to seek out the users’ identities for the capital deposit. Thus they begin the process of centralized record collection and storage of data that is chiefly personal information. Centralized cryptocurrencies exchanges give their users permission to transact currencies as opposed to creating an ecosystem that is essentially permissionless.
If you want to look at it through an architectural perspective, decentralization means that there is no server that is centrally-controlled and the nodes within the network are distributed. As is, the only truly decentralized exchange that exists is the Blocknet “BlockDX,” and this is mostly because other attempts do not decentralize all four of the above-mentioned functions.
The two types of DEX
A decentralized exchange (DEX) revolves around transacting currencies, and there are two essential models of exchange: Currency-centric and Currency-neutral. Either one of these models can be centralized or decentralized, depending heavily on how the four basic functions of the exchange are handled.
Exchanges that are categorized as ‘currency-centric’ are built on top of singular blockchain platforms, such as Ethereum. A standard currency-centric exchange is limited to escrowing only the currency belonging to the platform that it is built on, an example of this being ERC20 assets and other contracts if the exchange is built on top of Ethereum. This is what is considered to be the traditional structure that exchanges are built on.
The newer model is ‘currency-neutral’, which is designed specifically to connect different types of native cryptocurrencies. It also means that users do not have to live by any specific kind of currency ecosystem. These particular systems allow users to exchange cryptocurrencies without any coins underlying that trade. So it basically functions as a sort of additional ‘middleman’ to go through as it is technically no longer fully peer-to-peer. Such examples of these types of models include Bisq, altcoin.io, and flyp.me.
These more recent projects allow the act of securely matching and managing order books and not just asset exchange, in a manner that is decentralized. This is carried out by utilizing the blockchain. Due to an exchange essentially being a community of users, there needs to be a way to broadcast and match orders.
One kind of method of trustless trading is through a system of cryptocurrency exchange that is made from one user to another, called ‘atomic swaps.’ However, these swaps on their own cannot create a trustless marketplace as it is done from one specific peer to another peer. It’s more like a larger scale broadcast to pretty much anyone residing on the network.
For those who don’t know, atomic swaps are a piece of smart contract technology (more on this later) that allows the exchange of one cryptocurrency for another without the use of centralized intermediates. They typically take place between blockchains of different cryptocurrencies. Alternatively, they can be done off-chain and away from the blockchain. These swaps are sometimes called “peer-to-peer swaps” due to the fact that the trades are usually made wallet-to-wallet.
For more information about atomic swaps, read one of my previous articles, “What are Atomic Swaps?”
Pros & Cons
Probably the most apparent benefit that a DEX offers is the exact same as with any type of decentralized application (DApp), which focuses very heavily on the philosophy of cutting out the middlemen and returning any related interactions to models that are peer-to-peer and permissionless without any real need for central authorities.
To be more specific, decentralization begets censorship-resistance, which in the general case of decentralized exchanges, basically means that no entity associated with central authority could forcibly impose rules and regulations. Nor could they ban currencies and/or the exchange itself. This point is especially important due largely in part to the fact that a great number of countries are clamping down on cryptocurrency trading. To shine more light on this, the two most populated counties in the world – China and India – have outlawed cryptocurrency exchanges, while countries such as Mexico, Russia, Saudi Arabia, and Brazil have restricted cryptocurrencies.
Without the existence of decentralized exchanges, the people’s’ ability to invest in crypto of any kind is subject to governments. Thus cryptocurrency transforms into something hardly more democratic than traditional asset markets. Governments can just as easily apply control over centralized exchanges, and users are subject to authority figures who may, at any given moment, track and tax users or even ban currencies.
Other notable merits of a DEX include a heightened level of security. Massive amount of security attacks, much like the roughly $470 million that was stolen from Mt. Gox, were only made possible because the centralized hot wallets (wallets that function on devices that are connected to the Internet, like computers and mobile phones) of the exchange were targeted. This presented a single key point of failure. In any conventional DEX, each user is in private control of their own funds. So there is absolutely no central point of the attack, making it much more difficult to hack.
With that being said, as we will go further into later on, numerous exchanges claim to be decentralized – such as the case of Bancor – but are actually hybrid and their centralized aspects make for such noticeable vulnerabilities. For example, close to $23 million was stolen from Bancor not too long ago. The exchange responded with a freeze attempt that was built into their protocol, which is really only possible with an overall structure that is at least partially centralized.
DEXs typically use ‘smart contracts’ in order to facilitate transactions, such as utilizing these contracts as collateral for peer-to-peer transactions. For those of you who are unfamiliar with the concept, smart contracts are self-executing settlements with the terms of the agreement between the buyer and the seller being written directly into lines of code. These kinds of contracts permit reliable transactions and agreements to be carried out among anonymous parties without the need for a central authority, legal system, or outside enforcement.
If the contracts themselves are indeed highly secure, then the exchange will benefit from the cryptographic security of the underlying blockchain. In spite of that, this is usually not always the case. Smart contracts have the capacity to contain many vulnerabilities, including underflows, overflows, attacks on re-entry, and many others. As a matter of fact, studies have discovered over 34,000 contracts with known liabilities. These, along with recent hacks such as the previously discussed Bancor attack, reflect the need for smart contract auditing as a means to validate the security of the code written into the contract and seek out any other vulnerabilities.
Furthermore, a DEX could aid in the progress at a faster rate and supply cheaper transactions than a centralized exchange, seeing as how there is no participation of a third party authenticator. At this point in time, this is all just theoretical and has yet to actually be proven by exchanges on a much larger scale. This is because DEXs have not quite achieved the ‘network effect’ of reaching just enough users for critical mass.
Quite possibly the largest disadvantage of current DEXs is the complete lack of functionality, which is something relative to centralized exchanges. A majority of DEXs only support the most basic of market functions, and not even features like margin trading and stop loss. In actuality, the technology has not yet caught up with the ambitions associated with most decentralized exchanges, though DEXs like BlockDX are planning on providing support for additional functionality.
In conclusion, because of both the KYC and AML regulations that were explained earlier, decentralized exchanges do not support fiat conversions. Essentially, whenever introducing traditional fiat currencies into a crypto exchange, you at this point will probably have to introduce a point of centralization.
For all the praise that is attached to decentralized exchanges, it is currently still far off from achieving the liquidity, scalability, and functionality that is needed for mass adoption. Nevertheless, current efforts built for tokens that are Ethereum-based include 0x Protocol, Kyber Network, EtherDelta, BlockDX by Blocknet, and Radex. One participating unique DAO (Decentralized Autonomous Organization)-based platform is IDEX. Decentralized exchanges in its early development included the Waves Platform, Binance Chain, and OasisDEX, the latter of which was built by MakerDAO.
Ox and Kyber
0x Protocol and Kyber Network are both considered to be serious contenders for the future of decentralized exchanges, with one notable similarity being that they use their own internal token (Kyber uses KNC and 0x uses ZRX). The biggest difference that sets them apart is in how order matching is carried out.
- 0x resolves this issue with a hybrid method wherein order matching is done off-chain with an intermediate party and then eventually using the blockchain for the actual trade
- Pretty much anyone can be an off-chain matchmaker by way of maintaining an open book
- Programmable smart contracts give market makers the ability to set fees for handling the transactions (accepting an order and later posting it in the order books)
- Kyber resolves this issue by utilizing smart contracts and reserves
- Unlike 0x, Kyber does not use off-chain matchmakers and, as a substitute, all reserve transactions are managed by smart contracts
- Reserves supply liquidity and a single reserve is upheld by Kyber
- Any additional reserves can be made public or private
- Private reserves are private coin holders who are given the opportunity to choose to act as a source of crypto for the exchange and establish their own rates
- Public reserves are able to receive contributors on behalf of the public, and likewise, the public benefits by engaging in the profits
In comparison to these two incredibly strong and stable platforms, EtherDelta is not as secure.
- EtherDelta had initially been breached and because of this, the exchange never fully recovered to function properly.
- Their ICO (Initial Coin Offering) was launched before the exchange had even begun to work properly.
- The cancellation orders are mined on-chain, so waiting for the next mined block basically means that real-time trading becomes next to impossible.
- The processing of orders is not done on-chain, yet EtherDelta does not experience the speed benefits that off-chain processing provides and users have reported very slow functionality.
With the case of EtherDelta, the order book matching (which if you remember is one of the four key functions) is handled by centralized EtherDelta servers. As a result of this centralization, orders in the order book can easily be censored, meaning that the censorship-resistance philosophy is made unsettled. However, the security benefit of being in control of your funds remains.
The 0x project is fairly similar to the EtherDelta system, with the most prominent difference being that 0x provides a multi-national chain, which is where many exchanges can work together to build a larger order book taking advantage of the shared liquidity pool. With that said, 0x has the exact same centralization concern associated with EtherDelta, by which the centralized servers of an individual exchange deal with order matching.
What makes the IDEX platform its own unique thing is that it essentially lies in a category of its own, due to the fact that it runs on top of the Aurora DAO, which is inspired by free banking.
- They have developed a multi-token structure by way of the DAO, along with IDXM, AURA, and Boreal tokens
- IDXM is primarily used as a membership fee token
- AURA is the Snowglobe staking token that provides support for the multi-exchange protocol
- Market makers are rewarded with AURA while the takers have to pay gas fees
- Boreal is the stable coin, while also being able to permit decentralized peer-to-peer lending
- The Decentralized Capital aspect of IDEX provides the users with both free banking and loans through Boreals
- Snowglobe, which utilizes the AURA token, is the protocol that constructs a secondary network of child-chains that link exchanges in order to improve on the liquidity
- IDEX is not wholly decentralized, as IDEX itself is the only authority that may submit signed trades directly to Ethereum
- This gives users the speed and UX (User Experience) of centralized exchanges, thus forming a hybrid model
OasisDEX is a key competitor to IDEX and this is because it is built by MakerDAO and aims for the similar levels of decentralized interactions along the side of decentralized governance. Be that as it may, OasisDEX is only in alpha stage and their GitHub shows little to no sign of seeing any development.
- Oasis does not necessarily aspire to have the same token support as IDEX and it is meant for assets in the Maker registry (currently it is MKR, DAI, and ETH)
Radex is very similar to IDEX in that the fashion that the market makers earn rebates for the liquidity they provide. This was the special value proposition that Radex provided up until IDEX came along, and now IDEX is a much more developed and decentralized platform.
- The usage of Radex will need you to utilize the centralized Saturn Wallet plugin in your web browser
- The handling of the order book is not really that ideal in Radex, due to it not being stored in a decentralized fashion, but rather being vigorously reconstructed by reading the events that Radex creates
Binance Chain (BNB), a system that claims to provide a DEX, will be swapped with a new coin based on the Binance blockchain at a 1:1 ratio. Since the announcement of the plans in March of 2018, there have been no notable updates, though Binance Chain is highly unlikely to end up being fully decentralized seeing as how capital deposits will be made to Binance, and Binance itself will not convert to a decentralized model.
Furthermore, as Binance practices the act of freezing funds in order to abide by the regulations and prevent theft, this means that there is centralized control over funds.
At the best of the knowledge of the general consensus, BlockDX is the most decentralized of the platforms, as all four of the exchange functions are decentralized. Further benefits to this include an alliance with 0x that enable interoperability with Ethereum tokens. For the peer-to-peer trades that work without a central escrow, Blocknet utilizes atomic swaps in a technology called ‘XChat.’
Blocknet additionally creates an inter-chain overlay using XBridge, which administers a DHT-based peer-to-peer network. More importantly, BlockDX comes with a decentralized API (Application Program Interface) that you can connect to over localhost without authorization, thus allowing for truly decentralized trading.
What’s preventing adoption?
Without any central processing of the exchange functions, authority figures such as taxation and regulatory bodies cannot access or control the information they want. This would ultimately mean that the platform users – as opposed to rent-seeking authorities – would be in control of the funds. Naturally, global adoption of decentralized exchanges are not in their best interest.
These ‘rent-seeking authorities” have already harnessed the use of massive efforts in order to put a stop to the blockchain revolution and preserve their control, including India and China effectively banning crypto. Other attempts that were made to maintain absolute authority include government-run cryptocurrencies without a lot of transparency, such as the asset-backed petro cryptocurrency belonging to Venezuela. Moreover, traditional mega-corporations are actively creating permissioned blockchain environments such as IBM.
A great number of exchanges claim that they are moving towards a more decentralized model, defending their current centralization by saying that it allows the acceleration of development. Now, whether or not this is true is a topic for debate because entire protocols will now have to be rewritten so that it can shift to decentralization.
The creation of a DEX
The ideal model for the standard DEX would be a Decentralized Autonomous Organization (DAO), which is an organization that is transparent, shareholder-controlled, and computer-represented and is a more complex version of a DApp. This would guarantee full decentralization of all aspects of the exchange and the users would be able to make decisions as opposed to any central body.
‘Proof-of-Identity’ becomes something of a non-trivial issue with a DEX, and that is especially the case with a DAO exchange. One particular solution is with Decentralized Identities (DiDs), which transform identifiers and names self-sovereign to their owning entity. Some existing DiDs include NuID, Identity.foundation, and Sovrin. The ongoing identity handling that many of the supposed DEXs are using is through email sign-ups, which is the same as most sites. Having said that, any service that requires your email – or any asset running on centralized servers – is not wholly decentralized.
First and foremost, creating a crypto exchange typically requires that all four of the key functions are built. Along with these functions includes permitting users to control their own funds, running the network on multiple functioning nodes, not revealing the identity of a user and integration with pre-existing wallets. Following this, a front-end is constructed that matches user input – such as simply clicking a “buy” button – to the smart contract functionality in the back-end.
The above is essentially how any DEX is built. However, even a single point of centralization introduces new kinds of vulnerabilities. Besides the technical formation of the DEX, it needs a governance model, which can really be up to either the creators or the users, as it is in a DAO. Furthermore, the exchanges have to achieve the ‘network effect’ in order to officially become scalable and maintain high enough liquidity for serious usage.
BlockDX describes their order system as being a “decentralized state machine,” wherein the very first step is placing an order, which will either be accepted or canceled depending on service node polls, market makers, whether or not the broadcast was received, and whether the recipient accepts or cancels the order.
To provide an example of how a DEX operates, let’s take a look at the BlockDX algorithm summary, influenced by the Blocknet GitHub. It will illustrate order matching by way of atomic swaps:
- The initiator conceives secret X and hashes it to create H(X).
- Next, the initiator shares H(X) and also pubkey i2 with the responder.
- Then, initiator conceives TxAb.
- The responder confirms TxAb. The responder creates TxBb. TxBb can be redeemed following T1 time with privkey r2. At any point in time, TxBb can be redeemed with a signature from privkey i2 and uncover secret X.
- The initiator conjures up TxBp, which sounds TxBb using privkey i2 and secret X. With the uncovered secret, the responder can create TxAp, which spends TxAb with privkey r1.
To sum up the above so that it’s more simplified, the users are in control of their own funds. They broadcast orders to the network from their end. The security and encryption of this particular process are dealt with on the user-end, as there is no centralized server.
By now, you should hopefully be well-versed in what makes a proper DEX. In addition, you can now make the distinction between a centralized exchange and a true decentralized exchange.