Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/reserve-protocol/reserve-index-dtf/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The FolioVersionRegistry contract maintains a registry of Folio implementation versions. It tracks which deployer contracts are available for creating new Folios and allows the protocol to deprecate insecure or outdated versions.

Key Features

  • Version Tracking: Maps version strings to FolioDeployer contracts
  • Latest Version: Maintains pointer to most recent deployment
  • Deprecation: Can mark versions as deprecated for security
  • Version Queries: Retrieve deployer and implementation for any version

Registration Functions

Register Version

Register a new Folio version with its deployer.
folioDeployer
IFolioDeployer
Address of the FolioDeployer contract for this version
FolioVersionRegistry.sol
function registerVersion(IFolioDeployer folioDeployer) external
The version string is automatically read from the deployer contract using Versioned(address(folioDeployer)).version(). Each version can only be registered once.
Only protocol owners can register new versions. The newly registered version automatically becomes the latest version.

Deprecate Version

Mark a version as deprecated, preventing its use in UI and warning users.
versionHash
bytes32
Keccak256 hash of the version string to deprecate
FolioVersionRegistry.sol
function deprecateVersion(bytes32 versionHash) external
Deprecation is irreversible. This should only be used for versions with security issues or critical bugs. Requires owner or emergency council role.

Query Functions

Get Latest Version

Retrieve the most recently registered version.
FolioVersionRegistry.sol
function getLatestVersion() external view returns (
    bytes32 versionHash,
    string memory version,
    IFolioDeployer folioDeployer,
    bool deprecated
)
Returns:
  • versionHash: Keccak256 hash of version string
  • version: Human-readable version string (e.g., “3.4.1”)
  • folioDeployer: Deployer contract address
  • deprecated: Whether this version is deprecated
The latest version may be deprecated if it was the most recent registration before being flagged. Always check the deprecated flag.

Get Implementation for Version

Retrieve the Folio implementation address for a specific version.
versionHash
bytes32
Version hash to look up
FolioVersionRegistry.sol
function getImplementationForVersion(
    bytes32 versionHash
) external view returns (address folio)

Get Deployer

Direct mapping access to get deployer for a version hash.
FolioVersionRegistry.sol
function deployments(bytes32 versionHash) external view returns (IFolioDeployer)

Check Deprecation Status

Check if a version is deprecated.
FolioVersionRegistry.sol
function isDeprecated(bytes32 versionHash) external view returns (bool)

Events

VersionRegistered
event
Emitted when a new version is registeredParameters:
  • versionHash - Keccak256 hash of version string
  • folioDeployer - Deployer contract address
VersionDeprecated
event
Emitted when a version is deprecatedParameters:
  • versionHash - Hash of deprecated version

Errors

VersionRegistry__ZeroAddress
error
Thrown when trying to register a zero address
VersionRegistry__InvalidCaller
error
Thrown when caller lacks required permissions
VersionRegistry__InvalidRegistration
error
Thrown when trying to register an already-registered version
VersionRegistry__AlreadyDeprecated
error
Thrown when trying to deprecate an already-deprecated version
VersionRegistry__Unconfigured
error
Thrown when querying an unregistered version

Access Control

roleRegistry
IRoleRegistry
Immutable reference to the RoleRegistry for permission checks
Permissions:
  • registerVersion(): Requires owner role
  • deprecateVersion(): Requires owner or emergency council role

Version Hash Calculation

Version hashes are calculated as:
bytes32 versionHash = keccak256(abi.encodePacked(version));
For example, version “3.4.1” becomes:
keccak256(abi.encodePacked("3.4.1"))

Usage Example

// Register a new version
FolioDeployer deployer = new FolioDeployer(/* ... */);
versionRegistry.registerVersion(deployer);

// Query latest version
(
    bytes32 versionHash,
    string memory version,
    IFolioDeployer folioDeployer,
    bool deprecated
) = versionRegistry.getLatestVersion();

require(!deprecated, "Latest version is deprecated");

// Use the deployer to create a Folio
address newFolio = folioDeployer.deployFolio(/* ... */);

// If security issue found
versionRegistry.deprecateVersion(versionHash);

Integration with Versioned Contract

All FolioDeployer contracts must inherit from the Versioned base contract, which implements a version() function returning a semantic version string.
contract FolioDeployer is Versioned {
    // version() returns something like "3.4.1"
}

Frontend Integration

Frontends should always check both if a version exists and whether it’s deprecated before allowing users to deploy with it. Use getLatestVersion() to show the recommended version.

Build docs developers (and LLMs) love