Flash Loans | Make profit in almost 14 secs - if you are smart enough. People have already started doing it.
Tags: blockchain, ethereum, smartcontracts
Published: 2020-02-23 07:00:38


_Assumption_:
Another one of my quick notes => I assume that you (the reader) understands Blockchain [Ethereum specifically], smart contracts and _DeFi_ (aka decentralised finance).  If not, this will be tough to follow and hence, advisable to dig about these first and come back over here.

### DeFi - in one sentence (almost): 
Traditional financial system of (a) lending, (b) borrowing, (c) doing something with the borrowed money, (d) repaying loans - but only by and for __blockchain assets__, through __smart contracts__.

## What is a Flash Loan?

A loan (yes, like a very traditional loan) that is taken out and paid out in 1 blockchain transaction [typically in ~14 secs].

## Why Flash Loans?

From the lenders' point of view: almost safe (my bet is 100%), principal and interest is received back instantly (well, ~14 secs and interest income.

From the borrowers' point of view: Can borrow a very very high amount, as far as I know what I am doing, **no collateral required**, **no collateral required** (again!!!), instant.

## How does it work?

#### Blockchain Transaction: 

On the Ethereum blockchain, everything that happens is a transaction.  For eg:
- If Alice sends Bob an Ether (aka ETH) it is a transaction.  
- If I write a smart contract that will the ETH that I give it and transfer it to Alice and Bob in two equal halves, it is **a** transaction.  
- If a Smart Contract 
	- takes ETH, 
	- looks up the price of gold on the LSE, 
	- buys appropriate amount of Gold Tokens, 
	- holds it for 30 mins, 
	- relooks at the value of gold on LSE, 
	- sells the Gold Tokens, 
	- gives out the proceeds back to the user who deposited the ETH, 
	- after computing a brokerage and then transferring the brokerage to my account - 
it is also **a** transaction (1 Single transaction).

of the above three examples, the last two can be a single transaction or can be broken into multiple transactions; they do not have to be 1 single transaction - it is the manner in which the transaction is defined and designed in a Smart Contract.

#### Flash Loan Capable Smart Contracts (the core of this entire article / blog post)

So flash loan smart contracts are written up in a manner that anyone (literally anyone; Yes, any darn one!) can (for ease of understanding), submit a transaction which will require some amount to begin with (this is the loan / principal), do something, and pay back the loan (with some interest) at the end of the __single__ transaction.  

More simply put, flash loan is an algorithm {loan algo}, to which I will submit my algorithm {my algo}, which will check that units that the loan algo gives (LHS) _is equal to_ the units that it gets back and the end of the execution of my algo (RHS).

## Implications

Now that you have some skeleton understanding of what a flash loan is and how it works - let us think and see some use cases / implications:

_Eg Use Case_ You see a potential arbitrage opportunity 
- buy Stock A on local stock exchange in you local currency, 
- transfer stock to a global custodian
- exchange stock units for its Global Depository Receipt (aka GDR)
- sell GDR in a foreign market
- convert foreign currency to local currency
- make arbitrage gains due to exchange rate difference
All executed in a matter of seconds!

__could you do this in a traditional financial world?__  _Answer:_ (if you are like me, a common man and not a highly rich dude and not much of an infrastructure required to execute the above): NO, you cannot.

__could you do this on the Ethereum blockchain?__  _Answer:_ (if you can write a smart contract): Hell YA! You can!

__Any restrictions?__  _Answer:_ No
__Any KYC?__  _Answer:_ No
__Any limit on amount?__  _Answer:_ No (mostly)

__Conclusion__  _Answer:_ I can (you can)(anyone can) do transactions worth MILLIONS of USD!! make gains, faster than it would have take to load an average webpage.

Eg REAL WORLD transactions: 
Eg 1: [Transaction 1 - click me!](https://etherscan.io/tx/0x762881b07feb63c436dee38edd4ff1f7a74c33091e534af56c9f7d49b5ecac15)
Eg 2: ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bf5teo9f4hk5kx704t7m.jpeg)
Eg 3: ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6cgn4zshyvukln1plq5j.png)


I would like to know what your thoughts are on Flash Loans - are you 
![Aye or Nay](https://cdn.dribbble.com/users/7070/screenshots/3479734/aye-or-nay.jpg)

_My Opinion_: __WOW__, this is going to take the financial system to a whole new level!  I take this to be in the likes of the Apple iPhone to the mobile-phone universe: things will not be the same ever again!



> Written with [StackEdit](https://stackedit.io/).