Skip to content

feat(staking): implement staking, rewards, and unbonding entrypoints (#201) - #324

Open
Dimank92 wants to merge 1 commit into
Zenith-options:mainfrom
Dimank92:feat/issue-201-staking-entrypoints
Open

Dimank92 wants to merge 1 commit into
Zenith-options:mainfrom
Dimank92:feat/issue-201-staking-entrypoints

Conversation

@Dimank92

Copy link
Copy Markdown

Summary

Closes #201

Reconstructs the zenith-staking crate into a production Soroban contract implementing complete staking, rewards, unbonding, and admin management functionality:

  • Core Staking Lifecycle:
    • stake: transfers principal, updates per-staker accruals, distributes carried-over rewards on first stake, enforces emergency pause check.
    • request_unstake: transitions earning stake to cooldown PendingUnstake position with atomic timer restart.
    • withdraw: validates cooldown expiration and transfers principal back to staker.
    • claim_rewards: settles and transfers accrued reward tokens to staker across all active tokens.
    • notify_reward: callable by fee splitter to increase RewardPerToken or carry over rewards when pool is empty.
  • Admin Configuration Surface:
    • set_reward_rate & reward_rate: admin-gated rate configuration capped at MAX_REWARD_RATE (10,000 bps) with "reward_rate_set" events.
    • set_cooldown & cooldown: admin-gated unbonding cooldown configuration with "cooldown_set" events; in-flight positions retain original timestamps.
    • set_emergency_unstake, emergency_unstake_enabled, and emergency_unstake: immediate exit bypass during emergency mode, prevents new stakes.
  • Contract Build & Spec Alignment:
    • Configured build = "../common/build_meta.rs" and repository.workspace = true in staking/Cargo.toml.
    • Added event-spec test dependency.

Test Verification

All 25 unit, lifecycle, and event spec tests pass cleanly:

test result: ok. 25 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.25s

Payout Address

  • Wallet: 0xC345C07229307d4f1c7935aD2cAe48e390215808
  • Network: Polygon / Base / Arbitrum / Stellar

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.

Implement the staking Contract's Staking, Rewards, and Unbonding Entrypoints

1 participant