{"id":"ERC-3156","name":"Flash Loans","status":"Final","chain":"both","category":{"id":"defi","name":"DeFi Patterns","description":"Vaults, bonds, and financial primitives"},"journeyStages":[{"id":"executing","name":"Executing Transactions","description":"Performing on-chain actions"}],"uxImpact":"Users (typically developers/arbitrageurs) borrow tokens with zero collateral, use them within a single transaction, then repay with fee — enabling complex DeFi strategies. Design implications: show maxFlashLoan available per token, display flashFee upfront, this is primarily a developer/power-user feature — most retail UIs won't expose it directly, but aggregators might use it under the hood. Design decisions: whether to expose flash loan functionality in consumer UI at all, how to explain the atomic single-transaction constraint, whether to show protocol's flash loan usage in transaction breakdowns.","hasDetailedContent":true,"content":{"id":"ERC-3156","summary":"ERC-3156 standardizes flash loans - borrowing millions in crypto with zero collateral, using it, and repaying all in one transaction. If you don't repay, the entire transaction reverts. This enables one-click arbitrage, collateral swaps, and self-liquidation protection.","applicability":{"whenToUse":["Your product addresses: arbitrage requires upfront capital.","Your product addresses: each protocol has different flash loan interfaces.","The flow should deliver: borrow $100K, arbitrage, repay + fee, keep profit. Zero capital needed.","You are designing a one-click collateral swap experience with visible states and recovery paths."],"whenToAvoid":["Emphasize: \"If any step fails, entire transaction reverts. Your funds are safe.\".","Disable execute button if net profit is negative.","Explain: \"Borrow → use → repay all in one transaction. If it fails, nothing happens.\".","No token balances, swaps, lending, or yield flows appear in the product."]},"designerTakeaways":["You can design UI that delivers borrow $100K.","You can standard interface works across all ERC-3156 lenders.","You can design UI that delivers flash loan to swap collateral atomically in one transaction."],"problemsSolved":[{"problem":"Arbitrage requires upfront capital","oldWay":"Need $100K to capture $100K arbitrage opportunity","newWay":"Borrow $100K, arbitrage, repay + fee, keep profit. Zero capital needed.","impact":"critical"},{"problem":"Each protocol has different flash loan interfaces","oldWay":"Aave, dYdX, Uniswap all have different flash loan APIs","newWay":"Standard interface works across all ERC-3156 lenders","impact":"high"},{"problem":"Swapping collateral requires complex multi-step process","oldWay":"Withdraw collateral → sell → buy new → redeposit (risky)","newWay":"Flash loan to swap collateral atomically in one transaction","impact":"high"},{"problem":"Self-liquidation is expensive and slow","oldWay":"Find capital to repay debt before liquidation hits","newWay":"Flash loan to repay, withdraw collateral, sell enough, repay flash loan","impact":"high"},{"problem":"Building flash loan integrations is complex","oldWay":"Custom code for each lending protocol","newWay":"Standard receiver callback simplifies integration","impact":"medium"}],"uxPatterns":[{"name":"One-Click Collateral Swap","description":"Change your collateral type without closing position","mockup":"concept/one-click-swap","userFlow":["User views current position","Selects new collateral type","Clicks \"Swap Collateral\"","Behind scenes: flash loan repays debt, withdraw ETH, swap to wstETH, redeposit, reborrow, repay flash loan","All happens in one transaction","User sees new collateral, same debt"]},{"name":"Self-Liquidation Protection","description":"Close position before liquidators take penalty","mockup":"generic/vault-position","userFlow":["User alerted to low health factor","Sees comparison: external liquidation vs self-liquidation","Clicks \"Self-Liquidate\"","Flash loan: borrow USDC → repay debt → withdraw collateral → sell enough for flash loan + fee → repay flash loan","User receives remaining collateral minus small fee","Avoided 10% liquidation penalty"]},{"name":"Leverage Adjustment","description":"Increase or decrease leverage in one click","mockup":"concept/one-click-swap","userFlow":["User views current leverage","Adjusts slider to desired leverage","UI shows position change preview","User confirms","Flash loan executes complex rebalance","Position updated in one transaction"]},{"name":"Arbitrage Opportunity","description":"Capture price differences across DEXs","mockup":"concept/one-click-swap","userFlow":["System detects price difference","Shows opportunity to user","User reviews profit/fee breakdown","Clicks Execute","Flash loan: borrow → buy low → sell high → repay + keep profit","Profit deposited to user wallet"]}],"uiComponents":[{"name":"FlashLoanIndicator","description":"Shows operation uses flash loan","states":["using-flash-loan","direct-capital","hybrid"],"props":["lender","amount","fee","tooltip"]},{"name":"AtomicOperationPreview","description":"Shows all steps that happen in one transaction","states":["loading","ready","executing","complete"],"props":["steps[]","netResult","gasEstimate"]},{"name":"CollateralSwapForm","description":"Interface for collateral type changes","states":["editing","simulating","executing","success"],"props":["fromAsset","toAsset","position","onSwap"]},{"name":"LeverageAdjuster","description":"Slider for leverage changes","states":["idle","adjusting","confirming","applied"],"props":["currentLeverage","maxLeverage","onChange","healthFactor"]},{"name":"ProfitBreakdown","description":"Shows gross profit, fees, net result","states":["profitable","break-even","unprofitable"],"props":["grossProfit","flashLoanFee","gasCost","netProfit"]}],"antiPatterns":[{"pattern":"Not explaining what a flash loan is","why":"Users scared of \"borrowing millions\" language","instead":"Explain: \"Borrow → use → repay all in one transaction. If it fails, nothing happens.\"","severity":"high"},{"pattern":"Hiding the flash loan fee","why":"Users surprised by unexpected cost","instead":"Show fee prominently: \"Flash loan fee: 0.05% ($50)\"","severity":"high"},{"pattern":"Not showing all-or-nothing guarantee","why":"Users fear losing funds if something fails","instead":"Emphasize: \"If any step fails, entire transaction reverts. Your funds are safe.\"","severity":"critical"},{"pattern":"Complex multi-step explanations","why":"Users don't need to understand 7-step atomic operation","instead":"Show outcome: \"Swap collateral from ETH to wstETH\"","severity":"medium"},{"pattern":"Letting users execute unprofitable arbitrage","why":"Gas + fee exceeds profit = user loses money","instead":"Disable execute button if net profit is negative","severity":"critical"},{"pattern":"Not simulating the transaction first","why":"Flash loan txs are complex, may fail unexpectedly","instead":"Always simulate and show expected outcome before execution","severity":"high"}],"onMonad":[{"aspect":"Flash Loan Speed","ethereum":"Complex flash loan tx may timeout or hit gas limits","monad":"High throughput handles complex atomic operations easily","designImplication":"Can offer more complex flash loan strategies"},{"aspect":"Arbitrage Windows","ethereum":"Price differences last multiple blocks","monad":"Fast finality means opportunities close faster","designImplication":"Arbitrage UI needs faster execution, less time to decide"},{"aspect":"Flash Loan Economics","ethereum":"High gas can eat into flash loan profits","monad":"Lower gas makes smaller arbitrage profitable","designImplication":"Show smaller opportunities that would be unprofitable on Ethereum"},{"aspect":"MEV Considerations","ethereum":"Flash loan arbitrage often front-run by MEV bots","monad":"Local mempools may reduce front-running","designImplication":"Arbitrage success rate may be higher on Monad"}],"keyTakeaways":["Flash loans = borrow → use → repay in one transaction","Zero collateral, zero risk if it fails (atomic)","Always show the fee and net profit clearly","Simulate before executing to catch failures","Abstract complexity: show outcome, not the 7 steps"],"technicalNotes":"ERC-3156 defines flashLoan(receiver, token, amount, data) on lenders and onFlashLoan(initiator, token, amount, fee, data) callback on receivers. Receiver must approve lender to pull back amount + fee. If approval fails or callback reverts, entire transaction reverts. Standard fee is typically 0.05-0.09%."},"sources":[{"label":"Official specification","url":"https://eips.ethereum.org/EIPS/eip-3156","type":"official-spec"},{"label":"Discussion","url":"https://ethereum-magicians.org/search?q=ERC-3156","type":"discussion"}],"urls":{"canonical":"https://www.eipsfordesigners.com/standards/ERC-3156","markdown":"https://www.eipsfordesigners.com/standards/ERC-3156/content.md","agent":"https://www.eipsfordesigners.com/standards/ERC-3156/agent.md","api":"https://www.eipsfordesigners.com/api/standards/ERC-3156","official":"https://eips.ethereum.org/EIPS/eip-3156","discussion":"https://ethereum-magicians.org/search?q=ERC-3156"},"freshness":{"lastReviewed":"2026-04-05","lastUpdated":"2026-04-05"}}