Oiler Network
Search…
FlashLoan
Step by step guide
The concept of the NFT Flash Loan is very similar to the concept of ERC20 asset Flash Loan → it is an uncollateralised loan that allow the borrowing of an NFT, as long as the borrowed NFT is returned before the end of the transaction(together with the loan cost paid to the pool).
Flash-loaned NFTs would behave in many cases exactly like you were the owner of them (you can flash-loan them every single time when you would normally use the NFT).

Overview

Here is how you can get started :

To execute an NFT Flash Loan you will have to deploy your own contract that will interact with Nafta smart contract:
  1. 1.
    Your contract calls Nafta contract requesting a Flash Loan using flashLoan(). You will indicate a certain nftID , nftAddress , maxLoanPrice - Price the user is willing to pay for the flashloan & receiverAddress.
  2. 2.
    After some sanity checks, Nafta transfers the requested nftID from _poolNFTs to your contract, then calls IFlashNFTReceiveron your contract (or another contract that you specify as the receiverAddress).
  3. 3.
    Your contract, now holding the flash loaned nftId, executes any arbitrary operation in its code.
  4. 4.
    Once your code is executed, you transfer the flashLoanednftID back to Nafta.
  • If the original NFT is not returned then the transaction is reverted.
All of the above happens in 1 transaction (hence in a single ethereum block)

Flash Loan Fee

flashFee - The fee user has to pay for a single rent (in WETH9) [Range: 0-4k ETH]

Step by Step

1. Set Up

Your contract that receives the flash loaned NFT has to integrate IFlashNFTReceiver interface by implementing the relevant executeOperation() function.
1
interface IFlashNFTReceiver is IERC721Receiver {
2
function executeOperation(
3
address nftAddress,
4
uint256 nftId,
5
uint256 feeInWeth,
6
address msgSender,
7
bytes calldata data) external returns (bool);
Copied!

2. Calling flashLoan()

To call flashloan() on Nafta, we need to pass in the relevant parameters.
1
function flashloan(
2
address nftAddress,
3
uint256 nftId,
4
uint256 maxLoanPrice,
5
address receiverAddress,
6
bytes calldata data) external;
Copied!

3. Completing the NFT flash loan

Once you have performed your logic with the flash loaned NFT (in your executeOperation() function), you will need to pay back the flash loaned NFTs with flashFee