feat/transfer-restriction-matrix#495
Open
Wetshakat wants to merge 1 commit into
Open
Conversation
|
@Wetshakat 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.
closed #470
Title
feat: enforce per-category transfer restriction matrix (Reg D / Reg S)Description
Securities-law restrictions often cap aggregate holders per category (e.g., maximum 99 Reg D accredited investors). This PR introduces a per-category counter and transfer restriction matrix to safely enforce aggregate caps directly at the protocol level.
The implementation enforces the cap dynamically and relies on strict
0 <-> >0state transitions to maintain perfectly synchronized slot counts.Key Features
TransferRestrictionsconfiguration and theset_transfer_restrictionsmethod to let issuers define max holder limits per category (e.g.,RegD,RegS).transfer_with_attestationto allow issuers/agents to transfer shares and explicitly assign the regulatory category of the recipient.category_holder_countseamlessly increments when a user's balance shifts from0to>0.0shares.CategoryCapReachedonce the specified threshold is hit.Security and Edge Cases Addressed
old_share == 0 && new_share > 0and vice-versa).from == toscenarios intransfer_with_attestationto completely prevent a potential double-spend vector where shares could be artificially inflated.>0balance updates their category affiliation, the state logic safely subtracts them from their old regulatory bucket before enforcing the cap and attributing them to the new one.Testing Strategy (≥95% Coverage)
test_transfer_restrictions: Validates the core logic. Asserts correct cap enforcement limits and correctly frees up slots when an existing user's shares are dropped to0.test_oscillating_across_zero: Ensures that transfers bypassing zero logic behave predictably, maintaining absolute correctness for holder counts across aggressive balance updates.