System Overview
Reserve Folio implements a sophisticated multi-layer architecture designed for secure, efficient portfolio management under governance constraints.The architecture is specifically designed to enable high-fidelity asset management and rebalancing even when operating under timelock delays.
Contract Architecture
Layer 0: DAO Contracts
The foundational layer managing ecosystem-wide concerns:FolioVersionRegistry.sol
FolioVersionRegistry.sol
Maintains a registry of approved
FolioDeployer versions. Owned by the DAO, this contract ensures only vetted deployer contracts can create new Folios.Key Functions:- Track approved deployer versions
- Enable/disable specific versions
- Prevent deployment from deprecated versions
FolioDAOFeeRegistry.sol
FolioDAOFeeRegistry.sol
Handles ecosystem-wide fee configuration, including the universal 15 bps minimum floor.Key Features:
- Set global minimum fee floor
- Configure per-Folio fee overrides (can only lower)
- Manage DAO fee recipients
- Track fee distribution
RoleRegistry (Interface)
RoleRegistry (Interface)
External contract providing role-based access control. Must implement
IRoleRegistry interface.Layer 1: Folio Contracts
Core portfolio management contracts:Folio.sol
The heart of the system. An ERC20 token backed by a flexible basket of assets with built-in auction logic for rebalancing.
FolioDeployer.sol
Factory contract for deploying new Folio instances with initial configuration and role assignments.
FolioProxy.sol
Upgradeable proxy enabling contract evolution while preserving storage. Checks upgrades against FolioVersionRegistry.
Layer 2: Governance System
1
StakingVault
ERC4626 vault where users stake Folio tokens to receive voting power. Supports:
- Multi-token reward streams
- Unstaking delays for security
- ERC20Votes for governance participation
- Optimistic governance with slashing (v5.0.0+)
2
FolioGovernor
Time-based governance system managing protocol parameters through proposals and voting.
3
GovernanceDeployer
Deploys complete governance systems including staking vaults and governors.
Layer 3: Staking and Rewards
StakingVault implements a sophisticated multi-reward system where rewards decay exponentially based on a configurable half-life (1 day to 2 weeks).
Rebalancing Architecture
Rebalance Lifecycle
1
Initiation: startRebalance()
Called by: Time periods created:
REBALANCE_MANAGERThe rebalance manager defines comprehensive ranges for the rebalancing operation:restrictedUntil: Only AUCTION_LAUNCHER can act (minimum 120s buffer)availableUntil: Rebalance TTL, after which no new auctions can start
2
Restricted Period: openAuction()
Called by:
AUCTION_LAUNCHERDuring the restricted period, the auction launcher opens auctions with optional parameter adjustments:- Token selection: Subset of tokens in rebalance
- Basket limits: Progressive narrowing (monotonic convergence)
- Weights: Progressive narrowing if
weightControl == true - Prices: Subset of ranges if
priceControl != NONE
3
Unrestricted Period: openAuctionUnrestricted()
Called by: AnyoneAfter the restricted period expires (or if AUCTION_LAUNCHER is inactive), anyone can open auctions using spot estimates:
- All tokens in rebalance are included
- Uses spot prices and weights
- No parameter customization allowed
4
Trading: bid() or createTrustedFill()
Called by: Anyone (for bid) or Trusted FillersParticipants execute trades at current auction prices. Trades are validated against:
- Current auction price curve
- Available sell amounts
- Required buy amounts
- Maximum auction sizes
5
Completion: closeAuction() or endRebalance()
Called by:
AUCTION_LAUNCHER, REBALANCE_MANAGER, or DEFAULT_ADMIN_ROLEAuctions close automatically after their duration. Rebalances can be ended early by authorized roles.Auction Mechanics
Price Curve: Exponential Decay
Auctions use exponential decay between optimistic and pessimistic price bounds:Auction Warmup Period
Auctions include a 30-second warmup before bidding begins:The warmup ensures fair competition from the first tradeable block. It is bypassed only when
priceControl == ATOMIC_SWAP and start price equals end price.Lot Sizing Algorithm
Auction sizes are calculated based on surpluses and deficits:- Surplus grows over time: If selling token surplus is limiting,
sellAmountincreases with each auction ashigh_limitdecreases - Deficit shrinks over time: If buying token deficit is limiting,
sellAmountdecreases aslow_limitincreases
The
AUCTION_LAUNCHER progressively narrows the [low, high] ranges to implement Dollar Cost Averaging (DCA) into the target allocation.Pairwise Auction System
Auctions run simultaneously on all possible token pairs in the auction:- Sell token: Must be in surplus (balance > high_limit * high_weight * shares)
- Buy token: Must be in deficit (balance < low_limit * low_weight * shares)
Rebalance Targeting
Rebalances are considered “complete” when all ranges have converged:Price Control Levels
ThepriceControl setting determines auction launcher authority:
- NONE
- PARTIAL
- ATOMIC_SWAP
Security: Highest
Flexibility: LowestThe
Flexibility: LowestThe
AUCTION_LAUNCHER cannot adjust prices. All auctions use the full price ranges specified by REBALANCE_MANAGER.Use case: Maximum security when AUCTION_LAUNCHER trust is limited.Weight Control
WhenweightControl == true, the AUCTION_LAUNCHER can adjust individual token weights:
- Percentage-based portfolios: Maintain specific asset percentages throughout rebalancing
- Dynamic rebalancing: Adjust targets as market conditions change
- Progressive convergence: Narrow weight ranges auction-by-auction for precise DCA
- Only
RebalanceLimits(basket units per share) define rebalancing targets - Best for portfolios with fixed quarterly/monthly targets
Trusted Fillers Integration
Folios can integrate with the Trusted Fillers system for async order matching:Supported Fillers
Currently supports CoW Swap for better price discovery and MEV protection through batch auctions.
Configuration
Enabled per-Folio by governance. When enabled, trusted fillers can compete alongside regular bidders.
Trusted fillers must respect all auction limitations including price curves, lot sizes, and timing constraints.
Disabling Permissionless Bids
In version 5.0.0+, governance can restrict trading to trusted fillers only:Fee Distribution Architecture
Dual-Layer Fee System
TVL Fee Mechanics
Changing from per-block to daily inflation in v4.0.0 reduced gas costs without changing the economic model.
Mint Fee Mechanics
Security Considerations
Reentrancy Protection
All state-changing functions usenonReentrant modifier:
Upgrade Safety
Upgrades are checked against the version registry:Token Safety Boundaries
State Management
Rebalance State Machine
Auction State Machine
Utility Libraries
RebalancingLib.sol
RebalancingLib.sol
Core rebalancing calculations:
- Lot size calculations
- Surplus/deficit determination
- Price curve interpolation
- Range validation and narrowing logic
FolioLib.sol
FolioLib.sol
Folio-specific utilities:
- Basket value calculations
- Share price computations
- Fee calculations
- Asset amount conversions
MathLib.sol
MathLib.sol
Mathematical operations:
- Safe arithmetic
- Fixed-point math (D18, D27)
- Exponential decay calculations
Constants.sol
Constants.sol
System-wide constants:
Deprecation Mechanism
Folios can be deprecated by theDEFAULT_ADMIN_ROLE:
- Minting disabled
- Rebalancing disabled
- Redemption still enabled (redemption-only mode)
Use deprecation when a Folio needs to wind down gracefully, allowing holders to exit but preventing new capital inflows.
Performance Optimizations
Gas Optimizations (v5.0.0)
- Daily fee inflation: Reduced from per-block to once-per-day calculations
- EnumerableSet usage: Efficient basket token tracking
- Calldata over memory: Where possible for external functions
- Packed structs: Optimized storage layout
Scalability Considerations
- Max auction length: 7 days (configurable down to 60 seconds)
- Basket size: No hard limit, but gas costs scale linearly
- Fee recipients: Limited to prevent gas issues during distribution
- Concurrent auctions: 1 active auction at a time per Folio
Peripheral Contracts
FolioLens.sol
View-only helper contract for batch queries:Next Steps
Quick Start
Deploy your first Folio with practical examples
API Reference
Complete function reference with parameters and return values