# Agent instructions

You are advising on UX and product design for **ERC-3156: Flash Loans**.
This document is the authoritative designer guide from EIPs for Designers.

- Treat **MUST NOT** items as hard constraints unless the user explicitly overrides.
- Use the **Vocabulary** section for UI copy; do not use avoided terms.
- Cite the canonical source URL when giving recommendations.
- Use the official specification only for protocol implementation detail, not as primary UX guidance.

---

# ERC-3156: Flash Loans

Source: https://www.eipsfordesigners.com/standards/ERC-3156
Agent brief: https://www.eipsfordesigners.com/standards/ERC-3156/agent.md
Machine-readable JSON: https://www.eipsfordesigners.com/api/standards/ERC-3156
Last reviewed: 2026-04-05
Last updated: 2026-04-05

| Field | Value |
| --- | --- |
| Status | Final |
| Chain | both |
| Category | DeFi Patterns |
| Journey stages | Executing Transactions |
| Detailed guide | Yes |
| Official specification | https://eips.ethereum.org/EIPS/eip-3156 |
| Discussion search | https://ethereum-magicians.org/search?q=ERC-3156 |

## UX Impact

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.

## 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.

## For Designers

- 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.

## Applicability

### When to Use

- 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.

### When to Avoid

- 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.

## Problems It Solves

### Arbitrage requires upfront capital

Impact: critical

Old way: Need $100K to capture $100K arbitrage opportunity

New way: Borrow $100K, arbitrage, repay + fee, keep profit. Zero capital needed.

### Each protocol has different flash loan interfaces

Impact: high

Old way: Aave, dYdX, Uniswap all have different flash loan APIs

New way: Standard interface works across all ERC-3156 lenders

### Swapping collateral requires complex multi-step process

Impact: high

Old way: Withdraw collateral → sell → buy new → redeposit (risky)

New way: Flash loan to swap collateral atomically in one transaction

### Self-liquidation is expensive and slow

Impact: high

Old way: Find capital to repay debt before liquidation hits

New way: Flash loan to repay, withdraw collateral, sell enough, repay flash loan

### Building flash loan integrations is complex

Impact: medium

Old way: Custom code for each lending protocol

New way: Standard receiver callback simplifies integration

## MUST NOT (Anti-Patterns)

- **Not showing all-or-nothing guarantee** (critical)
  - Why: Users fear losing funds if something fails
  - Instead: Emphasize: "If any step fails, entire transaction reverts. Your funds are safe."

- **Letting users execute unprofitable arbitrage** (critical)
  - Why: Gas + fee exceeds profit = user loses money
  - Instead: Disable execute button if net profit is negative

- **Not explaining what a flash loan is** (high)
  - Why: Users scared of "borrowing millions" language
  - Instead: Explain: "Borrow → use → repay all in one transaction. If it fails, nothing happens."

- **Hiding the flash loan fee** (high)
  - Why: Users surprised by unexpected cost
  - Instead: Show fee prominently: "Flash loan fee: 0.05% ($50)"

- **Not simulating the transaction first** (high)
  - Why: Flash loan txs are complex, may fail unexpectedly
  - Instead: Always simulate and show expected outcome before execution

- **Complex multi-step explanations** (medium)
  - Why: Users don't need to understand 7-step atomic operation
  - Instead: Show outcome: "Swap collateral from ETH to wstETH"

## UX Patterns

### One-Click Collateral Swap

Change your collateral type without closing position

User flow:

- 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

Mockup registry key: `concept/one-click-swap` (React UI on the live standard page).

### Self-Liquidation Protection

Close position before liquidators take penalty

User flow:

- 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

Mockup registry key: `generic/vault-position` (React UI on the live standard page).

### Leverage Adjustment

Increase or decrease leverage in one click

User flow:

- 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

Mockup registry key: `concept/one-click-swap` (React UI on the live standard page).

### Arbitrage Opportunity

Capture price differences across DEXs

User flow:

- 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

Mockup registry key: `concept/one-click-swap` (React UI on the live standard page).

## UI Components

### FlashLoanIndicator

Shows operation uses flash loan
States: using-flash-loan, direct-capital, hybrid
Props: lender, amount, fee, tooltip

### AtomicOperationPreview

Shows all steps that happen in one transaction
States: loading, ready, executing, complete
Props: steps[], netResult, gasEstimate

### CollateralSwapForm

Interface for collateral type changes
States: editing, simulating, executing, success
Props: fromAsset, toAsset, position, onSwap

### LeverageAdjuster

Slider for leverage changes
States: idle, adjusting, confirming, applied
Props: currentLeverage, maxLeverage, onChange, healthFactor

### ProfitBreakdown

Shows gross profit, fees, net result
States: profitable, break-even, unprofitable
Props: grossProfit, flashLoanFee, gasCost, netProfit

## On Monad

### Flash Loan Speed

Ethereum: Complex flash loan tx may timeout or hit gas limits

Monad: High throughput handles complex atomic operations easily

Design implication: Can offer more complex flash loan strategies

### Arbitrage Windows

Ethereum: Price differences last multiple blocks

Monad: Fast finality means opportunities close faster

Design implication: Arbitrage UI needs faster execution, less time to decide

### Flash Loan Economics

Ethereum: High gas can eat into flash loan profits

Monad: Lower gas makes smaller arbitrage profitable

Design implication: Show smaller opportunities that would be unprofitable on Ethereum

### MEV Considerations

Ethereum: Flash loan arbitrage often front-run by MEV bots

Monad: Local mempools may reduce front-running

Design implication: Arbitrage success rate may be higher on Monad

## Key Takeaways

- 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

## Technical Notes

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%.

## Official specification (reference only)

https://eips.ethereum.org/EIPS/eip-3156
