IGenericClearinghouse
Functions
debtToken
The debt token of the clearinghouse.
function debtToken() external view returns (IERC20);
collateralToken
The collateral token of the clearinghouse.
function collateralToken() external view returns (IERC20);
duration
The duration of the loan.
function duration() external view returns (uint48);
interestRate
The interest rate of the loan. Stored as a percentage, in terms of 1e18.
function interestRate() external view returns (uint256);
loanToCollateral
The ratio of debt tokens to collateral tokens.
function loanToCollateral() external view returns (uint256);
maxRewardPerLoan
The maximum reward (in collateral tokens) per loan.
function maxRewardPerLoan() external view returns (uint256);
lendToCooler
Lend to a cooler.
function lendToCooler(ICooler cooler_, uint256 amount_) external returns (uint256 loanId);
Parameters
| Name | Type | Description |
|---|---|---|
cooler_ | ICooler | The Cooler instance to lend to. |
amount_ | uint256 | The amount of debt token to lend. |
Returns
| Name | Type | Description |
|---|---|---|
loanId | uint256 | The id of the granted loan. |
extendLoan
Extend the loan duration.
function extendLoan(ICooler cooler_, uint256 loanId_, uint8 times_) external;
Parameters
| Name | Type | Description |
|---|---|---|
cooler_ | ICooler | The Cooler instance to extend the loan for. |
loanId_ | uint256 | The id of the loan to extend. |
times_ | uint8 | The number of times to extend the loan. |
claimDefaulted
Batch several default claims to save gas. The elements on both arrays must be paired based on their index.
Implements an auction style reward system that linearly increases up to a max reward.
function claimDefaulted(address[] calldata coolers_, uint256[] calldata loans_) external;
Parameters
| Name | Type | Description |
|---|---|---|
coolers_ | address[] | Array of contracts where the default must be claimed. |
loans_ | uint256[] | Array of defaulted loan ids. |
getCollateralForLoan
View function computing collateral for a loan amount.
function getCollateralForLoan(uint256 principal_) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
principal_ | uint256 | The amount of debt tokens to compute collateral for. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | collateral_ The amount of collateral tokens required for the loan. |
getLoanForCollateral
View function computing loan for a collateral amount.
function getLoanForCollateral(uint256 collateral_) external view returns (uint256 principal, uint256 interest);
Parameters
| Name | Type | Description |
|---|---|---|
collateral_ | uint256 | The amount of collateral tokens to compute the loan for. |
Returns
| Name | Type | Description |
|---|---|---|
principal | uint256 | The amount of debt tokens for the loan. |
interest | uint256 | The amount of interest tokens for the loan. |
interestForLoan
View function to compute the interest for given principal amount.
function interestForLoan(uint256 principal_, uint256 duration_) external view returns (uint256 interest);
Parameters
| Name | Type | Description |
|---|---|---|
principal_ | uint256 | The amount of reserve being lent. |
duration_ | uint256 | The elapsed time in seconds. |
Returns
| Name | Type | Description |
|---|---|---|
interest | uint256 | The amount of interest for the loan. |
principalReceivables
The amount of principal receivables.
function principalReceivables() external view returns (uint256);
interestReceivables
The amount of interest receivables.
function interestReceivables() external view returns (uint256);
getTotalReceivables
Get total receivable reserve for the treasury. Includes both principal and interest.
function getTotalReceivables() external view returns (uint256);
Events
YieldSwept
event YieldSwept(address indexed to, uint256 amount);
InterestRateSet
event InterestRateSet(uint256 interestRate);
MaxRewardPerLoanSet
event MaxRewardPerLoanSet(uint256 maxRewardPerLoan);
LoanToCollateralSet
event LoanToCollateralSet(uint256 loanToCollateral);
DurationSet
event DurationSet(uint48 duration);
Errors
BadEscrow
error BadEscrow();
DurationMaximum
error DurationMaximum();
OnlyBurnable
error OnlyBurnable();
TooEarlyToFund
error TooEarlyToFund();
LengthDiscrepancy
error LengthDiscrepancy();
OnlyBorrower
error OnlyBorrower();
NotLender
error NotLender();
InvalidParams
error InvalidParams(string reason);