Ethereum vs Terra Flash Loans

It is standard for DeFi platforms to offer loans with too much collateral, with borrowers putting more in assets than they take out. Some DeFi platforms (such as AAVE) support a newer type of loan called the flash loan. When a borrower takes out a flash loan, no collateral is required. This is possible because flash loans are repaid within the same transaction in which they were taken out – a smart contract is used to quickly execute a series of transactions that lead to the borrower eventually paying back the loan.

Flash loans are atomic, meaning they will only be processed once all included transactions have been executed. If not, they will be rolled back. This allows individuals to borrow huge amounts with almost no risk. It is common for borrowers to withdraw tens of thousands, millions, or even tens of millions of dollars at once, albeit for a short period of time.

What are flash loans used for?

Flash loans have three primary uses: trade arbitrage, collateral exchange, and self-liquidation. Here’s an explanation of each:

Trading arbitrage: Different exchanges may charge different prices for certain assets, creating opportunities to buy and sell the same assets on different exchanges for a profit. This process is called “trade arbitration”. While it can be done manually, it usually doesn’t yield much of a profit as the prices of these assets usually differ by only a small amount. Flash loans can be used to automatically execute large arbitrage orders, quickly making much larger profits.

Swapping Collateral: Changing the basic collateral used in DeFi loans can be frustrating and time consuming, especially for those diversifying their collateralized assets. Flash loans can be used to quickly pay off loans to free up locked-down assets and then exchange those assets for others.

Self-liquidation: If the basic collateral of a traditional DeFi loan falls too much in value, it will be liquidated. This means that collateralized assets are sold at a discount to repay the loan, incurring a loss to the borrower. Flash loans can be used to self-liquidate, repay the loan in full and borrow the collateralized assets without a loss.

What are the real risks of flash loans?

Because flash loans are atomic, they are risk-reducing. However, they are not entirely without risk. Flash loans incur network costs whether they succeed or not. This exposes borrowers to front-running, where other parties execute identical flash loans at higher network rates. Front-run flash loans are processed first, often requiring the original borrowers only to pay network fees.

Most of the flash loan platforms use the Ethereum network as it was the first major DeFi support network to be massively used. With Ethereum gas costs so high, front running has become a major problem for those seeking flash loans.

Using Ethereum for flash loans poses another serious risk. Ethereum smart contracts are vulnerable to reentrancy attacks, where hackers take all the money stored in a smart contract. This is done using an external smart contract that withdraws several times before confirming the withdrawn balance.

Ethereum smart contracts are particularly vulnerable to reentrancy attacks due to Ethereum’s Solidity programming language. Technical jargon aside, Ethereum smart contracts are only safe if they are encrypted in a very specific way. Small mistakes can make them very vulnerable. Actually, a single misarranged line of code allowed hackers to steal USD 60 million worth of Ether in the infamous “The DAO” hack.

Avoid risks for flash loans?

If a re-entry vulnerability is found in the smart contracts of popular Ethereum-based DeFi platforms, flash borrowers could lose millions. Needless to say, many are looking for DeFi solutions outside of the Ethereum network. An alternative that has been gaining popularity lately is: white whalethe first cryptocurrency project to offer UST arbitration for flash loans within the Terra ecosystem.

Flash loans on Terra are much safer than flash loans on Ethereum. This is because Terra was built using Cosmos, which powers several other popular projects such as Binance Chain. Cosmos smart contract engine (KosmWasm) doesn’t allow calls to external smart contracts, and Terra’s smart contract language is much more forgiving than Ethereum’s. This makes White Whale’s arbitration system immune to re-entry attacks.

As for front running, it’s an inescapable risk. The best course of action is to reduce the chance and the damage it causes. Most front-running attacks are carried out on the Ethereum network by bots, which take advantage of Ethereum’s high and volatile gas prices. Switching to a network with lower and more stable network rates can significantly reduce the risk of front run.

White Whale offers a sleek and easy web application interface that makes arbitration accessible to everyone.

Leave a Comment