Skip to content

feat: add reward pool balance validation before hunt activation#568

Merged
Samuel1-ona merged 1 commit into
Samuel1-ona:mainfrom
otobongdev:add-reward-pull
Jun 30, 2026
Merged

feat: add reward pool balance validation before hunt activation#568
Samuel1-ona merged 1 commit into
Samuel1-ona:mainfrom
otobongdev:add-reward-pull

Conversation

@otobongdev

Copy link
Copy Markdown
Contributor

Description

Adds reward pool balance validation before hunt activation. When a reward manager is configured, activate_hunt now verifies that the pool balance is sufficient to cover min_distribution_amount * max_winners before allowing the hunt to be activated.

Acceptance Criteria

  • Check pool balance >= min_distribution_amount * max_winners
  • Return descriptive error (InsufficientRewardPool) if insufficient
  • Optional: warn but allow activation with flag (not implemented - can be added in follow-up)

Changes

contracts/reward-manager/src/lib.rs

  • Added get_min_distribution_amount public getter that returns the min_distribution_amount from the pool config (or 0 if no pool exists)

contracts/hunty-core/src/lib.rs

  • Updated activate_hunt to query the reward manager for min_distribution_amount via cross-contract call
  • Added validation: pool_balance >= min_distribution_amount * max_winners (using saturating_mul for overflow safety)
  • Returns HuntErrorCode::InsufficientRewardPool with detailed error info when validation fails
  • Validation only enforced when min_distribution_amount > 0 (0 = no minimum constraint)

Testing

  • cargo build -p reward-manager && cargo build -p hunty-core
  • cargo test -p hunty-core && cargo test -p reward-manager

Closes #360

@Samuel1-ona Samuel1-ona merged commit abbcd08 into Samuel1-ona:main Jun 30, 2026
2 of 8 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.

Add reward pool balance validation before hunt activation

2 participants