Problem Statement: DeFi Lending at Protocol Scale
Problem Statement: DeFi Lending at Protocol Scale — DeFi lending interview depth
Designing a DeFi Lending Protocol
This question is the sharpest reframe in the category, and stating it up front separates a strong candidate from one who will design the wrong system. Unlike the wallet (which signs transactions to someone else's contracts) or the exchange (a centralized server running a matching engine), here the protocol itself is immutable smart contracts deployed on-chain. An Aave/Compound-class money market is its Pool contract: that contract is simultaneously the matching engine, the ledger, and the settlement layer, all running on Ethereum where anyone can read it and no one — not even you — can patch it after deploy. Internalize that and the whole system design changes shape.
The on-chain core is a pooled money market. Suppliers deposit assets (ETH, USDC) into shared reserves and receive interest-bearing receipt tokens (Aave's aTokens, Compound's cTokens) that accrue yield. Borrowers post collateral and draw variable-rate debt against it, governed by a health factor — roughly HF = (collateral × liquidation_threshold) / debt — that must stay above 1. An algorithmic interest-rate model clears supply and demand by raising rates as utilization climbs. And permissionless liquidators repay the debt of any position whose HF falls below 1, seizing its collateral plus a bonus. All of that is contract code; the protocol holds the funds and enforces the rules trustlessly.
So if the protocol is on-chain, what do you actually design? The system is the off-chain support layer around contracts you cannot change: a subgraph/indexer that turns raw on-chain events into a queryable API for the frontend; the dApp frontend itself; keeper/liquidation bots that watch every position and call the contract the instant one goes underwater; price oracles (Chainlink) feeding the contracts the prices that drive health factors; resilient RPC infrastructure; monitoring of protocol health (TVL, utilization, bad debt); and governance (a multisig plus timelock, often with token voting) that is the only sanctioned way to change parameters or upgrade via proxy patterns. Scale anchors worth quoting: a major lending market runs on the order of $15B TVL and hundreds of thousands of daily on-chain transactions.
The reason this question is hard is the three constraints that have no analog in a normal backend. Immutability: a bug is not a hotfix, it is funds lost forever — which is why audits, formal verification, bug bounties, and timelocks are first-class design elements, not afterthoughts. Economic and oracle security: the attacks are financial — flash-loan-funded oracle manipulation, MEV-sandwiched liquidations, a stale price triggering wrongful liquidations during volatility. And composability: other protocols build on top of yours (money legos), so your contract is a public API that hostile and friendly code alike will call in ways you never anticipated. A strong answer also names the bad-debt plan — an insurance fund, reserve-factor accumulation, or socialized loss — because not all risk is eliminable on-chain.
Key Highlights
- •suppliers deposit ETH/USDC into pooled reserves and receive interest-bearing receipt tokens
- •borrowers draw variable-rate debt against collateral with health factor HF = collateral×LTV / debt
- •permissionless liquidators repay underwater debt and seize collateral plus liquidation bonus
Section Rescue Kit
Buzzwords to use:
Safe statements:
- "For Problem Statement: DeFi Lending at Protocol Scale, I'll state solvency invariants before naming cloud SKUs."
- "I'll walk supply → borrow → oracle shock → liquidation when stuck."