Skip to content

Add reward Gini coefficient, seasonal multiplier, staker bio, sunset workflow - #325

Merged
Rickyy1017 merged 1 commit into
Rickyy1017:mainfrom
JessicaOmoyeme:feature/gini-seasons-bio-sunset
Jul 28, 2026
Merged

Add reward Gini coefficient, seasonal multiplier, staker bio, sunset workflow#325
Rickyy1017 merged 1 commit into
Rickyy1017:mainfrom
JessicaOmoyeme:feature/gini-seasons-bio-sunset

Conversation

@JessicaOmoyeme

Copy link
Copy Markdown

Summary

  • get_reward_gini_coefficient() — admin-gated bps approximation of reward distribution fairness across active stakers, via insertion sort (bounded at 100 stakers).
  • Seasonal reward multiplier — admin-scheduled ledger-range boosts (add_season/remove_season/get_seasons/get_active_season) that stack with the existing campaign boost, with time-weighted accrual across season boundaries.
  • Staker bio — set_staker_bio/get_staker_bio/clear_staker_bio, a short free-text note per position that persists after unstake.
  • Pool sunsetting workflow — one-way state machine (Active -> SunsetAnnounced -> GracePeriodActive -> ForceResolutionActive -> Closed) with announce_sunset/start_grace_period/start_force_resolution/force_resolve_position/close_pool.

New storage (Season, SunsetState) uses raw symbol-keyed instance/persistent storage rather than new DataKey variants, since DataKey is already at Soroban's 50-variant cap. New error cases land in VaultFeatureError for the same reason (VaultError and VaultExtError are both already at the cap).

Also fixes a pre-existing bug uncovered while wiring up the season multiplier: the actual reward-accrual path (reward_dust_for_ledgers) silently ignored the campaign multiplier entirely — only a separate, shadowed/discarded local variable applied it. Without this fix the season multiplier (and the existing campaign boost) would compute correctly for preview/simulation calls but never actually affect real accrued rewards.

Note on build state

main currently has ~66 pre-existing compile errors in unrelated code (issues in the #266-273 area: insurance completions, matching program, cohort stats, anti-sybil min stake age, pool merger, and a broken duplicate staker-bio stub referencing a nonexistent storage::Storage module). These predate this branch and are out of scope here. This PR was verified to add zero new errors on top of that baseline — in fact one fewer, since the broken duplicate bio stub (which collided with this PR's real implementation) was removed.

Issues Resolved

Closes #275
Closes #276
Closes #274
Closes #298

Test plan

  • Unit tests added for all four features in src/test.rs (equal/unequal Gini distributions, admin-auth gate, season boost/base-rate/boundary-crossing, bio set/get/clear/persistence/length-limit, full sunset workflow/force-resolve payout/close-with-positions-remaining/queries-after-close).
  • cargo test --features testutils cannot currently run to completion — blocked by the pre-existing unrelated compile errors on main described above, not by this PR's changes.

@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@JessicaOmoyeme 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! 🚀

Learn more about application limits

@Rickyy1017
Rickyy1017 merged commit 6a67e0f into Rickyy1017:main Jul 28, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment