While token prices in the crypto market have been sleepily drifting sideways, for the most part, decentralized finance (DeFi) has been pumping and is currently the most exciting place to be. And decentralized exchanges (DEXs) are part of that ecosystem.
What is a DEX?
A DEX, or decentralized exchange, is mainly a type of cryptocurrency exchange. It operates like a stock exchange, except it is run by a smart contract on the Ethereum blockchain that enforces rules and executes trades. Users can trade cryptocurrencies and DEXs do not require a centralized authority to operate, but they do need access to a reliable source of liquidity to service their users.
To better understand how they operate, let’s compare a DEX to a centralized exchange (CEX).
Financial exchanges are where users buy and sell financial assets. Traditionally, the CEX takes orders from buyers and sellers and takes custody of their assets. DEXs do the same thing but without the custodial aspect and they can offer more in the way of security and anonymity. A user can simply interact with a smart contract directly from their crypto wallet.
Some DEXs have pools of currencies to trade or swap, whilst other DEXs use order books with Maker and Taker orders. Maker orders provide liquidity because they’re not immediately matched on the order book. Whereas a Taker order is instantly matched with an order already on the books. Thus, fees for Maker orders are lower than fees for Taker orders (or they can even be zero).
How does a DEX work?
While DEXs can differ in how they’re designed, they are similar in how they connect buyers and sellers across a global liquidity pool. Most DEXs require the user to have at least enough ETH to cover the transaction cost of doing the trade. Some don’t charge transaction fees for Maker orders but make up the difference by charging higher fees for Taker orders, while some return a portion of the trading fees to traders who willingly supply capital to their liquidity pools.
Are DEXs Risky?
There’s always a risk anytime you use a CEX because you first have to deposit your funds. CEXs hold millions of dollars in deposits and thus are constantly targeted by hackers looking for big money heists. The big risk in a CEX, therefore, is that of custody, which a user forfeits the entire time their deposit is being held.
Hackers have made off with millions of dollars as well as reams of user data by cracking into CEXs over the years, the most infamous being the Mt. Gox hack in 2014. That exploit gave Bitcoin a black eye from a security reputation standpoint, and opened the door for gold-shilling naysayers like Peter Schiff to boast, “I told you so!” It’s this lack of security that has tarnished the image of crypto exchanges and hampered them from becoming potential competitors to conventional exchanges.
Hopefully, DEXs can change all that because the assets are only transferred at transaction time naturally making them more secure. So DEXs can offer non-custodial solutions that bigger CEXs like Coinbase or Binance cannot. Even though they are still the 800-pound gorillas in the room, DEXs are poised to compete with them due to improvements being made in usability, liquidity, and security.
Here is a list of some of the advantages of trading on a DEX:
- Pseudo-anonymous: No lengthy forms, background info, or ID is required to participate.
- Automatic: So long as there is sufficient liquidity, DEX trading is instant.
- Non-custodial: You don’t have to turn over your funds to 3rd party control.
- Lower cost: Minimal trading fees.
So, as long as a user can keep their private keys in check, using a DEX should mitigate the risk of getting hacked. However, different DEXs can vary in how they operate, so let’s take a brief look at three you may have heard of:
Uniswap is one of the most popular DEXs around and has rapidly become the leading exchange for active traders looking to swap DeFi tokens. Far from the DEXs of old that offered a poor user experience and thin order books, Uniswap crashed through the window of opportunity to create a simple yet effective DEX known for its wide selection of trading pairs.
Uniswap launched in 2018 with funding from the Ethereum Foundation after creator Hayden Adams (inspired by Ethereum’s Co-Founder, Vitalik Buterin) began studying the Solidity programming language. Many observers often stress the advantages of being a “bidler” (not just a “hodler”) to be successful in crypto, and Hayden certainly defines what it means to be a successful bidler. After all, he ended up creating one of the most interesting projects recently seen on Ethereum that’s quite different from the traditional DEX.
The short description of Uniswap is that it’s a simple one-click interface where traders can swap ETH or ERC-20 tokens on-chain by pooling liquidity. This can all be done through a Web 3.0 wallet without having to deal with a centralized order book to deposit or withdraw.
A set of smart contracts on the Ethereum network is deployed, but it’s open-source and there are no Uniswap investor tokens, no fees paid to the founders, and of course, no central authority involved. Simply by leveraging smart contracts, Uniswap allows traders to perform on-chain transactions at lower costs in a few clicks. There are no KYC or custodial issues to worry about.
For example, let’s say you want to trade ETH for DAI. On a traditional exchange, you would have to deal with centralized order books organized around various price points with different demands at each price point. Not so on Uniswap. You simply connect your wallet, select ETH to trade, and DAI to receive, and Uniswap automatically performs the transaction and updates your wallet balance.
Automated Market Maker
So, rather than selecting a buy or sell price, you would select ETH and DAI and get the market rate from Uniswap. Global liquidity pools are leveraged to create markets for ETH and DAI by using an Automated Market Maker (AMM), the exchange can then quote prices. AMMs are controlled by algorithms and they define rules for trades to be able to provide constant liquidity regardless of the order’s size.
Also, with the new and improved Uniswap V2 version, traders can now benefit from new token pairs and flash swaps.
Here are some of the advantages Uniswap has over the traditional DEX:
- There are no listing fees
- It boasts some of the lowest gas costs.
- The project is trustless and permissionless.
Kyber’s emerging DEX, Kyber Swap is designed to be an on-chain liquidity protocol and is expected to be one of the market leaders throughout 2020. Back in 2017, Kyber raised approximately $50 million through its successful ICO sale of the KNC token and Vitalik Buterin is listed as an advisor.
Kyber’s protocol is implemented as a stack of smart contracts that can operate on top of any blockchain and it allows for seamless integrations into other protocols. Various actors (Takers, Reserves, Maintainers) can interact with the network.
- Takers perform trustless token exchanges with minimum slippage on the network. A Taker can be a trader, a wallet address, a DEX, or a dApp.
- Reserves are liquidity providers that can list token pairs.
- Maintainers have permission to add/remove token pairs and reserves.
Kyber’s long-term goal is to facilitate liquidity for stakeholders in different, digital ecosystems to provide frictionless cross-chain token swaps across multiple blockchains.
How is Kyber Different from Other DEXs?
- Kyber has some of the deepest liquidity pools.
- Many dApps already use Kyber.
- Illiquid or niche assets that are not tradeable on other DEXs can be found in Kyber.
Also, Kyber is set to launch Katalyst on the 7th of July, 2020. Katalyst promises to usher in not only technical improvements and enhanced liquidity but more importantly KyberDAO—which will further the decentralized governance of the protocol.
This is a bullish signal from a “tokenomics” perspective because users will now start staking to participate in the decision making roles of governance.
Balancer is a brand new DeFi liquidity provider (launched in March 2020). On Balancer, portfolio owners can create what’s called “Balancer Pools” and traders can then trade against them. The pools provide liquidity and traders pay a trading fee directly to the pool liquidity providers. These pools can be thought of as AMMs (see Uniswap above) since trading can occur between any two tokens in a pool.
Balancer is permissionless in that the pools cannot be censored nor can the smart contracts be edited or shut down once they’ve been activated. It allows liquidity providers to earn trading fees by creating or adding liquidity (two or more ERC-20 tokens required) to the following pools:
- Private Pools: The owner has full permissions and only he/she can contribute liquidity.
- Shared Pools: The pool creator has no special privileges and anyone is allowed to add liquidity. Ownership is tracked by Balancer Pool Tokens (BPT).
- Smart Pools: Like Shared Pools, ownership is tracked by BPTs and these pools can also accept liquidity from anyone, however, the controller is a smart contract.
Who Should Use Balancer?
Balancer works for liquidity providers who own Balancer Pools and traders who seek to profit from these diverse pools by discriminating between a variety of fees, slippage and spot prices, such as:
- Arbitrageurs seeking to profit off the market inefficiencies between Balancer and other exchanges.
- Portfolio managers who want exposure to different assets without undertaking complex rebalancing actions.
- Hodlers who have ERC-20 tokens sitting idly.
- Ethereum Smart Contracts seeking liquidity.
Balancer just released BAL as its governance token which is distributed to liquidity providers. Unfortunately, just about the same time, their DEX fell victim to a hack that relieved its users of approximately $500,000 worth of tokens.
This hack stands in stark contrast to what we’ve been discussing about DEXs being more secure than CEXs. However, Balancer has run the disclaimer that even though they have conducted extensive audits theirs is still “very much a beta product.” Small consolation to the victims who got burned, but the hack serves as fair warning to anyone getting greedy or overextended on any one protocol.
You can read the full details by searching the internet, but to summarize, it all started with the hacker borrowing $23 million in WETH tokens via a flash loan from dYdX that they used to trade against themselves with Statera (STA) until the STA liquidity pool was drained. Balancer thought it had equal amounts of STA so it released WETH giving the hacker a larger margin for each trade. The hacker then repeated the same process using WBTC, SNX, and LINK against STA tokens. This attacker was well versed in DeFi protocols and covered his tracks by using ETH laundered through Tornado Cash to pay any transaction fees.
What does all this mean? Well, it means that even though DEXs are being touted as safer than CEXs, there is always risk involved, especially with a protocol like Balancer that has a disclaimer about still being in beta. As we speak, there is no doubt some little script kiddie in the nether regions of Eastern Europe dreaming of becoming a top cracker and the pimp of his village. With plenty of brainpower and programming talent to go around, but little in the way of opportunities for honest work, there will always be plenty of up-and-comers attracted to the big money flowing through cryptocurrency exchanges whether they be a CEX or a DEX.
So, if you don’t want this kid to grow up pimping around in designer kicks and gaudy, over-priced jewelry at your expense, it’s best to spread your risk and do a little homework before you jump in and start trading on DEXs.
This is not financial advice, but here are a few things to look for:
- Audit History: Check that the DEX has undergone a rigorous amount of audits before launching. Although the audits didn’t seem to help much in the Balancer hack, apparently there were voices in the crypto space that were already warning about the STA flaw.
- Volume: DEXs with the most volume over 30 days tend to be more reputable.
- Slippage: It’s likely with the continuing interconnectedness in DeFi, that slippage will become a thing of the past. For now just be wary that the more obscure and exotic the trading pair, the more slippage you’re likely to pay. A good DEX will display the expected slippage on each trade.
- Custody: The degree of custody a DEX requires can vary greatly. Just remember that less is more.
- Beta Mode: Balancer listed themselves as still in beta mode. That should be a good signal not to go crazy with risk.
- Community: Check that your DEX has a decent size community backing it and that they are engaging regularly on places like Twitter.
- Other Factors: Look at KYC stipulations, liquidity, trading fees, supported tokens—all should be factored into your decision.
DEXs will continue to grow in both improved user experience and popularity as the lure of passive income isn’t going out of favor anytime soon.
To further your education in Decentralized Exchanges, check out the DeFi 101 and DeFi 201 courses at Ivan on Tech Academy, the premier platform for blockchain education. Ivan on Tech Academy offers world-class blockchain courses and free explainers on things including stock to flow Bitcoin and smart contracts.