Market
market
marketThe market directories deals with interfaces, implementations, libraries and facets that implement the creation of loans, collateral escrows and the repayment of loans.
collateral
collateralThe
collateraldirectory 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
librariesThe 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.
LibCollateralcontains functions that interact with theICollateralEscrowLibConsensuscontains 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
LibLoanscontains 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
facetsAll the facets are available in the root directory. They are the CollateralFacet, CreateLoanFacet, LoanDataFacet, RepayFacet and the SignersFacet.
CollateralFacetinterfaces directly with theLibCollateralto deposit, add, get and withdraw collaterals.LibLoansis also used to help with some functionsCreateLoanFacetconnects to multiple libraries to help:createLoanWithTerms()create a loantakeOutLoan()take out a loantakeOutLoanWithNFTs()take out a loan with an NFTIt also contains a
CreateLoanLibthat:initLoan()initializes a loancreateEscrow()creates a loan escrowverifyCreateLoan()verify a newly created loan
LoanDataFacetcontains 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
RepayFacetcontains 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
RepayLibthat 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
SignersFacetsimply adds signers and checks if a signer is part of a list of signers in an asset
Last updated
Was this helpful?