// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.4;
/**
* @title LoanData
* @author NFTfi
* @notice An interface containg the main Loan struct shared by Direct Loans types.
*/
interface LoanData {
/* ********** */
/* DATA TYPES */
/* ********** */
/**
* @notice The main Loan Terms struct. This data is saved upon loan creation.
*
* @param loanERC20Denomination - The address of the ERC20 contract of the currency being used as principal/interest
* for this loan.
* @param loanPrincipalAmount - The original sum of money transferred from lender to borrower at the beginning of
* the loan, measured in loanERC20Denomination's smallest units.
* @param maximumRepaymentAmount - The maximum amount of money that the borrower would be required to retrieve their
* collateral, measured in the smallest units of the ERC20 currency used for the loan. The borrower will always have
* to pay this amount to retrieve their collateral, regardless of whether they repay early.
* @param nftCollateralContract - The address of the the NFT collateral contract.
* @param nftCollateralWrapper - The NFTfi wrapper of the NFT collateral contract.
* @param nftCollateralId - The ID within the NFTCollateralContract for the NFT being used as collateral for this
* loan. The NFT is stored within this contract during the duration of the loan.
* @param loanStartTime - The block.timestamp when the loan first began (measured in seconds).
* @param loanDuration - The amount of time (measured in seconds) that can elapse before the lender can liquidate
* the loan and seize the underlying collateral NFT.
* @param loanInterestRateForDurationInBasisPoints - This is the interest rate (measured in basis points, e.g.
* hundreths of a percent) for the loan, that must be repaid pro-rata by the borrower at the conclusion of the loan
* or risk seizure of their nft collateral. Note if the type of the loan is fixed then this value is not used and
* is irrelevant so it should be set to 0.
* @param loanAdminFeeInBasisPoints - The percent (measured in basis points) of the interest earned that will be
* taken as a fee by the contract admins when the loan is repaid. The fee is stored in the loan struct to prevent an
* attack where the contract admins could adjust the fee right before a loan is repaid, and take all of the interest
* earned.
* @param borrower
*/
struct LoanTerms {
uint256 loanPrincipalAmount;
uint256 maximumRepaymentAmount;
uint256 nftCollateralId;
address loanERC20Denomination;
uint32 loanDuration;
uint16 loanInterestRateForDurationInBasisPoints;
uint16 loanAdminFeeInBasisPoints;
address nftCollateralWrapper;
uint64 loanStartTime;
address nftCollateralContract;
address borrower;
}
/**
* @notice Some extra Loan's settings struct. This data is saved upon loan creation.
* We need this to avoid stack too deep errors.
*
* @param revenueSharePartner - The address of the partner that will receive the revenue share.
* @param revenueShareInBasisPoints - The percent (measured in basis points) of the admin fee amount that will be
* taken as a revenue share for a t
* @param referralFeeInBasisPoints - The percent (measured in basis points) of the loan principal amount that will
* be taken as a fee to pay to the referrer, 0 if the lender is not paying referral fee.he partner, at the moment
* the loan is begun.
*/
struct LoanExtras {
address revenueSharePartner;
uint16 revenueShareInBasisPoints;
uint16 referralFeeInBasisPoints;
}
/**
* @notice The offer made by the lender. Used as parameter on both acceptOffer (initiated by the borrower) and
* acceptListing (initiated by the lender).
*
* @param loanERC20Denomination - The address of the ERC20 contract of the currency being used as principal/interest
* for this loan.
* @param loanPrincipalAmount - The original sum of money transferred from lender to borrower at the beginning of
* the loan, measured in loanERC20Denomination's smallest units.
* @param maximumRepaymentAmount - The maximum amount of money that the borrower would be required to retrieve their
* collateral, measured in the smallest units of the ERC20 currency used for the loan. The borrower will always
* have to pay this amount to retrieve their collateral, regardless of whether they repay early.
* @param nftCollateralContract - The address of the ERC721 contract of the NFT collateral.
* @param nftCollateralId - The ID within the NFTCollateralContract for the NFT being used as collateral for this
* loan. The NFT is stored within this contract during the duration of the loan.
* @param referrer - The address of the referrer who found the lender matching the listing, Zero address to signal
* this there is no referrer.
* @param loanDuration - The amount of time (measured in seconds) that can elapse before the lender can liquidate
* the loan and seize the underlying collateral NFT.
* @param loanAdminFeeInBasisPoints - The percent (measured in basis points) of the interest earned that will be
* taken as a fee by the contract admins when the loan is repaid. The fee is stored in the loan struct to prevent an
* attack where the contract admins could adjust the fee right before a loan is repaid, and take all of the interest
* earned.
*/
struct Offer {
uint256 loanPrincipalAmount;
uint256 maximumRepaymentAmount;
uint256 nftCollateralId;
address nftCollateralContract;
uint32 loanDuration;
uint16 loanAdminFeeInBasisPoints;
address loanERC20Denomination;
address referrer;
}
/**
* @notice Signature related params. Used as parameter on both acceptOffer (containing borrower signature) and
* acceptListing (containing lender signature).
*
* @param signer - The address of the signer. The borrower for `acceptOffer` the lender for `acceptListing`.
* @param nonce - The nonce referred here is not the same as an Ethereum account's nonce.
* We are referring instead to a nonce that is used by the lender or the borrower when they are first signing
* off-chain NFTfi orders. These nonce can be any uint256 value that the user has not previously used to sign an
* off-chain order. Each nonce can be used at most once per user within NFTfi, regardless of whether they are the
* lender or the borrower in that situation. This serves two purposes:
* - First, it prevents replay attacks where an attacker would submit a user's off-chain order more than once.
* - Second, it allows a user to cancel an off-chain order by calling NFTfi.cancelLoanCommitmentBeforeLoanHasBegun()
* , which marks the nonce as used and prevents any future loan from using the user's off-chain order that contains
* that nonce.
* @param expiry - Date when the signature expires
* @param signature - The ECDSA signature of the borrower or the lender, obtained off-chain ahead of time, signing
* the following combination of parameters:
* - Borrower
* - ListingTerms.loanERC20Denomination,
* - ListingTerms.minLoanPrincipalAmount,
* - ListingTerms.maxLoanPrincipalAmount,
* - ListingTerms.nftCollateralContract,
* - ListingTerms.nftCollateralId,
* - ListingTerms.revenueSharePartner,
* - ListingTerms.minLoanDuration,
* - ListingTerms.maxLoanDuration,
* - ListingTerms.maxInterestRateForDurationInBasisPoints,
* - ListingTerms.referralFeeInBasisPoints,
* - Signature.signer,
* - Signature.nonce,
* - Signature.expiry,
* - address of the loan type contract
* - chainId
* - Lender:
* - Offer.loanERC20Denomination
* - Offer.loanPrincipalAmount
* - Offer.maximumRepaymentAmount
* - Offer.nftCollateralContract
* - Offer.nftCollateralId
* - Offer.referrer
* - Offer.loanDuration
* - Offer.loanAdminFeeInBasisPoints
* - Signature.signer,
* - Signature.nonce,
* - Signature.expiry,
* - address of the loan type contract
* - chainId
*/
struct Signature {
uint256 nonce;
uint256 expiry;
address signer;
bytes signature;
}
/**
* @notice Some extra parameters that the borrower needs to set when accepting an offer.
*
* @param revenueSharePartner - The address of the partner that will receive the revenue share.
* @param referralFeeInBasisPoints - The percent (measured in basis points) of the loan principal amount that will
* be taken as a fee to pay to the referrer, 0 if the lender is not paying referral fee.
*/
struct BorrowerSettings {
address revenueSharePartner;
uint16 referralFeeInBasisPoints;
}
/**
* @notice Terms the borrower set off-chain and is willing to accept automatically when fulfiled by a lender's
* offer.
*
* @param loanERC20Denomination - The address of the ERC20 contract of the currency being used as principal/interest
* for this loan.
* @param minLoanPrincipalAmount - The minumum sum of money transferred from lender to borrower at the beginning of
* the loan, measured in loanERC20Denomination's smallest units.
* @param maxLoanPrincipalAmount - The sum of money transferred from lender to borrower at the beginning of
* the loan, measured in loanERC20Denomination's smallest units.
* @param maximumRepaymentAmount - The maximum amount of money that the borrower would be required to retrieve their
* collateral, measured in the smallest units of the ERC20 currency used for the loan. The borrower will always have
* to pay this amount to retrieve their collateral, regardless of whether they repay early.
* @param nftCollateralContract - The address of the ERC721 contract of the NFT collateral.
* @param nftCollateralId - The ID within the NFTCollateralContract for the NFT being used as collateral for this
* loan. The NFT is stored within this contract during the duration of the loan.
* @param revenueSharePartner - The address of the partner that will receive the revenue share.
* @param minLoanDuration - The minumum amount of time (measured in seconds) that can elapse before the lender can
* liquidate the loan and seize the underlying collateral NFT.
* @param maxLoanDuration - The maximum amount of time (measured in seconds) that can elapse before the lender can
* liquidate the loan and seize the underlying collateral NFT.
* @param maxInterestRateForDurationInBasisPoints - This is maximum the interest rate (measured in basis points,
* e.g. hundreths of a percent) for the loan.
* @param referralFeeInBasisPoints - The percent (measured in basis points) of the loan principal amount that will
* be taken as a fee to pay to the referrer, 0 if the lender is not paying referral fee.
*/
struct ListingTerms {
uint256 minLoanPrincipalAmount;
uint256 maxLoanPrincipalAmount;
uint256 nftCollateralId;
address nftCollateralContract;
uint32 minLoanDuration;
uint32 maxLoanDuration;
uint16 maxInterestRateForDurationInBasisPoints;
uint16 referralFeeInBasisPoints;
address revenueSharePartner;
address loanERC20Denomination;
}
}