Flash loan
A flash loan is a temporary loan in crypto that must be repaid within the same transaction. If it isn’t, the entire transaction is reversed.
What is a flash loan?
A flash loan isn’t a regular loan that stays open for days or months. A smart contract temporarily borrows tokens, carries out predefined steps, and immediately repays the amount. Smart contracts are programs that automatically carry out agreements on a blockchain.
With a flash loan, the borrower doesn’t need to put up collateral in advance. However, there may be a fee for the loan. All the steps must succeed together. This is called atomic: either everything happens, or nothing does.
If repayment fails, the blockchain doesn’t process the transaction. So the borrower doesn’t end up with an outstanding debt. However, the sender may still pay gas fees for the computing work involved in the failed transaction.
An example of a flash loan
A smart contract sees that the same token is temporarily priced differently on two markets. It borrows tokens through a flash loan, sells them on the more expensive market, and buys them back on the cheaper market. This kind of exchange is called a swap.
The contract then repays the borrowed tokens and the fee. The transaction goes through only if every step succeeds and there are enough tokens left after all costs. This is an example of arbitrage: trying to profit from a price difference.
Why are flash loans important in crypto?
Flash loans make it possible to carry out several DeFi steps at once. DeFi refers to financial applications on a blockchain. Flash loans can, for example, help with arbitrage or with adjusting a collateralized loan position.
You’ll also see the term in reports about attacks on DeFi protocols. A flash loan doesn’t cause a flaw in a protocol. But someone can use it to temporarily access a large number of tokens and exploit an existing weakness more quickly and on a larger scale.
A flash loan isn’t an easy way to make money. The technology is complex, and costs, price changes during a swap, and limited available liquidity can make a transaction unprofitable.