Whale Loans
Searchโ€ฆ
๐Ÿค– Developer Info
The Whale Loans platform runs on Binance Smart Chain but flash-minting will be deployed to many chains.
Devs will need to deploy a contract (with logic) on the appropriate chain to perform a flash-mint much like with flash loans.
The contract has two main fuctions:

beginFlashMint

This is the function to fire off the flash mint. You will call this function from the wallet and the blockchain provided to run the flash mint.
The amount passed to this function will be flash minted in the address of the current contract -- and is available to use during the transaction.
1
// call this function to fire off your flash mint
2
โ€‹
3
function beginFlashMint(uint256 amount) public onlyOwner {
4
fBEP20.flashMint(amount);
5
}
Copied!

executeOnFlashMint

This function executes during your flash mint -- and where the DeFi magic happens.
In other words, this is where devs implement their strategy utilizing flash minted funds. For example, running an arbitrage between AMMs or liquidating under-collateralized loans.
1
function executeOnFlashMint(uint256 amount, uint256 debt) external {
2
require(msg.sender == address(fBEP20), "only FlashBEP20 can
3
execute");
4
โ€‹
5
// At this point we have flash tokens available
6
// We swap to the underlying token by depositing the flash minted
7
tokens
8
// For this particular transaction we are limited by the size of the
9
pool
10
// But we could also swap in any AMM with the flashToken if included
11
in any pair
12
โ€‹
13
fBEP20.deposit(amount);
14
โ€‹
15
// When this executes, this contract will have `amount` more fBEP20 tokens.
16
// Do whatever you want with those tokens here.
17
// You can even redeem them for bep20 by calling
18
โ€‹
19
`fBEP20.withdraw(someAmount)`
20
โ€‹
21
// But you must make sure this contract holds at least `amount` fBEP20
22
before this function finishes executing
23
// or else the transaction will be reverted by the `fBEP20.flashMint`
24
function.
25
26
fBEP20.withdraw(amount);
27
IBEP20(fBEP20.underlying()).approve(address(fBEP20), debt);
28
}
29
โ€‹
Copied!