Skip to content

Add Loan Extension & Modification to Borrowing Contract #502

@ONEONUORA

Description

@ONEONUORA

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 date
  • increase_loan_amount() - Borrow more against same collateral
  • modify_loan_terms() - Change interest rate or terms
  • get_extension_fee() - Calculate extension fee
  • get_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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions