Can you imagine being able to borrow a large amount of money and not have the obligation to leave any collateral? In Blockchain it is possible and they are called Flash Loans.
The Flash Loans are fast loans that platforms like AAVE and now it seems that they are going to implement it in Uniswap, they allow us to take out an unsecured loan with the obligation to return it in the same transaction if we want everything to be executed. In case of not being able to return the Flash Loan in the same transaction, all of the above is invalidated.
The operation is usually as follows:
- You apply for a Flash loan at AAVE from X ETH.
- You create a logic of exchanges between different DEX, purchases, sales, trying to make a profit. (This is where it really gets complicated.)
- You repay the loan.
If you manage to repay the loan, the transaction works and generates your profit.
If you cannot return it, all of the above is reverted, you do not lose anything you have ordered.
It is an easy way to play with liquidity without having it, and not risk anything. It is a highly debated formula within the Ethereum community but many worthwhile uses are being found.
We have created a mechanism to search for possible arbitrage options between the different DEXs and we are looking at how to automate it. We will see other use cases later.
Many of us have taken the step of getting to the bottom of the DeFI world thanks to the news in February where it was said that someone had hacked a decentralized protocol platform called bZx obtaining a profit in a single interaction of 1,193 ETH, which is what itself, about € 150,000. Four days later, the same or another attacker managed to extract from the same platform a balance of 2,378 ETH, approximately € 300,000. Was it really a hack? Not really, I just use the mechanisms available to me to find a point of failure in a very well thought out logic.
The steps were as follows:
- A Flash Loan of many thousands of Ethers is requested without any guarantee.
- You change those ethers looking for a combination between different DEX and markets to get profit.
- In this case, you manage to buy a lot of hit of an ERC20 that simulates a stablecoin and be able to raise its price.
- You exchange that currency at the exchange houses taking advantage of the crazy price and pay back the loan.
- All in a single transaction on the Ethereum network.
It is assumed that after the first attack the security problem was solved and in the second attack an oracle was manipulated, which we already know is a fundamental piece for a smart contract. The smart contract feeds on these oracles to obtain any price of any coin or information and act, so it is a clear point of possible failure.
To facilitate these atomic exchanges, called swaps, in the different DEXs, we have different ERC20s created for this called wrapped, such as wBTC or wETH … And each DEX has its peculiarities. The success of these exchanges is that they occur in the same transaction, giving the Flash Loan system even more meaning.
Among the use cases, there is the one that we are exploring of arbitration between different exchanges, being able to close different open CDPs that we see in danger of being liquidated or simply being able to change the collateral.
There is a platform that does the following using Flash Loans:
You have a CDP (we have seen that it is a contract in the guaranteed debt position Maker in the previous post) of 1000 DAIs and you have it collateralized, that is, guaranteed with $ 1500 in ETH.
Imagine that ETH suffers a brutal drop, there is a health indicator of the loan that if it falls below 1%, anyone can liquidate you, that is, appropriate your 50% of the CDP by paying your debt and obtaining a profit from the penalty that will be executed in this Maker case about your warranty (there are also platforms about this).
There are people who in the decline of a few weeks ago have liquidated contracts with values of hundreds of thousands of euros that they have not been able to save, they did not know this tool.
There are places where you automatically connect through your metamask, check if you have a CPD and use Flash Loans, to borrow what you owe, send it, close the CDP and, for example, change the collateral from ETH to USDT, that is to say, to stable currency. Or, you can simply close it and open another one giving more leeway before a penalty. The penalties are no joke, they can go up to 13%.
A very innovative tool (the possibility was launched a few months ago) that has created for many of us the need to explore this world of decentralized finance with all its possibilities.