IFixedInterestBulletLoans
Inherits: IAccessControl
Functions
issueLoan
Issue a new loan with the specified parameters
function issueLoan(IssueLoanInputs calldata loanInputs) external 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 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 |
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 |
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;
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;
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;
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;
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | The ID of the loan to mark as defaulted |
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 |
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 |
getLoansLength
Get the total number of loans
function getLoansLength() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The total number of loans |
currentUsdValue
Calculate the loan value at the current timestamp
function currentUsdValue(uint256 loanId) external view 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) external view 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 |
Events
Created
Emitted when a new loan is created
event Created(uint256 indexed loanId);
Started
Emitted when a loan is started
event Started(uint256 indexed loanId);
Repaid
Emitted when a loan is repaid
event Repaid(uint256 indexed loanId, uint256 amount);
RepayDefaulted
Emitted when a defaulted loan is repaid
event RepayDefaulted(uint256 indexed loanId, uint256 amount);
Defaulted
Emitted when a loan is marked as defaulted
event Defaulted(uint256 indexed loanId);
Canceled
Emitted when a loan is canceled
event Canceled(uint256 indexed loanId);
LoanStatusChanged
Emitted when a loan status is changed
event LoanStatusChanged(uint256 indexed loanId, FixedInterestBulletLoanStatus newStatus);
Errors
NotPortfolio
error NotPortfolio();
PortfolioAlreadySet
error PortfolioAlreadySet();
NotSuitableLoanStatus
error NotSuitableLoanStatus();
NotEqualRepayAmount
error NotEqualRepayAmount();
Structs
LoanMetadata
struct LoanMetadata {
uint256 krwPrincipal;
uint256 usdPrincipal;
uint256 usdRepaid;
uint256 interestRate;
address recipient;
address collateral;
uint256 collateralId;
uint256 startDate;
uint256 duration;
FixedInterestBulletLoanStatus status;
IERC20 asset;
}
IssueLoanInputs
struct IssueLoanInputs {
uint256 krwPrincipal;
uint256 interestRate;
address recipient;
address collateral;
uint256 collateralId;
uint256 duration;
IERC20 asset;
}