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. 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. 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. Your contract, now holding the flash loaned nftId, executes any arbitrary operation in its code.

  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.

interface IFlashNFTReceiver is IERC721Receiver {
    function executeOperation(
     address nftAddress, 
     uint256 nftId, 
     uint256 feeInWeth, 
     address msgSender, 
     bytes calldata data) external returns (bool);

2. Calling flashLoan()

To call flashloan() on Nafta, we need to pass in the relevant parameters.

function flashloan(
address nftAddress, 
uint256 nftId, 
uint256 maxLoanPrice, 
address receiverAddress, 
bytes calldata data) external;

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

Last updated