Skip to main content

IGenericClearinghouse

Git Source

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

NameTypeDescription
cooler_ICoolerThe Cooler instance to lend to.
amount_uint256The amount of debt token to lend.

Returns

NameTypeDescription
loanIduint256The id of the granted loan.

extendLoan

Extend the loan duration.

function extendLoan(ICooler cooler_, uint256 loanId_, uint8 times_) external;

Parameters

NameTypeDescription
cooler_ICoolerThe Cooler instance to extend the loan for.
loanId_uint256The id of the loan to extend.
times_uint8The 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

NameTypeDescription
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

NameTypeDescription
principal_uint256The amount of debt tokens to compute collateral for.

Returns

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

NameTypeDescription
collateral_uint256The amount of collateral tokens to compute the loan for.

Returns

NameTypeDescription
principaluint256The amount of debt tokens for the loan.
interestuint256The 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

NameTypeDescription
principal_uint256The amount of reserve being lent.
duration_uint256The elapsed time in seconds.

Returns

NameTypeDescription
interestuint256The 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);