Flash Loans on Anchor

Hello @atebites.

Flashloans security

Security concerns that I’m aware of are:

  1. For lender: make sure you can stop transaction from being completed if the borrower didn’t pay the loan and interest back.
  2. For borrower: make sure you make some profit from the loan, as it’s not free to access the funds.

In both cases the actor has to have a way to revert. Borrower would do that if they made less than repayment (loan + fee). Lender has to have a final say, as it would check their balances right before the transaction is confirmed on chain.

Risks

  1. Smart contracts can contain bugs, letting the attacker to borrow funds and never return them back. Or even access the lender’s vault directly and withdraw the funds.

What flashloans are

I recommend reading Sneak peak at Flash Loans that was published back in 2020 in Aave Blog.

There’s also a great video by Finematics that is suitable for anyone, even if they never heard of flash loans before.

How flash loans can help the Anchor Protocol

Low-risk stream of revenue

First and foremost, provide additional, low-risk stream of revenue.

The low risk comes from using CosmWasm technology in a way, that give the Lenders a right to revert a flash loan transaction. The funds transferred during a flash loan leave the Lender’s wallet for a brief moment, and are repaid back with all the interest before the transaction is completed.

In short, any idle pool of crypto assets can be still used to make profit in a safe way.

Risk management

Flash loans can serve as a great tool to provide liquidation protection (@bitn8 mentioned that). Let’s see what the options are.

Self-hedging

This is simply following the rule: only risk funds that you can afford to loose.

Let’s say a person has a debt on Anchor, and it turns out that it’s too large for them to feel comfortable. They would like to manage their risk levels by decreasing the size of the current Anchor debts.

The use case could well-served by risk management bots.

Liquidation protection

Let’s say market conditions are getting less and less favourable. It could lead to a cascade of debt liquidations. However, people could use a flash loan to close their near-liquidation positions. It would save them some funds that otherwise would be dedicated for an incentive to liquidators.

Arbitrage

Arbitrage is quite demanding task, but if anyone has a capability to notice inefficiencies between markets, they can move some liquidity from one market to another and keep the change.

Summary

Flash loans can be a low risk revenue stream for liquidity providers. They can also enable users of lending platforms to manage their personal risk levels. Arbitrage is another use case, especially interesting when it comes to accessing other markets via IBC protocol.

1 Like