The blockchain also plays a central role in the area of decentralised financial markets (DeFi). Decentralised financial transactions are hardly conceivable without blockchain technology, as it is precisely here that decentralisation can play out its maximum benefits. In the area of blockchains and cryptocurrencies, there are numerous instruments that further increase the economic benefits of the blockchain.
At the same time, DeFi benefits from this, as in this area new technologies can quickly represent a major advantage in the speed and effectiveness of transactions. Flash loans are one such tool that is becoming increasingly important in the use of blockchain. In this article, we show why this is so and how the technology works.
Flash loans bring credit to the blockchain
With flash loans, cryptocurrencies have also had the option of using credit since around 2018. Marble, the self-proclaimed “smart contract bank”, created these possibilities with the Marble protocol.
Marble is now no more, but the idea of Flash Loans has established itself in the market and some providers make them available. Flash loans are still in the early stages of development. However, billions are already being controlled by Flash Loans. It is worthwhile for every user in the crypto sector to think about the topic and to deal with flash loans.
In the meantime, Aave is one of the best-known platforms for flash loans with the Ethereum blockchain. The provider makes its DeFi protocol for flash loans available as open source. dYdX is also a well-known provider of this type of loan in the crypto sector.
However, flash loans work completely differently from conventional loans. Banks and other intermediaries play no role in flash loans, which are controlled by a smart contract on the Ethereum blockchain. In addition, borrowers basically do not have to deposit any collateral for flash loans. The process of a loan takes place in a few seconds. We explain why this is the case in this post. With flash loans, borrowers can borrow various cryptocurrencies, use them for their own transactions and return them to the lender.
Getting started with Flash Loans
The control of the individual actions in the use of flash loans is carried out via smart contracts, usually in the Ethereum blockchain. In the Ethereum blockchain, for example, loans worth over four billion dollars were granted in 2021 through Aave, a DeFi protocol for flash loans.
For this purpose, AAVE offers its own token with the same name, which can also be traded and stacked as normal. The smart contract used for this purpose collects cryptocurrencies from potential lenders in a pool. Borrowers can withdraw capital from this pool on the basis of the deposited conditions. The processes for this must take place within a single Ethereum block, and a smart contract controls all processes.
However, flash loans are not limited to Ether (ETH) due to the connection to Ethereum. On platforms like Aave, other cryptocurrencies can also be exchanged for tokens that are available for flash loans on the platform. These include, for example, DAI, Basic Attention Token (BAT), Chainlink (LINK), Synthetix (SNX), Bitcoin, Enjin Coin (ENJ), 0x (ZRX), Curve DAO Token (CRV).
In addition, stablecoins such as USD Coin, TrueUSD or Binance USD can also be used on Aave. This in turn enables crypto lending based on the US dollar. More currencies are to be added in the future. Ethereum, Ether and ERC20 tokens play an important role in the use of flash loans.
Flash Loans in brief
Simply put, from a financial perspective, flash loans are unsecured lending in decentralised finance (DeFi). Flash loans are already used extensively in Ethereum and Ether, where providers also offer the corresponding functions via smart contracts.
Flash loans use the functions of smart contracts, which are of course particularly popular on the Ethereum blockchain. Therefore, flash loans were already heavily focused on the Ethereum blockchain through the introduction of Marble.
In the process with a flash loan, the borrower takes out a loan, and pays it back in a few seconds, within an Ethereum block. This consists of several operations. We will show how this works and why it makes sense in the next sections.
These are the areas of application for flash loans
The loans are used, for example, for the quick and uncomplicated exchange of a cryptocurrency into another currency.
Flash loans are also interesting for arbitrage transactions, i.e. different prices on different crypto exchanges, as borrowers can use them to make profits. For example, borrowers can obtain tokens via a flash loan and buy a cryptocurrency on an exchange with a low price.
The same currency is then sold on an exchange with a higher price. The borrower then repays the flash loan and benefits from the profit. At the same time, this process stabilises the crypto market, as discrepancies in the prices of cryptocurrencies on different exchanges can be balanced out. These processes only take a few seconds. This is made possible by the smart contract, which handles all processes in the Ethereum blockchain in a fully automated and transparent way.
The process can also be useful for self-liquidation in the context of a flash loan when one’s own collateral falls. For example, if users have borrowed DAI for ETH and the value of ETH drops, it can make sense to borrow DAI via a flash loan, pay off the loan and receive their own ETH again.
This can significantly improve the security situation for crypto transactions. Repaying loans or collateral on other platforms can also be lucrative with cheap flash loans, as borrowers can also switch from expensive loans to cheaper loans.
What is the process for a flash loan?
The smart contract that controls the flash loan handles the operations in a single Ethereum block. This way, the borrower gets the capital immediately, and the lender gets it back very quickly, within one Ethereum block. If this does not work, the system declares the Ethereum block used invalid, and resets it. In this case, the capital reverts to the lender as if he never paid it out. All actions performed with the flash loan are completely reset by the blockchain in this case.
Flash loans offer numerous possibilities in the crypto sector, which offer many opportunities, but also dangers. In view of this, not all crypto experts are convinced that flash loans will have a positive impact on the crypto market in the long run. We also address the dangers of using flash loans in this article.
The advantages of loans are also obvious in the crypto sector. However, there are also significant disadvantages. Flash loans have already become a means to attack DeFi protocols and steal money. In the absence of intermediaries such as banks, there is no central element that can quickly intervene and retain the protocols in the event of criminal activity. The platforms are eliminating the vulnerabilities over time to make the technology even more secure.
Flash Loans versus Conventional Loans
Normally, borrowers have to deposit collateral, sign contracts and pay interest before taking out a loan. Such loans usually have a term of years or at least months. Approval also takes some time, and in many cases banks involve numerous people.
In the crypto sector, it naturally makes no sense if granting loans takes days or weeks. Of course, repayment must also be much faster. In addition, the technologies in the blockchain play an important role, especially smart contracts.
With flash loans, the granting and processing of loans is different. The general process of granting such a loan is completed in a few seconds. Loans (flash loans) can be granted and repaid quickly via individual transactions in the blockchain.
Flash loans are based on smart contracts, which are an important basis of the Ethereum blockchain. The automation of transactions and processes in the blockchain via smart contracts significantly accelerates the granting of loans. At the same time, borrowers quickly receive the capital they need and lenders do not require any collateral, as the smart contract protects the capital and automatically posts it back again.
Borrowers can use borrowed capital immediately via smart contracts
Borrowers can use the borrowed capital in seconds to carry out transactions. In most cases, this is also done by the smart contract, which also controls the granting of the loan. There are also fees for flash loans, but these are very low and are also based on the profit made with the loan.
The fees depend on the purpose of the loan and, using Aave as an example, are usually around 0.09% of the loan amount. Other platforms and protocols use a similar amount. The fee is mainly charged if the transaction, i.e. the flash loan, results in a profit for the borrower. An example of this is arbitrage trades between different crypto exchanges.
Aave splits the fees between the platform and the lenders. This approach is now one of the standards for processing flash loans. Those who grant loans can therefore definitely expect to pay interest.
Since the loan is controlled via a smart contract, the latter also retains control over the loan. Transactions can be processed back via conditions in the smart contract, so that the lender receives his borrowed capital back as soon as the respective conditions in the smart contract are fulfilled.
For this purpose, the Ethereum block used is defined as invalid. This also has the great advantage that, in theory, granting and drawing down a flash loan does not involve any risk for either party. However, in practice, it has turned out that there are certainly many starting points with which attackers can use flash loans for their criminal machinations. We will discuss this topic in more detail in the next sections.
Smart contracts control the transactions in the Ethereum block of the flash loan
In an Ethereum block, which is the basis for the flash loan, all operations must be valid for the entire block to be valid. If the borrower does not pay back the principal, the underlying smart contract defines the respective operation as invalid and thus the entire Ethereum block.
The Ethereum blocks consist of different transactions that the flash loan’s smart contract controls. If one transaction is invalid, then all transactions of the Ethereum block are invalid. In this case, the smart contract resets the block and all connected operations are no longer valid. In this case, the lender receives its capital back, just as it did when the flash loan was successfully settled.
Flash Loans at Aave
Aave is one of the most popular platforms and protocols when it comes to using flash loans in the Ethereum blockchain. The Aave wallet is necessary for granting credit and claiming a flash loan in Aave. This java-based wallet is very easy to link with traditional Ethereum wallets. By linking, lenders can transfer funds from their traditional wallet to the Aave wallet.
As part of the transfer, users bind the respective capital to a smart contract in the Ethereum blockchain. In the process, an exchange of the cryptocurrency used takes place, for example in aETH. This later controls the flash loans. The system automatically calculates the interest for the loans based on the available capital and the amount of loans that users take out.
In addition to using loans with flexible interest rates, borrowers can also take advantage of offers that provide a fixed interest rate. If the lender wants to exchange their chapter back into their original wallet and cryptocurrency used, Aave transfers the capital back into the original wallet and destroys the corresponding tokens at Aave.
What are the dangers of using flash loans?
Flash Loans were already the focus of hacker attacks in 2020. Hackers captured almost one million euros in Ether. The attackers used Flash Loans and a vulnerability in Fulcrum. Simply put, the hackers successfully manipulated prices. This allowed the criminals to make a profit after paying back the flash loan.
The vulnerability of flash loans is therefore primarily in recognising the correct prices of the cryptocurrencies used. By manipulating the prices, hackers could successfully carry out multiple attacks even after the platform detected the first attack. Many flash loans use stablecoins such as DAI and USDC. In the attack on Fulcrum, the attackers successfully manipulated the price of these stablecoins on the platforms they used.
In the attack on Chainswap, a project on the Binance smart chain, users also lost millions of dollars through flash loans. The attackers took over smart contracts of various projects and thereby stole Ether (ETH). Here, too, price feeds were the cause, which attackers were able to successfully exploit to influence the smart contract used.
Flash loans are a relatively new solution in blockchain technologies. The functions of flash loans enable numerous advantages for blockchains. Arbitrage trades make up for differences on cryptocurrency platforms more quickly, and the ability to switch loans offers users many opportunities to reduce costs. Flash loans are another tool at DeFi that can help to better process decentralised financial transactions.
However, as the technology is new and completely based on IT and the blockchain, it naturally offers a lot of potential for attack. For this reason, all stakeholders need to work on improving the technology. Through arbitrage trades, borrowers can generate profits in a short time. Of course, there is also a lot of potential to lose money. In any case, it makes sense for every user who deals with DeFi to also take a look at the possibilities of flash loans.