-
Notifications
You must be signed in to change notification settings - Fork 63
Add Loan Extension & Modification to Borrowing Contract #502
Copy link
Copy link
Open
Description
Component: Contracts (Borrowing) | Effort: 3-4 days | Priority: MEDIUM
Current State
Loans have fixed terms with no modification options.
Missing Functions
Loan modification functions:
extend_loan()- Extend loan due dateincrease_loan_amount()- Borrow more against same collateralmodify_loan_terms()- Change interest rate or termsget_extension_fee()- Calculate extension feeget_max_additional_borrow()- Calculate max additional borrow
Why This Matters
- Flexibility: Borrowers need time extensions
- Growth: Increase loan as collateral appreciates
- User retention: Avoid forcing loan closure
- Revenue: Extension fees generate income
Tasks
- Implement
extend_loan()function- Validate loan exists and active
- Calculate extension fee (e.g., 1% of principal)
- Update due date
- Collect fee
- Emit LoanExtended event
- Add
increase_loan_amount()function- Validate health factor allows more borrowing
- Calculate max additional amount
- Update loan principal
- Transfer additional funds
- Emit LoanIncreased event
- Implement
get_extension_fee()calculation - Add
get_max_additional_borrow()view - Add extension limits (max 2 extensions per loan)
- Track extension count per loan
- Add tests for loan modifications
- Document modification rules
Acceptance Criteria
- Loans can be extended with fee
- Additional borrowing works correctly
- Health factor validated on increases
- Extension limits enforced
- Tests cover modification scenarios
- Documentation complete
Reactions are currently unavailable