Skip to content

feat(staking): implement early withdrawal penalty#454

Merged
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
munyanezaarmel:feat/early-withdrawal-penalty
May 31, 2026
Merged

feat(staking): implement early withdrawal penalty#454
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
munyanezaarmel:feat/early-withdrawal-penalty

Conversation

@munyanezaarmel
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

@nanaf6203-bit nanaf6203-bit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nanaf6203-bit nanaf6203-bit merged commit 88a09a7 into MettaChain:main May 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

Development

Successfully merging this pull request may close these issues.

Staking: Implement early withdrawal penalty

2 participants