Chelo Finance
Published in

Chelo Finance

Chelo: the tech guide (1)

Collateralized Loans

How ?

The Collateral Loan smart contract

/// @inheritdoc ILoanManager
function createLoanWithCollateral(
uint256 principal,
uint256 repayment,
uint256 duration,
uint256 collateralId,
uint256 poolId,
address borrower
) external onlyOwner returns (LoanMetadata memory loanData) {
ILendingPool pool = _pools[poolId];
loanData = LoanMetadata(
LoanStatus.Issued,
pool,
true,
collateralId,
principal,
repayment,
0,
duration,
block.timestamp + duration,
borrower
);
assetWrapper.transferFrom(borrower, address(this), collateralId);
_createLoan(loanData, pool);
}

The Mini DAO

The user interface

In the gitbook below we explain how to use the front end we have developed — we strongly suggest that you read the guide from the link as it might change slightly from time to time.

In case of default

In case of default the Mini DAO Needs to call the function markLoanAsDefaulted(ILendingPool pool, uint256 loanId) from our LoanManager.

/// @inheritdoc ILoanManager
function markLoanAsDefaulted(ILendingPool pool, uint256 loanId) external onlyOwner {
LoanMetadata memory loan = _loans[pool][loanId];
require(loan.status != LoanStatus.Repaid, “LoanManager: Loan already repaid”);
require(loan.repaymentDate <= block.timestamp, “LoanManager: Loan timestamp is not finished”);
_setLoanStatus(pool, loanId, LoanStatus.Defaulted);
if (loan.hasCollateral) {
assetWrapper.safeTransferFrom(address(this), owner(), loan.collateralId);
}
}

Loan repayment after default

Contracts:

API: https://github.com/chelofinance/chelo_treasury/tree/prototype/lending/docs (private repository — contact us for access)

--

--

We develop ready-to-deploy tools that help DAOs attract, retain, and support their community.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store