You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document serves as the audit-readiness package for the Brain-Storm smart contract suite. It covers documented invariants per contract, known-risk register, reentrancy/auth/arithmetic review, and evidence of testing ahead of mainnet deployment.
Date: 2026-06-29 Scope: All 17 contracts under contracts/ Prepared for: External audit handoff
1. Invariants Per Contract
Token (contracts/token/)
Invariant
Description
Severity
I-TOK-01
Total supply must never exceed 10,000,000,000,000,000 base units (10 quadrillion)
Critical
I-TOK-02
balanceOf(a) + balanceOf(b) + ... = totalSupply must hold at all times
Critical
I-TOK-03
Minting is admin-only; totalSupply increases exactly by the minted amount
Critical
I-TOK-04
Burning decreases totalSupply exactly by the burned amount; BurnStats are updated atomically
High
I-TOK-05
Allowances cannot be set above u128::MAX; approve overwrites, transfer_from respects allowance
High
I-TOK-06
Vesting schedules enforce cliff >= start and end > cliff; claimed <= total_amount always
High
I-TOK-07
Reentrancy guard prevents concurrent state mutation in transfer / transfer_from
Critical
I-TOK-08
Staking rewards are calculated only on staked balance; unstaking reduces staked amount atomically
Medium
Badges (contracts/badges/)
Invariant
Description
Severity
I-BAD-01
Each badge has exactly one owner at any time
High
I-BAD-02
badge_type_record.total_minted is monotonically non-decreasing and never overflows
High
I-BAD-03
Only admin can define new badge types
High
I-BAD-04
Burned badges cannot be transferred or unburned
Medium
Certificate (contracts/certificate/)
Invariant
Description
Severity
I-CER-01
Each certificate ID is unique and monotonically increasing
Critical
I-CER-02
Certificates are soulbound by default — transfer is rejected unless opt-in
High
I-CER-03
Only authorized issuer can mint certificates
Critical
I-CER-04
Revocation is irreversible; revoked certificates are marked and cannot be un-revoked
High
Market (contracts/market/)
Invariant
Description
Severity
I-MAR-01
Escrow amount is locked on creation and released only on settlement or refund
Critical
I-MAR-02
Paused flag prevents all state-mutating operations when set
✅ from.require_auth() on transfer; owner.require_auth() on approve
Auth verified in all state-mutating functions
market
✅ admin.require_auth() on fee set, pause, treasury withdraw
✅ payer.require_auth() on escrow fund
initialize checks !has(Admin) — safe
governance
✅ admin.require_auth() on config
✅ proposer.require_auth() on create; voter auth on cast
Weighted voting reduces sybil risk
badges
✅ admin-only minting, type definitions
N/A
Badges are soulbound; transfer rejected
certificate
✅ admin/issuer-only minting
N/A
Soulbound by default
reputation
✅ admin-only decay config, authorized callers
✅ user.require_auth() on claim
update_reputation uses authorized caller pattern
dispute
✅ arbiter gating
✅ parties auth on submission
Lifecycle state machine enforced
liquidity_pool
✅ admin only for drain
✅ LP provider auth for add/remove
Swap is permissionless
remaining
✅ Admin auth on all admin functions
✅ User auth on user-scoped functions
Consistent pattern across all contracts
Reentrancy Review
Contract
Reentrancy Guard
Risk Level
Notes
token
✅ Custom lock in transfer, transfer_from
Low
Guard uses storage boolean; released on exit
market
✅ State updates before cross-contract calls
Low
Escrow status set before external calls
governance
❌ Not applicable
None
Soroban execution model prevents reentrant calls
others
❌ Not needed
None
Soroban host-level reentrancy protection
Soroban Reentrancy Context: The Soroban host runtime does not allow reentrant contract calls by default. However, the token contract implements an additional mutex for defense-in-depth.