Comment on page
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).
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 usingflashLoan()
. You will indicate a certainnftID
,nftAddress
,maxLoanPrice
- Price the user is willing to pay for the flashloan &receiverAddress
. - 2.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
). - 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 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)
flashFee
- The fee user has to pay for a single rent (in WETH9) [Range: 0-4k ETH]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);
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;
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 modified 1yr ago