// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.4;
import "./DirectLoanFixedOffer.sol";
/**
* @title DirectLoanFixedOfferRedeploy
* @author NFTfi
* @notice Same as DirectLoanFixedOffer, we have to duplicate it because we have to re-deploy,
* but we need the old and the new simultaneously in the coordinator
*
*
* Main contract for NFTfi Direct Loans Fixed Type. This contract manages the ability to create NFT-backed
* peer-to-peer loans of type Fixed (agreed to be a fixed-repayment loan) where the borrower pays the
* maximumRepaymentAmount regardless of whether they repay early or not.
*
* There are two ways to commence an NFT-backed loan:
*
* a. The borrower accepts a lender's offer by calling `acceptOffer`.
* 1. the borrower calls nftContract.approveAll(NFTfi), approving the NFTfi contract to move their NFT's on their
* be1alf.
* 2. the lender calls erc20Contract.approve(NFTfi), allowing NFTfi to move the lender's ERC20 tokens on their
* behalf.
* 3. the lender signs an off-chain message, proposing its offer terms.
* 4. the borrower calls `acceptOffer` to accept these terms and enter into the loan. The NFT is stored in
* the contract, the borrower receives the loan principal in the specified ERC20 currency, the lender receives an
* NFTfi promissory note (in ERC721 form) that represents the rights to either the principal-plus-interest, or the
* underlying NFT collateral if the borrower does not pay back in time, and the borrower receives obligation receipt
* (in ERC721 form) that gives them the right to pay back the loan and get the collateral back.
*
* b. The lender accepts a borrowe's binding terms by calling `acceptListing`.
* 1. the borrower calls nftContract.approveAll(NFTfi), approving the NFTfi contract to move their NFT's on their
* be1alf.
* 2. the lender calls erc20Contract.approve(NFTfi), allowing NFTfi to move the lender's ERC20 tokens on their
* behalf.
* 3. the borrower signs an off-chain message, proposing its binding terms.
* 4. the lender calls `acceptListing` with an offer matching the binding terms and enter into the loan. The NFT is
* stored in the contract, the borrower receives the loan principal in the specified ERC20 currency, the lender
* receives an NFTfi promissory note (in ERC721 form) that represents the rights to either the principal-plus-interest,
* or the underlying NFT collateral if the borrower does not pay back in time, and the borrower receives obligation
* receipt (in ERC721 form) that gives them the right to pay back the loan and get the collateral back.
*
* The lender can freely transfer and trade this ERC721 promissory note as they wish, with the knowledge that
* transferring the ERC721 promissory note tranfsers the rights to principal-plus-interest and/or collateral, and that
* they will no longer have a claim on the loan. The ERC721 promissory note itself represents that claim.
*
* The borrower can freely transfer and trade this ERC721 obligaiton receipt as they wish, with the knowledge that
* transferring the ERC721 obligaiton receipt tranfsers the rights right to pay back the loan and get the collateral
* back.
*
*
* A loan may end in one of two ways:
* - First, a borrower may call NFTfi.payBackLoan() and pay back the loan plus interest at any time, in which case they
* receive their NFT back in the same transaction.
* - Second, if the loan's duration has passed and the loan has not been paid back yet, a lender can call
* NFTfi.liquidateOverdueLoan(), in which case they receive the underlying NFT collateral and forfeit the rights to the
* principal-plus-interest, which the borrower now keeps.
*/
contract DirectLoanFixedOfferRedeploy is DirectLoanFixedOffer {
/* *********** */
/* CONSTRUCTOR */
/* *********** */
/**
* @dev Sets `hub` and permitted erc20-s
*
* @param _admin - Initial admin of this contract.
* @param _nftfiHub - NFTfiHub address
* @param _permittedErc20s - list of permitted ERC20 token contract addresses
*/
constructor(
address _admin,
address _nftfiHub,
address[] memory _permittedErc20s
) DirectLoanFixedOffer(_admin, _nftfiHub, _permittedErc20s) {
// solhint-disable-previous-line no-empty-blocks
}
/* ******************* */
/* READ-ONLY FUNCTIONS */
/* ******************* */
/**
* @notice This function returns a bytes32 value identifying the loan type for the coordinator
*/
// all caps, because used to be a constant storage and the interface should be the same
// solhint-disable-next-line func-name-mixedcase
function LOAN_TYPE() public pure override returns (bytes32) {
return bytes32("DIRECT_LOAN_FIXED_REDEPLOY");
}
}