LineOfCredit.sol

Core functions and methods of LineOfCredit.sol

LineOfCredit.sol is the core contract responsible for:

  • Recording credit lines, positions and accounting for Borrowers and Lenders

  • Defining Line of Credit terms (Oracle, Arbiter, Borrower, loan duration, interest rate, escrow and spigot collateral)

  • Coordinating the Escrow, Spigot, and InterestRateCredit modules

  • External calls to Oracle.sol and InterestRateCredit.sol

  • Libraries - LineLib.sol, CreditLib.sol, CreditListLib.sol

External functions
function init() external virtual returns(LineLib.STATUS)
function addCredit(uint128 drate,uint128 frate,uint256 amount,address token,address lender) external payable override nonReentrant whileActive mutualConsent(lender, borrower) returns (bytes32)
function borrow(bytes32 id, uint256 amount) external override nonReentrant whileActive onlyBorrower returns (bool)
function accrueInterest() external override returns(bool)
function counts() external view returns (uint256, uint256)
function healthcheck() external returns (LineLib.STATUS)
function increaseCredit(bytes32 id, uint256 amount) external payable override nonReentrant whileActive mutualConsentById(id)returns (bool) 
function setRates(bytes32 id,uint128 drate,uint128 frate) external override mutualConsentById(id) returns (bool)
function updateOutstandingDebt() external override returns (uint256, uint256)
function withdraw(bytes32 id, uint256 amount) external override nonReentrant returns (bool)
function depositAndRepay(uint256 amount )external payable override nonReentrant whileBorrowing returns (bool)
function declareInsolvent() external returns (bool)
function depositAndClose() external payable override nonReentrant whileBorrowing onlyBorrower returns (bool)
function close(bytes32 id) external payable override nonReentrant onlyBorrower returns (bool)
Methods

function init(): tests that any collateral facility is set up as expected, pointing to the correct address for the Line of Credit. If so, status changes to 'active'.

function addCredit(): a Lender deposits for the first time to an active Line of Credit

function borrow(): a Borrower draws down from an available credit position

function accrueInterest(): updates the amount of Interest Accrued that the Borrower owes

function counts(): returns the number of active credit positions within a Line of Credit and the number of credit positions irrespective of status

function healthcheck(): returns the status of the Line of Credit

function increaseCredit(): an existing Lender deposits additional capital

function setRates(): updates the Drawn Rate and the Facility Rate for a credit position

function updateOutstandingDebt(): returns total Borrower debt across all Lenders

function withdraw(): a Lender withdraws principal and accrued interest

function depositAndRepay(): anyone can deposit funds to repay a Lender

function declareInsolvent(): Arbiter signifies that a Borrower is incapable of repaying debt permanently (used for secured lending)

function depositAndClose(): Borrower deposits enough Credit Tokens to repay and close a credit position

function close(): deletes a credit position that has already been fully repaid

Last updated

Was this helpful?