ILoanManager
Inherits: ILoanManagerBase
Author: bull.haus
Manages all loans.
Functions
createLoan
Create loan, mint corresponding LoaNFT.
Maximum 10 loans per asset per user address.
Provided collateral assets are locked within the borrower's deposit, they are not transferred to the lender.
function createLoan(LoanInfoUser calldata config, CollateralAssets calldata collateralAssets) external;
Parameters
Name | Type | Description |
---|---|---|
config | LoanInfoUser | loan parameters |
collateralAssets | CollateralAssets | provided collateral and chosen asset configuration |
pay
Pay back loan interest and/or principal.
Can be paid on behalf of another user.
Does not refund when too much interest is paid.
All interest payments go to the current holder of the corresponding LoaNFT.
Paid interest is taken from payee's unlocked deposit, and added to LoaNFT holder's unlocked deposit.
function pay(uint256 loanId, uint256[] calldata interestAssetAmount, uint256 principalAmount) external;
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | loan id to pay interest for |
interestAssetAmount | uint256[] | amount of each asset to pay interest with |
principalAmount | uint256 | amount of principal to pay |
liquidate
Liquidate a loan.
function liquidate(uint256 loanId) external;
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | loan id to liquidate. |
setCollateral
Update collateral.
Collateral value should be at least the minimum collateral + safety buffer.
Collateral values are absolute numbers, values lower than the previously configured collateral result in unlocking of those assets.
Provided collateral assets are locked within the borrower's deposit, they are not transferred to the lender.
function setCollateral(uint256 loanId, uint256[] calldata assetAmount) external;
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | loan id to update collateral for |
assetAmount | uint256[] | provided collateral amounts |
Events
LoanCreated
Emitted when a loan is created.
event LoanCreated(uint256 configId, uint256 loanId);
LoanEvent
Emitted when an action is performed on a loan.
Actions are defined in LoanAction
: interest paid, loan paid off, liquidated, collateral updated.
event LoanEvent(uint256 loanId, LoanAction action);
Errors
AssetUsageNotAllowed
When setting collateral or paying interest with assets not allowed per loan config, the transaction is
reverted with AssetUsageNotAllowed
.
error AssetUsageNotAllowed(uint256 check);
CannotLiquidate
When liquidating a loan that cannot be liquidated, the transaction is reverted with CannotLiquidate
.
Check the liquidate
method for details on the check
value.
error CannotLiquidate(uint256 check);
LoanError
Loan with invalid parameters reverts with LoanError
.
Check the methods returning this error for details on the check
value.
error LoanError(uint256 check);
PrincipalTooLow
Reducing principal to a lower percentage of the initial principal, than the percentage of interest paid,
is reverted with PrincipalTooLow
.
error PrincipalTooLow();
Enums
LoanAction
Type of action being performed on a loan, used in events.
NoAction
0-value for invalid actions.
InterestPaid
An interest payment has been done. This does not imply that the interest has been paid
fully, or according to the loan plan.
PrincipalPaid
A principal payment has been done. This does not imply that the principal has been paid
fully, or according to the loan plan.
CollateralUpdated
The collateral for a loan has been updated.
Liquidated
A loan has been liquidated.
Closed
A loan has been closed; all fees, interest and collateral has been paid, the LoaNFT shares have
been deleted.
enum LoanAction {
NoAction,
InterestPaid,
PrincipalPaid,
CollateralUpdated,
Liquidated,
Closed
}