Flash Loan

How does a flash loan work?

Let's call a flash loan an unsecured loan, purely because you don't provide any collateral. But you also don't need to pass a credit check or anything like that. You simply ask the lender if you can borrow $50,000 in ETH, they say yep! Here you go! and you're off.

The catch? A flash loan must be repaid in the same transaction. That's not very intuitive at all, but that's only because we're used to a typical transaction format where funds move from one user to another. Like when you pay for goods or services, or deposit tokens into an exchange.

However, if you know a bit about Ethereum, you'll know that the platform is pretty flexible – that's why some call it programmable money. In the case of a flash loan, you can think of your transaction "program" as being made up of three parts: receive the loan, do something with the loan, repay the loan. And it all happens in a flash!

Let's just attribute it to the magic of blockchain technology. The transaction gets submitted to the network, temporarily lending you those funds. You can do some stuff in part two of the transaction. Do whatever you want, so long as the funds are back in time for part three. If they're not, the network rejects the transaction, meaning that the lender gets their funds back. Actually, as far as the blockchain is concerned, they always had the funds.

That explains why the lender doesn't require collateral from you. The contract to repay is enforced by code.

But what's the point?

At this stage, you're probably wondering why you'd take out a flash loan. If all of this occurs in a single transaction, you can't exactly purchase a Lambo, can you?

Well, that's not really the goal here. Let's focus on part two of the transaction described previously, where you do something with the loan. The idea is to feed the funds into a smart contract (or chain of contracts), flip a profit, and return the initial loan at the end of the transaction. As you can see, the point of flash loans is to profit.

There are a couple of use cases where this could come in handy. Evidently, you can't do any off-chain stuff in the meantime, but you can tap into DeFi protocols to make more money using your loan. The most popular applications are in arbitrage, where you take advantage of price disparities across different trading venues.

Suppose that a token trades for $10 at DEX A, but $10.50 at DEX B. Assuming zero fees, buying ten tokens on DEX A before reselling them on DEX B would yield a profit of $5. This kind of activity isn't going to buy you a private island anytime soon, but you can see how you could make some money by trading large volumes. If you purchased 10,000 tokens for $100,000 and successfully flipped them for $105,000, you’d be left with a profit of $5,000.

If you acquire a flash loan (via the Aave protocol, for instance), you can take advantage of arbitrage opportunities like this on decentralized exchanges. Here's an example of what that might look like:

  • Take out a $10,000 loan

  • Use the loan to buy tokens on DEX A

  • Resell the tokens on DEX B

  • Return the loan (plus any interest)

  • Keep the profit

All in one transaction! Realistically, though, the fees to transact, combined with high competition, interest rates, and slippage, make the margins for arbitrage razor-thin. You would need to find a way to game price differences to make the activity profitable. When you compete against thousands of other users trying to do the same, you won't have much luck.

Last updated