Let's break down the concept of DeFi looping, also known as "flash loans" or "arbitrage loops," and why multiple borrows are often involved.
Understanding DeFi Looping
DeFi looping typically refers to strategies that involve borrowing, arbitraging, and repaying within a single transaction. The most common form of this is a flash loan. Here’s a step-by-step explanation:
- Borrow Funds: The user borrows a large amount of funds from a DeFi protocol without requiring any collateral. This loan must be repaid within the same transaction.
- Execute Arbitrage/Strategy: The borrowed funds are immediately used to execute an arbitrage opportunity or some other profitable strategy. This could involve trading across different decentralized exchanges (DEXs), providing liquidity, or exploiting price differences.
- Repay Loan: The profits generated from the strategy are used to repay the loan, along with any fees. If the strategy is unsuccessful, the transaction is reverted, and no funds are lost—except for the gas fees.
Why Multiple Borrows?
You asked why an investor can't just be granted the final amount in the first step with less collateralisation. Let's address this:
-
Collateralisation in Traditional Loans vs. Flash Loans
- Traditional Loans: When you borrow in traditional DeFi lending, you need to provide collateral. The amount you can borrow is determined by your collateral and the loan-to-value (LTV) ratio. For example, if the LTV is 50%, and you provide 10,000worthofcollateralyoucanborrow5,000.
- Flash Loans: Flash loans do not require collateral because they must be repaid within the same transaction. This is what allows for the borrowing of large sums without any initial collateral. Since the loan is repaid in the same transaction, there is no risk to the lender.
-
Single Transaction Requirement
- The defining feature of a flash loan is that it must be borrowed and repaid within the same transaction. This is what eliminates the need for collateral. If the loan were to be granted and repaid in multiple steps, it would no longer be a flash loan and would require collateral.
- Because the loan is repaid in the same transaction the risk to the lender is mitigated. If at any point the transaction fails the state is reverted and the loan does not need to be repaid.
-
Arbitrage and Strategy Execution
- The reason for borrowing a large amount is often to execute an arbitrage or market-making strategy that requires significant capital to be profitable. For example, to arbitrage price differences between two DEXs, you need enough capital to make the price impact negligible and ensure a profit.
- By borrowing a large amount the investor can execute a strategy that would otherwise be impossible due to capital constraints.
-
Profit Generation
- The borrowed funds are used to generate a profit, which is then used to repay the loan. If the strategy doesn't generate enough profit to cover the loan and fees, the transaction is reverted, and no funds are transferred—except for the gas fees paid by the user.
- Because the loan is repaid using the profits from the strategy there is no need for initial collateral.
-
Risk Management
- Since the loan must be repaid within the same transaction, there is no risk of default. This is why no collateral is required. If the user cannot repay the loan, the transaction is simply reverted, and the state remains unchanged.
- This also means that the user does not need to provide any initial collateral, as the risk is mitigated by the requirement to repay the loan in the same transaction.
Couldn't the Investor Just be Granted the Final Amount at the First Step?
If an investor were granted the final amount at the first step without the need to repay it immediately, it would no longer be a flash loan. Instead, it would be a traditional loan, which would require collateral.
- Traditional Loan: If you want to borrow a final amount and not repay it immediately you would need to provide collateral. The amount you can borrow would be limited by the LTV ratio and the value of your collateral.
- Risk to Lender: Without the single-transaction repayment requirement the lender would be exposed to risk. The borrower could default which is why collateral is required.
In summary, the multiple borrows and immediate repayment within a single transaction are what define and secure a flash loan. This structure eliminates the need for collateral and allows users to borrow large sums to execute profitable strategies. Without this immediate repayment requirement, the loan would need collateral, and the strategy would not be a flash loan.