Problem
repay_installment() in creditline-contract (lib.rs:755-813) marks
installments paid and decrements remaining_balance, but it never moves
any tokens and never calls the liquidity pool. Compare repay_loan()
(lib.rs:701-704) which correctly calls
lp_client.receive_repayment(principal, interest) and transfers USDC.
As a result a borrower can drive a loan all the way to LoanStatus::Paid
through installments without any USDC ever leaving their wallet, and
LPs earn zero yield on the installment repayment path. This is a
critical accounting and value-loss bug in the primary repayment flow.
Before Starting
Read ALL of these before writing any code:
- context/architecture-context.md
- context/code-standards.md
- context/progress-tracker.md
What To Build
Make repay_installment() a real settlement operation, symmetric with
repay_loan():
- Pull the installment
amount in USDC from the borrower into the
contract (token transfer with require_auth).
- Split the paid amount into principal vs interest (see the
repayment-waterfall issue) and forward it to the pool via
LiquidityPoolContractClient::receive_repayment(principal, interest)
so locked_liquidity is reduced and interest raises share price.
- Only transition to
LoanStatus::Paid once real funds have settled.
- Keep all state effects before external calls (checks-effects-interactions)
and inside the existing non-reentrant guard.
Files To Touch
- contracts/creditline-contract/src/lib.rs (
repay_installment)
- contracts/creditline-contract/src/tests.rs
Acceptance Criteria
Mandatory Checks Before Opening PR
Problem
repay_installment()increditline-contract(lib.rs:755-813) marksinstallments paid and decrements
remaining_balance, but it never movesany tokens and never calls the liquidity pool. Compare
repay_loan()(lib.rs:701-704) which correctly calls
lp_client.receive_repayment(principal, interest)and transfers USDC.As a result a borrower can drive a loan all the way to
LoanStatus::Paidthrough installments without any USDC ever leaving their wallet, and
LPs earn zero yield on the installment repayment path. This is a
critical accounting and value-loss bug in the primary repayment flow.
Before Starting
Read ALL of these before writing any code:
What To Build
Make
repay_installment()a real settlement operation, symmetric withrepay_loan():amountin USDC from the borrower into thecontract (token transfer with
require_auth).repayment-waterfall issue) and forward it to the pool via
LiquidityPoolContractClient::receive_repayment(principal, interest)so
locked_liquidityis reduced and interest raises share price.LoanStatus::Paidonce real funds have settled.and inside the existing non-reentrant guard.
Files To Touch
repay_installment)Acceptance Criteria
repay_installment()transfers USDC from borrower to contractreceive_repaymentlocked_liquiditydecreases by the principal repaidPaidonly after funds settle on-chainMandatory Checks Before Opening PR