Description
Many regulatory frameworks limit the number of investors in a private securities offering (e.g., Regulation D in the US limits to 35 non-accredited investors, MiFID II in Europe has similar thresholds). The vault has no concept of investor count — anyone who passes KYC can deposit regardless of how many other investors already hold shares.
Requirements
- Add a
DataKey::InvestorCount → u32 in instance storage
- Add a
max_investors: u32 field to InitParams (0 = unlimited)
- Track unique investors: increment counter on first deposit (
user_deposited == 0 before this deposit), decrement when a user fully redeems (all shares burned, balance == 0)
- In
deposit and mint: if investor_count >= max_investors and this is a new investor, panic with Error::MaxInvestorsReached
- Add view functions:
investor_count() -> u32, max_investors() -> u32
- Add
set_max_investors(caller, max) -> () — admin-only
- Consider edge case: user A deposits, transfers all shares to user B (new investor), then A has 0 balance — should A be decremented? Yes, on next interaction or via a
cleanup_investor_count function
Key Files
- lib.rs —
deposit, mint, withdraw, redeem, redeem_at_maturity, transfer
- storage.rs — new keys
- types.rs —
InitParams new field
- errors.rs — new
MaxInvestorsReached variant
Definition of Done
Description
Many regulatory frameworks limit the number of investors in a private securities offering (e.g., Regulation D in the US limits to 35 non-accredited investors, MiFID II in Europe has similar thresholds). The vault has no concept of investor count — anyone who passes KYC can deposit regardless of how many other investors already hold shares.
Requirements
DataKey::InvestorCount → u32in instance storagemax_investors: u32field toInitParams(0 = unlimited)user_deposited == 0before this deposit), decrement when a user fully redeems (all shares burned,balance == 0)depositandmint: ifinvestor_count >= max_investorsand this is a new investor, panic withError::MaxInvestorsReachedinvestor_count() -> u32,max_investors() -> u32set_max_investors(caller, max) -> ()— admin-onlycleanup_investor_countfunctionKey Files
deposit,mint,withdraw,redeem,redeem_at_maturity,transferInitParamsnew fieldMaxInvestorsReachedvariantDefinition of Done