How To Use White Whale’s Flash Loans: Step-By-Step Guide

Alnura
White Whale
Published in
2 min readMay 5, 2022

At White Whale, our development team has worked to augment our original UST Vault concept and enable users on the network to benefit from the first Flash Loans on the terra network and possibly also the first non-EVM implementation of Flash Loans.

Flash Loans are unique transactions that help you borrow an asset if the borrowed amount and the fee are returned to the network before the end of the transactions. Flash Loans do not require you to provide collateral and are a concept unique to the world of blockchain.

One of the most common use cases of flash loans is to develop arbitrage between different assets without having to produce the principal amount for executing the arbitrage. Let’s talk about how to use White Whale’s Flash Loans.

Step-by-Step Guide to using Flash Loans

To use Flash Loans on White Whales and start arbitraging digital assets, follow these steps:

  • The first step is to call the Flash Loan on a Vault by sending a Flash Loan variant of Execute Msg to the Vault. To generate this request, the requested assets must be the same as the base asset of the Vault.
  • The Flash Loan Payload is a structure that allows you to request a Flash Loan. You must fill the requested_asset and callback.

For Instance,

// Construct return call with received binary

let return_call = CosmosMsg::Wasm(WasmMsg::Execute {

contract_addr: info.sender.into(),

msg: payload.callback,

funds: vec![],

});

  • White Whale only offers one type of Flash Loans and handles all the repayment logic for you to help you focus on the use case for the loaned funds without losing hours on figuring out the repayment strategy.

It is important to note that White Whale does not check on your callback series of messages. This also includes ensuring that your logic works as intended. However, if you compose a Flash Loan that causes you to lose money there is a contract’s in-built profit checking logic to assist you, so you can’t make an unprofitable transaction.

Example Repo

You can find an example contract repository worked on by the White Whale Smart Contract team here. It gives a starting point for calling flash loans for your own use cases.

The provided boilerplate contract has everything you need to perform a general flashloan against the vault with the expectation that you will provide your own logic for what to do with the loaned funds. Perhaps you liquidate on the bot-first Kujira markets or maybe you help arb the Nebula Clusters. In the words of Marco Pierre White: It’s your choice.

--

--