NFT can also be a flash loan? Understand the new features of the NFT20 protocol

0

 207 total views

Briefly understand the implementation methods and use cases of the lightning loan function of the NFT20 protocol.

Extended reading: ” Understanding NFT Derivatives Trading Agreement NFT20 in Five Minutes: Let Common People Easily Buy NFT

Original Title: ” New NFT Gameplay | One Article to Understand NFT Lightning Loan
Written by: Very Nifty
Compilation: Captain Hiro

Today we are very happy to talk about a new feature of the NFT20 agreement: NFT flash loans. As NFT usage scenarios increase, there will be more use cases to buy and sell NFT programmatically, and even use NFT for other new use cases in games.

You can now use Lightning Loan in any of our pools and use any NFT locked on our platform. There is currently no charge for using Lightning Loan, but there may be a certain handling fee in the future.

NFT20 Lightning Loan is built for developers, once the liquidity returns to the pool within a single transaction block, they can borrow funds quickly without collateral. If you do not do this, the entire transaction will be resumed and the actions taken will be effectively cancelled, which ensures the safety of the funds in the pool.

Examples of using flash loans include arbitrage, asking for NFT rewards when they accumulate in the pool, and anything you can imagine.

Lightning loan provides unlimited use cases for the DeFi ecosystem, and we are very happy to see developers creating this feature in the NFT field.

In order to guide you to start using lightning loans and be inspired, we have created a small example of lightning loans.

The first ever NFT flash loan

Hashmasks is a living digital art collection created by more than 70 artists around the world. By holding artworks, you can accumulate a certain amount of NCT tokens every day, which allows you to choose a name for your portrait on the Ethereum blockchain.

NCT tokens are also valuable in the market: at the time of writing, the price of each NCT is $0.17. The NFT20 Hashmask pool currently contains 164 items.

We implemented the first smart contract that can be implemented in one transaction with the help of wafflemakr:

  • Borrow a set of Hashmasks from our NFT20 pool.

  • Claim the NCT tokens accumulated while in the pool

  • Sell ​​these NCT tokens and exchange for ETH

  • Return Hashmasks to the pool.

We have set up a front desk , which will obtain the 20 most profitable HashMasks in the pool, automatically lend them, and obtain their NCT. NCT will be converted to ETH and returned to the caller (10% will go into our DAO wallet). Taking into account the price of NCT tokens and gas, the current NFT lightning loan is not profitable, but it was profitable in our test a few days ago.

The code for this operation is very simple:

New NFT gameplay | Learn about NFT lightning loan in one article

In order for the contract to return the borrowed assets correctly, you need to ensure that it executes the setApprovalForAll function at least once:

New NFT gameplay | Learn about NFT lightning loan in one article

Once implemented, you only need to call the flash loan function on the NFT20 pair you selected, pass the ID of the NFT you want to borrow, receive and use the address of the asset contract and an additional data field as your additional parameters:

New NFT gameplay | Learn about NFT lightning loan in one article

The implementation of Lightning Loan is very similar to Aave one, so if you are already familiar with the implementation of Aave, you will not find our operation difficult.

Source link: www.8btc.com

Disclaimer: As a blockchain information platform, the articles published on this site only represent the author’s personal views and have nothing to do with ChainNews’ position. The information, opinions, etc. in the article are for reference only, and are not intended as or regarded as actual investment advice.

Let’s block ads! (Why?)