Architecture
Introduction
MethLab is a liquidation-free lending/borrowing protocol.
Core Components
MethLab is based on creation of Intents. Intents consist of the terms that lenders/borrowers create to lend/borrow using the protocol. To create a collection of intents, a lender must create a Vault: Lenders Vault.
Lenders can create a Vault using the Factory contract. The MethLab Factory has abstracted a deployVault
function to create Vault clones. Once a Vault is deployed, the lender becomes the owner of the Vault. They can deposit assets, write intents, modify intents, invalidate an intent etc.
A borrower can go through the list of various intents and vaults created by lenders. MethLab uses - a Filter to match borrowers with their intended lending terms. The final step is borrower creating the Loan contract. Loans are created when borrowers call the createLoan
function on the particular vault.
All the vaults and loans are whitelisted in the Registry smart contract.
Borrowers can also create loans using leverage. MethLab allows leverage by taking a flash-swap from the Lender Vaults. The swap is used to create or repay the position respectively.
What is LoanExecutor?
LoanExecutor smart contract that allows borrowers to create multiple loans using different intents. The main idea behind LoanExecutor is to solve fragmented liquidity. A single vault may not have enough liquidity to let borrowers create a loan according to their own intents. More on this can be found here.
The collateral token deposited by the borrower is locked in the Loan contract. The borrower must repay the loan amount with the specified interest to get the hold of the deposited collateral. Borrowers can call the repay
on the Loan contract to do the same.
If the borrower is not able to repay the loan before the expiration, the lender or anyone can liquidate the collateral. The collateral is sent to the LendersVault for the lender to withdraw.
Core Tenets of MethLab
MethLab is based upon the following:
Intent Space
The collection of all intents created by Lender that are available to be matched with the borrowers. Learn more here.
Lenders Vault
Vault is created by lenders to deposit their assets and make intents. Intents are written onto the Vault itself. Learn about the vault here.
Loan
Loan contract is the agreement between the lender and the borrower. Borrowers may deploy loans directly using the lender's vault. Learn more here.
Matching Filter
A matching-filter simply matches the intents from the intent space for the borrowers. Borrowers can choose from the filtered intents and create a loan using the vaults.
Leverage
Leverage works by taking a flash-swap from the lender vault. The vault liquidity is swapped to collateral asset to create a loan. And vice versa during loan repayment. Learn more about leverage here.