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
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
Addresses
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).
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.
Read functions
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
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.
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.
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.
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)
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)
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.
Multichain aggregation
The offchain NAV Worker collects per-chain NAV values and sums them:
Call
getAccountNavon every chain the fund operates on.Verify
stalePriceAssetsis empty,sequencerDownisfalse, andquoteAssetStaleisfalseon every chain.If any chain is unhealthy, the global NAV is withheld until the condition clears.
Otherwise, sum all per-chain
valuefields to produce the global fund NAV.Treat a non-empty
irregularPriceAssetsas 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.Treat a non-empty
monitorsUnhealthyPriceAssetsas an alert on the check itself rather than on the price: those assets lost their cross-check this read, so an emptyirregularPriceAssetssays nothing about them. Reconcile the two lists together; an asset in the third array is unverified, not verified-clean.
Last updated