Skip to content

sTitle: [contract] Emission Schedule, Anti-Whale, Proposal Cancellation & Token/Staking Lifecycle Tests#730

Merged
Devsol-01 merged 1 commit intoDevsol-01:mainfrom
Emeka000:observe
Apr 29, 2026
Merged

sTitle: [contract] Emission Schedule, Anti-Whale, Proposal Cancellation & Token/Staking Lifecycle Tests#730
Devsol-01 merged 1 commit intoDevsol-01:mainfrom
Emeka000:observe

Conversation

@Emeka000
Copy link
Copy Markdown
Contributor

@Emeka000 Emeka000 commented Apr 29, 2026

Description:

Closes #712,

closes #713
Closes #714,

closes #715

This PR implements four Soroban smart contract features for the Nestera protocol in a single cohesive change.

Changes
#712 — Emission Schedule
Introduces
emission.rs
— a new module that defines how new NST tokens are released over time.

EmissionConfig struct stores emission_rate_per_second, max_supply, last_emission_time, total_emitted, and active flag
initialize_emission() — admin-only, one-time setup
update_emission_config() — admin or active governance can adjust rate, cap, or pause emissions
process_emission(recipient) — mints all tokens accrued since the last call; enforces the supply cap automatically
is_supply_cap_reached() — read-only cap status check
All arithmetic uses checked math with overflow protection
Events emitted: EmissionConfigSet, TokensEmitted
#713 — Anti-Whale & Fair Distribution
Extends StakingConfig with two new fields and enforces them in the staking logic.

max_staking_limit: i128 — maximum tokens a single user may have staked in total (0 = no limit). Checked cumulatively on every stake() call
max_wallet_holding: i128 — maximum token balance a single wallet may hold (0 = no limit). Enforced via validate_wallet_holding() helper
default_staking_config() defaults both to 0 (no limits) for backward compatibility
No bypass is possible — limits are checked before any state mutation
#715 — Governance Proposal Cancellation
Upgrades the existing cancel_proposal stub into a fully spec-compliant implementation.

Added canceled: bool field to both Proposal and ActionProposal structs (replaces the previous workaround of setting executed = true)
Cancellation is allowed for: proposal creator OR contract admin / active governance
Already-executed proposals cannot be canceled (TooLate)
Already-canceled proposals cannot be canceled again (TooLate)
Queued proposals can still be canceled before execution
vote(), queue_proposal(), and execute_proposal() all reject canceled proposals
ProposalCanceled event emitted on success
#714 — Token & Staking Integration Tests
New test file
token_staking_lifecycle_test.rs
with 27 tests covering the full token lifecycle and all features in this PR.

Full lifecycle flow:

Mint → distribute rewards → stake → accrue staking rewards → unstake & claim → burn → participate in governance
Emission tests: init, double-init guard, correct amount per elapsed time, supply cap enforcement, pause behavior, rate update, unauthorized access blocked

Governance cancellation tests: creator cancel, admin cancel, unauthorized blocked, executed proposal blocked, double-cancel blocked, queued proposal can be canceled

Anti-whale tests: limit enforced, no limit when zero, per-user isolation, at-limit allowed, one-over-limit rejected, cumulative enforcement across multiple stakes, restake after unstake, below-minimum rejected, disabled staking rejected

Files Changed
File Change
emission.rs
New — emission schedule module
governance.rs
Updated — canceled field, full cancel_proposal implementation
storage_types.rs
Updated — max_wallet_holding, max_staking_limit fields
storage.rs
Updated — anti-whale enforcement in stake(), validate_wallet_holding() helper, updated default config
lib.rs
Updated — mod emission, cancel_proposal, and 5 emission public functions wired in
token_staking_lifecycle_test.rs
New — 27 integration tests
Testing
All 27 new tests pass. No existing tests were broken. All diagnostics are clean across all modified files.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nestera Ready Ready Preview, Comment Apr 29, 2026 3:05am

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 29, 2026

@Emeka000 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

@Devsol-01 Devsol-01 merged commit ada9ee9 into Devsol-01:main Apr 29, 2026
2 of 3 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

2 participants