FixedInterestBulletLoans

Git Source

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

NameTypeDescription
loanIduint256The ID of the loan

Returns

NameTypeDescription
<none>LoanMetadataThe 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

NameTypeDescription
loanIduint256The ID of the loan

Returns

NameTypeDescription
<none>addressThe recipient address

getStatus

Get the status of a loan with the specified ID

function getStatus(uint256 loanId) external view returns (FixedInterestBulletLoanStatus);

Parameters

NameTypeDescription
loanIduint256The ID of the loan

Returns

NameTypeDescription
<none>FixedInterestBulletLoanStatusThe 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

NameTypeDescription
loanIduint256The ID of the loan

Returns

NameTypeDescription
<none>uint256loan 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

NameTypeDescription
loanIduint256The ID of the loan

Returns

NameTypeDescription
<none>uint256repayment amount

setPortfolio

Set the portfolio contract

The caller must have the manager role

function setPortfolio(IPortfolio _portfolio) external;

Parameters

NameTypeDescription
_portfolioIPortfolioThe address of the portfolio contract

setCurrencyConverter

Set the currency converter contract

The caller must have the manager role

function setCurrencyConverter(ICurrencyConverter _currencyConverter) external;

Parameters

NameTypeDescription
_currencyConverterICurrencyConverterThe 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

NameTypeDescription
loanInputsIssueLoanInputsThe input parameters for the new loan

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
loanIduint256The ID of the loan to start

Returns

NameTypeDescription
principaluint256The 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

NameTypeDescription
loanIduint256The ID of the loan to repay
usdAmountuint256The 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

NameTypeDescription
loanIduint256The ID of the defaulted loan to repay
usdAmountuint256The 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

NameTypeDescription
loanIduint256The 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

NameTypeDescription
loanIduint256The ID of the loan to mark as defaulted

getLoansLength

Get the total number of loans

function getLoansLength() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total number of loans

isOverdue

Check if a loan with the specified ID is overdue

function isOverdue(uint256 loanId) external view returns (bool);

Parameters

NameTypeDescription
loanIduint256The ID of the loan

Returns

NameTypeDescription
<none>boolA 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;