fix(liquidity): derive LP rewards from real fee revenue with time weighting - #503
Merged
RUKAYAT-CODER merged 2 commits intoAug 18, 2026
Conversation
…ghting LP rewards previously used a synthetic proportional model that ignored fees actually collected by the pool and how long positions were held. Rewards now draw from the pool's accumulated_fees (recorded via record_fee_revenue), apply a time-in-pool multiplier that grows +1.0x every 30 days up to 3.0x, and are hard-bounded by the fees collected. Closes rinafcode#494
Contributor
|
Thank you for contributing to the project. |
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.
Closes #494
Summary
calculate_lp_rewardspreviously paid rewards from a synthetic proportional formula (amount² / total_liquidity) with no connection to fees the pool actually collected and no regard for how long a position was held, so flash liquidity earned the same as long-term provision.This change makes LP rewards fee-revenue-backed and time-weighted:
LiquidityPoolnow tracksaccumulated_fees. A new admin-gatedrecord_fee_revenue(chain_id, amount)credits collected bridge fees to the pool (with aFeeRevenueRecordedEvent), and rewards are computed as the provider's share of that balance. No fees recorded → no rewards.accumulated_fees, so the reward pool can never pay out more than the fees actually collected.New public functions:
record_fee_revenueandget_accumulated_fees.Tests
liquidity.rs: zero rewards without fee revenue, proportional fee-share rewards, long-term > flash for equal size, boundedness under max multiplier, and multiplier growth/cap.tests/test_liquidity_rewards.rscovering the full flow: zero rewards until fees are recorded, long-term vs flash comparison, and rewards never exceeding collected fees.All CI checks pass locally:
cargo fmt --check,cargo clippy --workspace --all-features -- -D warnings,cargo build --target wasm32v1-none --release,cargo test --workspace --lib, andcargo test --workspace --test cross_chain_integration.