Installment Market

The installment market is an NFT rental market developed based on Rentero Protocol. Renter can pay Lender the rent by installments to lease an NFT. Lender generally entrusts an installment market contract as the delegator under Rentero Protocol, licenses the power to allocate NFT usage-right to the installment market contract, and pledges an NFT under Rentero Protocol through the installment market contract to lend the NFT to the installment market. When lending an NFT, Lender can set relevant rental parameters, such as the type of ERC20 token, amount of deposit, whitelist address, daily rent, number of days in each payment cycle, minimum number of rental days and maximum number of rental days. Further, Lender can reset the rental parameters at any time, so long as the NFT has not been rented. Renter can choose the NFT to be leased in the installment market, set the number of rental days, and pay the deposit and the first installment of rent in ERC20 token to lease an NFT. The deposit will be kept in the installment market contract, and Lender will get the first installment of rent. Renter can return the NFT and cancel NEF rental in advance, but he will lose the deposit which will be used by the installment market to compensate Lender. After paying the rent for the whole rental period, Renter will receive the deposit returned by the installment market. Lender also has the right to redeem an NFT in advance, provided that he should return the rent already paid by Renter but not used, and pay Renter an amount equal to the deposit in ERC20 token. Lender can directly redeem an NFT, so long as the NFT has not been rented in the installment market or its rental period has expired. When each rental period expires, the installment market will deduct ERC20 token equal to the rent of the next period from Renter’s wallet and pay it to Lender. After such deduction, Renter can continue to use the NFT. If the deduction fails, Renter will lose the right to use the NFT and the deposit under the installment market contract. After the rent of the last period is deducted, the installment market will return Renter’s deposit. After the rental period expires, NFT will re-enter the market and become available for renting again, and there is no need for Lender or Renter to reset the state of NFT.

Installment Market interface

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

interface IInstallmentMarket {
    event Lend(address indexed nftAddress, uint256 indexed tokenId, address indexed lender);

    event Rent(
        address indexed nftAddress,
        uint256 indexed tokenId,
        address lender,
        address indexed renter,
        uint256 paidExpires,
        uint256 expires
    );

    event ReLend(address indexed nftAddress, uint256 indexed tokenId, address indexed lender);

    event Abort(address indexed nftAddress, uint256 indexed tokenId, address lender, address indexed renter);

    event Reclaim(address indexed nftAddress, uint256 indexed tokenId, address indexed lender);

    event ForceReclaim(address indexed nftAddress, uint256 indexed tokenId, address indexed lender, address renter);

    event InstallmentSuccess(
        address indexed nftAddress,
        uint256 indexed tokenId,
        address lender,
        address indexed renter,
        uint256 paidExpires
    );

    event InstallmentFailed(
        address indexed nftAddress,
        uint256 indexed tokenId,
        address lender,
        address indexed renter
    );

    event ReturnDeposit(address indexed nftAddress, uint256 indexed tokenId, address indexed renter, uint256 deposit);

    function lend(
        address nftAddress,
        uint256 tokenId,
        address erc20Address,
        address whitelist,
        uint256 deposit,
        uint256 rentPerDay,
        uint16 daysPerPeriod,
        uint16 minRentalDays,
        uint16 maxRentalDays
    ) external;

    function rent(
        address nftAddress,
        uint256 tokenId,
        uint16 rentalDays
    ) external;

    function reLend(
        address nftAddress,
        uint256 tokenId,
        address erc20Address,
        address whitelist,
        uint256 deposit,
        uint256 rentPerDay,
        uint16 daysPerPeriod,
        uint16 minRentalDays,
        uint16 maxRentalDays
    ) external;

    function abort(address nftAddress, uint256 tokenId) external;

    function reclaim(address nftAddress, uint256 tokenId) external;

    function lease(address nftAddress, uint256 tokenId)
        external
        view
        returns (
            address lender,
            address erc20Address,
            address whitelist,
            uint256 deposit,
            uint256 rentPerDay,
            uint256 daysPerPeriod,
            uint256 minRentalDays,
            uint256 maxRentalDays,
            address renter,
            uint256 paidExpires,
            uint256 expires
        );
}

Flow chart of installment market

First, the Rentero developer needs to configure the ERC721 contract address and its corresponding Rentero Protocol address to the installment market, and add supports for the NFT rental under the ERC721 contract.

Lend

  1. Lender needs to call the Approve (address to, uint256 tokenId) function or setApprovalForAll (address operator, bool approved) function of ERC721 contract to authorize the installment market contract to transfer the corresponding NFT.

  2. Lender calls the Lend function of the installment market to lend the NFT

2.1 The installment market contract calls the setDelegator (uint256 tokenId, address delegator) function of Rentero Protocol to set the NFT delegator as the installment market contract address.

2.2 The installment market contract calls the safeTransferFrom (address from, address to, uint256 tokenId) function of ERC721 contract to transfer the NFT from Lender’s address to the Rentero Protocol contract address.

2.3 The installment market contract calls the Stake (uint256 tokenId, address owner) function of Rentero Protocol contract to pledge the NFT under Rentero Protocol and lend the NFT to the installment market. Rentero Protocol contract mints ReNFT with the same tokenId and sends it to Lender’s address as the certificate of NFT holding, that is, the one holding ReNFT is Lender of the NFT with the same tokenId.

Relend

Before the NFT is rented, Lender can call the Relend function of installment market to reset the rental parameters, such as the type of ERC20 token, amount of deposit, daily rent, whitelist address, number of days in each payment cycle, minimum number of rental days and maximum number of rental days.

Rent

  1. Renter needs to call the Approve (address spender, uint256 amount) function of ERC20 contract in NFT rental parameters to authorize the installment market contract to transfer a corresponding amount of ERC20 token for paying the deposit and the first installment of rent.

  2. Renter calls the Rent function of the installment market to rent the NFT.

2.1 The installment market contract calls the transferFrom (address from, address to, uint256 amount) function of ERC20 contract to transfer the first installment of rent and the deposit from Renter’s address to the installment market contract address.

2.2 The installment market contract calls the setUser (uint256 tokenId, address user, uint64 expires) function of Rentero Protocol contract to set NFT user and expires.

Abort

Renter calls the Abort function of the installment market to abort the rental in advance.

1. The installment market contract calls the setUser (uint256 tokenId, address user, uint64 expires) function of Rentero Protocol contract to set the NFT user and expires to be 0.

2.The installment market contract calls the Transfer (address to, uint256 amount) function of ERC20 contract to transfer Renter’s deposit to Lender.

Reclaim

  1. Lender needs to call the Approve (address spender, uint256 amount) function of ERC20 contract in NFT rental parameters to authorize the installment market contract to transfer a corresponding amount of ERC20 token for paying liquidated damages equal to the unused rent and the deposit.

  2. Lender calls the Redeem function of the installment market to redeem the NFT.

2.1 If the NFT is being used at the time of call:

2.1.1 The installment market contract calls the transferFrom (address from, address to, uint256 amount) function of ERC20 contract to transfer liquidated damages equal to the unused rent and the deposit from Lender’s address to Renter’s address.

2.1.2 The installment market contract calls the Transfer (address to, uint256 amount) function of ERC20 contract to return the deposit in the installment market to Renter.

2.2 The installment market contract calls the Redeem (uint256 tokenId) function of Rentero Protocol contract.

2.2.1 Rentero Protocol contract calls the _burn function to destroy Lender’s ReNFT.

2.2.2 Rentero Protocol contract calls the safeTransferFrom (address from, address to, uint256 tokenId) function of ERC721 contract to transfer the NFT from the Rentero Protocol contract address to Lender’s address.

Installment

The chainlink keeper will automatically initiate an installment payment transaction.

1.The chainlink keeper calls the checkUpkeep (bytes checkData) function of the installment market contract to inquire whether there is any NFT rental that requires Renter to pay the rent of the next rental period.

2.The chainlink keeper calls the performUpkeep (bytes calldata performData) function of the installment market contract to deduct the rent of the next rental period payable by Renter. The installment market contract calls the transferFrom (address from, address to, uint256 amount) function of ERC20 contract to transfer the rent of the next rental period from Renter’s address to Lender’s address.

3 If the deduction under Paragraph 1.2 fails, the same operations as Abort will be conducted.

Last updated