For the complete documentation index, see llms.txt. This page is also available as Markdown.

NAV Calculator

The core accounting contract, registers assets, feeds, and adapters, and returns NAV and positions.

The NAV Calculator (NAVCalculator) is the core accounting contract. It registers the assets a fund can hold, the price feeds that value them, and the balance adapters that locate them, then returns the fund's NAV and full position breakdown for any account on that chain.

Source: NAVCalculator.sol

At a glance

Contract

NAVCalculator

Type

UUPS upgradeable proxy, one instance per chain

Roles

DEFAULT_ADMIN_ROLE · MANAGER (NAV timelock · Security Council Safe; Robinhood Chain: its Governance Safe)

Chains

Ethereum · Optimism · Arbitrum · Base · Gnosis · BSC · Polygon · Arc (+ 17 canonical-only) · Robinhood Chain

It is fund-agnostic: a single instance per chain prices any account. It is deployed as a UUPS proxy at a canonical CREATE2 address, identical across all chains, and is upgradeable by the holders of DEFAULT_ADMIN_ROLE: the NAV timelock and the Security Council Safe (the Robinhood Chain Governance Safe on Robinhood Chain).

Roles are held by the NAV timelock and the Security Council Safe on all 25 chains of the fleet: both DEFAULT_ADMIN_ROLE (proxy upgrades, the sequencer uptime-feed setter, and granting and revoking the roles) and MANAGER (asset, feed, and adapter configuration).

The timelock is an OpenZeppelin TimelockController at 0xAB92EA75D07792915eB1f29259354866B880dFC2, the same address on all 25 chains. Its only proposer and canceller is the Security Council Safe 0x8b884f80B3B839F52b6cE168f133e7a5D1f0A537, anyone may execute, and it administers itself. Its delay (minDelay) is currently 0, and the Security Council Safe also holds both roles directly.

AssetKindRegistry holds MANAGER only, so that it can register, classify, and label an asset in one transaction.

The Security Council Safe is 5-of-8 on every chain.

Robinhood Chain (4663) runs the same proxy and implementation but is governed separately: there is no timelock, both roles are held by the Robinhood Chain Governance Safe 0x2F0d561B9a8CD981e6E73069592BDeA4e48A8bec (2-of-5), and AssetKindRegistry holds MANAGER.

Deployed addresses are listed on the Deployment addresses page. Always call the proxy; the implementation may change on upgrade.

How it works

getAccountNav(account, quoteAsset)
  ├─ for each registered balance adapter:
  │    └─ adapter.getAdapterPositions(account, …) → PositionBalance[]
  ├─ for each position:
  │    ├─ (price, decimals, stale) = primary feed for balanceAsset
  │    ├─ irregular = primary vs monitor feeds beyond tolerance (signal only)
  │    └─ value = ±(amount × price) / 10^(assetDecimals)          // − when isDebt
  └─ return NAV {
         value,               // total in quote asset units (USD = 8 decimals)
         quoteAsset,
         timestamp,
         stalePriceAssets,    // assets whose primary feed was stale
         irregularPriceAssets,// assets whose primary diverged from monitors / peg
         sequencerDown,       // L2 sequencer status
         quoteAssetStale,     // quote-asset feed stale → value falls back to USD
         monitorsUnhealthyPriceAssets  // monitors configured, none readable → no divergence check ran
     }

Solidity interface

Structs

The interface defines the position model, the NAV snapshot, and the price-feed snapshot. Expand each group for the full definitions.

Position model, Asset, PositionBalance, Position, VerbosePosition, VerboseNAV
Partial NAV snapshot: PartialNAV

Returned by getAccountNavForAdapters, for paging a NAV read that no longer fits in a single eth_call. It mirrors NAV's first eight fields in order, then appends the adapters the slice actually covered:

The positional mirror stops at those eight fields. monitorsUnhealthyPriceAssets sits after adaptersCovered here, while in NAV it is the last field, so the two structs no longer line up past the prefix. That is deliberate: keeping adaptersCovered at the offset a live offchain reassembler already decodes matters more than the documentation convenience of a positional mirror. Decode each struct against its own ABI; never assume the mirror extends to new fields.

It is a distinct type from NAV, deliberately: a partial result must not be assignable or decodable where a complete NAV is expected. Both reads run the same underlying computeNav, with the validated slice in place of the full adapter set, so a complete read and the sum of its slices agree because they are literally the same code path.

A meta-adapter is the atomic unit. Naming one in a slice includes all of its governed instances; there is no paging within a single adapter, since the instance set is itself swap-and-pop mutable and an instance range would carry the identical hazard. If one meta-adapter alone exceeds the budget, pagination cannot help.

Price-feed snapshot: PriceFeedData

For a Custom feed, a composite of a rate and a base/USD leg, (updatedAt, chainlinkHeartbeat) report the governing leg: the underlying Chainlink leg with the greatest age / heartbeat ratio, i.e. the one closest to its own staleness deadline. The pair is therefore a real, matched pair from one actual oracle rather than a mix of two, and it reduces to the single leg's values for a single-leg feed. Which leg governs can change between reads as the ratios cycle, so a two-leg feed's reported heartbeat may alternate between its legs' values. See Price feeds.

Read functions

Function
Purpose

getAccountNav

Total chain-local NAV for an account in a quote currency (address(0) = USD)

getAccountNavForAdapters

NAV over a caller-supplied subset of adapters, for paging a read too large for one call (returns PartialNAV)

getAccountPositions

One priced Position per balance entry reported for an account

getAccountPositionsForAsset

Priced positions for a single asset across all adapters that report it

getAccountNavVerbose

getAccountNav plus per-position protocolName + labels[] (returns VerboseNAV)

getAccountPositionsVerbose

getAccountPositions enriched with protocolName + labels[] (returns VerbosePosition[])

getAccountPositionsForAssetVerbose

Single-asset verbose positions (returns VerbosePosition[])

healthCheck

Sequencer status + currently-stale and currently-irregular assets, without a full NAV

getPriceData

Detailed data for an asset's primary feed + divergence signal (price, stale, irregular …)

getPriceDataNoDivergence

Same as getPriceData but skips the monitor read (used on the base/USD hot path)

getPriceDivergence

Live primary-vs-monitor divergence read (median, worst-case bps, irregular, direction)

hasPositions

Whether an account has any non-zero position

getAssetsWithPositions

Assets for which an account holds a non-zero position

calculateValue

Value of a set of (asset, amount) pairs in a quote currency

getAssetInfo

One asset's classification and display labels, in a single call

getRegisteredAsset

Resolves one asset to its (address, symbol, decimals) in O(1), plus a found flag

getRegisteredAssets · isAssetRegistered · getAssetCount

Asset-registry introspection

usdDecimals · version

USD value decimals (e.g. 8); implementation version

Full read-function signatures

Examples

Illustrative calls and returns. Values are example data (not live); addresses are abbreviated. The account is a portfolio Safe, USDC = 0xA0b8…eB48 (6 dp), WETH = 0xC02a…6Cc2 (18 dp), and the USD quote asset is address(0).

Stale prices and sequencer status

The NAV struct carries hard reliability signals, stalePriceAssets, sequencerDown, and quoteAssetStale, that must block a pricing read, plus two soft signals: irregularPriceAssets (and quoteAssetIrregular), which flags a price the primary and monitor feeds disagree on, and monitorsUnhealthyPriceAssets, which flags assets where no monitor answered at all, so the disagreement check never ran. See Stale prices & sequencer for the full model, and use healthCheck() to poll chain health without computing a full NAV; noting that healthCheck does not carry the third array.

Admin / Manager API

Configuration is privileged. Most mutations require the MANAGER role; the sequencer uptime-feed setter, proxy upgrades, and granting and revoking the roles require DEFAULT_ADMIN_ROLE. Both roles are held by the NAV timelock and the Security Council Safe (the Governance Safe on Robinhood Chain); AssetKindRegistry holds MANAGER only. All batch calls are all-or-nothing: if any item fails its check, the whole transaction reverts.

Assets & price feeds (MANAGER)

An asset enters the system with its primary feed via registerAsset, carries one pricing feed plus optional monitor feeds and tolerances, and leaves via unregisterAsset. See Price feeds for the primary-feed + divergence-monitor model.

Function
What it does · key reverts

registerAsset(asset, priceFeed, priceType, heartbeat)

Registers a new asset and its primary price feed in one call; reads symbol/decimals from the ERC-20 (or the native-token constant) and adds the asset to the default (wallet) adapter's inclusion list, unless a meta-adapter already claims the token, in which case the token is not added to the default adapter's inclusion list. Reverts NotAContract("asset") for an address with no code (the native-token sentinel aside), so a typo'd or not-yet-deployed token cannot be registered.

addOrModifyPriceFeed(asset, priceFeed, priceType, heartbeat)

Adds another pricing feed to an already-registered asset (transitional; production keeps one) or, for a feed the asset already carries, rewrites its heartbeat in place and emits PriceFeedHeartbeatUpdated. Reverts PriceFeedAlreadyRegistered only if the heartbeat is unchanged, PriceFeedTypeImmutable if priceType differs from the stored one (a type whose decimals cannot be resolved, or resolve differently, reverts first with InvalidPriceOracle / PriceFeedDecimalsMismatch), or PriceFeedDecimalsMismatch (the feed's live decimals must equal those stored for the asset's existing pricing feed, checked on a heartbeat update too); heartbeat must be non-zero.

removePriceFeed(asset, priceFeed)

Removes one pricing feed by address. Reverts PriceFeedNotFound, or CannotRemoveLastFeed if it is the only pricing feed left.

removePriceFeedAt(asset, index)

Same, by array index. Reverts PriceFeedIndexOutOfBounds or CannotRemoveLastFeed.

setDivergenceTolerance(asset, bps)

Sets the primary-vs-monitor divergence tolerance. Must be in (0, 10000]; 0 reverts InvalidTolerance; it does not disable the check. Required before any monitor feed can be added.

setPegTolerance(asset, bps)

Sets the $1-peg tolerance (stablecoins). Must be in [0, 10000]; 0 is accepted and disables the peg check (only a value above 10000 reverts InvalidTolerance). Also the switch that decides the asset's peg classification; crossing zero flips it.

setAssetKindRegistry(registry)

Points this NAV at the chain's AssetKindRegistry. Rejects address(0) (InvalidArguments). Re-settable: the registry is a plain contract, so replacing it is a redeploy plus this call.

addMonitorFeed(asset, priceFeed, priceType, heartbeat)

Adds a divergence-only monitor feed. When admitting a new monitor it reverts DivergenceToleranceRequired (no tolerance set). On both paths it reverts MonitorFeedDecimalsMismatch (monitor must report 8 decimals). For a monitor already registered it rewrites the heartbeat in place and emits MonitorFeedHeartbeatUpdated, reverting MonitorFeedAlreadyRegistered only if the heartbeat is unchanged, or PriceFeedTypeImmutable if priceType differs.

removeMonitorFeed(asset, priceFeed) · removeMonitorFeedAt(asset, index)

Removes a monitor feed by address or index (MonitorFeedNotFound). Monitors are optional; the last one may be removed.

unregisterAsset(asset)

Fully removes the asset: clears all its pricing and monitor feeds, removes it from the default-adapter list, and drops it from the asset registry. Use only after the asset is no longer held anywhere.

Balance adapters (MANAGER)

Plain (single-scope) adapters only; meta-adapters use the next group. See Balance adapters.

Function
What it does · key reverts

addBalanceAdapters(address[] adapters)

Batch-registers plain adapters into the global registry. Reverts InvalidArguments (empty list / zero address), DuplicateBalanceAdapter, or MetaAdapterNotAllowed if any adapter implements IMetaBalanceAdapter (those must use addMetaBalanceAdapter).

removeBalanceAdapters(address[] adapters)

Batch-removes adapters from the registry. Removing a meta-adapter also clears its whole instance set and releases its coordinates. Reverts if any is not registered or is the built-in ERC20Default adapter (which cannot be removed).

Meta-adapters & their instances (MANAGER)

A meta-adapter is registered with its initial instance set; the set is then grown or shrunk incrementally. See Meta balance adapters.

Function
What it does · key reverts

addMetaBalanceAdapter(adapter, bytes32[] instances)

Registers a meta-adapter and seeds its instance set atomically; any coordinates left from an earlier registration of the same address are cleared first, so the set is exactly instances. The adapter must implement IMetaBalanceAdapter (else NotMetaAdapter / InvalidBalanceAdapter). Reverts DuplicateBalanceAdapter, DuplicateMetaInstance or MetaInstanceClaimedByAnotherAdapter (see below). An empty instance list is allowed (seed later).

addMetaInstances(adapter, bytes32[] instances)

Adds instance coordinates to a registered meta-adapter. Reverts DuplicateMetaInstance (this adapter already holds the coordinate, or it is repeated in the batch; a duplicate would double-count NAV), MetaInstanceClaimedByAnotherAdapter(instance, claimedBy) (another adapter holds it), InvalidArguments (empty), or NotMetaAdapter.

removeMetaInstances(adapter, bytes32[] instances)

Removes coordinates, freeing them for another adapter. It does not put a removed token back on the default adapter's inclusion list; re-include it with includeAssetInDefaultAdapter. Reverts MetaInstanceNotFound, InvalidArguments (empty), or NotMetaAdapter. Order is not preserved.

Adding a market/vault/pool to coverage is thus an addMetaInstances transaction; never a new contract deploy.

Each coordinate has at most one owning adapter. Claiming a coordinate that is a registered token also removes that token from the default adapter's inclusion list in the same transaction, so the two can never both report it. Releasing a coordinate leaves the token reported by nobody until it is re-included (the safe direction: an under-report rather than a double count). To retire a meta-adapter, release its coordinates and re-include the tokens first, then remove the adapter.

Default (wallet) adapter inclusion (MANAGER)

Function
What it does

excludeAssetFromDefaultAdapter(asset)

Stops the built-in ERC20Default adapter from reporting wallet balances for an asset, without unregistering the asset (its protocol positions still count).

includeAssetInDefaultAdapter(asset)

Re-enables wallet-balance reporting for the asset. Reverts MetaInstanceClaimedByAnotherAdapter if a meta-adapter claims the token.

L2 sequencer & upgrades (DEFAULT_ADMIN_ROLE · grace period: MANAGER)

Function
What it does · key reverts

setChainlinkL2SequencerUptimeFeed(feed)

Sets the Chainlink L2 sequencer uptime feed (address(0) on L1). Admin-gated because disabling sequencer detection on an L2 has upgrade-level impact.

setChainlinkL2SequencerGracePeriod(seconds)

Sets the post-recovery grace period. MANAGER-gated, unlike the uptime feed. Reverts UptimeFeedNotSet if no uptime feed is configured, or InvalidArguments below 1 hour.

UUPS upgrade

upgradeToAndCall(...) (UUPSUpgradeable) is authorised by DEFAULT_ADMIN_ROLE; the implementation can change, the proxy address never does.

Admin / Manager function signatures

Plain adapters are registered with addBalanceAdapters; meta-adapters (one adapter covering many protocol instances) are registered with addMetaBalanceAdapter and have their queried instance set adjusted with addMetaInstances / removeMetaInstances. See Balance adapters.

Multichain aggregation

The offchain NAV Worker collects per-chain NAV values and sums them:

  1. Call getAccountNav on every chain the fund operates on.

  2. Verify stalePriceAssets is empty, sequencerDown is false, and quoteAssetStale is false on every chain.

  3. If any chain is unhealthy, the global NAV is withheld until the condition clears.

  4. Otherwise, sum all per-chain value fields to produce the global fund NAV.

  5. Treat a non-empty irregularPriceAssets as an alert, not a hard block: the value is still usable, but the divergence should be investigated before it widens into a stale/blocking condition.

  6. Treat a non-empty monitorsUnhealthyPriceAssets as an alert on the check itself rather than on the price: those assets lost their cross-check this read, so an empty irregularPriceAssets says nothing about them. Reconcile the two lists together; an asset in the third array is unverified, not verified-clean.

See Code examples for TypeScript and Python examples of the single-chain and multichain read paths.

Last updated