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:
Your contract calls
Nafta
contract requesting a Flash Loan usingflashLoan()
. You will indicate a certainnftID
,nftAddress
,maxLoanPrice
- Price the user is willing to pay for the flashloan &receiverAddress
.After some sanity checks,
Nafta
transfers the requestednftID
from_poolNFTs
to your contract, then callsIFlashNFTReceiver
on your contract (or another contract that you specify as thereceiverAddress
).Your contract, now holding the flash loaned
nftId
, executes any arbitrary operation in its code.Once your code is executed, you transfer the flashLoaned
nftID
back toNafta
.
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.
2. Calling flashLoan()
flashLoan()
To call flashloan()
on Nafta
, we need to pass in the relevant parameters.
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