# Freezing Time with Flashloans **Published by:** [0xDanki ( Tin Erispe )](https://paragraph.com/@tinerispe/) **Published on:** 2023-04-13 **URL:** https://paragraph.com/@tinerispe/freezing-time-with-flashloans ## Content Let’s say I walk into a bank and ask them to lend me $500,000 with the promise of giving it back before it’s the next person’s turn to the counter. Now, I don’t look like your typical Wallstreet guy. As a matter of fact, imagine me wearing donkey ears. At best, they’ll think I’m a lunatic and politely usher me out of the building. At worst, they’ll think I’m robbing the bank, hit the red hot alarm, and send the donkey straight to jail. That’s just how centralized authorities work. They make sure that you’re credible and have the capacity to deliver your promises before doing business with you. You can’t blame them because that’s how they make sure that their system remains sustainable and profitable. And if you’re a stinkin’ 4ft tall equine with a few coins in your purse then sorry but you’re outta luck. But DeFi enables checking without needing anyone’s judgement. If everything is programmed correctly then you’d be able to borrow from a lending protocol if proven that you will pay it back. You can even borrow all of the liquid assets in their pool if you wish to do so… no checks and no collateral needed. How awesome is dat?So protocols give away free money just like that?Hekkin yes. But before you plot some evil plans, you cannot get away without paying them back either. You see, the condition before a Flashloan could happen is that you should also be programmed to give back the money in the same transaction that you borrowed it. If you’ve programmed it in a way that you cannot repay what was borrowed, then the loan will simply not happen. The beautiful thing about the blockchain is that transactions happen one-at-a-time. When it’s your turn to transact, then the state of the blockchain freezes and there won’t be anyone else who can alter it until your transaction is completed. This is a gross oversimplification, but think of your “borrow and repay” transaction as one row in a ledger. So, if time freezes while it’s your turn, you reallly have to pay your Flashloan back before you could make another transaction, like withdrawing from your wallet.Wait, but doesn’t that make a Flashloan useless?Not really. You see, every single Flashloan robot (we call them Flashbots) is programmed to transact in this structure:Receive the moneyDo something with the moneyPay it backThe opportunity lies in the middle part of the transaction. There are various reasons why you would want to take a Flashloan while proving to the network that what you’ll do with the money is profitable with 100% certainty (remember that the state of the chain is frozen while you transact, so the network can check). Without going into much detail here are some of them:Arbitrage When exchanges have different rates for the same pair then you can buy low in one protocol and sell it at a higher rate in the other.Collateral Swaps When you have to close a loan to change your collateral, you can use the borrowed money to close the loan and reopen it with a different asset as collateral.Liquidations You can also get rewards from lending protocols by helping them liquidate undercollateralized loans.Some nefarious bizniz Hackers sometimes use the borrowed money to manipulate price oracles (we’ll talk about oracles in the future), making the protocols that depend on them vulnerable to an attack.Would you take the loan?Flashloans are quite a fascination when the Danki first learned about them. There are also a lot of indirect implications for DeFi users. For example, there was this one time when the gas prices were so high because arbitrageurs went into a bidding war to fill in arb opportunities. But on the bright side, they also make exchanges more liquid. It’s a mix of positives and negatives. In future posts, I might wanna talk about the other characters in this dark, dark abyss, like Flashbot’s twin brother, the MEV bot. But for now I’m content with telling ya about Flashloans.Anyway I’m giving out a free-to-mint nft for my first few fellow travellers. Here it iz mah frens: https://opensea.io/assets/ethereum/0x7674b264817b17BBCf6D983ee39391D4C851ED62/0 ## Publication Information - [0xDanki ( Tin Erispe )](https://paragraph.com/@tinerispe/): Publication homepage - [All Posts](https://paragraph.com/@tinerispe/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@tinerispe): Subscribe to updates