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 FolioLens contract provides convenient read-only functions for analyzing Folio state. It’s designed for off-chain use by frontends, analytics tools, and indexers. These functions are gas-intensive and should not be called on-chain.Key Features
- Spot Weight Calculation: Compute current token weights from balances
- Batch Bid Queries: Get all auction bids at once
- Surplus/Deficit Analysis: Calculate which tokens need buying or selling
- Off-Chain Optimized: Not intended for on-chain calls
Analysis Functions
Get Spot Weights
Calculate token weights based on current Folio balances.Folio contract to analyze
FolioLens.sol
tokens: Array of token addresses in the basketweights: Token weights in D27 format (tokens per share)
Weights are calculated as:
(D27 * tokenBalance) / totalSupply. This gives the actual composition by current holdings, which may differ from target weights during rebalancing.Get All Bids
Retrieve all possible bids for an auction in a single call.Folio contract with active auction
ID of the auction to query
FolioLens.sol
- Array of
SingleBidstructs for all valid token pairs
This function attempts to call
getBid() for all N² token pairs. Invalid pairs (those that would revert) are filtered out. Only returns bids with non-zero amounts.Surpluses and Deficits
Calculate which tokens are over/under the target limits.Folio contract to analyze
Upper BU limit for selling (D18 format)
Lower BU limit for buying (D18 format)
FolioLens.sol
tokens: Array of token addressessurpluses: Amount above sell limit for each token (0 if not surplus)deficits: Amount below buy limit for each token (0 if not deficit)
Data Structures
SingleBid
Represents a single auction bid for a token pair.Token being sold by the Folio
Token being bought by the Folio
Amount of sell token available
Amount of buy token required
Price in D27 format (buyTok/sellTok)
Usage Examples
Analyze Current Composition
Find Best Auction Bids
Calculate Rebalancing Needs
Constants
18-decimal fixed point scaling factor
27-decimal fixed point scaling factor (used for weights and prices)
Integration Notes
Frontend Integration: Use these functions via
eth_call (read-only RPC calls). Never send transactions to FolioLens.Indexing: These functions are useful for building subgraphs or analytics dashboards. Call them periodically to track Folio state changes.
Error Handling
Functions usetry/catch to gracefully handle invalid states: