Skip to content

Vault Security Hardening: Admin Overrides, Investor Caps, Transfer Safety, and Lock-Up Enforcement#251

Open
Nanle-code wants to merge 1 commit into
StellarYield:mainfrom
Nanle-code:security-enhancements
Open

Vault Security Hardening: Admin Overrides, Investor Caps, Transfer Safety, and Lock-Up Enforcement#251
Nanle-code wants to merge 1 commit into
StellarYield:mainfrom
Nanle-code:security-enhancements

Conversation

@Nanle-code
Copy link
Copy Markdown

@Nanle-code Nanle-code commented Apr 1, 2026

Overview

This PR delivers a comprehensive security hardening of the vault system by addressing four critical issues:
Closes #101
Closes #105
Closes #104
Closes #103

The changes introduce:

  • Fine-grained admin controls
  • Investor participation limits
  • Safer cross-contract asset transfers
  • Share transfer lock-up enforcement

All enhancements are implemented with backward compatibility preserved.


Key Improvements

1. Per-Vault Admin Configuration (Fixes #101)

  • Added optional parameters:
    • vault_admin
    • zkme_verifier
    • cooperator
  • Updated factory methods:
    • create_single_rwa_vault
    • create_single_rwa_vault_full
    • create_single_rwa_vault_batch
    • batch_create_vaults
  • Implemented fallback to factory defaults when overrides are not provided
  • Extended VaultCreated event to include admin metadata
  • Maintained full backward compatibility

2. Investor Count Tracking and Cap Enforcement (Fixes #105)

  • Added storage keys:
    • InvCount
    • MaxInvestors
    • DepTimestamp
  • Implemented:
    • Increment on first deposit
    • Decrement on full withdrawal/redeem
  • Enforced max investor cap in:
    • deposit()
    • mint()
  • Added error:
    • MaxInvestorsReached
  • Added admin function:
    • set_max_investors()
  • Added view functions:
    • investor_count()
    • max_investors()
    • lock_up_remaining()

3. Safe Cross-Contract Asset Transfers (Fixes #104)

  • Added pre-transfer vault balance validation
  • Introduced error:
    • InsufficientVaultBalance
  • Added view function:
    • vault_asset_balance()
  • Improved failure diagnostics
  • Documented atomicity guarantees in transfer flows

4. Share Lock-Up Period Enforcement (Fixes #103)

  • Added storage:
    • LockUpPeriod
    • Per-user deposit timestamps
  • Enforced lock-up in:
    • transfer()
    • transfer_from()
    • withdraw()
    • redeem()
  • Excluded redeem_at_maturity() from lock-up restrictions
  • Added error:
    • SharesLocked
  • Added admin function:
    • set_lock_up_period()
  • Added helper function:
    • lock_up_remaining()
  • Updated deposit/mint to record timestamps

Technical Notes

  • Storage schema extended with new keys and serialization mappings
  • Event schema enhanced for better observability
  • All changes preserve transactional atomicity
  • No breaking changes introduced

Checklist


Closes

Closes #101, #105, #104, #103

…improved admin controls

- Issue StellarYield#101: Factory now supports per-vault admin, zkme_verifier, and cooperator overrides
- Issue StellarYield#105: Added investor participant counter with maximum investor cap enforcement
- Issue StellarYield#104: Enhanced asset transfer failure handling with balance checks and atomicity documentation
- Issue StellarYield#103: Implemented share transfer lock-up period with bypass for matured vaults

Key features:
- Per-vault admin configuration in factory
- Investor counting and cap enforcement in deposit/mint
- Lock-up period enforcement for transfers/redeems
- Improved error handling and vault balance checks
- Admin functions to update investor caps and lock-up periods
- Comprehensive view functions for monitoring

Closes StellarYield#101, StellarYield#105, StellarYield#104, StellarYield#103
@Nanle-code
Copy link
Copy Markdown
Author

@Jayy4rl Review this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant