Notes on the DeFi Space

Updated 5/8/2020

At a very high level, the basic goal of capital markets and a financial system is to allocate capital and risk in an efficient manner among the participants of a market. The way this works today is through financial intermediaries (banks, insurance companies, clearinghouses and exchanges) in which various entities trade or exchange capital/risk/whatever with one another, and have a high enough degree of trust in the other entities involved in a transaction.

Decentralized Finance (deFi) is the concept of replicating this existing financial system in a decentralized fashion using blockchain/crypto technology to (1) remove the various centralized ‘middlemen’ in our current system, and (2) eliminate the need for trust. Think of bank lending replaced by fully peer-to-peer lending (without even any company acting as marketmaker – a true matching of buyers and sellers), or insurance contracts underwritten between two individuals without an insurance company, or derivatives contracts being exchanged completely between participants without any clearinghouse or other friction (just code that automatically allocates according to whatever smart contract rules govern it).

Broadly speaking, the underlying premise of deFi relies on smart contracts – code that enforces the agreement between two participants automatically; in practice, most are being built on the Ethereum protocol. In short, developers build programs on the blockchain using decentralized technology, which are then able to ‘smartly’ execute whatever contracts and details are set out by the program. These programs are known as decentralized apps, or dapps.

Note: it seems like there are a lot of people with some amount of skepticism/criticism as to whether the deFi space is actually doing anything worthwhile with blockchain technology or if it’s basically just another way for people to speculate in the broader crypto space. I’m not super interested in that debate. I just think the general concept is pretty cool and enjoy interesting market structures / incentives / etc, so that’s the focus here.

A few relevant links on broad stuff:

Messari, who has a lot of good research, had a nice article about 2019 returns in deFi sectors. Decent ‘lay of the land’ before wading into specific sectors:

Various important bits (this is largely summarizing those primers, some other stuff too):

  • Stablecoins
    • These are crypto tokens pegged to some fiat currency, usually the dollar. While many people have a pipe dream of crypto actually replacing regular currently, in practice it is quite useful to have some stable unit of cryptocurrency. For one, this acts as a nice bridge between the fiat world and the crypto world; most people’s economic lives are denominated in dollars, euros, pounds, or some other fiat currency. This allows you to participate in various deFi products without implicitly being levered to the price of a particular cryptocurrency with which you’d be transacting in (e.g. if you want to make a loan to someone in ethereum, you both have lending risk and ethereum currency risk – what’s the point of getting paid 10% interest annually if the value of ethereum could drop by 50% against the dollar? Only lending risk if you use a stablecoin). 
    • If these tokens are pegged to the dollar, how do they maintain this peg? Seems like two main solutions being used:
      1. Centralized fiat-collateralized: backed 1:1 by cash in a bank account. You buy a coin, you trust that the coin issuer has $1 set aside somewhere.
      2. Decentralized crypto-collateralized: stablecoins backed by the value of other crypto-currency pledged as collateral. Maker is a system that does this with their Dai stablecoin, where participants can pledge cyrpto as collateral and receive a Dai loan. If the value of the crypto collateral falls, the Maker algorithm makes a margin call and sells off (a portion of) your collateral in auction to get its value back. 
    • An overview of a few of the biggest stablecoins:
      • USD Coin (USDC) – Stablecoin fully backed by the US dollar, developed by CENTRE consortium (a partnership between Coinbase and Circle). Each coin is backed by $1 held in regularly audited/publicly disclosed accounts. CENTRE members can receive fiat currency and then ‘mint’ a new coin, exchanging coin for fiat. When the coin is redeemed for fiat, the coin is then burned so the supply always stays 1:1. As best I can figure out, consortium members can make money from (1) interest on the USD they’re holding or (2) fees to redeem USDC for dollars (make it buy at 1.000 and sell at 0.999 or something). White paper here.
      • Gemini Dollar (GUSD) – basically the same thing but issued by Gemini, a popular crypto exchange founded by the Winklevoss twins. 1 GUSD is backed by $1 held in a trust account. White paper here.
      • Dai (DAI) – a decentralized crypto-collateralized token issued by MakerDAO. As with others, 1 Dai = $1, but Dai is not literally backed by dollars sitting in a bank account – that’s much too centralized for them. Instead, you pledge collateral (ether) and receive Dai in exchange – essentially borrowing Dai. This is known as a CDP – Collateralized Debt Position. Your position is overcollateralized with the collateral worth 150% of what you borrow ($150 of collateral to borrow $100 of Dai), giving the token a secure value even if the price moves around. If the value of the collateral falls far enough (typically below something like 120-125%), smart contracts liquidate the collateral via auction so the system gets repaid and the $1 value of the Dai isn’t broken. White paper on MakerDAO here.
      • Reserve (RSV) – a stablecoin that is starting as a centralized, fully USD-token collateralized token, and plans to transition to a decentralized asset-backed approach in the long run. Kind of interesting if they can pull of the transition well? RSV is the stablecoin token, RSR (Reserve Rights) is the token facilitating the protocol of RSV. White paper here.
  • Decentralized Lending
    • Alright, so we’ve got some unit of currency we feel okay about transacting in. Now we can do financial stuff with it via smart contracts. Lending is a good place to start. In a typical centralized exchange for peer to peer lending, you’d have a bid / ask book for loans at various rates and various sizes, and the market would clear at various points of time. Decentralized lending takes this a step further and lends or borrows via the smart contract itself (no clearinghouse). Interest rates dynamically change to match demand.
    • Currently all the big decentralized lending platforms rely on collateralized borrowing – meaning that if a borrower doesn’t repay a loan, there is some asset that the smart contract will seize to make the lender whole. Lenders have to pledge $X of collateral in some crypto asset to borrow. There’s some risk here to price volatility of the assets – to protect against this, the lending contracts will have some ‘liquidation’ terms forcing the loan to be repaid when the value of collateral falls below some threshold (similar to a margin call in traditional finance).
    • Assuming correct implementation, the key remaining risks are smart contract bugs and crypto volatility (even with liquidation, there’s a non-zero risk of a huge swing in price that leaves you short). Smart contract should take care of the credit risk.
    • Examples of lending protocols:
      • Compound – for every asset available to borrow, there’s a global pool of capital (asset). All borrowers pay and lenders earn the same rate, based on the percent of the pool that is being borrowed. Interest rates are set by algorithm reflecting the percent of the pool being borrowed. If investors want to lend, they put funds into the pool, and interest begins to accrue. There’s no fixed loan duration or anything like that, and lenders can withdraw their assets at any time (technically once per Ethereum block, which is about once every 15 seconds). Kind of like a ‘money market fund’ if you squint a bit. Borrowers need to collateralize their accounts with 150% of the value borrowed. This article seems like a reasonable overview of some ‘what should you know’ about the risk inherence in using Compound. The bank run/liquidity risk section was most interesting to me. Compound white paper here.
      • dYdX – dYdX is basically a full trading platform for crypto and derivatives, one of the major components of which is margin lending/borrowing – again via collateralized loans (125% collateral requirement, min collateral ratio of 115%). The margin lending element again uses a pooled lending approach, with variable rates set by algorithm similar to Compound. Collateral is auctioned off if they need to liquidate it, and some interest goes into an insurance pool too in case positions can’t be recovered. As with any other protocol involving overcollateralized lending, the key risk for lenders is the speed at which you can liquidate collateral to recoup your investment in the event that prices fall – if you’re 125% collateralized and prices fall over 20% before you liquidate, you lose money. This is a pretty big deal when the collateral is as volatile as crypto is. White paper here.
      • Aave Has shifted from P2P model to the pool model too. Seems like a trend! Issued the LEND coin on an ICO to help underwrite their platform, the token is what governs the protocol. Couple unique things on Aave – (1) ‘flash loans’ that don’t have collateral but are automatically reversed if not paid back within X number of blocks, (2) allowing borrowers to lock in at fixed rates instead of the volatile floating rates that underpin most pools, if they so choose. Good interview with founder here, white paper here.
      • Maker Through their DAI token, Maker is also effectively a lender. DAI is never truly issued; it’s offered as a collateralized loan against ETH collateral, which ensures the DAI token retains its stabilized value. Again, white paper on MakerDAO here.
      • Cred – peer to peer lending protocol build on Ethereum, uses LBA token. Loans based on credit quality of applicant and credit quality of collateral. Seems like loans still need to be collateralized. Started under the name Libra Credit but has since changed to Cred (no affiliation with the Facebook stuff). White paper here.
      • Ripio – peer-to-peer credit network focused on Latin America, ICOed with the RCN token in 2016. Offers peer-to-peer microloans matching individuals via smart contract, with loans requiring either collateral or co-signers to mitigate credit risk. The payment history and loan data is recorded on blockchain which will enable borrowers to build credit history.
  • Decentralized Exchange
    • Instead of lending, it’s an order book for buying and selling cryptocurrencies between parties. Basic concept seems similar. Think of this as a replacement for Coinbase Pro or Binance’s exchange or something like that. Rather than a centralized marketplace where you have an intermediary with custody of your assets who executes trades for you, you have a smart contract take your coins and buy or sell for you. 
    • One of the key metrics for both lending and exchanges is Total Value Locked (TVL), which gives a sense for the quantity of assets being put into various lending or liquidity pools. Here’s a useful tracker on TVL in the space: https://defipulse.com/
    • Overview of some exchange protocols:
      • Uniswap: Instead of using an order book matching buyers + sellers, Uniswap pools assets that are traded with a dynamic algorithmically determined price. This actually seems like a cool concept! Market makers deposit assets into a pool, which traders can then trade against. The prices to buy/sell are based on the proportion of the two assets being traded using a Constant Product Market maker, where larger orders result in exponentially higher slippage, resulting in liquidity always able to be received. Here’s a good overview of how this actually works. In theory arbitrageurs should ensure that the assets in the pool are in line with whatever the ‘public market prices’ suggest they should be, so trades of small size should be at the right price. Liquidity providers are compensated via an 0.3% fee generated on each trade as well as via newly minted liquidity tokens entitling them to their proportion of the total pool’s asset base. White paper here.
      • Kyber: Kyber Network again uses a ‘reserve’ to provide liquidity in trading, rather than using a peer-to-peer approach. Reserve managers maintain liquidity and update the bid/ask spreads, they receive a fee paid in KNC (Kyber Network Crystal) equal to 0.25% on every transaction. White paper here.
      • Airswap – peer to peer decentralized exchange on Ethereum, uses off-blockchain negotiation and on-chain settlement to make p2p cheaper (on-chain order books can be costly). Seems like a reasonably good idea for the exchange, I am unclear on the value of the token itself. White paper here.
      • Loopring, 0x, and Bancor are among other competitors in the space.
  • Decentralized Asset Management
    • Synthetix – decentralized ‘synthetic asset’ platform giving you exposure to real-world currencies, stocks, commodities, etc. These Synths (synthetic assets) are backed by Synthetic Network Tokens (SNX) locked into a smart contract as collateral – similar to how Maker locks in ETH collateral to mint stable DAI coins. Oracles track the price of whatever the assets are, letting users trade p2c on their exchange without liquidity concerns. I’m not sure if I really get the point. White paper here.
    • Melon decentralized asset management allowing for the creation of tokenized asset management vehicles instead of a fund with a prospectus, etc. Paper here, better explainer here. This… actually does seem kinda useful? Obviously a lot of KYC and compliance concerns for actual institutional usage but strikes me as a useful addition to deFi world.
    • Polymath – platform for decentralized securities (or security tokens), meant to handle the compliance/registration side well (e.g. having a process for individuals to verify their identity/citizenship/domicile so they can purchase tokens they’re allowed to). White paper here.
Some other noteworthy things going on in the deFi space

  • Decentralized Insurance – Nexus Mutual is creating a decentralized insurance company using a risk-sharing pool with token owners sharing membership in the mutual, starting with smart contract bug insurance (white paper here). Opyn Insurance is an insurance project allowing you to buy or sell put options on both stablecoins (giving you the right to sell them for $1 in the future – basically insurance that a stablecoin doesn’t ‘break’) as well as on ETH – more info here.
  • Decentralized Lottery – This is a cool project from PoolTogether participants buy ‘lottery tickets’, the pool of money earns interest via Compound, one guy wins the pool of interest after a set period fo time and then everybody else gets their money back. Basically a prize-linked savings account! On the blockchain!
  • Decentralized Identity/Credit Scoring – Bloom is developing a decentralized credit system with identity and credit scores on the blockchain, intended to replace centralized systems for places that don’t have good credit infrastructure (which is a shockingly large part of the world – and the infrastructure we have doesn’t always transfer, e.g. I have no credit score in the UK despite having a good one in the US. Transferability seems important!). Includes credit scores based on repayment (and you vouching for people who repay, helping to verify identities in the system) and a credit registry system to track repayment of debts.
  • Decentralized Prediction Markets – quite a few players here, and something I really like a lot. These are basically binary derivatives exchanges on predicting real world events (like “Will Donald Trump get reelected?” or “Will the Cubs win the 2020 World Series?” or “Will it rain today in Chicago?”) where contracts either pay out at $1 or $0 depending on if something occurs and the price of the contract represents some implied probability of the event happening. The decentralized part is that rather than one entity validate the outcome of an event, instead the network validates the results by pledging tokens towards a given outcome, with a multiround appeals process if there is any doubt as to which outcome is the correct one. I think something like this has really interesting potential long-term, especially as the questions move both towards things like “Will Team A cover the spread” (sports betting is a pretty large market!) as well as “Will the price of Commodity Y be above $Z as of a certain date” (futures / financial derivatives is a very very large market). That’s a long way away, but is at least interesting. Augur, Amoveo, and Gnosis are a few of the bigger projects in the space.
  • Connecting to off-chain data: Doesn’t quite fit neatly into a category, but Chainlink seems like a pretty useful project, building the connectivity between off-blockchain data sources and on-chain smart contracts. Imagine a smart contract that resolves when someone verifies a package has shipped, or something – they’re building the layer allowing that someone in the real world to confirm the package shipped so the contract can run.
  • Anonymity – By definition, every transaction on the Ethereum blockchain is recorded, so what participants are somewhat anonymous there is actually a very clear ‘paper trail’ for any participant’s flow of funds which you can trace, as every participants’ transaction history and present balance are public. One can think of any number of reasons why that might not be desirable. Tornado.cash is kind of a cool project allowing transactions on the Ethereum blockchain anonymously by breaking the link between a recipient and destination address – by basically pooling deposits from various participants so when withdrawals occur, you can’t tell which came from whom. Some more info here
Some issues
Feels difficult to talk about the space without mentioning a lot of high profile attacks/issues with various protocols recently. A quick summary:

  • bZx is a decentralized exchange which endured a couple attacks recently – the first involved an individual taking out a flash loan on dYdX to borrow a lot of ETH, depositing the ETH into Compound to borrow WBTC, then making a margin trade on bZx to short ETH relative to WBTC. bZx filled this trade via Uniswap (actually KyberSwap, which in turn used Uniswap), and was a big enough block trade to notably move/manipulate the price of WBTC / ETH in Uniswap. The individual then used some of the WBTC they borrowed to buy WETH in Uniswap, taking advantage of the manipulated price to buy it lower, and then used a bug in the bZx margin trade code to repay the trade in a manner such that bZx was left holding the bag. There are a lot of good recaps of how this happened, like here, here, here, and here. Honestly pretty impressive to me that all the pieces from different exchanges can come together like that.
  • bZx then had a fun second attack, playing out as a guy borrowing a flashloan in ETH from bZx, buying as much sUSD as possible at market rates, then pumping the price of sUSD in Kyber, and repaying their flashloan to bZx in sUSD – since bZz relies on Kyber to report the accurate price of sUSD / ETH. As a result bZx was stuck with an undercollateralized loan. Again, good recaps here and here. Fun silver lining for bZx – they had insurance from Nexus Mutual! So they got paid out on that at least.
  • iEarn and Curve had an interesting controversy, again involving traders manipulating significant slippage in prices as a result of the AMM between two stablecoins. Things seemed to mostly get sorted out thanks to a friendly whale (trader with lots of capital to throw around) who could correct the pricing issue. Detailed recap here.
  • Not an attack, but MakerDAO had a lot of controversy in March as a result of a rapid decline in the price of ETH resulting in many stakers getting their collateral liquidated as their loans became undercollateralized. As promised, the collateral was auctioned off… but in some instances the ETH collateral traded for $0, thanks to a thinly attended auction, resulting in huge gains for the auction buyers and massive losses for stakers. Controversy ensued.
Thanks to Jack Power, Patrick Callahan, and Martin Durkin for reviewing / providing feedback.