-
Notifications
You must be signed in to change notification settings - Fork 19
Loan Creation
Lucas Manuel edited this page Dec 20, 2021
·
6 revisions
Creating a Loan in Maple requires the following transactions (assuming that the Maple protocol is in a fresh, newly deployed state).
- Deploy LoanFactory
- Deploy CollateralLockerFactory
- Deploy FundingLockerFactory
- Deploy RepaymentCalc
- Deploy LateFeeCalc
- Deploy PremiumCalc
-
globals.setValidLoanFactory(address(loanFactory), true);
- Validate LoanFactory -
globals.setValidSubFactory(address(loanFactory), address(clFactory), true);
- Validate CollateralLockerFactory -
globals.setValidSubFactory(address(loanFactory), address(flFactory), true);
- Validate FundingLockerFactory -
globals.setCalc(address(repaymentCalc), true);
- Validate RepaymentCalc -
globals.setCalc(address(lateFeeCalc), true);
- Validate LateFeeCalc -
globals.setCalc(address(premiumCalc), true);
- Validate PremiumCalc -
globals.setPriceOracle(WETH, address(wethOracle));
- Set collateralAsset oracle (example: WETH collateral) -
globals.setPriceOracle(USDC, address(usdcOracle));
- Set liquidityAsset oracle (example: USDC liquidityAsset) -
globals.setCollateralAsset(WETH, true);
- Validate WETH as a collateralAsset -
globals.setLiquidityAsset(USDC, true);
- Validate USDC as a liquidityAsset
- Create a Loan from the LoanFactory:
function createLoan(
address liquidityAsset,
address collateralAsset,
address flFactory,
address clFactory,
uint256[5] memory specs,
address[3] memory calcs
)
The calcs array should be set to [RepaymentCalc, LateFeeCalc, PremiumCalc]
The specs array should be as follows:
specs[0] = apr (basis points)
specs[1] = termDays
specs[2] = paymentIntervalDays
specs[3] = requestAmount (denominated in liquidityAsset precision)
specs[4] = collateralRatio (basis points)
For example:
uint256[5] memory specs = [500, 180, 30, 1000 * 10 ** 6, 2000];
address[3] memory calcs = [address(repaymentCalc), address(lateFeeCalc), address(premiumCalc)];
Loan loan = loanFactory.createLoan(address(USDC, WETH, address(flFactory), address(clFactory), specs, calcs);
This would create a Loan with:
- 5% APR
- 180 day term length
- 30 day interest payment intervals
- 1000 USDC requested amount
- 20% collateralized with WETH