DeFi Basics
What Is a DeFi Protocol?
Learn what a DeFi protocol is, how decentralized finance protocols work, the different types of DeFi protocols, and how they are governed by their communities.
Learn what oracles are in DeFi, how they bring off-chain data on-chain, the different types of oracle networks, and why accurate price feeds are essential for lending, borrowing, and other decentralized finance applications.
If you have spent any time exploring decentralized finance, you have likely encountered the term "oracle." It sounds mysterious, but the concept is straightforward: an oracle is a service that brings real-world data onto a blockchain so that smart contracts can use it.
Blockchains are powerful, but they are also isolated. A smart contract running on Ethereum, for example, has no built-in way to know the current price of Bitcoin, the temperature in Tokyo, or the outcome of an election. It can only see data that already exists on its own chain. Oracles solve this limitation by acting as trusted data bridges between the off-chain world and on-chain applications.
Without oracles, most of the DeFi ecosystem as we know it simply would not work. Lending protocols, decentralized exchanges, insurance platforms, and prediction markets all depend on external data to function. Understanding how oracles work is essential for anyone who wants to navigate DeFi safely and confidently.
Smart contracts are self-executing programs that run exactly as coded. Their deterministic nature is a strength because every node on the network must arrive at the same result when processing a transaction. But this determinism also means smart contracts cannot make HTTP requests, call APIs, or fetch data from the outside world on their own.
This creates what the industry calls the "oracle problem": how do you get reliable, tamper-proof external data into a system that is designed to be trustless and self-contained?
The stakes are high. Consider a lending protocol that allows users to borrow stablecoins against Bitcoin collateral. If the price feed reports an incorrect BTC price, borrowers might get liquidated unfairly, or the protocol might fail to liquidate undercollateralized positions, putting lenders' funds at risk. A single inaccurate data point can cascade into millions of dollars in losses.
This is why oracle design is one of the most critical infrastructure challenges in DeFi, and why platforms like Borrow by Sats Terminal aggregate across protocols that use battle-tested oracle solutions.
At a high level, an oracle follows a simple pattern:
Oracles generally operate in one of two ways:
Each model has trade-offs. Push oracles ensure data is always fresh but consume gas continuously. Pull oracles are more gas-efficient but require users to initiate the update.
A centralized oracle relies on a single data provider. While simple to implement, this design introduces a single point of failure. If the provider's servers go down or the provider is compromised, every DeFi protocol depending on that oracle is affected.
Centralized oracles also require users to trust one entity, which conflicts with the trustless ethos of decentralized finance. For these reasons, most serious DeFi protocols avoid single-source centralized oracles for critical functions like collateral pricing.
Decentralized oracle networks distribute the responsibility of data sourcing and validation across many independent node operators. Chainlink, the largest decentralized oracle network, uses a network of nodes that each independently fetch data and stake tokens as collateral. If a node reports inaccurate data, it risks losing its staked collateral, creating a strong economic incentive for honesty.
This decentralized approach mirrors the security model of blockchains themselves: no single participant can corrupt the system because the consensus mechanism catches and discards outliers.
Some protocols use price data that is already available on-chain. For example, Uniswap v3 provides time-weighted average price (TWAP) oracles based on its own trading activity. These are sometimes called "on-chain oracles" because they do not rely on external data sources at all.
TWAP oracles are resistant to short-term manipulation because they average prices over time. However, they are only as reliable as the liquidity in the underlying trading pool. For major pairs like ETH/USDC, this works well; for low-liquidity pairs, TWAP oracles can still be exploited.
A newer category, compute oracles, go beyond delivering data. They perform off-chain computations and return the results on-chain. This is useful for tasks that would be too expensive to execute on-chain, such as generating random numbers, running complex risk models, or processing verifiable computations.
Lending protocols are among the heaviest users of oracle infrastructure. When a user deposits Bitcoin as collateral to borrow stablecoins, the protocol needs a continuous, accurate price feed to know the dollar value of that collateral.
Borrow by Sats Terminal aggregates across leading lending protocols, all of which rely on high-quality oracle feeds to price collateral accurately. When you compare rates on Borrow, the underlying oracle infrastructure is part of what determines how much you can borrow and at what loan-to-value ratio. On Borrow, that oracle output is what you actually see in the comparison view: the LTV and liquidation price each lender's feed is producing for your BTC, shown alongside the rate, fees, and which wrapped form (wBTC, BTCB, or cbBTC) the protocol will use.
If the value of a borrower's collateral drops below a certain threshold, the protocol must liquidate the position to protect lenders. Oracles provide the price data that triggers these liquidations. A delayed or inaccurate oracle update could mean the difference between a healthy liquidation and a bad debt event for the protocol.
This is why oracle latency and update frequency are critical design parameters. Lending protocols typically choose oracles with tight deviation thresholds and fast heartbeat intervals for their most important price feeds.
Some protocols use oracle data to dynamically adjust interest rates based on market conditions, utilization rates, or the relative prices of different assets. In these systems, the accuracy of oracle data directly affects how much borrowers pay and how much lenders earn.
Oracle manipulation is one of the most common attack vectors in DeFi. An attacker might use a flash loan to temporarily distort the price on a low-liquidity exchange, causing an oracle to report an incorrect price. The attacker then exploits this incorrect price to borrow more than their collateral is worth or to trigger unfair liquidations.
High-profile oracle manipulation attacks have resulted in hundreds of millions of dollars in losses across DeFi, making this a well-known risk that protocols must actively defend against.
Protocols and oracle networks use several strategies to prevent manipulation:
When choosing a DeFi protocol to use, especially for lending and borrowing, consider the oracle infrastructure:
These questions can help you assess the reliability of the protocol's price data and, by extension, the safety of your funds.
Chainlink is the most widely adopted decentralized oracle network, securing tens of billions of dollars in DeFi value. It operates a large network of independent node operators that source data from premium data providers. Chainlink's Price Feeds are the standard oracle solution for many lending protocols, including Aave and Compound.
Pyth Network focuses on high-frequency financial market data and uses a pull-based oracle model. It sources data directly from first-party financial institutions, market makers, and exchanges, providing sub-second latency updates. Pyth is particularly popular on Solana and other high-throughput chains.
Oracle technology continues to evolve rapidly. Key trends include:
As DeFi matures, oracle infrastructure will become increasingly important. Platforms like Borrow by Sats Terminal help users navigate this complexity by aggregating across protocols that use robust oracle solutions, so you can focus on finding the best rates for your Bitcoin-backed loans without needing to evaluate oracle infrastructure yourself.
Common Questions
An oracle in DeFi is a service that connects blockchains to external, real-world data. Because smart contracts cannot natively access information outside their own network, oracles act as trusted data bridges. They deliver price feeds, weather data, sports scores, and other off-chain information that decentralized applications need to function correctly.
Related Questions
DeFi Basics
Learn what a DeFi protocol is, how decentralized finance protocols work, the different types of DeFi protocols, and how they are governed by their communities.
DeFi Basics
Learn about the key risks of decentralized finance (DeFi), including smart contract vulnerabilities, protocol risk, systemic risk, and how to protect your assets.
DeFi Basics
Understand how DeFi lending protocols work, including how interest rates are set, how collateral is managed, and which protocols are most widely used for crypto-backed borrowing.
DeFi Basics
Learn what decentralized finance (DeFi) is, how it works, and why it matters. Understand the core concepts of DeFi including smart contracts, blockchain, and permissionless financial services.