Skip to content

core: implement interest accrual calculation on-chain #14

@EmeditWeb

Description

@EmeditWeb

Problem

Interest rate calculation currently happens off-chain
in the API. This means the API can charge any interest
rate regardless of what the parameters and reputation
contracts say.

What To Build

  1. On-chain interest calculation in create_loan()
  2. Store monthly_payment, interest_rate_bps, total_repayment
  3. Update repay_installment() to use stored values

Files To Touch

  • contracts/creditline-contract/src/lib.rs
  • contracts/creditline-contract/src/types.rs
  • contracts/creditline-contract/src/tests.rs

Acceptance Criteria

  • Interest calculated from on-chain reputation score
  • Correct rate applied per tier
  • monthly_payment stored in loan on creation
  • repay_installment uses stored monthly_payment
  • Tests cover all 4 reputation tiers

Mandatory Checks Before PR

  • cargo build passes
  • All tests pass
  • PR references this issue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions