Understanding Flashloans

Istari Vision
9 min readJun 16, 2021



When looking to understand Flashloans we must first look at traditional loans, understand how these work, their limitations and then we can start looking at what Flashloans are and how they come to fill a missing gap in the lightning fast DeFi space.

In order to fully grasp the concept, we have to understand that Flashloans are an adaptation of an existing traditional product, but greater enhanced with the help of blockchain technology.

Loans in the traditional sense

We all know what loans are in the broad sense, borrowing money to acquire/fund things is not something very complex. But the underlying processes and conditions that make loans possible are often overlooked.

There are 3 main components behind the lending system we see today:

  1. Credit scores
  2. Collateral
  3. Interest rates

When we take out loans from an institution, like a bank, we often get our credit score checked, which means that the institutions checks our financial history in order to asses how good are we at managing our money and what will be an acceptable level of debt that we can pay back in monthly installments, without putting too much financial strain on us.

Now given an individual credit score, some institutions or even individuals, can ask for a certain collateral to be deposited before any loans are given. This means that a person has to deposit upfront an amount of money, that can be counted towards the repayment of the loan or can be given back when the loan is fully repaid. This is a safety feature that is used by the lenders to ensure that they aren’t fully exposed to the risk of giving out large sums and such borrowers, given their credit score, have to put a % of the total sum borrowed as guarantee for repayment.

Financing loans is not an easy endeavor and requires a large capital pool, meaning that the institutions or persons who are lending money, they themselves have that capital beforehand and most of the times they want to gain from lending such big sums. As such borrowers are subjected to interest rates which in essence are fees for the money they borrowed, as paying for the service that the lenders offer. These rates are usually regulated and they can’t fluctuate that much, but they do exist and will add to the total sum that needs to be repaid.

Limitation of traditional loans

Traditionally loans are mostly collateralized, meaning that there is always a requirement for locking in capital or assets upfront as collateral for the loan. This means that for a lot of people accessing loans to finance things is still a costly endeavor and when we factor the interest rate in, it becomes even greater.

Enter uncollateralized loans as a solution to the above deposit requirement and enable an easier access to capital. But this often comes at a great risk for the lender and in practice that risk is taken only when there is a big premium to gain from. Lenders that offer uncollateralized loans do so with hefty interest rates on top, which in the end put a similar strain on the borrower. The only instance where a lender agrees to offer this type of loan and not take a big premium is when the reputation of the borrower supersedes the risk, but these cases are rare.

When lending and borrowing was introduced into the blockchain world, it came with certain challenges. Given the decentralized and anonymous world of DeFi, people can’t be checked for credit scores, which increase the risk of the lenders. As such the burden of the credit score was transferred on the collateral side, meaning that most protocols require the borrowers to deposit over 100% of the loan value as collateral. This model is what kept lending protocols safe and financially healthy, but as we saw above it is a huge strain for the average user.


Flashloan example (Aave.com)

With the advent of smart contracts and lending protocols loans didn’t need to be intermediated by any middlemen, opening the avenue for additional use-cases and to a much larger user base as a alternative to the traditional banking sector.

As we have spoken about how loans work and how the staple overcollateralized loans work in DeFi, requiring huge amounts of capital upfront, we introduce the Flashloan concept that was created to address the problems with undercollateralized loan’s security and the overcollateralized loan’s high capital requirements.

Flashloans are a certain niche of undercollateralized loans that work by providing anyone the ability to borrow instantly and easily, with no collateral required, but with the condition that the loan is repaid within the same transaction block that it was taken on.

Now you might ask how are these loans useful if you need to repay them seconds later in the same block. As we can see in Flashloan example picture above, they are meant for developers to use, so that they can move large capital around efficiently, close any market discrepancies in the form of arbitrages or even a dark usage, exploit smart contract and economic vulnerabilities of various DeFi protocols.

Hacks due to Flashloans and protection against

Recent events have shown that Flashloans are a very powerful tool that can do both good and bad. There are a multitude of examples on how Flashloans have been used for various exploits to extract a lot of capital from multiple protocols. At the time of writing the DeFi industry has experienced almost $300 Million in assets lost due to Flashloan attacks.

One of the first Flashloans attacks that occurred was on Fulcrum (built on the bZx protocol) in which the attacker took an ETH flashloan on dYdX, splitting the sum by depositing on Compound and on Fulcrum.

  • On Fulcrum the attacker took a short position on ETH versus wrapped BTC (WBTC), which resulted in Fulcrum requiring to buy WBTC to cover the other side of the position. It did so by utilizing Kyber protocol to fill a WBTC buy order on Uniswap. But the attacker knew that Uniswap had low liquidity for WBTC, it’s price rose significantly, meaning that Fulcrum acquired the WBTC with a big premium.
  • On Compound, at the same time as the Fulcrum short position was taken, the attacker took a loan of WBTC using the rest of the ETH obtained from the dYdX flashloan. As the price pumped due to Fulcrum buying WTBC, the attacker sold the borrowed WBTC on Uniswap for ETH and made a hefty profit out of it, after repaying the ETH initially loaned from dYdX, pocketing the difference.

Not even the biggest and most respected protocols escaped such attacks that resulted from Flashloans, with Yearn, a popular DeFi aggregator suffering $11 Million in losses from an exploit of their smart contracts.

  • The attacker started with an ETH stablecoin Flashloan from dYdX and Aave, which was used to borrow DAI and USDC from Compound, which in turn was deposited into the Yearn V1 vault product. That product deposits users funds into Curve (Stablecoin AMM Exchange) on the “3pool” product that contained 3 stablecoins (DAI, USDT and USDC). The Yearn V1 vault was relying on the DAI price given by the “3pool” product and as such the attacker was able to exploit that weakness.
  • The attack goes as follows, depositing the borrowed DAI in the V1 Vault and USDT in the “3pool”, then withdrawing the DAI from the vault and the USDT from the “3pool”. This caused the prices of DAI and USDC to be lowered while the price of USDT to increase and as such allow the attacker to drain the Yearn V1 vault of funds.

How can we protect against Flashloans ?

That is one of the million dollar question of today’s DeFi industry and a very tough one to crack. Flashloans are in general not the main problem, as they are a big innovation in DeFi, because allowing users to borrow without collateral as long as the liquidity is restored to the pool under one transaction block unlocks a lot of interesting use-cases for otherwise small players to participate in the markets and make them more efficient. In addition, it also enables handy DeFi features like self-liquidation, arbitrage, collateral swapping, and many more.

The main issues here are in general with 3 big vulnerability factors:

  • Oracle manipulation
  • Smart Contract vulnerabilities
  • Economic misalignment

Oracles are the main tool used for blockchains to access data outside of the blockchain itself. It is hard to get accurate information such as price data in a secure and reliable manner, that is also decentralized and tamper proof.

Smart Contracts are complex tools, that are very hard to build and to structure in such a way that they are exploit proof. Most of Smart Contracts suffer from bugs or poor design choices that make them prone to attacks and which aren’t discovered until it is too late. Even with extensive auditing, the intricacies and dependencies of smart contracts are hard to test and cleaned of weak links.

Economic design is of absolute importance when considering how a protocol operates. Ensuring that all the key player’s incentives are aligned is paramount to creating a secure environment for the protocol. Failure to create a sound incentive structure may lead to exploits that drain the protocol of resources in an unforeseen way.

A protocol must consider tackling all these 3 factors to ensure the maximum level of security and thus protection against Flashloan exploits.

How can 3rd generation networks such as Elrond, protect users ?

In a way it is hard to gauge at an early stage as Flashloans prey on the weakest link and there will always be novel ways of using capital to manipulate various protocol features in order to gain from them.

But as we all know, prevention is something that can be undertaken early in order to ensure that the 3 big vulnerability factors are addressed already.

Elrond network already took a big step with the addition of Formal Verification within the Elrond smart contract environment. Elrond is working to improve their dev toolkit with a set of formal tools based on K Framework, which will enable developers to better write their code, immediately see and increase testing code coverage, and ultimately, add symbolic execution and even formally verify their Elrond Smart Contracts. This will establish better standards for security and reduce the occurrence of Smart Contract bugs.

Oracles available on Elrond through partnerships (https://elrond.com/assets/files/elrond-ecosystem.pdf)

Another big step that Elrond took is to partner with and make available as many oracles as possible, effectively reducing the possibility of oracle manipulation on the network’s protocols and dApps. Multiple oracle sources result in a distributed data fetching method and thous a more robust way of gathering non-blockchain information. This way developers can use oracles to check and verify the data feed from other oracles, essentially creating a safety net.

And last but not least, the economic incentives are thoroughly aligned on every aspect of the Elrond network, including the design of the EGLD and MEX tokens that reward the users for providing security and liquidity to the ecosystem. Although these are good steps, they don’t guarantee that future protocols and dApps built on Elrond network will all have sound designs, but with the expected development of the Maiar Launchpad, which will offer a lot of support from the Elrond team to the projects that are selected to be launched through it, we can be confident that better and more resilient economic designs for various protocols and dApps will emerge.


As we have seen Flashloans are not a tool that was created for destruction and exploiting, but it can also be immensely useful to close the gap on a certain niche sector that previously, in the traditional finance world, hasn’t been possible to achieve.

As such Flashloans can create positive value and offer a more fair access to market opportunities for all participants, but protocols and dApps in the DeFi sphere have to design their projects with Flashloans in mind and take into account all the factors and possible attack vectors that come with them.

We at Istari Vision are confident into the capability of the Elrond network team and developer community to overtake the current constrains and create a safer environment that is Flashloan exploit resistant.

For more information, please visit us:



Istari Vision

Trusted Staking-as-a-Service Provider