Markets

Decentralized Finance:
A Primer

One of the key applications of blockchain technology is the use of smart contracts, which replicate many aspects of conventional finance. Here’s an overview of the aspirations and current realities of DeFi.

In his 2016 history of finance, Money Changes Everything, William Goetzmann argued that “finance is a technology.”1 Finance consists of contracts, and there has to be some passage of time between the beginning and the fulfillment of the contract. One of the earliest known financial contracts came from ancient Mesopotamia. Using a pointed stick in wet clay, the Sumerians created wedge-shaped symbols to represent quantities of borrowed goods. The design principle of today’s blockchain technology, which underlies cryptocurrencies, is not very different from ancient clay tablets: Like those tablets, it was designed to prevent tampering.

Humanity has had thousands of years since the Sumerians to develop finance. We now possess a complex network of institutions that work together to exchange and transfer capital from one place to another or from one function to another. Conventional financial transactions are regularly channeled through centralized entities, such as banks and exchanges. These entities manage almost every aspect of banking, trading, lending and borrowing. The laws that control how the institutions operate are written and passed by legislatures and interpreted and enforced by regulatory bodies such as the Federal Reserve and the Securities and Exchange Commission (SEC). Financial institutions may charge a premium, control access and pose systemic risks. Despite the sophistication of this system, however, there are other limitations. For instance:

  • Some individuals can’t access bank accounts or financial services such as cross-border bank accounts.
  • Financial institutions can collect and sell valuable personal data, such as credit ratings, credit scores and transaction histories.
  • Governments and centralized institutions can open and close markets at will.2
  • Trading hours are often limited to business hours in specific time zones.
  • Money transfers require days to be processed. International bank transfers that could occur in nearly real time can take as long as five days.3
  • Intermediary institutions take cuts of financial transactions, increasing costs.
  • Participants must trust institutions and individuals that can and do fail. Markets and banks intermittently melt down, as they did in the 2008 financial crisis.

Since the 2009 launch of Bitcoin, the blockchain has made claims that it can remedy some — perhaps all — of these problems. In this primer, we will focus on one major blockchain application that has emerged: decentralized finance, or DeFi. We will examine the design principles behind DeFi and explain some of its key components and the risks that are now apparent. And we will ask: What might come next?

Code Is Law: Smart Contracts

Imagine a fully transparent, global network of financial services: loans, trades, insurance, asset management and much more. This open network would be fully decentralized so that no one person or entity could control it.4 The rules of these services would be clearly laid out and available for everyone to assess. The system would guarantee that these rules would be followed and that anyone with an internet connection could participate. These are the objectives of DeFi.

The essence of DeFi is the “smart contract.” The term appears to have been coined by computer scientist Nicholas Szabo in a 1994 paper, well before the blockchain and bitcoin emerged. Szabo wrote: “A smart contract is a computerized transaction protocol that executes the terms of a contract. The general objectives of smart contract design are to satisfy common contractual conditions (such as payment terms, liens, confidentiality, and even enforcement), minimize exceptions both malicious and accidental, and minimize the need for the trusted intermediaries. Related economic goals include lowering fraud loss, arbitration and enforcement costs, and other transaction costs.”5

The practical application of these goals only became possible with the development of Bitcoin. By employing the proof-of-work consensus mechanism, Bitcoin showed how the Byzantine Generals’ Problem,6 a game theory problem in which decentralized agents struggle to reach consensus without a centralized party, could be overcome, and established that it is possible to maintain a decentralized ledger that is tamper-proof and not controlled by any single entity or institution. Proof of work involves so-called miners solving computationally hard puzzles for a chance to add blocks to the Bitcoin blockchain and reap the rewards associated with it. Bitcoin transactions are logged onto the blockchain, allowing the receiver of funds to confirm that the transaction was successful.

The Bitcoin blockchain is decentralized, so no one fully controls it. The core Bitcoin code establishes procedures and guarantees that the contract (that is, the transaction) will be enforced. In other words, the code of the Bitcoin protocol — the smart contract — is the law.

To understand how DeFi actually works, it helps to explore how it can be used to replicate fundamental real-world functions.

A limiting aspect of the Bitcoin protocol is that it does not support the creation of arbitrary contracts. Bitcoin’s most prevalent use is as a single peer-to-peer currency. Among those who realized this limitation was Vitalik Buterin, a Canadian programmer and writer who co-founded the decentralized, open-sourced blockchain Ethereum and launched its crypto token, Ether (ETH), in July 2015. Ethereum, according to a white paper by Buterin, “comes with a built-in Turing-complete programming language [Solidity], allowing anyone to write ‘smart contracts’ and decentralized applications where they can create their own arbitrary rules for ownership, transaction formats and state transition functions.”7

Ethereum operates on the power of smart contracts. Suppose you are a digital artist and you are sitting with your friends in a bar. You promise them that if they send you one Ether (roughly $1,300), you will create a new digital painting (using your generator algorithm) and send them the painting and its ownership. In a centralized world, you might use an escrow account — an account overseen by a third party to hold and disperse funds for parties in a transaction — to guarantee that the contract would be honored. But in the Ethereum world, the smart contract consists of a few lines of code that can be pushed to the Ethereum blockchain. It would look something like this:

If msg.fee == 1ETH:

nft = mint_new_NFT()

Send(nft, to=msg.sender)

Your friends can audit the smart contract code and verify that it does what you have promised. The Ethereum blockchain guarantees that the smart contract is deterministic, trustless, secure, immutable and decentralized. Your buyers can send their money to this contract address (which you own), and the Ethereum blockchain guarantees they will receive a newly minted piece of digital art in exchange. This potentially creates a network of open, permissionless and decentralized finance based on smart contracts and the blockchain — that is, DeFi.

Exchanges in Decentralized Finance

DeFi aims to create a more efficient, more secure network of financial services. That means it must replicate the most vital functions of traditional financial institutions. To understand how DeFi actually works, it helps to explore how it can be used to replicate fundamental real-world functions, from exchanges to lending to creating liquidity.

Formally, an exchange is a marketplace where securities, commodities, derivatives and other financial instruments are traded. Its core function is to ensure fair and orderly trading. In our current financial system, exchanges mainly operate on an order driven model. Exchange participants submit market or limit orders for bids and asks, with a list of active orders maintained in an order book. Participants such as market makers provide liquidity to the order book and generally profit from differences in bid-ask spreads.

Building an order book–based decentralized exchange using smart contracts is possible but difficult; it would require too much overhead for nodes maintaining the blockchain to store and relay every market and limit order. Thus, the most popular decentralized exchanges (DEXes), such as Uniswap, which has 70 percent market share of total DEX volume are based on automated market makers (AMMs). The smart contracts hold liquidity reserves of trading pairs, and trades are executed directly against these reserves. Prices are set automatically using the constant product (x*y=k) market-maker mechanism, which keeps overall reserves in relative equilibrium. Reserves are pooled among a network of liquidity providers that supply the system with trading pairs in exchange for a proportional share of transaction fees.

In the algorithms of these constant product AMMs, every trade alters reserves so that the product of the reserves stays the same. Consider an example taken from a Uniswap white paper8: Ten ETH and 500 COINS (a hypothetical cryptocurrency) are deposited into a smart contract by liquidity providers. An invariant is automatically set so that ETH_pool * COIN_pool = invariant.

ETH_pool = 10

COIN_pool = 500

invariant = 10 * 500 = 5,000

A COIN buyer sends 1 ETH to the contract. Let’s say a 0.25 percent fee is automatically taken out for the liquidity providers and the remaining 0.9975 of ETH is added to the ETH pool. The invariant is divided by the new amount of ETH in the liquidity pool to determine the new size of the COIN pool. The remaining COIN is sent to the buyer.

Buyer sends: 1 ETH

Fee = 1 ETH / 400 = 0.0025 ETH

ETH_pool = 10 + 1 – 0.0025 = 10.9975

COIN_pool = 5000/10.9975 = 454.65

Buyer receives: 500 – 454.65 = 45.35 COIN

In this case, the buyer receives a rate of 45.35 COIN/ETH.

Lending and Borrowing

In conventional banking, a customer deposits funds in a bank, which lends that money to a borrower who is prepared to post collateral as insurance against the failure to repay. The bank charges the borrower an interest rate and offers the customer interest on the deposit, the latter usually smaller than the former. Thus, for lending and borrowing, we have a lender of funds, a borrower of funds and an intermediary.

The DeFi ecosystem needs to find players who are ready to provide liquidity by lending tokens.

In conventional finance, the money market specializes in lending and borrowing. It provides access to the bond market or instruments like Treasury bills. In DeFi, smart contracts serve as intermediaries. Suppose we are talking about the money market for ETH. A lender can supply ETH tokens to the smart contract and receive interest on the deposited ETH. A borrower who needs ETH must deposit collateral. The amount of collateral is determined by the collateral factor of the smart contract. If the price of borrowed tokens fluctuates, the borrower may need to replenish or increase the collateral. If the borrower fails to do so, the smart contract will automatically liquidate the collateral. An analogy is a margin call, but in the smart contract world no person is calling; the code is the law. The interest rate generally changes at every Ethereum block, generally every ten to 15 seconds. This variable interest is a function of the supply versus the demand for the ETH token.

For instance, Compound is a lending and borrowing protocol that in the second quarter of 2022 had $3 billion to $4 billion in total value locked (TVL) — a measure of user funds deposited in a DeFi protocol. Compound establishes money markets, pools of assets with algorithmically derived interest rates based on the supply and demand for an asset. Suppliers (and borrowers) of an asset interact directly with the protocol, earning (and paying) a floating interest rate without having to negotiate terms such as maturity, interest rate or collateral with a peer or counterparty.9, 10

Mining Liquidity

A key, if often overlooked, function of the conventional financial system is the creation and availability of liquidity. Liquidity is necessary for engaging in financial transactions. The ability to borrow and lend, and to buy or sell, securities of all kinds depends on ample sources of liquidity. Financial systems seize up when liquidity is withdrawn because of rising risk and uncertainty, as we saw in the 2008 financial crisis.

A DeFi protocol also requires liquidity to bootstrap and sustain itself. So the DeFi ecosystem needs to find players who are ready to provide liquidity by lending tokens. The protocols algorithmically reward those liquidity providers, usually with the native token of the protocol. Earning this yield is referred to as liquidity mining.

DeFi features a unique twist on creating liquidity, known as staking. In blockchain’s earlier years, projects rewarded bitcoin miners who were able to provide calculations to solve mathematical puzzles that prevented anyone from gaming the system, and that validated transactions and allowed the creation of new blocks. Solving, or mining, these calculations resulted in the payment of bitcoin. Proof of work drove the expansion of blockchains and created liquidity, but at a very high cost in energy usage. Recently, many newer blockchains have adopted the more scalable and energy-friendly proof-of-stake mechanism, in which users stake their coins to get a chance to mine a new block. Ethereum, the second-largest blockchain, recently shifted from proof of work to proof of stake — a tectonic shift in crypto, known as the Merge. Just as bitcoin miners earn rewards, users staking their capital earn rewards for maintaining the blockchain. Miners with larger stakes have a greater opportunity to validate new blocks on the blockchains.

DeFi Extensions: NFTs and GameFi

The foundational innovations of DeFi, like the blockchain and  smart contracts, have proven to be, quite literally, creative. The first nonfungible token (NFTs) was created by digital artist Kevin McCoy on May 3, 2014: a piece of pulsating art called Quantum. NFTs are digital tokens first used to represent the ownership of provably scarce digital assets, mostly art objects. In DeFi, NFTs have begun to be used as collateral for peer-to-peer loans. Interestingly, Yinsure NFTs from Yearn.Finance founder Andre Cronje, who is often regarded as the godfather of DeFi, provide smart contract insurance for various protocols and can be traded on secondary markets.11 Sales of NFTs jumped to $17 billion in 2021, an increase of 210 times over 2020. However, in 2022 the trend reversed in a larger crypto downturn, with Morgan Stanley even warning of a NFT crash.12

A similar process has taken place in what has been called the financialization of video gaming. One reason the financial industry is so important is that it allows consumers to transact relatively seamlessly around the globe.

In its 2021 report “Gaming: The Next Super Platform,” Accenture estimated there were 2.7 billion gamers worldwide and that the value of the industry exceeded $300 billion.13 With smartphones increasingly ubiquitous, much of video gaming has migrated to those devices. GameFi (for “game finance”) refers to popular blockchain-based games that are mostly “play to earn.” Video game publishers can issue their own tokens in initial coin offerings that can help finance the development of their games, much like an initial public offering of stock in conventional finance. Players of these games can earn in-game assets that can be traded outside the world of crypto exchanges or NFT marketplaces. GameFi has exploded in popularity, with decentralized applications (DApps), which exist on a blockchain or in peer-to-peer computer networks, nearly tripling in 2021.14 In August 2022, CoinDesk estimated that 60 percent of all blockchain activity came from game DApps.15

GameFi rests on three features:

  • Play to earn: Players earn money by trading collectibles or earning game tokens as they play.
  • DeFi components: Gamers can stake their tokens in smart contracts to earn yields. Blockchain gaming guilds offer such services.
  • Asset ownership: Gamers can earn in-game assets via NFTs. In contrast to traditional games, the rarity of these assets can be proven on the blockchain, and gamers can safely trade these assets in secondary marketplaces.

An Emerging DeFi World

Conventional finance is more than just institutions that facilitate the movement and trading of assets. Companies underlie stocks and bonds. Regulatory bodies ranging from central banks to securities agencies provide rules and oversight. Traditional finance operates in a complex social and economic environment of industries, companies, consumers and public bodies with a great diversity of interests and products. The DeFi world is beginning to see the emergence of analogous digital corporations in the form of decentralized autonomous organizations (DAOs). DAOs are built upon smart contracts that define the rules and hold the funds of the group. Because smart contracts are tamper-proof, once the ground rules of running the organization are defined, they can’t be changed arbitrarily without the group’s approval. Thus, DAOs offer a trustless way to start and run an internet organization of individuals; you only have to verify the smart contract code (which is 100 percent transparent).

On May 31, 2021, entrepreneur Mark Cuban tweeted: “The future of corporations could be very different as DAOs take on legacy businesses. It’s the ultimate combination of capitalism and progressivism. Entrepreneurs that enable DAOs can make $. If the community excels at governance, everyone shares on the upside. Trustless can pay.”16

DeFi comes with its own risks, many a result of the relative novelty of the innovations and the rapid evolution of crypto.

Questions remain. Can enough smart contracts be written to meet every need of what could be a complex organization, particularly when it comes to governance? Can a governance scheme be developed that can anticipate the many tensions within a corporation, many of which are difficult to resolve or even paradoxical?

The ultimate digital analogue may well be the metaverse or, rather, various metaverses built for specific users and interests. The concept gained visibility when Facebook announced a strategic shift to focus on the construction of the metaverse and renamed itself Meta Platforms. According to Meta’s corporate website: “The metaverse is the next evolution of social connection. Our company’s vision is to help bring the metaverse to life.” A metaverse has three elements: a virtual reality (VR) interface, digital identities and digital ownership. If the dream of a metaverse becomes a reality, it may require a trustless financial system to function. DeFi, with its functions of spending, lending, borrowing and investing without a central governing unit, could well serve as the backbone of the metaverse economy.

And Now the Risks

What could possibly go wrong? So far in this overview, we have seen how DeFi and its applications might solve problems associated with our current financial system. But DeFi comes with its own risks, many a result of the relative novelty of the innovations and the rapid evolution of crypto. Here is a short, but hardly exhaustive, list.

Smart Contract Bugs: Decentralized finance protocols rely on smart contracts, which are decentralized, permissionless and transparent. Smart contracts are pieces of code, which means they could contain very sophisticated bugs. This poses inherent risks. The best way to mitigate them is through vigilant audits, rigorous reviews, formal verifications and an efficient flow of information in case a bug is discovered. In 2016, one year into Ethereum’s existence, a bug in one of the technology’s smart contract codes resulted in a $150 million hack that reduced roughly 14 percent of Ethereum’s supply at that time.17

Platform Risk: The blockchain ecosystem is continuously evolving. Thus, there is a constant risk that a platform may be shut down, as many have been. Apart from that, platform upgrades are common. Ethereum, for instance, was recently upgraded to Ethereum 2.0 through the Merge. No one really can predict what longer-term consequences will arise from the move from proof of work to proof of stake. Upgrades are common and usually well thought-out, but they may inadvertently result in the malfunctioning of older smart contracts.

Oracle Failure: Many blockchain decentralized applications, or digital apps, use real-world, “off the chain” data, and because blockchains cannot be centralized, they rely on so-called oracles — complex computer systems that connect real-world data to the blockchain. The development of oracles solved a weakness of smart contracts, but it could spawn new problems. For example, if a protocol relies on an oracle for the real-world price of bitcoin, and if someone manipulates the oracle for a few seconds and leads the contract to accept an incorrect price, then a hacker could drain funds from the protocol. In 2020, about $90 million was liquidated on Compound due to an “oracle exploit.”18 Chainlink, which attempts to restore decentralization to a protocol that has been centralized into a single oracle, is one of the projects trying to reduce or remove such risks.

Governance Failure and Centralization: There is a concern that the “whales” (accounts that hold a large amount of tokens) can exert a disproportionately large influence on the governance of a protocol, leading to centralization of decision-making and control.

Unclear Regulation and Taxation: By now, it may have occurred to you that many elements of the DeFi ecosystem are akin to the current financial system, which is highly regulated with clear taxation. This creates a paradox for DeFi, which aims to be decentralized and fully automated, and because of its global nature offers the possibility of avoiding national laws. Such decentralization makes it difficult to enforce regulatory demands to “know your customer” and combat financial crimes such as money laundering, tax evasion or bribery. Regulatory authorities around the world, including the SEC, have task forces studying crypto regulation. A 2019 Bank for International Settlements report,  “Embedded Supervision: How to Build Regulation into Decentralised Finance,” suggests a framework for protocol-level regulations.19

De-pegging: As DeFi became popular, many so-called stablecoins came into play. They mimic a fiat currency like the U.S. dollar or the euro and are often used to provide liquidity. This creates a risk that such stablecoins could lose their pegs due to factors like market volatility or poor governance. Recently, Terra’s stablecoin, USTC, lost its peg; within 24 hours, its market cap dropped from over $40 billion to $500 million as users fled — a crypto version of a run on a bank or a money market fund.20

Phishing: DeFi is an emerging technology. Usually, accounts are controlled by using a private key or a pass phrase. Phishing attacks are easier when the technology is new and evolving. Research shows that $10.5 billion was lost to DeFi fraud and theft in 2021.21

Final Thoughts

The advent of blockchain technology is a zero-to-one innovation — a term popularized in a book by venture capitalist Peter Thiel that means the act of creating something entirely new.22 It has, in some sense, revolutionized our world. In terms of assets, DeFi is the equivalent of the 31st biggest bank in the U.S. Globally, there are now some 62 crypto-focused unicorns — start-ups worth over $1 billion — up from 49 in the fourth quarter of 2021.

Of course, with great technology comes great risks. Crypto markets have seen speculative crazes, pyramid schemes and phishing scams, which can reduce the confidence of investors. But this shouldn’t surprise anyone. In his well-known investing guide A Random Walk Down Wall Street, Princeton economist Burton Malkiel discussed the speculative stock bubble of the late 1920s. By 1928, stock market speculation had become a national pastime and stock prices were rising 10 to 15 points a day. The betting spirit was unrivaled in its intensity and obsessiveness. By the time the market hit its Depression-era low in 1932, most blue-chip stocks had fallen 95 percent or more, and the subsequent recovery was long and choppy.23

Crypto is very young. In its 2022 “State of Crypto” report, venture capital firm Andreessen Horowitz argued that these are still early days for the crypto ecosystem. Contrasting crypto with the internet, the firm wrote: “We estimate there are somewhere between 7 million and 50 million active Ethereum users today, based on various on-chain metrics. Analogizing to the early commercial internet, that puts us somewhere circa 1995 in terms of development.”24

Only time will tell if crypto will become as ubiquitous as the internet or whether DeFi will replace or subsume large pieces of conventional finance. But given the intense labor and thought of crypto pioneers, computer scientists, entrepreneurs and investors, it’s a world we probably cannot ignore.

Ritik Vijayvergiya is a Vice President at WorldQuant and has a bachelor of technology in electrical engineering from the Indian Institute of Technology, Delhi.