What is a flash loan?
Flash loans are a type of uncollateralized loan in the decentralized finance (DeFi) ecosystem, where assets are borrowed and returned within the same blockchain transaction.
They are facilitated by smart contracts and do not require upfront collateral, making them unique in the financial world.
Flash loans have various use cases, including arbitrage, liquidations, collateral swapping, and the creation of leveraged positions, but they also pose certain risks.
Understanding Flash Loans
Flash loans are a novel financial tool in the DeFi ecosystem. They allow users to borrow assets from an on-chain liquidity pool without any upfront collateral, provided the borrowed amount, plus a small fee, is returned to the pool within the same transaction. If the borrower fails to repay the loan within the same transaction, the entire transaction is reverted, including the initial borrow and any subsequent actions. This mechanism aims to increase access to resources for users across various use cases while maintaining the solvency of the underlying on-chain liquidity pool.
How Do Flash Loans Work?
In traditional collateralized lending, borrowers need to put up resources (collateral) to borrow funds. If the borrower fails to meet the loan terms, the lender can cover the loan using the borrower’s collateral. Flash loans, however, do not have this requirement; the loan can only exist if the borrower pays it back within the same transaction. This means defaulting on a flash loan is not possible, as the entire transaction would simply revert. For a short period—the span of a single transaction—a flash loan can provide anyone with substantial resources, creating unique opportunities for arbitrage, liquidations, collateral swapping, and the creation of leveraged positions.
What Are Flash Loans Used For?
Flash loans are commonly used for arbitrage, where a large amount of resources is used to fill a market inefficiency, such as differing exchange rates on different markets. This can generate a profit by bringing the market to equilibrium and improving liquidity for everyone in the DeFi market. Flash loans are also used for liquidations, where third-party liquidators may receive compensation for processing loan liquidations that fail to meet a certain collateralization ratio requirement. Other use cases include collateral swaps, creating leveraged positions, and transferring loans across protocols.
Flash Loans and Price Oracle Attacks
Flash loans have a controversial reputation as they can also be used to fund various types of attacks on DeFi protocols. Once a vulnerability is uncovered by a malicious actor, the attacker can manipulate certain functions of the protocol using a flash loan. This highlights the importance of understanding the risks associated with flash loans and the need for robust applications to be built for users.
Flash Loans vs Traditional Loans
Flash loans differ significantly from traditional loans. They are unsecured, meaning no collateral is needed. Instead, smart contracts on the blockchain enforce the loan. If the loan is not paid back immediately, the blockchain does not confirm the transaction, and the loan does not proceed. This is a stark contrast to traditional loans, which can last for decades and require collateral. Flash loans, on the other hand, require repayment within minutes, with a smart contract executing the loan and immediately settling it with a fee.