What are Flashloans?
A Flashloan is a type of loan in DeFi where you are not required to lock up any security or collateral, i.e. it is an unsecured loan. The catch is that the loan has to be borrowed and also repaid within the same transaction (i.e. within a single block).
At first, the utility of a loan where the borrowed money has to be returned within a few moments might seem bleak. But this assumption is overturned by the fact that the Ethereum blockchain (and others like it) are programmable, i.e. one can code instructions in a smart contract which takes advantage of the loan within a single transaction. And this is exactly what occurs.
Flashloans are extremely powerful as they offer leverage for any type of transaction that can be executed on the blockchain. The most common use is to engage in arbitrage. Arbitrage consists of taking advantage of the price difference for an asset between two exchanges. It is possible to closely watch an asset’s prices across a market, buy it at one exchange and then immediately sell it at another exchange where the price is slightly higher. Arbitrage is a staple of any economy where markets exist.
The typical process in which a flashloan is executed is: borrow flashloan, buy asset at a low price, sell asset at higher price, return loan and pocket the arbitrage profit. While this is a very simple model, the actions that occur between opening and close and the flashloan can get extremely complex. The protocol offering the loan, while not requiring any collateral (i.e. security), is kept safe by the fact that the entire process is executed in one transaction. Which means, if the programmed actions fail at any point, then the entire process is reversed and no transaction gets executed. As far as the blockchain is concerned, the loan amount never leaves the protocol, regardless of the success of the flashloan, as the funds are returned in the same transaction.
Flashloans were popularised by the Aave protocol, and are fairly complex to be put to use. Nonetheless, there are now various graphical interfaces which allow one to make use of flashloans without coding.