Decentralized Exchanges: Operating Principles and Distinctive Features
Fasten your intellectual seatbelts as we dive into the world of decentralized exchanges — the upstarts claiming to be something entirely different from our beloved, tried-and-true centralized exchanges.
Decentralized exchanges, or 'DEX' as they're affectionately called, are the offspring of the blockchain technology family, hailing from the ever-booming decentralized finance (DeFi) realm.
In this piece, we're going on a thrilling exploration of the inner workings of these DEX darlings and see how they stack up against their more traditional counterparts, the centralized exchanges, or 'CEXes.'
How the Whole DEX Thing Started
Decentralized exchanges have not merely tiptoed onto the crypto scene, they've stormed in, posing a significant challenge to their centralized counterparts. The rapid ascension of DEXs is a tale worth telling, given their meteoric rise in such a brief span.
In the nascent stages of decentralized exchange evolution, one would encounter hashed time-locked contracts, or HTLCs, as the cradle of development. HTLCs served as a rudimentary cryptographic escrow system that enabled trustless, on-chain transactions between parties.
👉 Notable early birds in the HTLC-based DEX landscape were LocalBitcoins and Bisq, launched in 2012 and 2014 respectively.
As the plot unfolded, the next chapter in the DEX saga was marked by the advent of the first DEXs on the Ethereum platform. The might of Ethereum smart contracts gave birth to a whole new breed of exchanges.
In the year 2016, a spark of innovation ignited a disruptive idea — an algorithm for on-chain cryptocurrency exchange. This brainchild, known as X * Y = K, was destined to become the cornerstone for future liquidity pool operations.
2017 saw the rise of a trailblazer in the domain of decentralized exchanges — EtherDelta. This maverick promoted peer-to-peer exchanges, but with a unique twist. To pull off a trade, the buyer and seller's wallets had to be directly plugged into the service, nixing the concept of 'liquidity' in the traditional sense.
In the same year, Bancor stepped onto the stage, introducing the innovative concept of an automated market maker with a constant reserve system.
But the crowning jewel of DeFi was yet to make its grand entrance — Uniswap.
In 2018, Uniswap, courtesy of a grant from the Ethereum Foundation, went from concept to a fully operational cryptocurrency exchange in a matter of months. Uniswap boasted two distinguishing features that set it apart from Bancor:
- It offered superior gas usage efficiency, translating into more perks for users.
- Every trade was mandated to include ETH as part of any trading pair.
Uniswap's charm was irresistible, attracting a flood of liquidity from users. It wasn't long before $1 billion daily trading volumes (Pic. 1) became the new norm in the DeFi sector.
Riding high on the success of Uniswap, a flurry of similar projects took flight, including SushiSwap on the Ethereum blockchain, PancakeSwap on the Binance Smart Chain, Curve for stablecoin trading, and Balancer, which permits liquidity pools with more than two assets.
This explosion in DeFi continues to be the breeding ground for groundbreaking innovation.
So, What’s DEX, and What DEX Types Are there?
Well, for starters, DEXs work like a digital self-service kiosk. Users get to play the role of their own bank, retaining custody of their funds for trading purposes.
Users interact directly with smart contracts on the blockchain when using DEXs, and just like at any self-service kiosk, they pay transaction fees in addition to trading fees.
There are three common types of DEXs: the order book DEXs, the DEX aggregators, and the Automated Market Makers (AMMs). Each one of them, in their own way, facilitates direct trades between users via smart contracts.
Automated Market Makers or AMMs
AMMs are the pop stars of DEXs. They use smart contracts to combat the age-old problem of liquidity. AMMs primarily depend on the asset ratio in their "liquidity pools" to set their prices.
Liquidity pools are like potluck dinner parties — everyone brings something to the table. These are pre-arranged pools of assets essential to the working of AMM-based DEXs. Users, the so-called liquidity providers, fund these pools and get rewarded with transaction fees from trades involving the relevant pair. To earn interest on their crypto assets, liquidity providers must deposit equal values of each asset in a trading pair, just like bringing equal portions of food to the potluck.
AMM-based DEXs allow traders to carry out orders and earn interest with an air of trustlessness and without asking for any permissions. They are often ranked based on the total amount of funds locked in their smart contracts, like a high score in a videogame.
Nevertheless, AMM-based DEXs do have a party spoiler: slippage. This happens when a lack of liquidity causes a buyer to pay more than the market price for their orders. Larger orders are like the big guys at the party who are more likely to cause significant slippage. Also, liquidity providers could face the risk of impermanent loss due to the volatility of one asset in a trading pair.
👉 AMM DEXs that often make the headlines include Bancor, Balancer, Sushi, Curve, and Uniswap.
Order Book DEXs
Order book DEXs are like the traditional diners of DEXs. They keep a ledger of all open orders for buying and selling specific asset pairs. Buy orders are like a shopper's wishlist, while sell orders are like a yard sale announcement.
There are two breeds of order book DEXs: on-chain and off-chain. On-chain order book DEXs store their open order information on the blockchain, allowing traders to leverage their positions using funds from lenders on the platform. Conversely, off-chain order book DEXs store the order books off the blockchain but still use smart contracts for transaction settlement.
Both types of order book DEXs sometimes struggle with liquidity issues and might compete with centralized exchanges, often imposing additional fees for on-chain transactions.
👉 Order book DEXs that often make the news include Loopring, Gnosis Protocol, and IDEX.
DEX Aggregators
DEX aggregators are the party planners of the DEX world. They source and route liquidity from multiple DEXs according to specified requirements. They don't maintain their own liquidity pools but instead rely on others, like a good party planner should.
👉 DEX aggregators that often get a name-drop include Slingshot, 1inch, and 0x (Matcha).
Differences between DEXes and CEXes
- Peer-to-peer exchange. One of the main differences between DEXes and CEXes lies in the very mechanics of the exchange process itself. With DEXes, token swaps happen right at the wallet level, completely sidestepping the deposit and withdrawal dance that centralized exchanges insist on. But don’t be fooled, using DEXes isn’t a free ride. Transaction fees may still apply, and they’re often linked to the blockchain network's operations.
- Lack of a physical center. Decentralized exchanges carry out all transactions on-chain, using smart contracts. This is a stark contrast to centralized exchanges, which rely on servers and software to function. While the heart of trading activities on DEXes takes place directly on the blockchain, it's worth noting that user interfaces and other supplementary services of DEXes may still live on good old traditional servers.
- Liquidity pools. Liquidity, or the availability of each asset involved in a transaction, is vital for any exchange. In centralized exchanges, liquidity usually flows from market makers who deposit large sums of assets. Decentralized exchanges, however, tap into liquidity pools contributed by users. Anyone can add to these pools by connecting their wallet to the exchange, and in return, earn a slice of the transaction fees relative to their contribution.
- No order book. While some projects still cling to the traditional "order book," the lion's share of popular decentralized exchanges have adopted automated market makers (AMMs). These are algorithms built to work out a "fair price" for an asset based on supply and demand. However, keep in mind that not all DEXes operate with AMMs; some adopt a hybrid model or even uphold an on-chain order book.
How Does a DEX with an AMM Work?
Let's take a closer look at the AMM model, which, in the grand world of DEXs, has emerged as the leading man.
To better understand AMM, the following diagram (Pic. 2) will demonstrate how Uniswap, our star player, interacts with the supporting characters — the liquidity providers and traders.
How Liquidity Providers Interact with a DEX
Liquidity providers interact with a DEX in a pretty straightforward way. They start by roping their cryptocurrency wallets into an alliance with the DEX. Then, they pick a liquidity pool, or a trading pair, they want to back. They might, for example, choose an ETH/USDT pool.
The providers then have to pony up an equal value of both tokens to the pool. So, if they're throwing 5 ETH into the ring, they also need to match it with an equivalent amount of USDT.
Once the providers have done their part, the DEX locks these funds away in a smart contract. To say "thanks for the help," the DEX gives the providers liquidity tokens. The number of tokens handed over is in line with the providers' contribution to the pool.
When liquidity providers want their original funds back, they can redeem them by returning the liquidity tokens to the DEX. Think of it as returning a rental car — you give it back, and you get your deposit. In this case, when the tokens are returned, the DEX unlocks the appropriate amount of funds from the smart contract.
Besides returning the original funds, the DEX also gives the liquidity providers a cut of the transaction fees accrued in the pool, and sometimes, a few extra proprietary tokens. This is the cherry on top that incentivizes them to keep providing liquidity to the DEX.
How Traders Interact with DEXes
A trader's interaction with a DEX begins when they link up their cryptocurrency wallets with the platform. They then pick their desired asset for trading and set the amount for the trade.
On some DEXs, like Uniswap, it's a bit like a game of tag. Direct exchanges are usually restricted to ETH trades. So, if a trader desires to swap asset XXX for asset YYY, the DEX's algorithm plays middleman in a two-step process. First, it trades asset XXX for ETH and then uses that freshly acquired ETH to buy asset YYY. This dance sequence is fondly known as a routed trade.
The Automated Market Maker (AMM) algorithm of the DEX, acting like a master chess player, evaluates all possible swap combinations. It then sets the "fair" market price based on the ratio of the assets in the corresponding liquidity pools. This ratio is the secret sauce that flavors the pricing of individual trades.
Once the trader gives a thumbs up to the swap terms, the DEX's smart contract springs into action like a well-trained butler. It withdraws asset XXX from the trader's wallet, executes the trade, and drops the new asset YYY into the trader's wallet.
But of course, nothing in this world comes for free. The trader also has to foot the bill for the associated transaction fees. These fees include the gas fees needed to drive the transaction on the blockchain highway, along with a tip for the DEX. This tip is then shared among the liquidity providers of the relevant liquidity pools as a pat on the back for their contribution to the liquidity.
How an AMM Works
AMM protocols typically apply the straightforward equation X * Y = K, where X and Y symbolize the volume of the two assets in the liquidity pool, and K is a stubborn constant value. Picture it as the "unwavering product" formula; it's a favorite amongst many AMMs, including the one and only Uniswap.
Let's say a trader is itching to buy ETH (token X) with their USDT (token Y). They'll have to pop their USDT tokens into the pool and scoop out an equivalent value of ETH. According to the "unwavering product" formula, the product of the quantities of X and Y in the pool (that is, X * Y) must keep its poker face on at all times.
When the trader stuffs USDT (Y) into the pool and yanks out ETH (X), the balance between X and Y in the pool does a little shuffle. This switcheroo effectively sets the price the trader shells out for the ETH. More specifically, the price tag for the trade is determined by the amount of USDT they're depositing into the pool divided by the amount of ETH they're taking out.
The more ETH a trader is keen to extract from the pool, the more USDT they have to stuff into it to keep the product (X * Y) unflinching. This effectively means that the price tag on ETH in terms of USDT balloons as more ETH is purchased, reflecting the price impact of hefty market orders on centralized exchanges.
However, it's crucial to remember that while the unwavering product formula (X * Y = K) is a common tool, different AMMs might employ different formulas or tactics to set prices and manage trades. For instance, Curve Finance breaks the mold by using a different formula to offer better prices for trades between similar assets.
Pros and Cons of DEXes
Now, let’s look at DEX's advantages and disadvantages.
Pros
- Steadfast reliability: DEXs generally lean on blockchain technology, which, being decentralized, can keep the wheels turning even during times of high market turbulence. For example, despite the market crash in May 2021, many DEXs kept their cool and functioned normally, while some centralized exchanges hit speed bumps due to server overload.
- No KYC process: DEXs usually skip the Know Your Customer (KYC) procedures. All users need is a crypto wallet to mingle with the exchange, which could be a big plus for those who hold their privacy dear.
- Plentiful liquidity: With the help of liquidity providers and the use of liquidity pools, DEXs can offer a deep well of liquidity. They also have the potential to scale up and handle vast amounts of liquidity.
Cons
- Notable slippage: Owing to the AMM algorithms employed by many DEXs, large trades can send ripples through the price of assets, leading to notable slippage. This can make big trades pricier than on centralized exchanges.
- Impermanent loss: Liquidity providers on DEXs can face impermanent loss if the pool's assets swing significantly in price. This risk takes a backseat when providing liquidity to pools stocked with stablecoins.
- Potential smart contract vulnerabilities: While blockchain technology and smart contracts boast many perks, they can also harbor weaknesses, especially if they're not well-written or audited. This can paint a target on DEXs for hackers, potentially leading to a loss of funds.
- Usage complexity: For many users, particularly crypto newbies, DEXs can be more challenging to navigate than their centralized counterparts. This is due to the technical know-how needed to interact with smart contracts, manage gas fees, and get a grip on concepts like liquidity pools and AMMs.
Bottom Line
DEXs stand tall as a cornerstone of the cryptocurrency landscape, enabling users to swap digital assets in a direct peer-to-peer fashion, sans the meddling middlemen.
Over the recent years, DEXs have seen their popularity skyrocket, thanks to the instant liquidity they provide for freshly minted tokens, their hassle-free onboarding process, and the egalitarian access they offer to trading and liquidity provisioning.
Still hooked on centralized cxchanges? No sweat, Bitsgap has got you covered. It links up with as many as 17 leading centralized crypto exchanges, allowing you to trade across all of them using a single, unified interface.
Who's to say what the future holds? Perhaps Bitsgap might soon cozy up with decentralized exchanges, letting you trade across both types of platforms from the comfort of one dashboard.
As it stands, it's pretty peachy — hook your favored centralized platforms up to Bitsgap and bask in the ease of hands-off trading with Bitsgap’s nifty trading tools and automated crypto bots that can churn out returns in any market.
Hop on board now to enjoy a free trial of the PRO plan!
FAQs
What Are DEX Features?
DEXs are decked out with a range of features such as lending, borrowing, yield farming, staking, and liquidity pools:
- Lending and borrowing: DEXs offer a platform for lenders to accrue interest by loaning out their crypto assets. This is typically channeled through lending pools where users pool their assets, which are then lent out to borrowers through smart contracts. A key aspect of these loans is that they are overcollateralized — borrowers have to deposit a crypto amount that outstrips the amount they wish to borrow. The borrowing limit is dictated by two factors: the total amount pooled by lenders in the protocol's funding pool, and the quality or "collateral factor" of the coins used as collateral by the borrower. If market fluctuations cause the collateral limit to be breached, the protocol will auto-liquidate the collateral, usually at a reduced rate, to settle the loan.
- Yield farming: Also known as liquidity farming, yield farming is a strategy to earn returns on cryptocurrency. It's akin to earning an annual interest percentage when you deposit money in a traditional bank. Yield farming allows an investor's cryptocurrency value to compound over time.
- Staking: This strategy enables users to reap rewards by holding onto certain cryptocurrencies. Cryptocurrencies that back staking employ a consensus mechanism dubbed proof-of-stake (PoS). By staking their coins, users bolster the network's security and functionality, and are rewarded for their efforts.
- Liquidity pools: These pools are pivotal to the workings of AMM-based DEXs. A liquidity pool is a communal pool of crypto assets locked in a smart contract used to enable trades on a DEX. In lieu of the standard market system of buyers and sellers, many Decentralized Finance (DeFi) platforms employ automated market makers (AMMs) to enable permissionless and automatic trading via liquidity pools.
Bear in mind that while these features can yield high returns, they also carry their own set of risks, including smart contract vulnerabilities, impermanent loss, and market volatility. It's always essential to conduct your own research and understand the risks involved before diving into these activities.
What Is Decentralized Trading?
Decentralized trading refers to the process where asset buyers and sellers interact and transact directly with one another, bypassing the need for a traditional, centralized exchange as an intermediary.
What Are DEX Principles?
Decentralized exchanges carve out an unconventional route in the trading of digital assets: They function without the need for a middleman to settle transactions, instead leaning on automated smart contracts to enable trading. This structure allows for trades to take place instantaneously, often at a cheaper cost compared to centralized crypto exchanges.
With no intermediaries in play, DEXs adopt a framework where users retain custody of their assets. This means that you hold onto your cryptocurrency, and the task of managing your wallets and private keys remains your responsibility. The lack of a middleman also implies that most DEXs have reduced counterparty risk and aren't required to comply with Know-Your-Customer (KYC) or Anti-Money-Laundering (AML) regulations.
What DeFi Exchanges Are There?
DeFi exchanges are, fortunately, aplenty: Uniswap, ParaSwap, Curve, dYdX, Balancer, 1inch, DexGuru, AirSwap, Bancor, Bisq, CowSwap, Dodo, IDEX, Matcha, PancakeSwap, and SushiSwap, among others.