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

Calculate share price

Read a fund's current share price onchain, from each chain's NAV Calculator and the shares contract's total supply.

A fund's share price must be computed onchain; this is the authoritative source, and the only one that reflects the fund's value right now. NAV is produced onchain by each chain's NAV Calculator; the circulating share supply lives in the shares contract. Read both live and divide.

Definition

A fund's share price is the sum of NAVs across all chains where it holds portfolio Safes, divided by the total circulating share supply (adjusting for decimals).

Read NAV and total supply

Read NAV from each chain's NAV Calculator and divide by the shares contract's totalSupply(). The NAV Calculator returns USD with 8 decimals (usdDecimals()); pass address(0) as the quote asset for USD.

function getAccountNav(address account, address quoteAsset) external view returns (NAV memory nav);
function totalSupply() external view returns (uint256);
import { createPublicClient, http, parseAbi, zeroAddress } from "viem";
import { mainnet } from "viem/chains";

const NAV_CALCULATOR = "0x..."; // per-chain NAV Calculator proxy
const PORTFOLIO_SAFE = "0x..."; // the fund's Portfolio Safe on this chain
const SHARES         = "0x..."; // shares contract (the chain it is deployed on)

const ASSET_T = "(address asset, string symbol, uint8 decimals)";
const navAbi = parseAbi([
  `function getAccountNav(address account, address quoteAsset) view returns (
     (int256 value, ${ASSET_T} quoteAsset, uint64 timestamp, ${ASSET_T}[] stalePriceAssets,
      bool sequencerDown, bool quoteAssetStale, ${ASSET_T}[] irregularPriceAssets,
      bool quoteAssetIrregular, ${ASSET_T}[] monitorsUnhealthyPriceAssets))`,
]);
const sharesAbi = parseAbi(["function totalSupply() view returns (uint256)"]);

const client = createPublicClient({ chain: mainnet, transport: http() });

const nav = await client.readContract({
  address: NAV_CALCULATOR, abi: navAbi, functionName: "getAccountNav",
  args: [PORTFOLIO_SAFE, zeroAddress],
});
const supply = await client.readContract({ address: SHARES, abi: sharesAbi, functionName: "totalSupply" });

// price (8-dec USD per 1e18 shares) = nav.value * 1e18 / supply
const sharePrice = (nav.value * 10n ** 18n) / supply;

Only use a complete reading

NAV Calculator

Last updated