Skip to content

fix(liquidity): derive LP rewards from real fee revenue with time weighting - #503

Merged
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
oladev2026-tech:fix/494-lp-rewards-fee-revenue-time-weighted
Aug 18, 2026
Merged

fix(liquidity): derive LP rewards from real fee revenue with time weighting#503
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
oladev2026-tech:fix/494-lp-rewards-fee-revenue-time-weighted

Conversation

@oladev2026-tech

Copy link
Copy Markdown
Contributor

Closes #494

Summary

calculate_lp_rewards previously 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:

  • Real fee revenue: LiquidityPool now tracks accumulated_fees. A new admin-gated record_fee_revenue(chain_id, amount) credits collected bridge fees to the pool (with a FeeRevenueRecordedEvent), and rewards are computed as the provider's share of that balance. No fees recorded → no rewards.
  • Time-in-pool weighting: rewards are scaled by a time multiplier that starts at 1.0x at deposit and grows +1.0x every 30 days held, capped at 3.0x, so long-term providers earn proportionally more than equally-sized flash positions.
  • Bounded payouts: rewards are hard-clamped to accumulated_fees, so the reward pool can never pay out more than the fees actually collected.

New public functions: record_fee_revenue and get_accumulated_fees.

Tests

  • Unit tests in 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.
  • Integration tests in tests/test_liquidity_rewards.rs covering 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, and cargo test --workspace --test cross_chain_integration.

…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
@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit ef80c5a into rinafcode:main Aug 18, 2026
4 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.

LP rewards use a synthetic proportional model, ignoring real fee revenue and time-in-pool

2 participants