What enables us to have truly programmable money? After your Welcome to Web3, let’s keep curiosity fed with hot sips on crypto and how decentralized finance (“DeFi”) galvanizes web3!
Extra Shot
This caffeinated contribution is by Scott Herren, a blockchain developer building at the forefront of web3.
Blockchains
As we dive into web3, we must grok the traditional finance world. One of the primary challenges that bitcoin and blockchains seek to solve is the double spend problem. Double spending occurs when digital tender/fiat/currency is sent to multiple parties simultaneously or after a sender’s balance has elapsed. (There’s a ton more to learn about consensus and the Byzantine Generals’ problem, but we’ll leave that for another cup.) This, effectively, creates money from thin air and is what banks and the central banking system have helped prevent for the last few centuries. This power can be abused, so bitcoin looked to democratize the process of approving transactions by folks called miners.
The Bitcoin network went live in 2009. Initial traction was modest, but the “unspent transaction output” (UTXO) model for tracking transactions and balances proved to be groundbreaking. Bitcoins are “fractured” from their initial whole. These fractions are used as currency, which makes accounting inclusive, verifiable, and very transparent.
Blockchain technologies have evolved toward mainstream adoption, but cryptography has been studied since the 1980s. Bitcoin was first to crack the code, but different blockchains and more on-chain layers are being combined in powerful ways. Today, there are four main types of blockchain networks: public blockchains, private blockchains, consortium blockchains, and hybrid blockchains. It’s impossible to count private blockchains, consortium blockchains, and hybrid blockchains, but there are hundreds of public blockchain that are permissionless, meaning they are fully decentralized and anyone with an internet connection can equitably access the blockchain as an authorized node. Bitcoin and Ethereum are the two largest, with 10% of the global population owning some form of over 2,000 different cryptocurrencies.
Within each blockchain, layers provide infrastructure for web3 developers. Hardware, data, network, consensus, and application layers make blockchain technologies more usable, with each layer offering unique functionality.
The last ingredient in the blockchain recipe is hashing, which gives blockchains verifiability. With hashing algorithms, miners are assembling a historical ledger where any tampering of previous transactions will disrupt current calculations. With verifiable ledgers storing only valid transactions, the next cool thing we can do is automate value.
Smart Contracts
Smart contracts allow us to program, exchange, and intermediate value using the storage mechanisms first introduced by Bitcoin.In 2014, Ethereum introduced a new programming language called Solidity, which allows smart contracts to store value and other data. Gas is paid in Ether, the native token of Ethereum, for transactions that interact with smart contracts. Computationally intensity and network activity determine gas fees at any given time. These primitives have helped developers explore a vast array of mechanisms for coordinating value. Some have been successful while many others have taught us valuable lessons about this antifragile system.
One of the earliest successful smart contracts of Ethereum, The DAO, had a catastrophic contract bug (flaw in the programming) which we now refer to as a Reentrancy Attack. The DAO had coded a “shared bank account” where stakeholders could deposit Ether into the contract and receive a proportional share of tokens back. The goal was to collectively fund projects via token-weighted voting. While tokenomics and technical improvements have addressed many of the early missteps, the major mechanisms are still widely used in token governance today.
Tokens & Standards
As the Ethereum Improvement Proposal (“EIP”) process matured in 2017, smart contracts began conforming to implementation standards. ERC-20 was the twentieth iteration, which included a request for comment offering a fungible token standard. To support an endless variety of projects, this token standard became the default for initial coin offerings (ICOs) that were sourcing funds to solve blockchain challenges. The power of this mechanism led to many overly ambitious projects that damaged trust with unfulfilled promises, but some of the powerhouses of today were launched during the ICO bubble.
Some other notable token standards are ERC-721, the non-fungible token,, and ERC-1155, the semi-fungible token. The adoption of these standards across the ecosystem allows for tight composability and interoperability across protocols. These “money legos” act like building blocks for DeFi, but before we get to decentralized finance, let’s first cash in on the most prolific tokens within our global economy: stablecoins.
Stablecoins
Stablecoins peg their value off another asset, generally something stable like the US Dollar or gold. Stablecoins can also derive value by being fiat-backed, collateral-backed, and algorithmic.
Fiat-backed stablecoins are backed by fiat money in an auditable bank account. Fiat money is a government-issued currency not backed by a commodity such as gold. Popular examples are Circle’s USDC, Gemini’s GUSD, and Tether. While fiat stablecoins are quite easy to scale they also have trade-offs with their decentralization properties. The blocklists of these stablecoins are growing as more projects comply with jurisdictional requirements.
Collateral-backed stablecoins are backed by assets that are locked on-chain and transparently auditable at any time. The largest of these, Dai, is mostly backed by Ether. When done right, these types of stablecoins have great decentralization properties, but are much more difficult to scale and can have liquidity issues from a market squeeze.
The final type of stablecoin is algorithmically balanced with a system known as “seigniorage shares”. It’s important to mention “algo-stablcoins”, as implementations have not been successful to-date, so you may want to avoid these types of stablecoins until technology can unequivocally support the ideology. Alright, with tokens and places to store value, let’s look at innovating within traditional financial exchanges.
Lending & Exchanges
After the rush of late 2017, the buidl market set in. Organizations committed to building, have delivered on overcollateralized lending and borrowing on-chain. Lenders can lock their collateral to earn from borrowers, but borrowers need to be lenders of another token and ensure their loans remain sufficiently overcollateralized. Lending and borrowing rely on asset prices to determine liquidation thresholds, but if these can be manipulated, then the system is vulnerable. The Oracle Problem is one that doesn’t often get surfaced, but is becoming more crucial as the value of attacks increases.
Early experiments around what order books looked like on-chain were clunky. Each bid, update, acceptance, or cancellation required another transaction and gas. This changed in 2018, when Uniswap used the Ethereum blockchain to provide a simple interface to swap tokens. Uniswap flipped the concept of traditional order books on its head. Instead of creating offers to buy or sell, a market maker can provide two tokens in a pool and the protocol holds the ratio of the tokens in the pool equal. These pools are called automated market makers (AMMs) and the pools leverage the equation k=x*y, generally referred to as the constant product market maker (CPMM). You’ll see AMMs often, with the CPMM formula occasionally cited. This supports a very simple token swap without accepting a costly series of orders. Being a non-custodial, decentralized exchange you also never give up control of your tokens until the swap actually occurs.
As crypto is managed, liquidity incentives were initially implemented by Yearn Finance, a protocol that automates the lending process to earn yields from on-chain assets that could be held or traded on the market. Many incentives came from token inflation that hadn’t found value loops and proved to be unsustainable. Since 2020, years of rapid experimentation has revealed innovations that are continuing to push DeFi forward.
DeFi’s Destiny
This magical dark forest can be treacherous, but system level engineering takes time and it’s liberating to build with so many intrepids learning together. As we complete this download, here are a few interesting use cases to keep us thinking about what’s possible beyond traditional finance.
- Instead of getting paid every two weeks or each month, smart contracts can create payment streams. Instant access to financial capital furnishes more financial freedom, while still maintaining refill or cancellation options. Along with incoming compensation, outgoing subscription fees and self-repaying loans are also use cases where automation can further optimize financial control.
- Also known as no-loss lotteries, prize-linked savings accounts, are not uncommon in the traditional finance world. Local municipalities and credit unions have generally handled them. Pooling capital and lending it to others is also used in smaller communities to help with small, low-cost loans. With an end-to-end process, smart contracts enable little to no overhead, which makes nearly all of the earnings available to participants.
- The most magical of our new tools! Flash loans allow for borrowing a near-infinite amount of a token, given the loan is paid back within the same transaction. This visualization of a flash loan transaction will add clarity, but in short, if there are transactions that require more capital and can be facilitated within one block, they have been democratized to anyone with access to a scripting language and a relaying node.
DeFi provides composable tools for traditional and innovative finance primitives. Being able to mechanize your money and the value it delivers within a network is super powerful. When web3 concepts hook into the financial primitives of crypto, the global economy can leverage faster, more equitable, and safer peer-to-peer commerce.