feat(SC-17): implement and test interest distribution in Liquidity Pool#80
Merged
Josue19-08 merged 4 commits intoJun 23, 2026
Merged
Conversation
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.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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)#[allow(dead_code)]toMERCHANT_FEE_BPSconstant — the merchant amount is computed as a remainder to avoid rounding dust, so the BPS constant serves as documentation onlydistribute_interestpublic entrypoint across three areas:LQINTDSTevent 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 faileddistribute_interest()function callable by admin/creditline ✅total_liquiditygrows) ✅InterestDistributedevent emitted with full payload ✅Closes #72