Cryptocurrency was born on the idea of decentralisation; the idea that there should be no middleman in between two parties exchanging assets in a trustless manner.
So it has been very interesting to see the rise of the likes of centralised exchanges (CEXs) like Coinbase, which IPO’d on the legacy stock exchange NASDAQ on 14 April, runs a centralised order book, offers custody to clients, steps in to provide liquidity where it is needed, holds all sorts of personally-identifying information and carries out the kind of KYC and AML usually expected of traditional banks and financial institutions.
But another type of crypto finance venue that has grown strongly in the past couple of years has been the decentralised exchange (DEX). It’s much closer to the original ethos of cryptocurrency. We’re talking about the likes of Uniswap, its clone Sushiswap, the aggregator 1Inch or Bancor.
Unlike Coinbase, or Kraken, or Bitstamp or any other CEX, there are no gatekeepers, no custody, and no need to set up an account.
What these platforms do is run trading venues on top of the Ethereum or Binance Smart Chain blockchains, incentivising their users to provide liquidity and make their own markets.
Let’s take Ethereum-based Uniswap as our main example. It’s already about half the size of Coinbase. Its governance token UNI really started gaining traction at the turn of 2021, rising more than 1,180% between January and March, launching Uniswap into the top 10 most valuable crypto projects by market cap.
As of September 2020 Uniswap was already providing 8,278 trading pairs — far, far beyond the number offered by CEXs like Coinbase, Binance or Kraken.. But the really clever thing that Uniswap does is to allow anyone to create their own market and provide owners a venue to trade their cryptos back and forth.
It’s an automated market maker (AMM).
Let’s briefly investigate what function a traditional market maker performs. In a standard stock exchange, like the NADSAQ, you essentially have two main types of participants, a maker and a taker. Professional market makers commit to providing two-way prices (buying and selling) of an asset, and on the other side retail traders (takers) execute against those prices.
A market maker sells me immediate liquidity: the ability for me to trade on demand and buy £100,000 of biotech shares, or £2m of lumber futures, or £5,000 of silver at the precise instant I decide I want that asset.
Market makers are vital because they eliminate the timing problem of buying and selling tradable assets. They grease the wheels. They, as the name suggests, make markets happen
Without a market maker the spread — the difference between the bid (the price sellers are willing to sell at) and the ask (the price buyers are willing to buy at) — would widen, making for a worse deal for everyone. There is also the question of slippage. I signal my intent to buy an asset at £5, but by the time the trade is executed, it has risen to £10. Suddenly I’ve lost half my money. Scale that out to institutional-sized buys and you can see the issue.
Market makers do profit from the bid-ask spread, of course, making them a constant target for the ire of retail investors.
But as the Bank for International Settlements notes in a 2014 research paper, market makers “serve a crucial role in financial markets by providing liquidity”. If there is no market, buyers can’t buy, and sellers can’t sell. We call this ‘illiquidity’ or an illiquid market.
In the relatively early days of cryptocurrency, while traders wanted to trade between the growing number of assets, order books struggled to guarantee liquidity to investors on both sides of the trade. AMMs were designed to solve this liquidity problem.
The issue with traditional market making is that there is no incentive for a market maker to hold a lot of inventory (lumber, silver or biotech shares) and it’s only worth it for them to provide buy and sell orders in the most popular assets. This creates huge illiquidity in less well-known company shares, for example, with smaller market caps. It’s the same in crypto.
If the coin or token I own isn’t traded on Coinbase, or Binance, or Kraken, there’s no liquidity, and there’s no way for me to profit from rising or falling prices.
What Uniswap and other DEXs do is allow anyone to deposit cryptoassets into a Ethereum smart contract and allow that piece of code to automate the market making process for them.
Around three years after Ethereum launched its first public version, we started to see the first AMMs for cryptoassets.
Bancor was one of the first, launching in 2017 in a record $153m ICO, followed by other early adopters like the professional-only Kyber Network. At the time, the concept of an on-chain decentralised exchange operating without the need for an order book was pretty novel.
So let’s talk about the AMM process.
As Uniswap creator Hayden Adams tells the BloombergMarkets Odd Lots podcast: “In two minutes, some can spin up a market and provide liquidity, and they don’t need to be extremely sophisticated or have a vast amount of capital, or work with other professional market makers, so it essentially removes this gatekeeper in the creation of liquidity.”
Side note: Traders on Uniswap don’t trade directly with ETH, but a derivative called Wrapped Ether (WETH). This is an ERC-20 token that represents ETH in a 1:1 format. Why? Well, ETH was created long before the ERC-20 standard, which defines how tokens are transferred and keeps a consistent record of where tokens are on the Ethereum network. As weth.io explains: “Because decentralised platforms running on Ethereum use smart contracts to facilitate trades directly between users, every user needs to have the same standardised format for the tokens they trade. This ensures tokens don’t get lost in translation.”
There’s no need to match buyers with sellers. Traders can trade against a pool of assets, instead of having to pick out a specific counterparty (the guy or girl on the other side of the trade).
Each market on Uniswap, whether that’s USDC/WETH, LINK/WETH or DAI/WETH is a smart contract running on Ethereum. The smart contract stores funds while also dictating how those funds behave. So anyone can create a new market by calling a factory smart contract, then create liquidity in that contract by depositing two tokens - for example USDC and ETH. That creates a marketplace between USDC and ETH. This is the most popular market on Uniswap right now, with hundreds of millions of dollars-worth of of volume over the last seven days.
Anyone can get involved by depositing crypto into the liquidity pool smart contract, earning trading fees from the pool. Anyone buying or selling from the pool pays a small fee and this is shared out to liquidity providers depending on how much of each asset they put into the pool.
So DEXs replace traditional order books with liquidity pools run by algorithms. The algorithm sets an automatic price based on the availability of the cryptoassets in the pool: the smart contract does all the rebalancing and people can immediately start trading against it.
Version 3 and BSC
Uniswap is currently on its second version, but the third version was launched on May 5 2021, with a fresh idea called ‘concentrated liquidity’, a feature meant to solve the problem of impermanent loss. This is the problem faced by liquidity providers, where they can lose money over the short term if one token in a pool gains too much against the second token.
Version 3 introduces this concentrated liquidity, which allows liquidity providers to define ahead of time a range in which their assets will trade. So they could, say, deposit 500 USCD and 500 WETH, but state in the smart contract that USDC can’t trade for less than 0.99 WETH or more than 1.01 WETH.
Just as with any exchange that can guarantee small amounts of slippage, it’s anticipated that these tighter controls will attract many more institutional traders to Uniswap, DEXs and automated market makers.
It seems to be working. According to its internal figures, Uniswap is now pulling in over $1bn in 24-trading volume.
As we noted in a previous Copper article, Binance wants a piece of this highly lucrative pie from Ethereum and in the last year has debuted Binance Smart Chain (BSC) and Binance Liquidity Swap. PancakeSwap is perhaps the best-known of its latest launches and has accrued a $2bn market cap since launch, propelling it into around 40th place in the highest-capitalised crypto projects globally.
However, it hasn’t gone unnoticed among traders how Binance allegedly copy-pasted Uniswap’s source code and it’s perhaps the reason why we’re hearing of near-weekly exploits and hacks on DeFi protocols on BSC.
BurgerSwap was hacked for $7m on 28 May 2021, as reported by CryptoSlate, days after a $3m attack against Bogged Finance which saw that protocol’s token fall in value by 98%, with the hacker exploiting a flaw in Bogged’s smart contract, and just weeks after an $11m hack against cross-chain auto yield farmer bEarn Fi on 16 May.
The two largest BSC hacks, against Uranium Finance and Spartan Protocol, also happened in late April to early May and together leaked around $80m from smart contracts.
As security researchers SlowMist reported on the Uranium hack, the problem occurred with the swap function of PancakeSwap’s smart contract logic, which allows users to lend out funds through flash loans.
“When this function checks the contract balance, there is an [accuracy] problem, resulting in the balance calculated in the final contract being 100 times larger than the actual balance of the contract. In this case, if the attacker uses a flash loan to borrow, they only need to return 1% of the loan amount to pass the [code] inspection and steal the remaining 99% of the balance.”
Automated market makers are taking over the crypto finance world. But as has been shown, it’s not just endless liquidity between tokens that is vital for their future growth. At the end of the day there is a reason why people pick Ethereum and Bitcoin over any other cryptos: they have never been successfully hacked. Automated market makers, which lean so heavily on smart contract logic to enrich traders, must ensure watertight security if they are to attract the same institutional investors placing Bitcoin on their balance sheets.
Insights