Design a DeFi protocol that provides trading, lending, and yield farming with transaction privacy using zero-knowledge proofs.
## ROLE You are a DeFi protocol designer who builds privacy-preserving financial applications. You understand AMM mechanics, lending protocols, and yield optimization — and how to implement them with ZK privacy guarantees. ## OBJECTIVE Design a privacy-preserving DeFi protocol on [BLOCKCHAIN] that supports [FEATURES: private swaps / private lending / private yield farming] while maintaining composability with the broader DeFi ecosystem. ## TASK ### Private Swap Protocol - Dark pool mechanism: order matching without revealing order details - ZK-AMM: automated market maker with encrypted reserves and trade amounts - Price discovery: maintain efficient pricing without revealing individual trade sizes - Slippage protection: users prove maximum slippage tolerance in ZK - MEV resistance: encrypted orders prevent sandwich attacks and front-running - Liquidity provision: add/remove liquidity without revealing position size ### Private Lending Protocol - Collateral privacy: deposit collateral without revealing amount or asset type - Borrow privacy: take loans without revealing terms or collateral ratio - Liquidation with privacy: trigger liquidations based on ZK-proven undercollateralization - Interest rate: computed on encrypted aggregate utilization - Credit delegation: private credit scores based on ZK-proven on-chain history - Flash loans: private flash loans for arbitrage without revealing strategy ### Private Yield Farming - Strategy privacy: deposit into yield strategies without revealing allocations - Reward claiming: claim rewards without linking to deposit address - Auto-compounding: automated reinvestment without revealing position size - Cross-protocol composability: private positions across multiple DeFi protocols - Performance tracking: users can verify their own returns without public exposure ### Compliance Integration - Selective disclosure: prove compliance without revealing transaction details - Audit keys: optional viewing keys for regulatory auditors - Sanctions screening: prove non-sanctioned status via ZK credential - Tax reporting: generate private tax reports for user's jurisdiction - Institutional access: compliance-compatible private trading for institutions ### Technical Architecture - Shielded pool: unified pool for all private DeFi operations - Note-based accounting: UTXO-style notes for private balances - Circuit library: reusable ZK circuits for common DeFi operations - Oracle integration: price feeds that maintain privacy (commit-reveal or ZK) - Governance: private voting on protocol parameters ### Risk Management - Solvency proofs: protocol proves solvency without revealing individual positions - Risk parameters: collateral factors, liquidation thresholds, interest rate curves - Insurance fund: privacy-preserving insurance pool for bad debt - Circuit bugs: formal verification of financial logic in ZK circuits - Economic attacks: analysis of privacy-specific attack vectors (information leakage through aggregate metrics) ## OUTPUT FORMAT DeFi protocol design document with financial mechanics, ZK circuit specifications, smart contract architecture, compliance framework, and risk analysis. ## CONSTRAINTS - Gas costs must be competitive with non-private alternatives (within 3x) - Proof generation under 10 seconds for swap transactions - Protocol must maintain price efficiency comparable to transparent AMMs - Include compliance pathway that doesn't compromise general user privacy - Design for upgradeability as ZK technology improves
Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[BLOCKCHAIN]