IFixedInterestBulletLoans

Git Source

Inherits: IAccessControl

Functions

issueLoan

Issue a new loan with the specified parameters

function issueLoan(IssueLoanInputs calldata loanInputs) external 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 returns (uint256 principal);

Parameters

NameTypeDescription
loanIduint256The ID of the loan to start

Returns

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

NameTypeDescription
loanIduint256The ID of the loan

Returns

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

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;

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;

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;

Parameters

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

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

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

getLoansLength

Get the total number of loans

function getLoansLength() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total number of loans

currentUsdValue

Calculate the loan value at the current timestamp

function currentUsdValue(uint256 loanId) external view 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) external view 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

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;
}