Skip to content

feat(staking): implement early withdrawal penalty#454

Open
munyanezaarmel wants to merge 1 commit into
MettaChain:mainfrom
munyanezaarmel:feat/early-withdrawal-penalty
Open

feat(staking): implement early withdrawal penalty#454
munyanezaarmel wants to merge 1 commit into
MettaChain:mainfrom
munyanezaarmel:feat/early-withdrawal-penalty

Conversation

@munyanezaarmel
Copy link
Copy Markdown

Summary

Implements early withdrawal penalty for staking as requested in #242.

Behaviour

  • Withdrawing before lock expiry deducts a penalty (default 10%)
  • LockPeriod::Flexible stakes are never penalised
  • Penalty is added to the reward pool, benefiting remaining stakers
  • Admin can adjust the rate between 0–50% via set_early_withdrawal_penalty()

Changes

  • contracts/staking/src/lib.rs — updated unstake(), added admin setter/getter, new EarlyWithdrawal event, new storage field
  • contracts/staking/src/errors.rs — added EarlyWithdrawalPenaltyApplied variant
  • propchain-traits/src/constants.rs — added DEFAULT_EARLY_WITHDRAWAL_PENALTY_BPS, MAX_EARLY_WITHDRAWAL_PENALTY_BPS

Tests

5 new #[ink::test] cases covering: penalty applied, flexible exempt, no penalty after expiry, admin-only setter, cap enforcement.

Closes #242

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@munyanezaarmel 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.

Staking: Implement early withdrawal penalty

1 participant