Code examples
Read NAV, positions, and prices from the NAV Calculator with viem, ethers.js, and Python.
1. Check chain health
function healthCheck()
external view returns (bool sequencerDown, address[] memory stalePriceAssets, address[] memory irregularPriceAssets);import { createPublicClient, http, parseAbi } from "viem";
import { mainnet } from "viem/chains";
const NAV_CALCULATOR = "0x..."; // proxy — see Deployment addresses
const ABI = parseAbi([
"function healthCheck() view returns (bool sequencerDown, address[] stalePriceAssets, address[] irregularPriceAssets)",
]);
const client = createPublicClient({ chain: mainnet, transport: http() });
async function checkHealth() {
const [sequencerDown, stalePriceAssets, irregularPriceAssets] = await client.readContract({
address: NAV_CALCULATOR, abi: ABI, functionName: "healthCheck",
});
if (sequencerDown || stalePriceAssets.length > 0) {
console.warn("Chain unhealthy:", { sequencerDown, stalePriceAssets });
return false;
}
if (irregularPriceAssets.length > 0) {
console.warn("Price divergence (soft alert):", { irregularPriceAssets }); // still usable — investigate
}
return true;
}2. Read NAV — single chain
Paging a read that no longer fits
3. Read global NAV — all chains
4. Enumerate positions with labels
5. Read the latest price for an asset
6. Value a basket of (asset, amount) pairs
7. Decode position identity & group by protocol
8. Single-asset exposure
9. List the assets a fund tracks
Last updated