Skip to content

feat(circle): add configurable cooldown period between payout rounds - #187

Open
fridaypetra55-afk wants to merge 1 commit into
cocor-tech:masterfrom
fridaypetra55-afk:feat/115-circle-payout-cooldown
Open

feat(circle): add configurable cooldown period between payout rounds#187
fridaypetra55-afk wants to merge 1 commit into
cocor-tech:masterfrom
fridaypetra55-afk:feat/115-circle-payout-cooldown

Conversation

@fridaypetra55-afk

Copy link
Copy Markdown
Contributor

Summary

  • Adds payout_cooldown_seconds: u64 to CircleConfig/Circle and last_payout_timestamp: u64 to Circle (updated on every successful trigger_payout).
  • trigger_payout now rejects with the new CircleError::PayoutCooldownActive if called again before last_payout_timestamp + payout_cooldown_seconds has elapsed since the previous round's payout.
  • The very first payout (current_round == 0) is never gated — there's no prior round to cool down from, and last_payout_timestamp defaults to 0, which would otherwise collide with a genuine ledger timestamp of 0 in tests.
  • payout_cooldown_seconds defaults to 0 (no cooldown), so this is opt-in and backward compatible with existing configs/behavior when left unset.
  • Added test_trigger_payout_enforces_cooldown_between_rounds: triggers round 0's payout, immediately attempts round 1's payout (expects PayoutCooldownActive), advances the ledger clock past the cooldown window, and confirms the payout then succeeds.

Note on a pre-existing, unrelated build break

Same as noted in #117's PR: packages/circle/src/contract.rs currently fails to compile on master (confirmed on a clean upstream/master checkout) because 15 functions end their body with the bare Ok() instead of Ok(()). Fixed here too since this PR also has to touch and build this file. If #117 merges first, this branch will need a rebase to drop the now-redundant part of that fix — that's expected for two PRs concurrently touching the same file.

cargo build -p circle and cargo test -p circle both pass locally (6/6 tests, including the new one). Test snapshot JSON diffs for existing tests are just the new Circle struct fields showing up in ledger storage entries.

Closes #115

trigger_payout could previously be called back-to-back with no
minimum interval between rounds. Adds payout_cooldown_seconds to
CircleConfig/Circle (defaults to 0, i.e. no cooldown, for existing
callers that don't set it) and last_payout_timestamp to Circle,
updated on every successful payout. trigger_payout now rejects with
the new CircleError::PayoutCooldownActive if called again before
last_payout_timestamp + payout_cooldown_seconds has elapsed. The
first payout of a circle (current_round == 0) is never gated, since
there's no prior round to cool down from.

Adds test_trigger_payout_enforces_cooldown_between_rounds, which
verifies a second round's payout is rejected immediately after the
first and succeeds once the cooldown window has elapsed.

Also fixes the same pre-existing, unrelated `Ok()` -> `Ok(())` compile
break in this file described in cocor-tech#117's PR (confirmed present on a
clean checkout of upstream/master) — required to build/test this
change in isolation.

Closes cocor-tech#115
@drips-wave

drips-wave Bot commented Jul 31, 2026

Copy link
Copy Markdown

@fridaypetra55-afk 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

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.

feat(contract): add configurable cooldown period between payout rounds

1 participant