Market
market
market
The market directories deals with interfaces, implementations, libraries and facets that implement the creation of loans, collateral escrows and the repayment of loans.
collateral
collateral
The
collateral
directory contains the interface and implementation of the collateral escrowFunctions include
init()
initializing the collateral escrowdeposit()
depositing collateral tokenswithdraw()
withdrawing collateral tokensloanSupply()
returning the loan supply of collateraltotalSupply()
returning the total supply of the collateral
The above functions are all included in
ICollateralEscrow
libraries
libraries
The libraries directory contains files that implement logic for the Facets to use. This logic relates to functionalities to interface with collateral escrows, loans and the processing of loans.
LibCollateral
contains functions that interact with theICollateralEscrow
LibConsensus
contains one function to process loan termsprocessLoanTerms()
and abstracted functions like_getConsensus()
,_getChainId()
andvalidateLoanRequest()
to help with processing the loan termsTo satisfy the Teller consensus of validating a loan, it is required that the ratio of responses to signers is greater than the percentage of required submissions
Each response after iteration is subjected to multiple checks to see if it's got the correct signer, asset address, correct signature and unexpired response time
When the response is processed correctly, then interest rate, collateral ratio and max loan amount is added to the loan terms. The values are then averaged out with a tolerance value supported by the consensus
LibLoans
contains functions that deal with pulling information from respective loansYou can get how much loan is owed, percentage of interest for a loan, ratio of interest and the amount needed in collateral
facets
facets
All the facets are available in the root directory. They are the CollateralFacet
, CreateLoanFacet
, LoanDataFacet
, RepayFacet
and the SignersFacet
.
CollateralFacet
interfaces directly with theLibCollateral
to deposit, add, get and withdraw collaterals.LibLoans
is also used to help with some functionsCreateLoanFacet
connects to multiple libraries to help:createLoanWithTerms()
create a loantakeOutLoan()
take out a loantakeOutLoanWithNFTs()
take out a loan with an NFTIt also contains a
CreateLoanLib
that:initLoan()
initializes a loancreateEscrow()
creates a loan escrowverifyCreateLoan()
verify a newly created loan
LoanDataFacet
contains functions that deals with pulling out data from both loans and loan escrows. Data includes :getLoanTerms()
loan termsgetBorrowerLoans()
borrower loansgetDebtOwed()
debt owedgetInterestOwed()
interest owedgetCollateralNeededInfo()
collateral needed
RepayFacet
contains functions that deal with both the repaying and the liquidation of loans given that a user wants to pay a little bit or a loan is undercollateralized (or expired), respectively. Functions include:escrowRepay()
repaying the loan with the respective escrowrepayLoan()
repaying the loan from a regular addressliquidateLoan()
liquidate a loan and payout the liquidatorThere's also a library
RepayLib
that stores other functions likeclaimEscrowTokens()
which claims escrow tokens to the liquidator after a loan failsgetLiquidationReward()
gets collateral value and reward amount for the liquidatorpayOutLiquidator()
checks if loan has an escrow and then claims any tokens before paying out the loan collateral
SignersFacet
simply adds signers and checks if a signer is part of a list of signers in an asset
Last updated