FAQ

DeFi Development FAQ — 20 Questions on Building Production DeFi

Protocols — Economics modeling, flash loan resistance, liquidation cascades, collateralization ratios, and more — answered by engineers who have shipped production DeFi.

20 expert answersProduction-tested patternsSecurity-focused guidanceReal-world examples

Detailed answer

DeFi development requires specialized knowledge beyond general Solidity: economics modeling, MEV awareness, oracle design, and liquidation engine architecture. Minimum budget for a production DeFi protocol: $150,000–$400,000. Never use spot prices as oracles. Always design for flash loan resistance. Run bear market stress tests before launch.

Q1: What is the minimum budget for a production DeFi protocol?

Economics modeling + smart contracts + audit + front-end: $150,000–$400,000. Below this, you have cut either the economics modeling (most common fatal mistake) or the audit (most dangerous cut).

Q2: How do we prevent DeFi exploits?

Economics modeling before development. Comprehensive test suite (95%+ coverage, invariant tests). Automated analysis (Slither, Mythril). Independent external audit by a recognized DeFi-focused firm. Post-launch Tenderly monitoring and Immunefi bug bounty.

Q3: What is flash loan resistance?

Your protocol does not use spot prices from a liquidity pool as an oracle (because flash loans can manipulate spot price in a single block). Instead: Chainlink TWAP oracle for all collateral prices. Circuit breaker if oracle price moves >15% in 1 hour.

Q4: What is a liquidation cascade?

When collateral prices fall rapidly, many positions become undercollateralized simultaneously. The liquidation engine must process all positions before they go underwater. Defense: tiered liquidation bonus (increasing bonus as health factor drops further incentivizes faster liquidation), adequate collateralization ratio buffer (150% vs 110% gives 40 percentage points more time), oracle circuit breaker (pause new borrowing during extreme price movement).

Q5: What is the correct collateralization ratio for ETH collateral?

130–150% minimum collateralization ratio for ETH as collateral in a lending protocol. At 150% minimum CR: a 33% ETH price drop still leaves the position overcollateralized, giving the liquidation engine time to process.

Q6: How do we choose between a fixed and variable interest rate model?

Variable rate (tied to pool utilization) is the DeFi standard — it automatically incentivizes liquidity provision when borrowing demand is high and incentivizes borrowing when utilization is low. Fixed rate products (Notional Finance, Element Finance) serve a market for predictability but require more complex architecture.

Q7: What is the purpose of a TWAP oracle?

Time-Weighted Average Price — the average price over a defined period (e.g., 30 minutes). Resistant to flash loan manipulation because manipulating a TWAP requires holding the manipulated price for the entire TWAP window — expensive and capital-intensive, making attacks economically irrational.

Q8: What is a sandwich attack and how do we prevent it?

A front-running attack where a bot sees your pending transaction in the mempool, places a transaction before yours (to move the price), and one after (to profit from the price impact). Prevention: slippage tolerance limits on AMM swaps (revert if price impact exceeds user's tolerance). MEV protection: private mempool submission via Flashbots Protect.

Q9: Should our DeFi protocol be upgradeable?

During early stages (first 6–12 months): yes — ability to patch bugs justifies the upgrade mechanism's trust assumption. As TVL grows and community forms: move toward immutability or minimal upgrade paths. TimelockController (48+ hours) on all upgrades. On-chain governance vote required for any upgrade.

Q10: What is MEV and does it affect our protocol?

Maximal Extractable Value — value extracted by validators/searchers by reordering or inserting transactions within a block. Affects: AMMs (sandwich attacks), lending protocols (liquidation front-running), arbitrage across pools. Mitigation: slippage limits, commit-reveal schemes for sensitive operations, private transaction submission.

Ready to Build Your DeFi Protocol?

Let's build a production-grade DeFi protocol that survives market stress.