**MVP**: 1. Lender can mark an NFT available for lending 2. Borrower can borrow an NFT based on lending constraints set by lender Two ways we can implement this: one is offering collateral equal to the value of the NFT; the other (more sensible way) is utilizing pallet-level locking and force transferring functionality. Non-collateral NFT lending is something that is possible with the power of Substrate and the NFTs pallet where as in other systems, traditionally this can only be done with the borrower forgoing ownership and instead receiving a derived asset. ## Pallet Logic ### Strategy #1: Use collateral The lending pallet locks the NFT and sets the collateral amount, interest, and lending min/max period. Example: I will allow my monkey NFT to be "borrowed" for: - collateral amount: 2000 DOT - interest: 1% (per block) - a minimum of 4 months (x blocks) - and a maximum of 12 months (y blocks) Two methods for charging interest: - Interest is charged per block. - If borrower's funds run out, they will need to return the NFT or collateral is released to lender (or force transfer) - A vesting amount is locked and vested for the selected lending period Collateral amount for NFT is denoted by lender and is reserved from borrower's account. Borrower specifies lending period they want based on lender's min and max. Ownership of NFT is transferred to borrower. On expiration if the NFT is not returned the lender will receive the full collateral. > This is not an ideal solution. With Substrate/FRAME we can develop a better solution by having the lending pallet have logic to do a force transfer at the end of the lending period At anytime the lender can check how much they already earned: ``` (now - lending_period_start_block) * price_per_block - already_paid ``` Lender can call a `pay_out` extrinsic which: - calculates the amount earned - pays out the earned amount to the lender - adds the amount to `already_paid` - unreserves from borrower - and force transfers the NFT back to the lender Lender can cancel lending as long as their NFT has not been borrowed. **Constraints** - Lended NFTs should not be able to be lent again (nor sold) - Example: If Alice lends out her NFT to Bob, then Bob should be the new owner without the ability to transfer that NFT further - min vesting period allowed - max vesting period allowed ### Strategy #2: No collateral, use force transfer We do all of the above without collateral and utilize a force transfer once lending period is complete. What would this look like from a dispatchable call perspective? ```rust pub fn list_nft( origin: OriginFor<T>, nft_collection_id: T::NftCollectionId, nft_id: T::NftId, min_period: u64, max_period: u64, price_per_block: BalanceOf<T>, ) ``` ```rust pub fn borrow_nft( origin: OriginFor<T>, nft_collection_id: T::NftCollectionId, nft_id: T::NftId, borrowing_period: u64, ) ``` `force_transfer` would be called when the NFT `borrowing_period` has ended. Problem: We need to create `force_transfer` in the NFTs pallet. ### Strategy #3 Transfer the ownership of the NFT to the NFTs lending pallet account. Set the borrower of the NFT in the `LentNfts` storage. Return ownership of the NFT to the lender when the borrowing period ends. This approach is permissionless and the borrower cannot steal the NFT. ### Optional Features - Lender can allow NFT to be returned before deadline (default) OR only allow NFT to be returned on deadline and not before - Payment logic: - pay in parts - pay in advance - pay on claim ### Post-MVP Features - **Delegation**: Allow lender to lend with no collateral, discounted collateral, or no interest to whitelisted account(s) - Example: I am lending my "house key NFT" to my friend to check on my dog while I am away - Allow for no deadline AND revocation of lending at anytime - Example: I am lending my "house key NFT" to my friend to check on my dog while I am away. I don't know for how long I will be away but when I get back I want to revoke lending the NFT to him. - Use any asset for collateral - Allow for more complex terms and conditions for lending the NFT ### Resources - https://bounties.gitcoin.co/grants/464/lend-and-borrow-ethereum-erc-721-tokens-with-lend - https://0xddd.medium.com/lend-and-borrow-ethereum-erc-721-tokens-with-lend721-platform-32f1a22905fd ### Interesting use cases Delegation - Security clearance, authentication, authorization, etc. Trials - 30 day trial Lending, Renting