Conversation
|
@CathyZaks Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
… pairs - Implement LpRewardContract with proportional pool share tracking and accumulator-based fee distribution - Add add_liquidity, remove_liquidity, claim_lp_rewards, and get_lp_position entrypoints - Expose LP reward management functions on CreatorKeysContract - Emit LPAdded and LPRewardClaimed contract events - Add comprehensive test suites verifying proportional share computation and fee accruals
CathyZaks
force-pushed
the
fix/issue-1002-lp-reward-contract
branch
from
September 27, 2026 17:34
0615ff5 to
fd7b035
Compare
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.
Header
Liquidity Provider Reward Contract for Key Pairs
Problem
Liquidity providers on key pairs currently lack a dedicated reward mechanism to lock tokens as liquidity, earn a proportional share of trading fees generated by pair trading activity, and claim accumulated fee rewards or withdraw liquidity with their accrued yield.
Solution
Implemented a dedicated
LpRewardContractcrate (and integrated equivalent entrypoints intoCreatorKeysContract) using high-precision accumulator accounting (SCALE = 1e12) and basis-point proportional share calculations (BPS_SCALE = 10_000):add_liquidity(key_id, amount)/add_liquidity_for(caller, key_id, amount): Locks tokens, calculates proportional pool share in basis points, records the position, and emits anLPAddedevent.remove_liquidity(lp_id): Computes accrued fee rewards plus principal, updates pool totals, clears the position, and emits anLPRemovedevent.claim_lp_rewards(lp_id): Claims pending accrued fee rewards without removing principal liquidity and emits anLPRewardClaimedevent.get_lp_position(lp_id): Returns contribution amount, basis-point pool share, and current pending reward amount.accrue_trading_fee(key_id, fee_amount): Accrues trading volume fees into the key pool reward accumulator for proportional distribution across all active liquidity providers.Changes
lp-reward-contract/Cargo.toml: Created workspace member crate with Soroban SDK dependencies and test utilities.lp-reward-contract/src/lib.rs: CoreLpRewardContractimplementation with data structures, error handling, events, and accumulator fee distribution.lp-reward-contract/src/test.rs: Unit test suite covering proportional shares, fee accrual over trading volume, reward claiming, liquidity removal, event emission, and parameter validation.Cargo.toml: Added"lp-reward-contract"to workspace members.creator-keys/src/lp_reward.rs: Matching module for LP reward tracking in the corecreator-keyscontract.creator-keys/src/lib.rs: Exposed LP reward entrypoints onCreatorKeysContract.creator-keys/src/test_lp_reward.rs: Integration tests verifying client invocations and fee distributions onCreatorKeysContract..gitignore: Added general pattern for**/test_snapshots/.Testing
cargo fmt --all -- --check: Passedcargo clippy --workspace --all-targets -- -D warnings: Passed (0 warnings)cargo build --workspace: Passedcargo test -p lp-reward-contract: 7 passed, 0 failedcargo test -p creator-keys --lib test_lp_reward: 4 passed, 0 failedCloses #1002