Skip to content

feat(SC-17): implement and test interest distribution in Liquidity Pool#80

Merged
Josue19-08 merged 4 commits into
TrustUp-app:mainfrom
akintewe:feat/72-interest-distribution-sc17
Jun 23, 2026
Merged

feat(SC-17): implement and test interest distribution in Liquidity Pool#80
Josue19-08 merged 4 commits into
TrustUp-app:mainfrom
akintewe:feat/72-interest-distribution-sc17

Conversation

@akintewe

Copy link
Copy Markdown
Contributor

Summary

  • Implements the distribute_interest() public entrypoint that can be called directly by the admin or the CreditLine contract, routing interest to the fee-split logic (85% LP / 10% protocol / 5% merchant)
  • Adds #[allow(dead_code)] to MERCHANT_FEE_BPS constant — the merchant amount is computed as a remainder to avoid rounding dust, so the BPS constant serves as documentation only
  • Adds 13 new tests covering the distribute_interest public entrypoint across three areas:
    • Access control: admin authorized, creditline authorized, unauthorized caller rejected, zero/negative amounts rejected, paused contract rejected
    • Fee split & LP accounting: LP portion stays in the pool (no transfer), share price increases correctly, multiple calls compound linearly, proportional benefit across multiple LPs
    • Event emission: LQINTDST event emitted with correct (total, lp, protocol, merchant) payload; rounding remainder goes to merchant fund (no dust lost)

Test plan

  • cargo test --locked -p liquidity-pool-contract — 98 tests pass, 0 failed
  • All 4 original SC-17 tasks from the issue are covered:
    • distribute_interest() function callable by admin/creditline ✅
    • Interest from repayments increases share value (total_liquidity grows) ✅
    • Fee distribution: 85% LP / 10% protocol / 5% merchant ✅
    • InterestDistributed event emitted with full payload ✅

Closes #72

akintewe added 4 commits June 21, 2026 19:37
Merchant fee is computed as a remainder (interest - lp - protocol) to
avoid rounding dust, so MERCHANT_FEE_BPS is never used in arithmetic.
Added allow(dead_code) to keep the constant as documentation of the
intended 5% split.
…entrypoint

Covers the public distribute_interest() function that can be called
directly by admin or creditline, verifying correct 85/10/5 fee split,
authorization guards (NotCreditLine for strangers, ContractPaused when
paused), and input validation (zero/negative amounts).
…nterest

Verifies that the LP portion (85%) of distributed interest stays in the
pool (no token transfer occurs), share price increases correctly after
each distribution, multiple sequential distributions compound linearly,
and interest benefits all LPs proportionally by share count.
…e case

Verifies that distribute_interest() emits the LQINTDST event with the
correct four-field payload (total, lp, protocol, merchant amounts), and
that rounding remainder goes to the merchant fund so no dust is lost.
@Josue19-08
Josue19-08 merged commit b3dccad into TrustUp-app:main Jun 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] SC-17: Implement interest distribution in Liquidity Pool

2 participants