Section 8 of 18
Price Oracle
Key takeaway: Compound V2's
PriceOraclereturns USD prices scaled by 1e18, with an additional10^(18 - underlyingDecimals)factor for non-18-decimal tokens (USDC at 6 decimals gets a 1e12 multiplier on top). A return value of zero means "no confident price available" and blocks borrows and liquidations in that market. This fail-closed design is deliberate: the alternative is what killed Mango ($114M) and Cream ($130M) when they accepted manipulated spot prices.
What You Are Building
You are building the price oracle interface and a simple implementation. The oracle tells the Comptroller how much each asset is worth, which is essential for every risk calculation in the protocol. Without accurate prices, the entire collateral and borrowing system breaks down.
Oracle manipulation is the single most exploited attack vector in lending protocols. Mango Markets lost $117M to oracle manipulation. Cream Finance lost $130M. When you audit Compound forks, this is where you look first.
Your Code
Requirements
Sign up free — keep reading + earn 10 Lynx
Zealynx Academy is free. Track your progress, earn Lynx, and climb the leaderboard.
Sign up free to continueAlready have an account? Log in