# Flash Loans - What TradFi can't

- Canonical URL: https://justus.sh/blog/Flash_Loans_-_What_TradFi_can't
- Markdown URL: https://justus.sh/blog/Flash_Loans_-_What_TradFi_can't.md
- Source: https://raw.githubusercontent.com/jstEagle/Personal_Blog/main/posts/Flash%20Loans%20-%20What%20TradFi%20can't.md
- Author: jstEagle
- Date: 2025-08-23
- Tags: DeFi, Blockchain, Educational
- Description: Imagine having access to **millions** of dollars worth of liquidity for a few seconds. Make any trade. Do *anything* you want. Without having to put down **any** collateral.

That ...

---

Imagine having access to **millions** of dollars worth of liquidity for a few seconds. Make any trade. Do *anything* you want. Without having to put down **any** collateral.

That makes no sense right? How could that possibly work? Who would do such a thing? And why is this so exciting for DeFi as a whole?

______
### From the beginning
Loans or the act of lending something for something else is as old as civilisation. The first recorded loans we can trace occurred in ancient Mesopotamia around 4 thousand years ago.

>In early Sumerian and Babylonian city-states, farmers often needed seeds or food to get through until the next harvest. Wealthy landowners or temple authorities would lend them **measured amounts of barley** or silver, recorded on clay tablets in cuneiform. These tablets included the amount borrowed, the due date (often tied to harvest season), and the interest rate—sometimes as high as **20% for silver** and **33% for grain**. - GPT5 (with some double checking on google)

Since then we have begun lending more and more. From mortgages to financing on cars. Even more recently the duration of these loans has gotten shorter and shorter. With services like Klarna or After Pay allowing users to turn almost any transaction into a loan which can then be paid off in small instalments over some time (usually a few weeks).

### DeFi Loans
For blockchain and more specifically, DeFi protocols, loans have been a difficult system to implement. Of course, there are many places where you can take loans. [Kamino](https://app.kamino.finance/lending), [Rain.fi](https://rain.fi/) and more recently [Jupiter](https://jup.ag/lend/borrow) allow you to borrow a variety of tokens or NFTs with one catch. You have to overcollateralize (definition: Overcollateralized means you must deposit more value as collateral than the amount you borrow (e.g., lock 150 USDC to borrow 100 USDC worth of SOL).) your loan.

This makes it ineffective as a means to leverage your current capital. Or in other terms, these loans don't allow you to buy more than you can currently spend. Instead they are used to earn yield generated by the interest on these lending pools or access liquidity without reducing exposure to the underlying asset. i.e. borrowing USDC against SOL to to have USDC to spend while still being exposed to SOL as you will get it back when the USDC loan is repaid.

### What are Flash Loans
Now that we understand what loans are and how general DeFi loans work we can talk about flash loans. 

>A flash loan consists of 2 instructions. Borrow and Repay with interest. When these instructions are packed into the same transaction and all instructions are valid. Then the transaction has the effect of borrowing some amount of capital without depositing any collateral.

Don't worry, I'll now explain the concept in *human* words (and with some pretty pictures).
First, transactions on multipurpose blockchains like Solana or Ethereum aren't just sending tokens from A to B, but are a set of instructions to execute. These instructions have to follow certain rules. Like respecting ownership and authority over accounts (definition: Accounts are the building blocks of Solana. They can represent a lot of different things, but for the most part are out of scope of this article). Instructions are calls to programs with some inputs. For example, to send a token from one wallet to another, a transaction is created with an instruction to invoke the `TransferChecked` instruction provided by the **Token Program** as shown in the picture bellow.

![](Pasted%20image%2020250821190328.png)

Lending protocols like [Marginfi](https://app.marginfi.com/) or [Kamino](https://app.kamino.finance/earn/lend) have on-chain programs that expose instructions like `Borrow` and `Repay` that allow the creation of transactions to start or repay loans. If they allow for it, transactions can be created that contain a `Borrow` instruction followed by some other instructions to trade something or swap something followed by a `Repay` instruction to repay the borrowed amount with interest. If the amount borrowed is available in the pool and the amount repaid is the borrowed amount plus interest then the transaction is executed and a flash loan is performed.

![](TransactionDiagram1.svg)

This works because every transaction is **simulated before being committed** to the chain. The node processing the transaction verifies that the repayment amount is correct and that all instructions are valid. This is called **atomic execution** - either everything succeeds, or nothing happens.

In practice, this means a user—let’s call him Ray—can borrow an amount $X$ and use it freely within a single block, as long as by the end of that block he repays $X + Y$, where $Y$ is the interest. If he fails to do so, the transaction is invalid and nothing changes on-chain. The key point is that **history is only written once a transaction is successfully committed and the block is finalized**.

____

### Why should anyone care?
"Free" money is pretty neat. And while it does make for a *great* present. The charm quickly fades when you only get access to it for less than a second. Funnily enough, traders tend to be less fussy as long as they come out the end a tiny bit richer.

In todays DeFi space, arbitrage trading has become very competitive. Fancy algorithms, thousand-dollar-per-month RPC node subscriptions and incredibly high priority fees (definition: A priority fee is an optional extra fee that a user can include in their transaction to increase their transactions priority. i.e. get their transaction executed faster.). All to make fractions of percentages most of the time. Picking up pennies can be very lucrative if you do it 100 million times over, but its rather tiresome. Instead **flash loans** can be used to increase profits as 0.1% on one million USDC is more than 0.1% on one thousand USDC. Flash loans are also popular with MEV bots (definition: MEV stands for Maximal Extractable Value. These arbitrage bots are often malicious and use high speed and high fees to front-run large trades to make profit.) and almost any kind of bot that operates on very small time-frames and benefits from more liquidity.

They can also be used to leverage assets and have other side effects. A good example of this is Kamino's [multiply](https://app.kamino.finance/multiply). But their [docs](https://docs.kamino.finance/products/multiply) do a way better job of explaining it than I ever could, so I recommend to read about it there.

### My Fascination
In the end, this article is not supposed to be a technical breakdown of how to use flash loans. Or how to implement them. Or even to create awareness about them. Flash loans are one of the few **new** and **cutting edge** concepts and financial tools made available and created through the nature of how blockchains work. Something traditional finance can't do.

Allowing **anyone** to borrow something without collateral, completely trustless, while maintaining security and protecting the lender is something that couldn't have been conceived of before the adoption of blockchain technology.  And that is f\*\*\*\*ing exciting. As this technology progresses, what other uses will be enabled? What new concepts will be discovered?

When math, machines and money melt together; some really interesting things can come of it. And I think we should all be looking forward to what could come next.
