How DeFi Works: Everything You Need to Know to Get Started
With the recent surge of interest in Decentralized Finance (DeFi) protocols, it has become increasingly important to understand the foundations on which DeFi is built, and how it enables people worldwide — regardless of their location or socioeconomic position — to gain from the ecosystem. This article provides a comprehensive guide to DeFi, including storing and managing your cryptocurrencies on a DEX, decentralized lending and borrowing, decentralized governance, and other use cases of DeFi on the Web3 stack, such as yield farming, insurance, stablecoins, and more.
In the mainstream (centralized) world, financial institutions offer customers access to opportunities like cash storage and loans through central authorities like banks and governments. Decentralized finance (DeFi), on the other hand, is a financial ecosystem that is built on blockchain technology and operates independently of central authorities, thus providing an open and transparent financial system that is accessible to all and enables people to control their assets and participate in financial services directly. DeFi applications typically use smart contracts, DEXs and other blockchain-based tools to offer a range of financial services, including lending, borrowing, trading, and insurance.
Wait, what’s a “DEX”?
At its core, a decentralized exchange (DEX) is a peer-to-peer (P2P) platform that allows users to trade cryptocurrencies without relying on third-party intermediaries. Primarily, this allows users to trade without giving up control of their funds, thus providing them with greater security and more control over their finances.
DEXs are powered by self-executing smart contracts that run on decentralized blockchain networks and eliminate the need for a central intermediary. This makes them tamper-proof and easily verifiable.
DEXs charge lower fees and commissions than centralized exchanges. This makes them a more attractive option for traders.
DEXs don’t require users to provide any personal information. This provides an added layer of privacy and security.
For example, Uniswap’s DeFi ecosystem enables users to swap, earn and vote with hundreds of DeFi apps, integrations and tools built on the Uniswap Protocol.
The exchange allows traders to exchange any ETH tokens in its pool at their current market price through its Automated Market Maker (AMM) mechanism. It uses smart contracts to determine prices and execute trades, thus eliminating the need for a central authority and making it more transparent and secure.
The protocol allows investors to stake their ETH tokens on Uniswap’s liquidity pool for a small fee paid to the staker for every trade.
The protocol is managed by a global community of Uni token holders and delegates, who participate by proposing upgrades and discussing the future of the protocol, and also vote on official governance proposals for the protocol.
How Staking works
Staking is a process in which individuals hold and lock up a certain amount of their cryptocurrency assets in order to support the security and functionality of a blockchain network. By doing so, individuals help validate transactions and maintain the network, which in turn helps ensure the stability and security of the blockchain.
Traders connect their wallets to Uniswap to swap their ETH tokens against other ETH tokens in the pool.
For every trade, traders pay a small fee to the staker.
Stakers who provide lesser-known, rare or unique ETH tokens earn greater incentives. For example, if a staker provides a token that no one else may have provided, then they earn all the fees for those swaps.
Decentralized Lending & Borrowing
Decentralized lending and borrowing is a form of lending service through which users can lend and borrow funds securely from one another. Governed by unbiased self-executing smart contracts, decentralized lending allows individuals to borrow as long as they meet all the collateral requirements — without discrimination, risk assessment or “credit scores”.
Defi lending works by allowing users to pledge crypto assets as collateral to borrow funds from a network of lenders. This is done via a decentralized application (dApp) that runs on a blockchain.
The borrower shares their loan requirement i.e. the amount and duration for which they might want to borrow, and the interest rate they’re offering to pay.
Thereafter, if the borrower can offer up the collateral required for the loan, the loan is approved and the assets are placed in a smart contract and sent to the borrower’s wallet.
The borrower then repays the lender as per the terms of the smart contract, and after the loan is repaid in full, receives the collateral back in their wallet.
Borrowing and Stability on MakerDAO
MakerDAO is a decentralized autonomous organization (DAO) built on the Ethereum blockchain. The platform provides blockchain-based loans to people in its native algorithmic stablecoin DAI, whose value is soft-pegged 1:1 to the US Dollar.
A multi-collateral algorithmic stablecoin
While most other stablecoins are collateralized against a single fiat or cryptocurrency, DAI can be borrowed against Ethereum (ETH), Basic attention token (BAT), USD Coin (USDC), Wrapped Bitcoin (wBTC), Compound (COMP), AAVE — and other tokens.
The value of DAI is kept stable through a system of smart contracts which adjusts the supply of DAI in response to changes in the value of the collateral against which the DAI is borrowed. Accordingly, if the value of a borrower’s collateral falls below the collateralization ratio, the MakerDAO protocol automatically liquidates the collateral to pay off the loan. This also prevents users from taking out loans they cannot afford to pay back.
Another key mechanism through which MakerDAO maintains the value of DAI is its “stability fee”, a floating interest rate charged to users who borrow DAI collateralized debt positions (CDPs), thus incentivizing CDP holders to repay their debt on time.
Collateralization ratio is the minimum “safe” debt to collateral ratio that a system allows.
When the value of the collateral in a debt falls below this threshold (150% to 165%), the smart contract triggers an automated liquidation of the collateral. The liquidated collateral is then sold on the open market to repay the debt. This measure alone, however, does not cover the entire cost of debt. So, simultaneously with the liquidation, the smart contract also triggers a “debt auction”, wherein the debt is sold to the highest bidder at a discount. The proceeds from this sale are used to repay the debt, and the remaining assets are returned to the owner.
Further, if the value of DAI begins to diverge from its target value relative to the US dollar, MakerDAO adjusts the stability fee to control the generation of DAI. For example, a sharp rise in the value of DAI triggers an increase in the stability fee, thus making it more expensive to generate DAI and reducing its supply. Conversely, if the value of DAI dips too low, the stability fee reduces, making it less expensive to generate DAI and increasing its supply.
Lastly, as we’ve stated earlier, by virtue of being a decentralized lending and borrowing platform, MakerDAO allows individuals to borrow easily without ID verification or risk assessment, as long as they can meet the collateral requirements for the debt.
Yield FarmingYield farming in DeFi allows individuals to earn returns on their cryptocurrency investments through a combination of staking, lending, and borrowing. The tokens earned through yield farming can be used to purchase other cryptocurrencies or services, or simply held as an investment for passive or semi-passive income generation.
A key component of yield farming in DeFi, liquidity mining is a process in which cryptocurrency holders lend their assets to a liquidity pool on a decentralized exchange (DEX) to make them available for trading. Thus, by providing liquidity to a DEX, investors earn a portion of the exchange’s trading fees as a reward, usually in the form of the protocol’s governance token.
In yield farming, individuals deposit a specific pair of assets into a liquidity pool on a DEX, such as Uniswap or Curve.fi. The more liquidity a user provides, the greater they will earn from the exchange’s trading fees. But that’s not all — These tokens can also be traded on other exchanges for other cryptocurrencies, thus allowing yield farmers to earn through the appreciation of these tokens as well.
Liquidity Mining on GMX’s GLP Pool
Launched in September 2021, GMX.io is a decentralized perpetual contract trading platform for top cryptocurrencies. Unlike decentralized spot exchanges, traders on GMX deposit collateral to take either long or short positions. The profits are then settled in either USDC (for short positions) or in the token of the paired asset (for long positions).
The GMX ecosystem has two native tokens —
1. The GMX token
GMX.io’s community governance tokenCan be staked to earn a yield with compounded rewardsCan be bought on any of the many decentralized exchanges, and…
2. The GLP Token
GMX.io’s core distinguishing feature — the GLP Pool — is a community-operated liquidity pool. The GLP token serves as an index for providing liquidity to leveraged trading. Holders of the token earn a “real yield” from the losses incurred by traders, and vice versa. Leveraged trading makes this a high-potential earning opportunity, especially for sophisticated whales.
Unlike the GMX token, the GLP token can be bought on GMX only, by swapping crypto assets that you own to stake GLP in the pool.
The process of yield farming is automated and requires no manual intervention, making it a convenient way to earn returns on cryptocurrency investments. However, as with any investment, yield farming comes with inherent risks, such as market volatility and the possibility of technical failure. As such, it is important for individuals to carefully consider the risks and rewards of yield farming before participating.
“Flash loans” on Aave
Aave, a DeFi lending platform based on the Ethereum blockchain, allows borrowers to avail of instant crypto loans against collateral from its liquidity pool, which is powered by lenders who deposit crypto into the pool for returns.
Aave’s protocol is perhaps most famous for popularizing “flash loans” — an innovative way of accessing capital instantly and easily, thus allowing users to borrow funds without collateral and with minimal risk — so long as the loan can be repaid in the same transaction. This, however, is a feature designed specifically for developers, due to the technical knowledge required to execute one.
Flash loans are generally used to facilitate arbitrage and other high-frequency trading strategies like NFT trading. The idea behind using flash loans to buy NFTs is to take advantage of market inefficiencies to make a profit.
How it works
An individual borrows a flash loan of a certain amount and uses the loaned cryptocurrency to purchase an NFT at its current market price.
Then, very quickly, the borrower sells the NFT for a higher price, taking advantage of any price fluctuations in the market.
Finally, the user repays the flash loan, returning the original amount of cryptocurrency borrowed, plus any interest.
Staking rewards come typically in the form of additional cryptocurrency tokens and are designed to incentivize individuals to help secure and maintain the network. And the amount earned depends on several factors, including the total number of tokens staked, the amount of time for which the tokens are staked, and the overall demand for staking.
Staking rewards on Ethereum
Since its inception in 2015, Ethereum mostly relied on a consensus mechanism called Proof-of-Work (PoW), which required miners to perform intensive mathematical calculations to validate transactions and create new blocks. While PoW was a key component of Ethereum’s security and decentralization, it was criticized for its high energy consumption and the centralization of mining power in the hands of a few large organizations.
In response to this, in September 2022, Ethereum transitioned its current system of Proof-of-Stake (PoS).
Under the PoS system, transactions are verified by addresses that have pledged a significant amount of ETH through staking. These staked addresses then earn proportional rewards based on the amount of ETH they have locked up.
DeFi insurance platforms allow users to purchase insurance policies that protect against the risks associated with smart contract failures. This provides DeFi users with a level of protection that is not available in traditional finance.
Nexus Mutual’s Smart Contract Cover
Nexus Mutual is a decentralized insurance platform registered in the United Kingdom and structured & governed as an Ethereum-based DAO that is owned fully by its members. The Nexus Mutual DAO works on a mutual model, where members pool their funds together in a risk-sharing pool, which is then used to pay out claims. Members who contribute to the pool and vote to assess coverage risks or to suggest changes in the protocol earn rewards in the NXM token — a multi-faceted utility token that fuels the Nexus ecosystem.
Nexus Mutual’s Smart Contract Cover is designed to protect its policyholders against smart contract bugs and hacks — important because transactions worth millions and sometimes billions of dollars are executed through smart contracts. Besides, smart contracts are mostly written in Solidity — a new coding language — which makes it harder to ensure error- or risk-free watertight security. So, Nexus has got that covered, for starters.
Nexus Mutual’s system of democratized risk assessment allows holders of the NXM token to collectively assess coverage risks for smart contracts by voting to accept claims.
Members also participate by suggesting changes to the protocol by submitting a proposal through its governance platform.
The weight of every member’s vote is proportional to the amount of NXM they might be staking.
While the weight of every vote is proportional to the amount of NXM staked for voting, rewards are distributed equally between the number of members who vote — regardless of the proportion in which tokens are staked by the voting members.
Getting a Nexus Mutual cover
Specify the address of the smart contract for which you want to buy coverage
Set coverage details, including the amount, time period and currency (ETH or DAI) for the coverage
Request a quote for the coverage
To complete the purchase, authorize a transaction using Metamask and pay in NXM, ETH or DAI
Note: Every new membership applicant is required to pay a one-time fee of 0.002 ETH and go through a KYC (Know-Your-Customer) and AML (Anti Money Laundering) screening to get accepted into the ecosystem. Further, the price of every coverage is determined by Nexus Mutual’s Risk Assessors, who have expertise in smart contract auditing.
DeFi for Developers
The DeFi ecosystem is highly modular, allowing developers to build new applications and services that can be integrated into the existing ecosystem. With its large (and growing) user base, supportive community, and zero regulatory resistance or bureaucratic hurdles, DeFi enables developers to create products and services that are accessible to anybody, irrespective of their location or financial status. This has resulted in a rapidly growing DeFi ecosystem, with new and innovative products and services being launched regularly.
Incentives for Developers in DeFi
In addition to the Uniswap Grants Program that’s covered earlier in this article, several other protocols have offered up millions in incentives to DeFi Developers.
NEAR, for example — a decentralized development program that was founded in 2018 to address the drawbacks (high gas fees, scalability issues) of other protocols in the DeFi space and create an environment that is conducive to smart contracts and dApps — announced a $350 million grant in May 2022 to encourage innovation in its ecosystem. Fast grants of up to $50K were being issued to applications from organizations and independent developers to build dApps (decentralized applications) on NEAR.
Before this (in March 2022), Kava.io allocated $750 million to on-chain developer incentives and committed majority ownership (62.5% of all block rewards) of its network to its contributing developers.
Other popular protocols that have actively offered up innovation grants to developers include Compound, MakerDAO, Curve.fi, and Aave, among many others.
Bug Bounty Rewards
In addition to grants, many DeFi projects also offer bug bounty programs, which incentivize developers to find and report security vulnerabilities in their respective platforms.
Ethereum’s bug bounty program is an opportunity for developers to earn up to $250,000 by finding protocol, client and Solidity bugs affecting the Ethereum network.
Developers can also earn from providing coding, design and marketing services to DeFi projects — an easy segue from developers that are ready to set foot in the industry.
In a nutshell, DeFi offers a range of opportunities for developers to make money and build innovative financial products and services. And it is certainly a very exciting area for developers to work in.
Transactions on the DeFi ecosystem are recorded on the blockchain, providing a transparent and auditable history of all transactions. Additionally, DeFi services and products are typically open-source, allowing users to inspect the code and verify that it is secure. This level of transparency and openness is not possible in traditional finance, where the inner workings of financial institutions are often kept confidential.
Still, tread with caution.
Yes, DeFi has unlocked for us a new world of possibilities. It has given us the power to take control of our finances, earn higher returns on our investments, and access new financial services that were previously unavailable to us. However, we must acknowledge that DeFi is still a relatively new industry that is evolving despite its failures, and we must be cautious and conduct thorough research before participating in a DeFi protocol.
At Dyor, we are dedicated to helping you make informed decisions about your cryptocurrency investments. In addition to our investment platform, Dyor’s community of contributors and investors are here to help you get started with decentralized Web3 investing.
About the author
Dyor is building an investor-friendly decentralized platform built to help you navigate and invest in Web3 and DeFi easily. Learn more on dyor.exchange