How DeFi protocols work: exchanges, lending, oracles and governance
DeFi moves financial rules into code on a blockchain
DeFi, short for decentralized finance, is a system of financial protocols that run on blockchains, which are shared digital ledgers, through smart contracts. A smart contract is code that carries out agreed rules automatically.
Instead of a bank, broker or central exchange handling each step, DeFi protocols use code, shared liquidity pools, price feeds and voting systems. Users can trade, lend, borrow, supply liquidity, vote on changes, or build new products by connecting protocols together.
The main building blocks of a DeFi protocol
- Smart contracts set the rules for trading, lending, collateral, fees, voting and settlement.
- Liquidity pools hold assets that traders and borrowers use.
- Liquidity providers supply assets to pools and accept the risks of that role.
- Oracles bring outside data, such as prices, into smart contracts.
- Governance coordinates upgrades, parameters, incentives and treasury decisions.
- Composability lets protocols connect to each other to form new products.
How decentralized exchanges handle trading
A decentralized exchange, or DEX, lets users trade on-chain through smart contracts. Early designs copied order books, where buyers and sellers post bids and asks. On-chain order books can be costly because each update uses gas, which is the fee paid to use a blockchain, and liquidity can sit unused.
Automated market makers, or AMMs, changed that model. A trader trades against a shared pool instead of matching one other person. A formula sets prices from the amounts of each token held in the pool.
One common AMM formula is x times y equals k. It keeps the product of the two reserves constant, so price moves as trades happen. It is simple and always offers liquidity, but it can spread capital across prices far from the market price.
Other designs try to improve on that. Concentrated liquidity lets providers choose price ranges for better capital use, but needs active management. Constant sum AMMs keep the exchange rate near a fixed level and can work well for stable pairs, but can break if one side is drained. Hybrid AMMs blend curves for pegged assets and are more complex. Intent-based DEXs let users state a desired outcome and have solvers compete to fill it, which can improve routing but depends on solver competition and quality.
How lending, borrowing and yield work
DeFi lending protocols let users supply assets to earn yield and borrow against collateral without a traditional bank. Many use overcollateralization, where a borrower deposits collateral worth more than the loan and must keep the position healthy.
If collateral value falls too far, the protocol can liquidate the position, meaning it closes or sells it to protect the pool. Other key terms include utilization, which shows how much of a pool is borrowed, supply and borrow APY, which are the rates earned by suppliers and paid by borrowers, and health factor, which measures how safely a position is collateralized.
Yield aggregators route deposits through vaults, which are contracts that hold and manage user funds, and follow automated strategies. They can compound returns and reduce manual work. They also add smart-contract risk, strategy risk, fee and governance risk, and reliance on keepers, which are people or bots that carry out routine tasks.
Why oracles, derivatives and governance are central
Oracles provide data that smart contracts need but cannot get on their own, such as asset prices for collateral values, derivatives and liquidations. Bad, delayed or manipulated data can cause wrong pricing and losses. Using multiple sources and averaging them can reduce dependence on one provider, but does not remove latency or governance risk.
Decentralized derivatives give exposure to assets or outcomes without holding the underlying asset directly. Examples include perpetual futures, options and synthetic assets. They rely on collateral, margin, funding payments and liquidation rules, and can add leverage risk.
Many protocols are governed by DAOs, which are on-chain groups that make decisions through proposals and voting. Governance tokens can give voting power. Rules may set a quorum, a minimum participation level, before a vote counts. Large holders can have strong influence, and low participation can make decisions fragile.
How connecting protocols creates both benefits and risks
Composability means protocols can plug into each other like building blocks. A yield vault can send deposits to a lending market, and that market can rely on an oracle for prices. This helps developers reuse liquidity and infrastructure.
The same links can spread problems. If a widely used protocol, oracle, bridge, collateral asset or governance decision fails, effects can move across connected apps. The source material lists other risks, including smart-contract bugs, shallow or imbalanced liquidity, fast liquidations, captured governance and changing legal treatment. This explainer is educational and is not investment, trading, tax or legal advice.