Skip to content

Feat/time weighted contributions - #408

Merged
cypriannwokolo2-creator merged 4 commits into
cocor-tech:masterfrom
AMDYFX:feat/time-weighted-contributions
Aug 31, 2026
Merged

Feat/time weighted contributions#408
cypriannwokolo2-creator merged 4 commits into
cocor-tech:masterfrom
AMDYFX:feat/time-weighted-contributions

Conversation

@AMDYFX

@AMDYFX AMDYFX commented Aug 31, 2026

Copy link
Copy Markdown

Summary

Implemented time-weighted contribution accounting so payout shares reflect both the amount contributed and how long each contribution has been held. This provides additional reward to members who commit funds earlier and maintain their contributions for longer periods.

Changes

  • Added time-weight tracking to contribution records.

  • Captured the relevant contribution timestamp required to calculate holding duration.

  • Updated payout calculation to derive each member's weighted contribution from:

    • Contribution amount.
    • Time held.
  • Calculated each member's payout share against the total time-weighted contribution pool.

  • Ensured contributions with longer holding periods receive proportionally greater weight.

  • Added validation for contribution timing and payout calculation boundaries.

  • Preserved existing contribution and payout behavior where time-weighting does not alter the applicable share.

  • Added comprehensive tests covering early and late contributions, different holding periods, equal contributions with different durations, and payout-share calculations.

Accounting & Reliability

  • Uses deterministic integer-based calculations suitable for on-chain execution.
  • Avoids floating-point arithmetic for contribution and payout calculations.
  • Ensures the total payout allocation remains consistent with the available payout amount.
  • Handles zero or invalid weighting conditions safely.
  • Keeps contribution history sufficient to reproduce payout calculations.

Validation

  • Verified equal contributions held for different durations produce different weighted shares.
  • Confirmed earlier contributions receive greater weight when held for longer.
  • Tested multiple contributors with different amounts and holding periods.
  • Verified payout shares are calculated against the total time-weighted contribution.
  • Tested edge cases around timestamps, zero contributions, and payout boundaries.
  • Ran the relevant Soroban contract tests and checks.

Acceptance Criteria

  • Add time-weight information to contributions.
  • Track the duration each contribution is held.
  • Calculate payout weight using amount × time held.
  • Calculate each member's share against total time-weighted contributions.
  • Reward earlier/longer-held contributions proportionally.
  • Preserve deterministic on-chain accounting.
  • Add regression and edge-case test coverage.

closes #129
closes #242
closes #128
closes #127

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@AMDYFX 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

@cypriannwokolo2-creator
cypriannwokolo2-creator merged commit ffb28f5 into cocor-tech:master Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants