Monolith
Published in

Monolith

Understanding DeFi: flash loans explained

Decentralised finance on Ethereum has created a new monetary paradigm. Ethereum’s smart contract architecture has laid the grounds for a near-limitless open system, giving rise to groundbreaking innovations unlike anything that exists in the traditional finance world.

Among the most frequently discussed innovations in the space today are flash loans. In some ways flash loans are not unlike their more common predecessors found in the regular world: a user borrows funds under the proviso that they pay it back. Unlike a regular loan, though, there’s no limit to the amount the user can borrow, and it can be taken out instantly, as long as it’s paid back in the same transaction — at a flash speed.

This is made possible by smart contracts. They’re programmed to ensure that the loan is returned, otherwise the transaction gets blocked. The revolutionary part is how quickly it all happens, and the borrower only needs to shell out for a transaction fee to pay for the whole process. That means that they can potentially borrow huge sums of money at a marginal cost thanks to the power of the blockchain.

Loans in traditional finance

To understand more about flash loans, let’s explore how loans work in traditional finance. There are two common types of loan most people are used to: unsecured and secured.

An unsecured loan is one where the borrower doesn’t need to provide any collateral. While this can benefit the borrower, usually they are required to pay back interest on top of the loan.

A secured loan is a little different: the lender asks the borrower to provide a form of security in case they can’t pay back the loan. This case usually applies to bigger sums of money.

While conventional loans have been a bedrock of the traditional finance system, they aren’t always easy for people to get hold of. This is part of what could make loans in DeFi so disruptive.

Use cases for flash loans

Smart contracts ensure that flash loans are always paid back in the same transaction. Wondering how this benefits the borrower? Well, the composability of DeFi means that with careful planning, the loan can still be used to the borrower’s advantage and paid back before the transaction completes. That’s to say, there are ways of interacting with multiple smart contracts to use the loan and walk away with a profit. And because there’s no limit to the amount of funds the user can borrow, those profits can be incredibly lucrative.

Perhaps the most common method of using flash loans for profit is through arbitrage. This is a process that takes advantage of an asset’s price difference in two different markets. Imagine that the borrower finds Z tokens on DEX A listed for $1, and the price of Z is $1.10 on DEX B. They could use the loan to buy up the cheap tokens on DEX A, then sell them on DEX B at a profit. Once they’ve paid back the loan at the end of the transaction, they still get to keep the extra sum for themselves.

Another method of profit-making is through wash trading. This involves executing buys and sells of an asset in order to increase the trading volume. The procedure is forbidden in traditional markets. Using wash trading in DeFi, the borrower could take out a flash loan of Y tokens on DEX A, then execute two trades swapping Y for Z and back again on DEX B. This increases the trading volume for Y, creating an artificial level of interest and opportunity for profit.

Flash loan borrowers can also benefit from collateral swapping. This is a process in which a collateral position can be replaced with a borrowed asset even if the borrower is unable to return the funds. If the borrower is providing collateral to DEX A using token Y, but then they start to notice Y’s price dropping, they could take out a flash loan for Z and swap the collateral to avoid a liquidation.

Flash Loan with Aave: collateral swap of a MakerDAO Vault

Flash loan attacks

Flash loans were pioneered by the DeFi lending protocol Aave, and they’ve been a hot topic of debate since emerging in early 2020. The main reason for this is how they’ve come to be used to facilitate a number of large scale DeFi exploits.

Though flash loans are a nascent innovation, there have already been a number of large scale attacks. As flash loans don’t have a limit or require any collateral, it’s possible to borrow millions of dollars worth of ETH to turn over a significant profit.

A flash loan attack on the DeFi protocol Origin. The attacker borrowed 70,000 ETH from dYdX, then took advantage of a bug to inflate the supply of OUSD. They finally swapped the tokens for a $7 million profit.

Notable flash loan attacks have involved techniques such as manipulating a rebase system to take advantage of a token’s excess supply, using oracles to artificially inflate the price of tokens, and carrying out trades to reduce the number of tokens in a pool in order to make the price surge. Usually these attacks are complex, multi-step processes carried out by highly sophisticated DeFi users. In many cases, they’ve involved draining liquidity pools that regular users have invested in, leaving a lot of people facing substantial losses.

Conclusion

DeFi has opened up the possibilities for money as we know it. Flash loans are a powerful innovation that have surfaced in the space, thanks to Ethereum and the pioneering protocols built on top of it. Through the use of programmable money legos running on smart contracts, it’s now possible to take out loans and use DeFi to turn a near-instant profit in ways that never existed in traditional finance.

But it’s important to remember that DeFi is still in its infancy. The space is often described as the Wild West of finance, which isn’t an entirely unfair description: since coming to the fore in 2020, flash loans have been at least partly responsible for many large scale DeFi attacks.

Now that you understand the basics of flash loans, what do you think about them? Should we agree that code is law, or have they simply become a tool for causing more harm than good?

--

--

--

Monolith: everything you would expect from a bank, built for the DeFi economy.

Recommended from Medium

Moving to an era of Decentralized DNS registry

Audius Selects Solana to scale community-owned music streaming

[LCAC conference] Lambda demand side market and main network progress conference

From startup to international product

Blockchain In the Gaming Industry: Trends, Obstacles, and Potential

Due to the increasing hacks and exploitation in the DeFi world, we have made a FAQ questions that…

Triathon — Blockchain Evaluation for Everyone

Blockchain down the road

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Monolith

Monolith

Monolith is the world’s first DeFi wallet and accompanying Visa debit card made for spending crypto assets anywhere.

More from Medium

The Google Chrome browser has been updated to address a new zero-day security flaw | Curated…

IntoTheBlock Analytics now available in crypto news site AltcoinBuzz

Commonly Cited Blockchain Applications

Uniswap Explained in 60 Seconds