Skip to content
Lucas Manuel edited this page Dec 20, 2021 · 1 revision

Loans in the Maple protocol are created by Borrowers and are used to facilitate the following:

  • Defining Loan terms
    • APR
    • Term Length
    • Payment Interval Length
    • Requested Loan Amount
    • Requested Loan Denomination
    • Collateral Ratio
    • Collateral Denomination
  • Receiving capital from lenders
  • Drawing down on funded Loan
  • Making interest payments
  • Performing liquidations of collateral (if a loan defaults)

Loan Creation

Loans are instantiated from LoanFactory contracts, which are whitelisted in MapleGlobals to ensure that only certain type of Loan contracts are used in the Maple protocol. Upon instantiation:

  • The terms of the loan are defined.
  • The payment calculators are specified (Used to calculate interest payments, late fees, and premium fees). These are whitelisted in MapleGlobals to ensure no malicious payment calculators are used.
  • The FundingLockerFactory and CollateralLockerFactory are specified, which are also whitelisted for the same reason as the LoanFactory.
  • The Loan is set to Ready status

Loan Funding

Once a Loan is instantiated, only Pools instantiated from allowlisted PoolFactory contracts can fund it, and Loans can have multiple Pools fund their loan. In this stage, Pools lend funds to a Loan by calling fundLoan. This moves capital into the FundingLocker and mints LoanFDTs to the Pool (held custody in a DebtLocker). LoanFDTs are tokens that represent a claim on the principal of the loan plus any interest that gets generated. In order for a Loan to be funded, it must be in the Ready state.

Loan Drawdown

Once the requested amount of funds have been raised for a given Loan, the Borrower can drawdown against it. They can drawdown any amount that is both above the requested Loan amount, and below the current balance of the FundingLocker. When the Borrower calls drawdown, the following happens:

  • Loan state is set from Ready to Active
  • The required amount of collateral (according to Chainlink oracle prices) that is needed to meet the collateralRatio at the time of drawdown is calculated and then transferred from the Borrower to the CollateralLocker
  • The treasury fee is paid to MapleTreasury, a percentage of the drawdown amount. This is sent from FundingLocker to the MapleTreasury
  • The investor fee is paid to the lenders, a percentage of the drawdown amount. This is sent from the FundingLocker to the Loan, to be claimed by lenders.
  • The drawdown amount minus fees is transferred to the Borrower.
  • Any excess funds from lenders that were not drawn down are sent from the FundingLocker to the Loan, to be claimed by lenders.

Loan Payments

Currently the Maple protocol is only supporting interest-only loan structures, where interest is paid in constant amounts at regular intervals, and principal is returned on the last payment.

There are three payment calculators that are used in Maple:

  • RepaymentCalc: Calculates due interest, and adds the principal if it's the last payment.
  • LateFeeCalc: Calculates late fees as a flat percentage of interest calculated by the RepaymentCalc.
  • PremiumCalc: Calculates a flat interest amount against the total principal when entire remaining Loan amount is paid back at once.

In order to make payments on Loans, borrowers can choose to either call makePayment or makeFullPayment. makeFullPayment pays the remaining balance of the loan in one transaction including principal, using the PremiumCalc to calculate the amount of interest that should be paid. makePayment uses RepaymentCalc and LateFeeCalc if necessary to calculate the amount of interest that should be paid.

Payments on Maple are time-based, meaning that Borrowers will have different outcomes if they wait for different amounts of time to make a payment. The diagram below outlines the three scenarios Borrowers can face when making payments at different time intervals.

Liquidations

Liquidations can occur when the Borrower does not pay back the Loan after the Grace Period has passed. Once this amount of time has passed, the Loan is considered to be in default. When a Loan is in default, triggerDefault becomes callable. This function is only callable by Pool Delegates for Pools that have funded the loan for more than the minLoanEquity (Globals parameter). In an example where three pools fund a Loan, one for $1m, the second for $2m and the third for $7m, the pools have 10%, 20%, and 70% loan equity respectively. In the case where minLoanEquity is set to 20%, only the second two Pools would have permissions to trigger the default on the Loan. This allows for the larger equity funders to have time to manually coordinate with the Borrower and see if they can still make the payment and save themselves from default.

triggerDefault takes all of the collateral in the CollateralLocker, and uses Uniswap to convert it into the asset that was used by the lenders to fund the Loan. The liquidated amount sits in the Loan contract, allowing LoanFDT holders to claim their portions of it. If the amount liquidated is more than the principal owed on the Loan, the difference is returned to the Borrower. The slippage amount allowed for the trade is determined by a globals parameter maxSwapSlippage. It is understood that due to the large amount of collateral that will be swapped there is the possibility for high slippage. PoolDelegates are trusted actors in the Maple protocol and are assumed to not make any flashloan AMM attacks during liquidation. In addition, this liquidation mechanism will be improved in subsequent Loan contracts post-launch (will likely move to an auction based system).