Decentralized Finance For the Real World Part 1: Decentralized Exchanges

Karen Scarbrough
11 min readMar 25, 2021

If you are not on “crypto Twitter”, have never heard of Discord, or have never heard of EIP 1559, this write up is for you.

If you are a fan of Jim Simons (Renaissance Technologies), Ray Dalio (Bridgewater Associates), John Paulson (Paulson & Co.), Milton Friedman, Henry Hazlitt or Nouriel Roubini, this post is definitely for you.

The soaring prices of cryptocurrencies have once again drawn in crowds of observers. Amongst undeniable inflation, even if redefined, macro-economic uncertainties, and an astounding amount of information without verification as well as statistical models lacking the disclosure of underlying assumptions, the use case for cryptocurrencies has suddenly become so simple — another form of a hedge (though not the only option, to be clear).

You need only turn to satire to reveal the modern world’s propensity towards finding a hedge. Although nearly 26 years after his death, Mikhail Bulgakov’s The Master & Margarita was published — a brilliant satire of 1930’s Russia.

In a scene in which the devil himself hosts a show in Moscow, in short, citizens are exposed for the possession of various currencies and bank notes, as had happened during a time of inflation. A crowd participant expresses, “They love money, but that has always been so…Mankind loves money, whatever it’s made of — leather, bronze, gold…only the housing problem has corrupted them…”

So, long before the time of blockchains and tokens, mankind sought and identified safe places within which to store whatever money they had.

If cryptocurrency has only succeeded in creating a hedge as a store of value, it is rather historically predictable.

A globally accessible digital offer is a fair improvement to acknowledge, but a digital offer does not necessarily overwhelmingly change or innovate the existing financial system.

Decentralized finance is the innovation — not in the creation of another hedge, but in the creation of a new system.

Decentralized finance (DeFi) is not the codification of existing financial institutions or processes but rather a complete revamp, enabled by the way that a public blockchain is intrinsically designed.

In order to understand the impact behind DeFi and its novel applications, I would like to take the reader through…

  1. A summary of the growth in DeFi
  2. Exchanges
  3. Lending (To be covered in Part 2)
  4. Insurance (To be covered in Part 2)
  5. Synthetic Asset Exchanges (To be covered in Part 3)

Growth in DeFi

First, let’s understand the metrics for growth — users, locked value, transaction fees, and stable coin growth.

Users

According to Dune Analytics, the total number of unique addresses using DeFi applications has increased from 93,061 unique addresses on January 1, 2020 to over 1.6M unique addresses to date. What do I mean by unique address? An address is one’s “wallet”, a single user may very well have multiple wallets. The degree to which this occurs in DeFi remains unclear, but a steady growth path in user adoption remains solidified.

Locked Value

What is meant by locked value?

Smart contracts are essentially sets of code that run on blockchains, and realistically, there is nothing particularly smart or contractual about them unless they are designed in such a way.

However, unlike programming a traditional financial tool or payment system, the value layer is by its very nature part of the underlying protocol, and it is this design that gives way to the ability of smart contracts to hold value. This means once one sends their money to a smart contract, it is debited from their account and credited to the smart contract. This transaction is not replayed through a myriad of applications to reflect the changes across difficult layers but is rather maintained in one place, on the blockchain itself.

DeFi applications operate on smart contracts, and this should lead the reader to conclusively decipher that if one was to build an exchange or lending platform on public blockchains, then the smart contracts would likely need to hold value to operate and provide services. When the smart contracts in DeFi are holding value for an application, such as an exchange, it is termed locked value.

But where does the locked value come from? The users of the application itself. That’s right. The liquidity in smart contract for a DeFi exchange or the collateral for lending platforms has indeed been provided the the users, and in the examples, we will further thrash out this concept and why users would have any incentive to participate in such a way.

So how much total locked value (TVL) is in DeFi? At the beginning of 2020, the total locked value in DeFi applications stood at about $660M. Today the total locked value in DeFi applications tops $40B.

Transaction Fees

Besides looking at user confidence by amount of locked value in these decentralized applications, we need to examine whether or not are users actually paying to use them. Currently, one can turn to the transaction fees paid on the public blockchain platform itself to examine this.

Currently, the seven day average for transaction fees on the seven of the largest DeFi applications tops $5.5M transaction fees per day. Thus, yes, users are paying platform fees to use these projects.

Stable Coin Growth

A stable coin is a coin whose value remains “stable” and hence, is most often tied to a fiat currency. Stable tokens may be maintained in a variety of ways. They can be collateralized with an assortment of cryptocurrencies in smart contracts, as in MakerDAO’s design for the DAI token, which is tied to USD. Conversely, they may also be collateralized with dollars or other fiat in traditional bank accounts as in USDC (USD Coin), operated through the Centre organization whose most prominent members are Coinbase and Circle. Less common, stable tokens may also be maintained algorithmically.

At the end of 2018, there was about than $60M in DAI stable tokens on the Ethereum network. After surviving a the fluctuations in cryptocurrency prices over the next few years, now, there is nearly $3B in DAI — all collateralized by users willing to lock cryptocurrency as collateral in smart contracts to produce DAI.

Similarly the amount of USDC on the Ethereum network has grown from ~$1.5B in mid-2020 to over $10.5B to date, and give the pace of growth by the time you read this, the number is likely to be higher.

While the growth in stable tokens on public blockchain still pales in comparison to fiat currencies that may be held as digital “tokens” at a bank, the ability to transact in well known, established currencies provides a bridge to the real world finances outside of cryptocurrency.

Further to that, stable coins enable users to ‘cash out’ in a more seamless fashion as well. For example, Circle’s API for USDC now supports payouts to USD in fiat.

What do the regulators think of this? According to the Office of the Comptroller of Currency, as of 2021, federally chartered banks may use stable coins for payment activities. This announcement follows the July 2020 announcement in which banks are now permitted to hold cryptocurrency on behalf of customers.

By now, the reader should be confident in the growth and accelerating changes in the decentralized finance world — and we have barely even gotten into the decentralized finance part.

Decentralized Exchanges

For the past few years, espousing the benefits of cryptocurrencies, many have cheered the ability to send money from one address to another without third party intermediaries. However, should a user desire to exchange their Ether for another token, most parties relied on centralized exchanges maintaining order books to provide liquidity.

Finding a counter-party with which to trade was a challenge that these centralized exchanges addressed, in addition to the provision of an on-ramp from fiat currencies to cryptocurrencies. While centralized exchanges remain a vital part of the ecosystem, decentralized exchanges now offer a compelling and competitive alternative.

Decentralized exchanges were not an overnight success. In 2018, designs mimicked that of centralized exchanges, allowing users to maintain an order book off chain that was verified through the digital signatures of a user’s cryptocurrency account. Once an order was met, the system the system would then execute the order. Still, this did not aid in solving the liquidity problem. Most of these off-chain order books remained comparatively small.

So how did decentralized exchanges solve their liquidity problem? Automated market makers and incentivizing liquidity provision.

I’ll provide an example almost identical to Uniswap’s explanation here with a few more details.

In a decentralized exchange design, users provide the liquidity themselves. Recall that smart contracts can hold value, and in fact, they can hold multiple tokens of different values. Let’s simplify the example and assume an Example Token (EXT) is worth ~$1,000 on the larger market. If Bob wants to become a liquidity provider, he can send 10 EXT and 10,000 USDC to a smart contract that functions as a liquidity pool for a decentralized exchange.

Why would Bob lock up his tokens in a decentralized exchange? Currently, Bob is incentivized to do so in order to attain a portion of transaction fees collected by the exchange. In these decentralized exchanges, an underlying premise is that liquidity providers will have a share in the fees collected by users. The mechanism with which these fees are dispersed is also novel in that the activity on decentralized exchanges is facilitated through self custodial wallets.

What are self custodial wallets? These are wallets in which a user is in full control of the private keys and hence full control of the wallet without a third party. Whenever one wants to send cryptocurrency from one location to another, your account, which is represented by your public key, must sign a transaction with your private key — one could argue they are your “username and password” of the blockchain world.

A major innovation of public blockchain is that anyone can spin up a wallet like this — I can download a Ethereum node and send a code to it to create a set of public and private keys that represent a wallet in which I can send and receive cryptocurrency. No exchange or bank is required to create or operate this wallet. Conversely, wallets in centralized exchanges are implemented with additional security layers to prevent cryptocurrency losses if a user loses their password or otherwise. Note though, if you are in total control of your self custodial wallet and you lose the keys (or the keys are obtained by a malicious party), you will lose access or control of that wallet.

There are services that allow for the creation of self custodial wallets such as Metamask, so that a user does not have to know the details of the code to produce such a wallet. However, users still have to manage their private keys as services like Metamask do not store or save the passwords of your generated wallets.

Since the liquidity is provided directly form self custodial wallets to the smart contracts, it means the application does not have access to or hold any user funds. Also, since the liquidity is technically provided in smart contracts that are coded such that the application cannot shut them down or withdraw the tokens in ways that are not onlined in the code, these decentralized exchanges also are not “holding” their own liquidity in a way.

Back to our example, so now, we know that Bob’s liquidity provision is coming directly from a user’s self custodial wallet with no other third parties involved in this transmission. Likewise, when Bob collects fees they can be allocated to him based on the address or account of his self custodial wallet and received directly.

How is trading executed in automated market makers? Assume Alice wants to trade 500 USDC for ETX.

Within the smart contract system that holds the liquidity, it also holds another value called the invariant. This invariant is calculated multiplying the amount of each token, so in our case 10 (ETX) * 10,000 (USDC) = 100,000. This invariant is used to calculate how much ETX Alice should receive for her USDC.

To walk through a full example, let’s say a (0.25%) fee is charged to use the exchange, so 500 USDC / 500 = 1 USDC. Now, we know 499 USDC will be added to the USDC pool for 10,449 USDC. Using the invariant from the previous calculation the new ETX pool should be 100,000/10,499 = ~9.52 ETX. So, Alice receives 0.48 ETX in exchange for her 500 USDC.

In this scenario, Alice does receive a slightly less advantageous exchange rate than the centralized market; however, she might also make up for that in transactions where the invariant is skewed favorably the other way for her trades. The hypothesis is that the decentralized exchange market will correct for these prices to more advantageously reflect the actual market by taking advantage of the arbitrage opportunities.

Have decentralized exchanges actually worked? Well, the total liquidity locked in the top decentralized exchanges (Uniswap, SushiSwap, Bancor & Balancer) now exceeds $11B, and last August, a single decentralized exchange, Uniswap, saw more volume than CoinbasePro. The total number of unique addresses using Uniswap is over 1.1M up form about 25,000 in January 2020, and the application surpassed $100B in total trading volume in February 2021.

Version 1 of Uniswap was launched in November 2018. SushiSwap, which works much the same way as UniSwap with variations in user experience and long term goals, was launched in fall of 2020 and has recently surpassed Uniswap in total value locked.

Another decentralized exchange, balancer offers users the opportunity to provide unbalanced liquidity (so in our example, not equal parts ETX and USDC) and uses certain properties that cause it to function as a self-balancing weighted portfolio and price sensor.

Taken from Balancer’s white paper:

Balancer turns the concept of an index fund on its head: instead of paying fees to portfolio managers to rebalance your portfolio, you collect fees from traders, who rebalance your portfolio by following arbitrage opportunities.

Another decentralized exchange, Bancor again offers users the ability to provide liquidity; however, exchanges are facilitated using price oracles rather than an invariant. Price oracles refer to the exchange prices that may be obtain from cryptocurrency price feeds and then used on chain — this can happen in a variety of ways that are out of scope for this write up.

Yet another decentralized exchange, Curve, operates only in stable tokens in order to provide very low slippage and has a total locked value on the order of UniSwap and SushiSwap (~4B). Curve further incentivizes users to provide liquidity by using the liquidity pools to supply other lending protocols in the background and increase returns.

The market for automated market makers is constantly evolving and seeking to identify new use cases and optimizations. The above only scratches the surface to start to explain the complexities and potential of what is being constructed. Emerging as one of the premier business models in public blockchain to date, one can expect to see rapid evolution in this space competing at levels that have previously been underestimated.

And this leaves one thinking, if you are able to participate in a decentralized exchanges at a lower slippage and lesser transaction fee than traditional banking institutions with a faster settlement time, then the premise of not needing a clearing house in trading on public blockchains may indeed continue to expand…

In Part 2, we will go into decentralized lending and insurance. In Part 3, we will cover synthetic asset exchanges.

These write ups are intended to bridge the gap between a general audience and what is happening in cryptocurrency with decentralized finance — if the technology explainers were not 100% thorough, you’re welcome to comment and suggest. However, it was likely intentionally written that way so that a wider audience could access this material without having wade through the jargon!

--

--

Karen Scarbrough

“If anything’s gonna happen, it’s gonna happen out there…” Captn’ Ron