Skip to content

AlephFi/smart-contracts

Repository files navigation

Aleph Protocol

Tests License Foundry Solidity

Aleph is a financial infrastructure for uncorrelated yield strategies, connecting digital asset allocators with institutional money managers.

Documentation β€’ Website β€’ Twitter β€’ GitHub


Overview

Aleph Vault tokenizes off-chain yield strategies into asynchronous vaults, deriving their value from the underlying NAV. The system simplifies complex operations for managers and allocators, handles whitelisting, subscriptions, Classes and Series, HWM, fee accrual, and capital distribution.

Aleph Vault operates as a settlement-based system; deposits/redemptions are settled only after a new NAV is published. The vault manager initiates NAV updates and settlement cycles, and the whitelisted vault is used as the β€œsubscription escrow”.

Features

  • Customization: apply custom parameters for subscription, fee logic, and other key controls.
  • Fee management: calculated per class/series and enforced by contracts.
  • Built-in compliance: whitelisted access through a verification process.
  • Canonical states: deposits/redemptions settle in batches at the same per-share price.

πŸ—οΈ Architecture

Aleph Architecture

Core Components

graph TB
    A[AlephVaultFactory] --> B[AlephVault]
    B --> C[AlephVaultDeposit]
    B --> D[AlephVaultRedeem]
    B --> E[AlephVaultSettlement]
    B --> F[FeeManager]
    B --> G[MigrationManager]
    H[Accountant] --> B
    I[Oracle] --> E
    J[Guardian] --> B
Loading

Smart Contract Overview

Contract Purpose Key Features
AlephVaultFactory Vault deployment and management CREATE2 deployment, protocol parameters
AlephVault Main vault logic Async operations, share management
AlephVaultDeposit Deposit handling Async deposits, batch processing
AlephVaultRedeem Redemption handling Async redemptions, notice periods
AlephVaultSettlement NAV settlements Oracle integration, batch settlements
FeeManager Fee management Management & performance fees
Accountant Fee accounting Protocol-level fee tracking
MigrationManager Upgrades Safe contract migrations

πŸš€ Quick Start

Prerequisites

  • Foundry - Smart contract development toolkit
  • Node.js v18+ - For TypeScript scripts
  • Git - Version control

Installation

# Clone the repository
git clone https://github.com/AlephFi/smart-contracts.git
cd Aleph

# Install Foundry dependencies
forge install

# Install Node.js dependencies (for scripts)
npm install

# Build contracts
forge build

# Run tests
forge test

# Run tests with gas reporting
forge test --gas-report

Development Setup

# Copy environment template
cp .env.example .env

# Edit environment variables
vim .env

# Run specific tests
forge test --match-test testDeposit

# Run tests with verbosity
forge test -vvv

# Check code coverage
forge coverage

πŸ”§ Configuration

Environment Variables

# Network Configuration
SEPOLIA_RPC_URL="https://gateway.tenderly.co/public/sepolia"
HOODI_RPC_URL="https://ethereum-hoodi-rpc.publicnode.com"

# Deployment
PRIVATE_KEY="your-private-key"
ETHERSCAN_API_KEY="your-etherscan-api-key"

# Safe Integration
SAFE_ADDRESS="your-safe-multisig-address"
SAFE_API_URL="https://safe-transaction-sepolia.safe.global"

Contract Configuration Files

  • factoryConfig.json - Factory deployment parameters
  • accountantConfig.json - Accountant setup
  • deploymentConfig.json - General deployment config

πŸ’‘ Usage Examples

Basic Vault Interaction

// Request a deposit (async)
uint48 batchId = vault.requestDeposit(
    IAlephVaultDeposit.RequestDepositParams({
        classId: 1,
        amount: 1000e18,
        signature: signature,
        deadline: block.timestamp + 1 hours
    })
);

// Oracle settles the batch
vault.settleDeposit(
    IAlephVaultSettlement.SettlementParams({
        classId: 1,
        batchId: batchId,
        totalAssetsDeposited: 1000e18,
        sharePrice: 1e6
    })
);

// Request redemption (async)
uint48 redeemBatchId = vault.requestRedeem(
    IAlephVaultRedeem.RedeemRequestParams({
        classId: 1,
        shareAmount: 500e18,
        signature: signature,
        deadline: block.timestamp + 1 hours
    })
);

Advanced Features

// Create new share class
uint8 classId = vault.createShareClass(
    IAlephVault.ShareClassParams({
        managementFee: 200, // 2%
        performanceFee: 2000, // 20%
        noticePeriod: 7 days,
        lockInPeriod: 30 days,
        minDepositAmount: 100e18,
        minUserBalance: 50e18,
        maxDepositCap: 1000000e18,
        minRedeemAmount: 10e18
    })
);

// Queue parameter changes (timelock)
vault.queueMinDepositAmount(classId, 200e18);

// Execute after timelock
vault.setMinDepositAmount(classId);

πŸ§ͺ Testing

Run Test Suite

# All tests
forge test

# Specific test file
forge test --match-path test/units/deposit/AlephVaultDeposit.unit.t.sol

# Integration tests
forge test --match-path test/integrations/

# Fuzzing tests
forge test --match-path test/invariants/

# Gas optimization tests
forge test --gas-report

Test Categories

  • Unit Tests (test/units/) - Individual contract testing
  • Integration Tests (test/integrations/) - End-to-end workflows
  • Invariant Tests (test/invariants/) - Property-based fuzzing
  • Gas Tests - Gas consumption analysis

πŸ“‹ Development

Code Style

The project follows strict formatting and style guidelines:

# Format code
forge fmt

# Check formatting
forge fmt --check

# Lint (if configured)
npm run lint

Key Development Principles

  1. Security First - All functions include proper access controls
  2. Gas Optimization - Efficient storage patterns and minimal external calls
  3. Modularity - Clean separation of concerns with delegate patterns
  4. Upgradability - Safe upgrade patterns with timelock governance
  5. Documentation - Comprehensive NatSpec documentation

πŸ” Security

Security Features

  • Role-Based Access Control - Fine-grained permission system
  • Emergency Pause System - Circuit breakers for critical functions
  • Timelock Governance - Delayed parameter changes
  • Reentrancy Protection - Guards against reentrancy attacks
  • Input Validation - Comprehensive parameter checking

Audit Status

  • βœ… Internal security reviews completed
  • πŸ”„ External audit in progress
  • πŸ“‹ Bug bounty program planned

Reporting Security Issues

Please report security vulnerabilities to dev@aleph.finance


πŸ“š Documentation

Core Interfaces

  • IAlephVault - Main vault interface with view methods
  • IAlephVaultDeposit - Async deposit functionality
  • IAlephVaultRedeem - Async redemption functionality
  • IAlephVaultSettlement - Oracle settlement interface
  • IFeeManager - Fee calculation and collection
  • IAccountant - Protocol-level accounting

Key Concepts

  • Share Classes - Different investment terms within a vault
  • Batch Settlement - Async processing with NAV updates
  • High Water Mark - Performance fee calculation benchmark
  • Notice Periods - Required waiting time for redemptions
  • Lock-in Periods - Minimum investment duration

🌍 Deployment

Supported Networks

Network Chain ID Status
Ethereum Mainnet 1 πŸ”„ Coming Soon
Sepolia Testnet 11155111 βœ… Active
Hoodi Testnet 560048 βœ… Active

Factory Addresses

Network Factory Address
Sepolia Testnet TBD
Hoodi Testnet TBD

Deployment Scripts

# Deploy factory
forge script script/DeploymentScripts/DeployFactory.s.sol --rpc-url $SEPOLIA_RPC_URL --broadcast --verify

# Deploy accountant
forge script script/DeploymentScripts/DeployAccountant.s.sol --rpc-url $SEPOLIA_RPC_URL --broadcast --verify

# Upgrade vault (via Safe)
npm run upgrade-vault

πŸ“„ License

This project is licensed under the Business Source License 1.1 (BUSL-1.1). See the LICENSE file for details.


πŸ“ž Support & Community


πŸ”— Related Projects


Built with ❀️ by Othentic Labs

Aleph Protocol - Redefining Digital Asset Management

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •