White Whale Releases Details on Flash Loan Architecture

2021-11-30 13:45

Let’s break it down. Simply put, a flash loan is, as the name implies, a loan that is opened and closed in a very short amount of time. More specifically, it is opened and closed in the same transaction. Flash loans are used to execute atomic trades that either capitalize off of inefficiencies in the market or provide some other functionality to the borrower. Atomic trades are trades that can be finalized in one transaction and almost all on-chain arbitrage falls under this category. By now you hopefully realize how powerful this financial instrument can be. But with this power comes responsibility.

While White Whale is said to be the first to roll out flash loans on Terra (and the whole Cosmos!), a number of protocols already offer it on Ethereum. The sometimes bad connotation linked to flash loans is caused by a number of exploits that happened on Ethereum in which hackers used this tool to do so-called re-entrancy attacks.  Fortunately, CosmWasm (the smart contract language of Terra) is designed to avoid this kind of attack. When comparing CosmWasm to Ethereum’s smart contract language the developers state:

“A big difference is that we avoid all reentrancy attacks by design. This point deserves an article by itself, but in short, a large class of exploits in Ethereum is based on this trick .”

And,

“Cosmwasm avoids this completely by preventing any contract from calling another one directly.”

These precautions enable White Whale to provide this service without having to worry too much about other protocols being exploited.

To really understand how all this works, let’s look at, and briefly unpack the White Whale flagship vault. The UST vault allows users to deposit UST into the vault in a simple, single-step process. The total liquidity in the UST vault then acts as a general-purpose liquidity pool with a series of in-house arbitrage strategies. The first of which is all about keeping the peg. There are also other strategies in the works, such as exploiting price inefficiencies among multiple exchanges, as well as automated liquidations on Mars and Levana. All of these strategies make the ecosystem more stable and efficient, and they all use the liquidity of the UST vault.

These strategies bring us back to flash loans: when any of our bots detect a profitable arbitrage opportunity, the smart contract linked to that strategy will ask for a flash loan from the UST vault. The UST vault will then withdraw the UST from Anchor protocol (where it is yielding a comfy 19.5% while idle) and provide the contract with borrowed money to execute the arbitrage. After the arbitrage, all funds are returned to the vault. This is how we plan to provide Anchor+ yields.

A question that has been raised, is this – what if the trade didn’t make a profit? Or what if the borrower just doesn’t repay the loan? Various mechanisms have been put in place, to ensure depositors don’t get rugged. First, when a flash loan is requested, White Whale saves the total value of the vault. Then funds are sent out to the borrower (i.e. the arb bot) for them to execute the trade. What has been added is a callback at the end of the program which can not be altered, and is guaranteed to execute.

After whatever the borrower has executed the trade, that callback is executed. The callback is essentially step two. It re-calculates the value of the vault and compares it with the initial value before the loan. If this amount is smaller than the initial amount it throws an ERROR and reverts the whole transaction, aka the flash loan. The transaction then fails and it’s like nothing ever happened. Effectively this means that the flash loan will only execute if it pre-determines a profitable result, otherwise, it will cancel itself.

Long term, there will be a whitelisting process for the community to build bots to onboard through on-chain governance and utilize the White Whale flash loan architecture. The community will be able to decide which bots will benefit and secure the ecosystem and vote to whitelist them. There will of course be a small fee (the borrowing cost of the loan) which will automatically get distributed to the depositors.

In order to ensure security for this complex and innovative architecture, White Whale has already scheduled multiple audits with some of the most highly respected auditors in the industry. The foundation has already been built,  and now the focus is about getting the tools into the hands of our community, empowering them to protect the peg and stabilize the ecosystem.

 

Similar to Notcoin - Blum - Airdrops In 2024

origin »

Lendoit (LOAN) на Currencies.ru

$ 0 (+0.00%)
Объем 24H $0
Изменеия 24h: 0.00 %, 7d: 0.00 %
Cегодня L: $0 - H: $0
Капитализация $0 Rank 99999
Доступно / Всего 0 LOAN

loan opened closed flash short amount very

loan opened → Результатов: 2