feat: Implement investor participant counter and maximum investor cap (#105)#149
Open
Nanle-code wants to merge 4 commits into
Open
feat: Implement investor participant counter and maximum investor cap (#105)#149Nanle-code wants to merge 4 commits into
Nanle-code wants to merge 4 commits into
Conversation
…ks (StellarYield#104) - Add Error::InsufficientVaultBalance variant for clearer diagnostics - Add explicit balance checks before all outgoing transfers in transfer_asset_from_vault - Wrap transfer_asset_to_vault to catch insufficient user balance scenarios - Add vault_asset_balance() public view function for frontend solvency verification - Document atomicity assumptions in all functions combining state changes with external calls - Add comprehensive tests for insufficient balance scenarios Addresses vault state inconsistency when token transfers fail by providing explicit balance checks and clear error diagnostics instead of opaque token contract failures.
Add comprehensive investor tracking and cap enforcement for regulatory compliance in private securities offerings. Features: - Track unique investors with automatic increment/decrement - Configurable maximum investor cap (0 = unlimited) - Admin-only cap adjustment function - MaxInvestorsReached error for cap enforcement - Comprehensive view functions and test coverage Supports compliance with Regulation D (35 non-accredited investors) and MiFID II frameworks. Handles transfer edge cases and maintains gas efficiency. Closes StellarYield#105
|
@Nanle-code 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.
This PR implements the investor participant counter and maximum investor cap feature to support regulatory compliance for private securities offerings.
🎯 Problem Solved
Many regulatory frameworks (e.g., Regulation D in the US, MiFID II in Europe) limit the number of investors in private securities offerings. The vault previously had no concept of investor count — anyone who passed KYC could deposit regardless of how many other investors already held shares.
✨ Features Implemented
Core Functionality
Public API
Error Handling
MaxInvestorsReachederror when cap exceeded by new investors🔧 Technical Implementation
Storage Layer
DataKey::InvestorCount→ u32 (instance storage)DataKey::MaxInvestors→ u32 (instance storage)Business Logic
Configuration
max_investors: u32field added toInitParams🧪 Comprehensive Testing
Created extensive test suite (test_investor_count.rs) covering:
📋 Requirements Fulfilled
DataKey::InvestorCount → u32in instance storagemax_investors: u32field toInitParams(0 = unlimited)Error::MaxInvestorsReachedpanic🏛️ Regulatory Compliance
This implementation enables compliance with:
🔒 Security Considerations
📁 Files Modified
src/types.rs- InitParams extensionsrc/errors.rs- New error variant🚀 Breaking Changes
lock_up_periodfields (backward compatible)📊 Definition of Done - Complete
Closes #105