Skip to content

fix(token): enforce PULSE supply cap - #112

Open
afeezorobsco-cyber wants to merge 3 commits into
SPulse-Org:mainfrom
afeezorobsco-cyber:fix/pulse-token-supply-cap
Open

fix(token): enforce PULSE supply cap#112
afeezorobsco-cyber wants to merge 3 commits into
SPulse-Org:mainfrom
afeezorobsco-cyber:fix/pulse-token-supply-cap

Conversation

@afeezorobsco-cyber

Copy link
Copy Markdown

##close #90

Summary

Enforces a global PULSE maximum supply at the token contract's mint() boundary so every authorized minting path shares the same hard ceiling.

Changes

  • Added the PULSE maximum-supply invariant.
  • Added a typed error for cap violations.
  • Added overflow-safe supply checks before state mutation.
  • Ensured failed mints do not modify balances or total_supply.
  • Verified the cap applies to both leaderboard reward paths.
  • Added boundary, authorization, and regression tests.
  • Documented the cap and deployment/migration behavior.

Security

The cap is enforced in the token contract itself rather than relying on individual callers. Therefore reward, reward_bonus, and other authorized minters cannot bypass the global supply ceiling.

An attempted mint that would exceed the remaining supply fails atomically.

Validation

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace

Issue

Closes #[ISSUE_NUMBER]

Cap lives in pulse_token::mint() (DataKey::MaxSupply, instance storage) so every
authorized minter - leaderboard reward/reward_bonus or any future minter -
shares one global ceiling. Result is computed via i128::checked_add before any
write; over-cap or overflow mints reject with MaxSupplyExceeded (SPulse-Org#7) leaving
balance and total_supply untouched. No authoritative tokenomics value exists in
the repo, so the cap is deployer-supplied via initialize(_, max_supply); legacy
instances fail closed until admin declares a cap through set_max_supply, an
admin-only one-way ratchet (cannot raise, cannot go below current supply).

Closes issue SPulse-Org#34.
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.

[CRITICAL] Unbounded PULSE minting — no supply cap, every claim mints without ceiling

1 participant