Understanding EIP-3156 – Flash Loans Standard

1.0. Introduction to EIPs

1.1. Definition and Purpose

Ethereum Improvement Proposals (EIPs) are formalized proposals to enhance the Ethereum blockchain, covering protocol changes, standards, or processes.

1.2. Purpose: Standardize improvements, ensure community consensus, and drive Ethereum’s evolution through transparent, documented changes.

1.3. Types of EIPs

1.) Standards Track: Modify Ethereum’s protocol or standards (e.g., EIP-3156, EIP-1559).

2.) Informational: Provide guidelines or information (e.g., EIP-1).

3.) Meta: Address governance or EIP process changes (e.g., EIP-3675).

1.4. EIP Creation Process

1.) Proposal: Idea submitted to the EIP repository.

2.) Draft: Formalized with technical details, open for discussion.

3.) Review: Community and developers provide feedback.

4.) Last Call: Final review period before acceptance.

5.) Final: Approved and implemented (or rejected/withdrawn).

2.0. EIP-3156: Flash Loans Standard

2.1. Overview

Title: EIP-3156: Flash Loans Standard

Authors: Alberto Cuesta Cañada, Fiona Kobayashi, Fubuloubu, Austin Williams, Ernesto García, Aave Community

Status: Final (as per eips.ethereum.org, accessed July 15, 2025)

Type: Standards Track (ERC – Ethereum Request for Comment)

Proposed: July 2020, finalized post-review

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

2.2. Simple Summary

This ERC provides standard interfaces and processes for single-asset flash loans.

2.3. Flash Loans

A flash loan is a smart contract transaction in which a lender smart contract lends assets to a borrower smart contract with the condition that the assets are returned, plus an optional fee, before the end of the transaction. This ERC specifies interfaces for lenders to accept flash loan requests, and for borrowers to take temporary control of the transaction within the lender execution. The process for the safe execution of flash loans is also specified.

2.4. What EIP-3156 Improves

2.4.1. Related EIPs:

Builds on the concept of flash loans introduced by protocols like Aave but standardizes the interface, indirectly related to EIP-20 (ERC-20 Token Standard) as it involves token interactions.

2.4.2. What It Improves:

Prior to EIP-3156, flash loans (uncollateralized loans repaid in the same transaction) lacked a standardized interface, leading to inconsistent implementations across DeFi protocols (e.g., Aave, dYdX).

EIP-3156 provides a unified ERC standard for flash loans, ensuring compatibility and security across platforms.

2.5. Why It Was Proposed

2.5.1. Motivation:

Flash loans allow smart contracts to lend an amount of tokens without a requirement for collateral, with the condition that they must be returned within the same transaction.

Early adopters of the flash loan pattern have produced different interfaces and different use patterns.

Many protocols have existing flash loan implementations, those include dYdX flash loans, Aave flash loans and Uniswap flash loans. Unfortunately the interface is different for all these. This is not only bad for the user of such flash loans, having to learn how to use a flash loan in each ecosystem newly. But it's also bad for security when everyone is trying to design a secure mechanism on their own.

That's why we have standards. EIP-3156 is designed to support various different underlying mechanisms for repaying the loan.

2.5.2. Problem:

Flash loans, pioneered by Aave, allowed users to borrow assets without collateral if repaid within the same transaction. However, each protocol used proprietary interfaces, causing fragmentation and integration challenges.

2.5.3. Need:

A standardized interface to make flash loans interoperable, secure, and easier to integrate into DeFi applications.

2.5.4. Benefits:

1.) Simplifies development for DeFi protocols.

2.) Enhances security by defining a clear, auditable standard.

3.) Promotes adoption by enabling cross-protocol compatibility.

2.6. Technical Approach(How It Works)s

2.6.1. Interface

Defines a standard IERC3156FlashLender interface for flash loan providers and IERC3156FlashBorrower for borrowers.

2.7. Interfaces and Functions in EIP-31561.

2.7.1. IERC3156FlashLender Interface

This interface is implemented by the lender contract (e.g., a DeFi protocol like Aave or dYdX) that provides flash loans.

It defines three functions to facilitate loan initiation, fee calculation, and availability checks.

a. maxFlashLoan(address token) → uint256

  • Purpose: Returns the maximum amount of a specific token available for a flash loan.

  • Parameters: token (address): The address of the ERC-20 token to be borrowed (e.g., DAI, USDC).

  • Return Value: uint256 representing the maximum loanable amount of the specified token.

b.) flashFee(address token, uint256 amount) → uint256

  • Purpose: Returns the fee charged for borrowing a specific amount of a token via a flash loan.

  • Parameters:

    • token (address): The address of the ERC-20 token to be borrowed.

    • amount (uint256): The amount of the token to borrow.

  • Return Value: uint256 representing the fee (in the same token) for the loan.

c.) flashLoan(IERC3156FlashBorrower receiver, address token, uint256 amount, bytes calldata data) → bool

  • Purpose: Initiates a flash loan by lending the requested tokens to the borrower and executing their callback logic.

  • Parameters:

    • receiver (IERC3156FlashBorrower): The address of the borrower contract implementing the onFlashLoan function.

    • token (address): The address of the ERC-20 token to lend.

    • amount (uint256): The amount of the token to lend.

    • data (bytes): Arbitrary data passed to the borrower’s onFlashLoan function for custom logic.

  • Return Value: bool indicating success (true) or failure (false).

2.7.2. IERC3156FlashBorrower Interface

This interface is implemented by the borrower contract that receives and processes the flash loan.

It defines one function for handling the loan callback.

a.) onFlashLoan(address initiator, address token, uint256 amount, uint256 fee, bytes calldata data) → bytes32

  • Purpose: Executes the borrower’s custom logic after receiving a flash loan and confirms repayment.

  • Parameters:

    • initiator (address): The address that initiated the flash loan (typically the borrower or a proxy).

    • token (address): The address of the borrowed ERC-20 token.

    • amount (uint256): The amount of the token borrowed.

    • fee (uint256): The fee for the loan (in the same token).

    • data (bytes): Arbitrary data passed from the flashLoan call for custom logic.

  • Return Value: bytes32 representing the keccak256 hash of “ERC3156FlashBorrower.onFlashLoan” (0x6b7ac414). This confirms the borrower adheres to the standard.

Check out the standardized interface on :https://github.com/alcueca/ERC3156

2.7.3. Key Functions:

  • flashLoan: Initiates a flash loan, specifying the borrower, token, amount, and data.

  • flashFee: Returns the fee for a flash loan (can be zero or non-zero).

  • maxFlashLoan: Returns the maximum amount available for a flash loan of a specific token.

  • Callback Mechanism: The lender calls onFlashLoan on the borrower’s contract, allowing custom logic (e.g., arbitrage, liquidations) before repayment.

2.8. Key Requirements:

  • Loans must be repaid (with fees) within the same transaction, or the transaction reverts.

  • Supports ERC-20 tokens (or compatible tokens).

  • Ensures atomicity: Either the entire flash loan process completes, or it fails without state changes.

2.9. Security Considerations:

  • Prevents reentrancy attacks by enforcing single-transaction repayment.

  • Requires lenders to verify borrower contracts implement IERC3156FlashBorrower.

2.9.1. Technical Changes:

Unlike proprietary flash loan implementations (e.g., Aave’s custom contracts), EIP-3156 introduces a universal standard, making flash loans a reusable building block for DeFi.

2.9.2. Example flow:

  • Borrower calls flashLoan on a lender contract.

  • Lender transfers tokens and calls onFlashLoan on the borrower.

  • Borrower executes logic (e.g., arbitrage).

  • Borrower repays the loan + fee, or the transaction reverts.

3.0. Why and How EIP-3156 Solves the Problem

3.1. Why the Proposal Was Needed

  • Fragmentation: Before EIP-3156, protocols like Aave and Uniswap had their own flash loan implementations, making it hard for developers to integrate or build cross-protocol applications.

  • Security Risks: Non-standardized interfaces increased the risk of errors or vulnerabilities (e.g., improper repayment checks).

  • Adoption Barriers: Lack of a standard deterred developers from using flash loans due to complexity and compatibility issues.

3.2. How It Technically Solves the Problem

  • Standardized Interface: IERC3156FlashLender and IERC3156FlashBorrower provide a clear contract for flash loan interactions, reducing development overhead.

  • Interoperability: Any protocol implementing EIP-3156 can interact with other compliant protocols, enabling seamless integration (e.g., a dYdX lender working with an Aave borrower).

  • Security: Enforces atomic repayment and includes checks (e.g., verifying borrower contracts), reducing attack vectors.

  • Flexibility: Supports any ERC-20 token and allows variable fees, accommodating different protocol designs.

3.3. Use Cases

  • Arbitrage: Borrow funds to exploit price differences across exchanges, repaying in the same transaction.

  • Collateral Swaps: Swap collateral in a lending protocol without upfront capital.

  • Liquidations: Use flash loans to liquidate undercollateralized positions in DeFi protocols.

  • Exploitation of bugs: It's often used for hacks. If you find a bug in a smart contract, flash loans allow you to leverage the bug. Instead of just getting a few thousands dollars, you can end up with millions of profit. And then paying back the loan at the end will be an easy task.

3.4. Conclusion

3.4.1. Importance of EIP-3156:

  • Standardizes flash loans, a powerful DeFi tool, making them secure, interoperable, and developer-friendly.

3.4.2. Impact:

  • Enables broader adoption of flash loans, fostering innovation in DeFi (e.g., arbitrage bots, complex financial strategies).

3.4.3. Relation to Ethereum’s Evolution:

  • Builds on ERC-20 and earlier DeFi innovations, showcasing how EIPs iteratively improve Ethereum’s ecosystem.

3.5. References

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

EIP-1 (Purpose and Guidelines): https://eips.ethereum.org/EIPS/eip-1

EIP-20 (ERC-20 Token Standard): https://eips.ethereum.org/EIPS/eip-20

1
Subscribe to my newsletter

Read articles from Pelumi Emmanuel Fadeni directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Pelumi Emmanuel Fadeni
Pelumi Emmanuel Fadeni