Loans
Loan is the agreement between the Lender and the Borrower. A Loan in MethLab is a smart-contract that is created when a borrower's intent is matched with lender's Intent. Borrowers choose from the collection of available Vaults and the Intent Collections in the listed Vaults.
Each Loan contract contains:
struct LoanData {
address borrower;
address lenderVault;
address collToken;
address borrowToken;
uint256 collAmt;
uint256 borrowAmt;
uint256 repaidAmt;
uint256 expiresAt;
}
How is a Loan created?
Just like a Vault, MethLab uses minimal proxy clones to create Loans. Borrowers choose Lender Vault(s) that are compataible with their terms and create a Loan contract.
// LendersVault.sol
function createLoan(
DataTypes.BorrowParams calldata bParams,
bytes calldata data
) external whenNotPaused nonReentrant returns (address loanContract)
The createLoan
function is available in the LenderVault.sol. This calculates the parameters associated with the loans and internally calls the deployLoan
function of Factory.sol to create a Loan.sol contract. If there's not enough liquidity to fulfil a particular borrower's intents, a loan may still be created using multiple Vaults.
Borrowers do not have to worry about liquidity and getting the best terms. The Maching Filter handles such cases and the Borrowers would only need to make a single transaction to create multiple Loans together.
Loan Executor
LoanExecutor solves for fragmented liquidity. It is a periphery contract that contains the logic to create multiple loans in a single transaction. If there's not enough liqudity, or if the borrower wants to intentionally create loans using various vaults, they can do so using the executeLoans
available in the LoanExecutor.
LoanExecutor also contains the logic for repayLoan
. This function allow borrowers to repay a loan using leverage. LoanExecutor allows to -
- Create multiple loans
- Create loans using leverage
- Repay loan using leverage
Learn about the various LoanExecutor functions here.