Skip to content

feat: Per-Vault Admin Override - Enable Independent Vault Governance#150

Open
Nanle-code wants to merge 4 commits into
StellarYield:mainfrom
Nanle-code:Factory
Open

feat: Per-Vault Admin Override - Enable Independent Vault Governance#150
Nanle-code wants to merge 4 commits into
StellarYield:mainfrom
Nanle-code:Factory

Conversation

@Nanle-code
Copy link
Copy Markdown

Per-Vault Admin Override - Enable Independent Vault Governance

Summary

This PR addresses the critical security issue where all vaults were controlled by the factory admin, creating a single point of failure. The implementation enables per-vault admin override functionality while maintaining full backward compatibility.

Problem Solved

Solution

Added optional admin override functionality to allow independent vault governance:

Key Changes

  • Optional Admin Override: vault_admin: Option<Address> field in BatchVaultParams
  • Per-Vault Settings: Optional zkme_verifier and cooperator overrides
  • Fallback Logic: Uses factory admin when custom admin not specified
  • Enhanced Events: VaultCreated event now emits actual vault admin
  • Backward Compatibility: Existing functions unchanged

Files Modified

  • vault_factory/src/types.rs - Added optional fields to parameter structs
  • vault_factory/src/lib.rs - Updated creation functions and core logic
  • vault_factory/src/events.rs - Enhanced event emission
  • vault_factory/src/tests.rs - Added comprehensive test coverage

Security Benefits

🔒 Eliminates Single Point of Failure: Different vaults can have different admins
🏢 Multi-Tenant Support: Asset managers can have independent control
📊 Enhanced Transparency: Events show actual vault governance
🔄 Zero Breaking Changes: Existing integrations continue working

Definition of Done

  • Vault admin is configurable per vault deployment
  • Default falls back to factory admin when not specified
  • Per-vault zkme_verifier and cooperator overrides supported
  • Tests verify independent admin control on separately deployed vaults
  • Existing simple creation function maintains backward compatibility
  • Factory admin can still set vault status in registry
  • VaultCreated event emits actual vault admin

Testing

Added comprehensive tests covering:

  • Custom admin override functionality
  • Factory admin fallback behavior
  • Batch creation with different admins per vault
  • Backward compatibility verification

Compatibility

  • Fully Backward Compatible: No breaking changes
  • Optional Parameters: Existing code continues to work
  • Enhanced API: New functionality available when needed

This implementation enables a truly multi-tenant RWA platform while maintaining the security and flexibility needed for different asset managers to operate independently.

closes #101

…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 optional vault_admin, zkme_verifier, and cooperator fields to BatchVaultParams
- Update _create_single_rwa_vault to use custom admin with fallback to factory admin
- Enhance VaultCreated event to emit actual vault admin
- Add comprehensive tests for independent admin control
- Maintain backward compatibility with existing vault creation functions

Fixes StellarYield#101
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Mar 26, 2026

@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! 🚀

Learn more about application limits

@Nanle-code
Copy link
Copy Markdown
Author

@Jayy4rl can you review this

@Jayy4rl
Copy link
Copy Markdown
Contributor

Jayy4rl commented Apr 1, 2026

@Nanle-code CI checks failed, resolve that please

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Factory Deploys All Vaults with Factory's Own Admin — No Per-Vault Admin Override

2 participants