This branch implements 4 major enhancements to the Stellar-based vesting vault protocol, making it more flexible, user-friendly, interoperable, and legally compliant.
Labels: devops, architecture, security
Implemented a proxy pattern that allows admins to upgrade contract logic by pointing to a new Wasm code hash, while ensuring immutable terms (total allocations) remain unchanged. This enables bug fixes and feature additions without breaking existing 4-year vesting schedules.
getCurrentCodeHash(): Retrieves current Wasm code hash from proxy contractupgradeContractLogic(): Upgrades to new code hash with admin authorizationgetImmutableTerms(): Fetches immutable terms (total allocations) from contractvalidateNewCodeCompatibility(): Validates new code compatibility before upgradeareTermsCompatible(): Ensures total allocations remain unchanged
GET /api/vault/code-hash- Get current contract code hashGET /api/vault/immutable-terms- Retrieve immutable termsPOST /api/vault/upgrade- Upgrade contract logic (requires admin auth)POST /api/vault/validate-code- Validate new code compatibility
- Immutable terms validation prevents modification of active vesting schedules
- Admin signature verification required for upgrades
- Compatibility checks ensure seamless transitions
Labels: logic, feature, ux
Implemented consolidate_schedules function that merges two vesting tracks into one, accurately summing unvested balances and calculating weighted averages for cliff and end dates. This prevents account bloat and simplifies the UI for power users.
consolidateSchedules(): Merges two schedules belonging to same beneficiarysumUnvestedBalances(): Accurately calculates combined unvested balancecalculateWeightedAverageDate(): Computes weighted average for cliff/end datescalculateWeightedAverageDuration(): Calculates weighted vesting durationearlierDate(): Selects earlier start date for consolidated schedule
GET /api/vesting/schedule/:scheduleId- Get schedule detailsPOST /api/vesting/consolidate- Consolidate two schedules (requires admin auth)POST /api/vesting/calculate-weighted-average- Preview consolidation calculations
- Reduces account bloat by merging multiple schedules
- Simplified UI for beneficiaries with multiple revenue streams
- Weighted average calculation ensures fair treatment of all parties
Labels: interop, backend, smart-contract
Implemented a "Registry" map within the main contract that tracks all active vault contract IDs by creator. The list_vaults_by_creator function enables meta-dashboards to dynamically discover all vesting activity on the Stellar network.
registerVault(): Register new vault contract ID for a creatorlistVaultsByCreator(): List all vaults for specific creatorgetAllVaults(): Get all registered vaults across all creatorsunregisterVault(): Remove closed vault from registryisVaultRegistered(): Check if vault is registered
GET /api/registry/vaults/:creatorAddress- List creator's vaultsGET /api/registry/all-vaults- Meta-dashboard endpoint with statisticsPOST /api/registry/register- Register new vault (requires admin auth)POST /api/registry/unregister- Unregister vault (requires admin auth)GET /api/registry/check/:vaultContractId- Check registration status
- Makes Vesting-Vault a "Public Utility" for the Stellar ecosystem
- Enables Portfolio Trackers and Meta-Dashboards
- No reliance on centralized off-chain databases
- Dynamic discovery of all vesting activity
Labels: legal, i18n, backend
Updated the contract to store hashes of the "Token Purchase Agreement" in multiple languages (English, Chinese, Spanish, etc.). The contract tracks which version was "Primary" during signing, ensuring legal clarity in multi-lingual disputes.
storeAgreementHashes(): Store multi-lingual agreement hashesgetAgreementHashes(): Retrieve all agreements for a vaultgetPrimaryAgreementByLanguage(): Get primary agreement for specific languageupdatePrimaryAgreement(): Update primary designationverifyAgreementHash(): Verify provided hash matches stored versiongetAgreementHistory(): Audit trail of agreement versions
POST /api/legal-agreements/store- Store multi-lingual agreementsGET /api/legal-agreements/:vaultId- Get all agreementsGET /api/legal-agreements/:vaultId/primary/:language- Get primary by languagePOST /api/legal-agreements/:vaultId/update-primary/:language- Update primaryPOST /api/legal-agreements/:vaultId/verify- Verify hash matchGET /api/legal-agreements/:vaultId/history- Get audit history
- Supports 10 languages: EN, ZH, ES, FR, DE, JA, KO, PT, RU, AR
- Tracks primary version at time of signing
- Enables hash verification for dispute resolution
- Bridges gap between "Code" and "Law"
- SorobanVaultManager - Contract upgrade management
- VestingScheduleManager - Schedule consolidation logic
- VaultRegistryService - Vault discovery and tracking
- LegalAgreementService - Multi-lingual legal document management
- 4 new route modules with 18 total endpoints
- All administrative endpoints require admin signature verification
- RESTful design with consistent error handling
- Uses Stellar SDK for all blockchain interactions
- Transaction simulation before execution
- Polling for transaction completion
- Proper error handling and status codes
- Admin Authorization: All state-changing operations require admin public key and signature
- Immutable Terms: Task 1 ensures total allocations cannot be modified
- Beneficiary Verification: Task 2 verifies both schedules belong to same beneficiary
- Language Validation: Task 4 validates ISO 639-1 language codes
- Hash Integrity: All agreement hashes are cryptographically verifiable
- Stellar SDK configured
- Soroban RPC URL set in environment
- Admin keys properly secured
SOROBAN_RPC_URL=https://...
SOROBAN_SOURCE_SECRET=...
SOROBAN_CONTRACT_ID=...
SOROBAN_NETWORK_PASSPHRASE=...All services include proper error handling and can be tested independently.
8c91ac7 feat: Implement Proxy/Wasm-Rotation pattern for contract logic updates (Task 1)
dcdb11b feat: Implement consolidate_schedules for merging vesting tracks (Task 2)
84ebb84 feat: Implement Registry map and list_vaults_by_creator (Task 3)
09e433e feat: Add multi-lingual Token Purchase Agreement hash tracking (Task 4)
- Seamless Upgrades: Contract improvements without disrupting active schedules
- Simplified Management: Merge multiple schedules into single view
- Better Discovery: Find all vaults through meta-dashboards
- Legal Clarity: Access legal terms in native language
- Extensible Architecture: Clean service layer for easy maintenance
- Comprehensive API: Well-documented RESTful endpoints
- Type Safety: Proper validation and error handling
- Testability: Modular design enables unit testing
- Public Utility: Vesting-Vault becomes infrastructure for entire Stellar network
- Interoperability: Other apps can read and integrate with vault data
- Legal Compliance: Multi-lingual support for global adoption
- Future-Proof: Proxy pattern enables evolution without breaking changes
All 4 tasks have been successfully implemented and committed with proper documentation. The code is ready for review and deployment.
Branch: feature/vesting-vault-enhancements
Status: ✅ Complete
Total Files Created: 8 (4 services + 4 routes)
Total Lines of Code: ~1,800 lines