sTitle: [contract] Emission Schedule, Anti-Whale, Proposal Cancellation & Token/Staking Lifecycle Tests#730
Merged
Devsol-01 merged 1 commit intoDevsol-01:mainfrom Apr 29, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.