Skip to main content

Indexer

Block-Level Indexing

Rosetta’s Indexer computes the state of every tracked vault and market at every block.

The Problem with Event-Based Systems

Most DeFi data infrastructure is event-based: state updates only when transactions occur. Between transactions, data goes stale. But interest accrues every block. A market with no transactions still has borrowers owing more, lenders entitled to more, utilization shifting, and rates adjusting. Event-based systems miss all of this.

What Rosetta Does Differently

Rosetta treats each block as the atomic unit of truth. Instead of waiting for events, the Indexer:
  1. Accrues interest forward: Computes what borrowers owe and lenders are entitled to at the current block, regardless of when the last transaction occurred
  2. Recomputes utilization: Calculates the current ratio of borrowed to supplied assets, reflecting accrued interest
  3. Recalculates rates: Runs the protocol’s IRM logic to determine current Borrow APY and Supply APY
  4. Updates vault state: Rolls up market-level changes to compute current vault positions, PPS, and blended yields
  5. Stores block-level snapshots: Maintains a time series of state at block granularity

Why This Matters

Block-level data enables:
  • Accurate yield comparison: Compare vaults using current rates, not stale snapshots
  • Precise routing decisions: The Yield Router acts on real-time data, not outdated signals
  • Honest APY reporting: Users see what they will actually earn, not what the rate was hours ago
  • Backtesting with fidelity: Historical analysis uses actual block-by-block state, not interpolated guesses
The Indexer is the foundation that makes intelligent routing possible.

How It Works

Accrual Computation

Interest accrues based on time elapsed and the current borrow rate. For each block, the Indexer computes:

Utilization and Rate Recalculation

With updated totals, utilization is recomputed:
The Indexer then runs the protocol’s IRM to get current rates. For an adaptive curve IRM:
Where C = 4 (curve steepness) and speed = 50 (adaptation speed). Supply rate derives from borrow rate:

APY Conversion

Rates are per-second. To convert to APY:

Price Per Share (PPS)

For markets and vaults, PPS tracks the value of each share over time:
As interest accrues, total_assets grows while total_shares remains constant (until deposits/withdrawals), causing PPS to increase.

Vault State Rollup

Vaults hold shares in multiple markets. The Indexer values each position and aggregates:
Vault Supply APY is the weighted average of underlying market rates:

Block Snapshot Schema

Each block produces a snapshot stored with the following structure:

Aave Accrual

The Indexer also tracks Aave markets using the Aave V3 accrual model. While the principles are the same — compute state at every block — the mechanics differ from Morpho.

Aave Interest Accrual

Aave tracks cumulative interest via a liquidity index, a monotonically increasing multiplier:
A supplier’s actual balance at any block is:
The scaled_balance is set at deposit time and remains constant. As the liquidity index grows, the actual balance increases — this is how Aave accrues yield.

Aave Supply APY

The Indexer computes this at every block, capturing rate changes that occur between transactions.

Multi-Chain Indexing

The same block-level approach applies across all supported chains. On Base, the Indexer tracks Morpho markets using the same accrual computation described above. Each chain maintains its own snapshot timeline indexed by block number.

What It Tracks

The Indexer maintains continuous state for three entity types: Morpho markets, Morpho vaults, and Aave reserves.

Morpho Markets

For each Morpho lending market, the Indexer tracks:

Morpho Vaults

For each vault, the Indexer tracks:

Aave Reserves

For each Aave reserve, the Indexer tracks:

Update Frequency

All metrics are recomputed every block. On HyperEVM with ~1 second block times, this means near real-time accuracy. On Base, block times are ~2 seconds. Historical data is retained at block granularity, enabling:
  • Point-in-time queries at any block height
  • Time-series analysis of yield trends
  • Backtesting of routing strategies
  • Cross-chain yield comparison at synchronized timestamps