Reserve Folio is a protocol for creating and managing portfolios of ERC20-compliant assets entirely onchain. Folios are designed to be used as a single-source of truth for asset allocations, enabling composability of complex, multi-asset portfolios.
Folios support rebalancing via Dutch Auction over an exponential decay curve between two prices. Control flow over the auction is shared between two parties, with a AUCTION_APPROVER
approving auctions in advance and a AUCTION_LAUNCHER
opening them, optionally providing some amount of additional detail. Permissionless execution is available after a delay.
AUCTION_APPROVER
is expected to be the timelock of the fast-moving rebalancing governor associated with the Folio.
AUCTION_LAUNCHER
is expected to be a semi-trusted EOA or multisig; They can open auctions within the bounds set by governance, hopefully adding basket definition and pricing precision. If they are offline the auction can be opened permissionlessly after a preset delay. If they are evil, at-best they can deviate rebalancing within the governance-granted range, or prevent a Folio from rebalancing entirely by repeatedly closing-out auctions.
- FolioDAOFeeRegistry.sol: Handles the fees associated with the broader ecosystem DAO that Folios pay into.
- FolioVersionRegistry.sol: Keeps track of various versions of
FolioDeployer
, owned by the DAO.
While not included directly, FolioVersionRegistry
and FolioDAOFeeRegistry
also depend on an existing RoleRegistry
instance. This contract must adhere to the contracts/interfaces/IRoleRegistry.sol interface.
- Folio.sol: The primary contract in the system. Represents a portfolio of ERC20 assets, and contains auction logic that enables it to rebalance its holdings.
- FolioDeployer.sol: Manages the deployment of new Folio instances.
- FolioProxy.sol: A proxy contract for delegating calls to a Folio implementation that checks upgrades with
FolioVersionRegistry
.
- FolioGovernor.sol: Canonical governor in the system, time-based.
- GovernanceDeployer.sol: Deploys staking tokens and governing systems.
- StakingVault.sol: A vault contract that holds staked tokens and allows users to earn rewards simultaneously in multiple reward tokens. Central voting token for all types of governance.
A Folio has 3 roles:
DEFAULT_ADMIN_ROLE
- Expected: Timelock of Slow Folio Governor
- Can add/remove assets, set fees, configure auction length, set the auction delay, and closeout auctions
- Can configure the
AUCTION_APPROVER
/AUCTION_LAUNCHER
- Primary owner of the Folio
AUCTION_APPROVER
- Expected: Timelock of Fast Folio Governor
- Can approve auctions
AUCTION_LAUNCHER
- Expected: EOA or multisig
- Can open and close auctions, optionally altering parameters of the auction within the approved ranges
The staking vault has ONLY a single owner:
- Expected: Timelock of Community Governor
- Can add/remove reward tokens, set reward half-life, and set unstaking delay
- Auction is approved by governance, including an initial price range
- Auction is opened, initiating the progression through the predetermined price curve a. ...either by the auction launcher (immediately, or soon after) b. ...or permissionlessly (after the auction delay passes)
- Bids occur
- Auction expires
Governance configures buy and sell limits for the basket ratios, including a spot estimate:
struct BasketRange {
uint256 spot; // D27{buyTok/share}
uint256 low; // D27{buyTok/share} inclusive
uint256 high; // D27{buyTok/share} inclusive
}
BasketRange sellLimit; // D27{sellTok/share} min ratio of sell tokens in the basket, inclusive
BasketRange buyLimit; // D27{buyTok/share} max ratio of buy tokens in the basket, exclusive
During openAuction
the AUCTION_LAUNCHER
can set the buy and sell limits within the approved ranges provided by governance. If the auction is opened permissionlessly instead, the governance pre-approved spot estimates will be used instead.
There are broadly 3 ways to parametrize [startPrice, endPrice]
, as the AUCTION_APPROVER
:
- Can provide
[0, 0]
to fully defer to the auction launcher for pricing. In this mode the auction CANNOT be opened permissionlessly. Loss can arise either due to the auction launcher settingstartPrice
too low, or due to precision issues from traversing too large a range. - Can provide
[startPrice, 0]
to defer to the auction launcher for just theendPrice
. In this mode the auction CANNOT be opened permissionlessly. Loss can arise due solely to precision issues only. - Can provide
[startPrice, endPrice]
to defer to the auction launcher for thestartPrice
. In this mode the auction CAN be opened permissionlessly, after a delay. Suggested default option.
The AUCTION_LAUNCHER
can always choose to raise startPrice
within a limit of 100x, and endPrice
by any amount. They cannot lower either price.
The price range (startPrice / endPrice
) must be less than 1e9
to prevent precision issues.
Note: The first block may not have a price of exactly startPrice
, if it does not occur on the start
timestamp. Similarly, the endPrice
may not be exactly endPrice
in the final block if it does not occur on the end
timestamp.
Auction lots are sized by Auction.sellLimit
and Auction.buyLimit
. Both correspond to Folio invariants about basket ratios that must be maintained throughout the auction:
sellLimit
is the min amount of sell token in the basketD27{sellTok/share}
buyLimit
is the max amount of buy token in the basketD27{buyTok/share}
The auction lot()
represents the single largest quantity of sell token that can be transacted under these invariants.
In general it is possible for the lot
to both increase and decrease over time, depending on whether sellLimit
or buyLimit
is the constraining factor in sizing.
Anyone can bid in any auction in size up to and including the lot
size. Use getBid()
to determine the amount of buy tokens required in any given timestamp.
Folio.getBid(uint256 auctionId, uint256 timestamp, uint256 sellAmount) external view returns (uint256 bidAmount)
Folios support 2 types of fees. Both have a DAO portion that work the same underlying way, placing limits on how small the fee can be.
Per-unit time fee on AUM
The DAO takes a cut with a minimum floor of 15 bps. A consequence of this is that the Folio always inflates at least 15 bps annually. If the tvl fee is set to 15 bps, then 100% of this inflation goes towards the DAO.
Fee on mints
The DAO takes a cut with a minimum floor of 15 bps. The DAO always receives at least 15 bps of the value of the mint. If the mint fee is set to 15 bps, then 100% of the mint fee is taken by the DAO.
The universal 15 bps fee floor can be lowered by the DAO, as well as set (only lower) on a per Folio basis.
Units are documented with curly brackets ({}
) throughout the codebase with the additional D18
or D27
prefixes being used to denote when additional decimals of precision have been applied, for example in the case of a ratio. Amounts and percentages are generally 18-decimal throughout the codebase, but exchange rates are generally 27-decimal.
Units:
{tok}
OR{share}
OR{reward}
: token balancesD27
: 1e27D18
: 1e18D18{1}
: a percentage value with 18 decimals of added precisionD18{tok1/tok2}
: a ratio of two token balances with 18 decimals of added precision{s}
: seconds
Example:
// {share} = {share} * D18{1} / D18
uint256 shares = (pendingFeeShares * feeRecipients[i].portion) / SCALAR;
Tokens are assumed to be within the following ranges:
Folio | Folio Collateral | StakingVault | StakingVault underlying/rewards | |
---|---|---|---|---|
Supply | 1e36 | 1e36 | 1e36 | 1e36 |
Decimals | 27 | 21 |
It is the job of governance to ensure the Folio supply does not grow beyond 1e36 supply.
Exchange rates / prices are permitted to be up to 1e54, and are 27 decimal fixed point numbers instead of 18.
Some ERC20s are NOT supported
Weirdness | Folio | StakingVault |
---|---|---|
Multiple Entrypoints | ❌ | ❌ |
Pausable / Blocklist | ❌ | ❌ |
Fee-on-transfer | ❌ | ❌ |
ERC777 / Callback | ✅ | ❌ |
Downward-rebasing | ✅ | ❌ |
Upward-rebasing | ✅ | ❌ |
Revert on zero-value transfers | ✅ | ✅ |
Flash mint | ✅ | ✅ |
Missing return values | ✅ | ✅ |
No revert on failure | ✅ | ✅ |
Note: While the Folio itself is not susceptible to reentrancy, read-only reentrancy on the part of a consuming protocol is still possible.
- After governors remove a token from the basket via
Folio.removeFromBasket()
, users have a limited amount of time to claim rewards. Removal should only be used if the reward token has become malicious or otherwise compromised.
delegatecall
functionality / way to claim rewards currently there is no way to claim rewards, for example to claim AERO as a result of holding a staked Aerodrome position. An autocompounding layer such as beefy or yearn would be required in order to put this kind of position into a Folio- alternative community governance systems currently only bring-your-own-erc20 governance is supported but we would like to add alternatives in the future such as (i) NFT-based governance; and (ii) an ERC20 fair launch system
- Required Tools:
- Foundry
- Node v20+
- Yarn
- Install Dependencies:
yarn install
- Build:
yarn compile
- Testing:
- Basic Tests:
yarn test
- Extreme Tests:
yarn test:extreme
- All Tests:
yarn test:all
- Basic Tests:
- Deployment:
- Deployment:
yarn deploy --rpc-url <RPC_URL> --verify --verifier etherscan
Set ETHERSCAN_API_KEY env var to the API key for whichever network you're targeting (basescan, etherscan, arbiscan, etc)
- Deployment: