Skip to main content

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:
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
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
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: REBALANCE_MANAGERThe rebalance manager defines comprehensive ranges for the rebalancing operation:
Time periods created:
  • 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
The restricted period auto-extends when the auction launcher is active, ensuring they always have time to act.
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
This ensures the system remains functional even without the AUCTION_LAUNCHER.
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:
Important: Prices on the first and last blocks may not exactly match startPrice and endPrice unless transactions occur at precise start and end timestamps.

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:
Key insights:
  1. Surplus grows over time: If selling token surplus is limiting, sellAmount increases with each auction as high_limit decreases
  2. Deficit shrinks over time: If buying token deficit is limiting, sellAmount decreases as low_limit increases
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:
Eligibility requirements:
  • 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

The priceControl setting determines auction launcher authority:
Security: Highest
Flexibility: Lowest
The 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.
Best Practice for ATOMIC_SWAP: The AUCTION_LAUNCHER should:
  1. Open auction with fixed price
  2. Fill auction atomically in same transaction
  3. End rebalance immediately after
All three operations should be bundled for security.

Weight Control

When weightControl == true, the AUCTION_LAUNCHER can adjust individual token weights:
Use cases:
  • 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
Without weight control:
  • 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:
This forces all auction fills through trusted filler protocols, potentially improving execution quality and MEV protection.

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 use nonReentrant modifier:
Read-Only Reentrancy: While the Folio itself is protected, consuming protocols must check stateChangeActive() before using view functions:

Upgrade Safety

Upgrades are checked against the version registry:

Token Safety Boundaries

Governance Responsibility: It is governance’s duty to ensure Folio supply never exceeds 1e36. Consider implementing supply caps or monitoring systems.

State Management

Rebalance State Machine

Auction State Machine

Utility Libraries

Core rebalancing calculations:
  • Lot size calculations
  • Surplus/deficit determination
  • Price curve interpolation
  • Range validation and narrowing logic
Folio-specific utilities:
  • Basket value calculations
  • Share price computations
  • Fee calculations
  • Asset amount conversions
Mathematical operations:
  • Safe arithmetic
  • Fixed-point math (D18, D27)
  • Exponential decay calculations
System-wide constants:

Deprecation Mechanism

Folios can be deprecated by the DEFAULT_ADMIN_ROLE:
Effects:
  • 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)

  1. Daily fee inflation: Reduced from per-block to once-per-day calculations
  2. EnumerableSet usage: Efficient basket token tracking
  3. Calldata over memory: Where possible for external functions
  4. 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:
Use this for frontend integrations to minimize RPC calls.

Next Steps

Quick Start

Deploy your first Folio with practical examples

API Reference

Complete function reference with parameters and return values