FixedInterestBulletLoans
Inherits: Base, ERC721, IFixedInterestBulletLoans
State Variables
portfolio
IPortfolio public portfolio;
currencyConverter
ICurrencyConverter public currencyConverter;
loans
LoanMetadata[] internal loans;
Functions
onlyLoanStatus
modifier onlyLoanStatus(uint256 loanId, FixedInterestBulletLoanStatus _status);
constructor
constructor(
string memory name_,
string memory symbol_,
IProtocolConfig _protocolConfig,
ICurrencyConverter _currencyConverter,
address _manager
)
ERC721(name_, symbol_)
Base(_protocolConfig.protocolAdmin(), _protocolConfig.pauser());
loanData
Retrieve loan data for a specific loan ID
function loanData(uint256 loanId) external view returns (LoanMetadata memory);
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | The ID of the loan |
Returns
Name | Type | Description |
---|---|---|
<none> | LoanMetadata | The loan metadata as a LoanMetadata struct |
getRecipient
Get the recipient address of a loan with the specified ID
function getRecipient(uint256 loanId) external view returns (address);
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | The ID of the loan |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The recipient address |
getStatus
Get the status of a loan with the specified ID
function getStatus(uint256 loanId) external view returns (FixedInterestBulletLoanStatus);
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | The ID of the loan |
Returns
Name | Type | Description |
---|---|---|
<none> | FixedInterestBulletLoanStatus | The loan status as a FixedInterestBulletLoanStatus enum value |
currentUsdValue
Calculate the loan value at the current timestamp
function currentUsdValue(uint256 loanId) public view override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | The ID of the loan |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | loan value. It remains the same after loan.endDate |
expectedUsdRepayAmount
Calculate the amount to repay. It is the same regardless of the repaying time.
function expectedUsdRepayAmount(uint256 loanId) public view override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | The ID of the loan |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | repayment amount |
setPortfolio
Set the portfolio contract
The caller must have the manager role
function setPortfolio(IPortfolio _portfolio) external;
Parameters
Name | Type | Description |
---|---|---|
_portfolio | IPortfolio | The address of the portfolio contract |
setCurrencyConverter
Set the currency converter contract
The caller must have the manager role
function setCurrencyConverter(ICurrencyConverter _currencyConverter) external;
Parameters
Name | Type | Description |
---|---|---|
_currencyConverter | ICurrencyConverter | The address of the currency converter contract |
issueLoan
Issue a new loan with the specified parameters
function issueLoan(IssueLoanInputs calldata loanInputs) external override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
loanInputs | IssueLoanInputs | The input parameters for the new loan |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The ID of the newly created loan |
startLoan
Start a loan with the specified ID
The loan must be in the Created status and the caller must be the portfolio contract
function startLoan(uint256 loanId)
external
whenNotPaused
onlyLoanStatus(loanId, FixedInterestBulletLoanStatus.Created)
returns (uint256 principal);
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | The ID of the loan to start |
Returns
Name | Type | Description |
---|---|---|
principal | uint256 | The borrowed principal amount of the loan in USD |
repayLoan
Repay a loan with the specified ID and amount
The loan must be in the Started status and the caller must be the portfolio contract
function repayLoan(
uint256 loanId,
uint256 usdAmount
)
external
whenNotPaused
onlyLoanStatus(loanId, FixedInterestBulletLoanStatus.Started);
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | The ID of the loan to repay |
usdAmount | uint256 | The amount to repay in USD |
repayDefaultedLoan
Repay a defaulted loan with the specified ID and amount
The loan must be in the Defaulted status and the caller must be the portfolio contract
function repayDefaultedLoan(
uint256 loanId,
uint256 usdAmount
)
external
whenNotPaused
onlyLoanStatus(loanId, FixedInterestBulletLoanStatus.Defaulted);
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | The ID of the defaulted loan to repay |
usdAmount | uint256 | The amount to repay in USD |
cancelLoan
Cancel a loan with the specified ID
The loan must be in the Created status and the caller must be the portfolio contract
function cancelLoan(uint256 loanId)
external
whenNotPaused
onlyLoanStatus(loanId, FixedInterestBulletLoanStatus.Created);
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | The ID of the loan to cancel |
markLoanAsDefaulted
Mark a loan as defaulted with the specified ID
The loan must be in the Started status and the caller must be the portfolio contract
function markLoanAsDefaulted(uint256 loanId)
external
whenNotPaused
onlyLoanStatus(loanId, FixedInterestBulletLoanStatus.Started);
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | The ID of the loan to mark as defaulted |
getLoansLength
Get the total number of loans
function getLoansLength() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The total number of loans |
isOverdue
Check if a loan with the specified ID is overdue
function isOverdue(uint256 loanId) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | The ID of the loan |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | A boolean value indicating if the loan is overdue |
supportsInterface
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl, ERC721) returns (bool);
_getUsdPrincipal
function _getUsdPrincipal(uint256 loanId) internal view returns (uint256);
_changeLoanStatus
function _changeLoanStatus(uint256 loanId, FixedInterestBulletLoanStatus _status) internal;
_requirePortfolio
function _requirePortfolio() internal view;