> For the complete documentation index, see [llms.txt](https://docs.kpk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kpk.io/funds/kpk-fund-integration/calculate-share-price.md).

# 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.

{% hint style="info" %}

#### 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).
{% endhint %}

## 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.

```solidity
function getAccountNav(address account, address quoteAsset) external view returns (NAV memory nav);
function totalSupply() external view returns (uint256);
```

{% tabs %}
{% tab title="viem" %}

```typescript
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;
```

{% endtab %}

{% tab title="ethers.js" %}

```typescript
import { ethers } from "ethers";

const NAV_CALCULATOR = "0x...";
const PORTFOLIO_SAFE = "0x...";
const SHARES         = "0x...";

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

const provider = new ethers.JsonRpcProvider("https://eth.llamarpc.com");
const calc = new ethers.Contract(NAV_CALCULATOR, navAbi, provider);
const shares = new ethers.Contract(SHARES, sharesAbi, provider);

const nav = await calc.getAccountNav(PORTFOLIO_SAFE, ethers.ZeroAddress);
const supply = await shares.totalSupply();
const sharePrice = (nav.value * 10n ** 18n) / supply;
```

{% endtab %}

{% tab title="Python" %}

```python
from web3 import Web3

NAV_CALCULATOR = "0x..."
PORTFOLIO_SAFE = "0x..."
SHARES         = "0x..."

ASSET = [{"name": "asset", "type": "address"}, {"name": "symbol", "type": "string"}, {"name": "decimals", "type": "uint8"}]
nav_abi = [{
    "name": "getAccountNav", "type": "function", "stateMutability": "view",
    "inputs": [{"name": "account", "type": "address"}, {"name": "quoteAsset", "type": "address"}],
    "outputs": [{"type": "tuple", "components": [
        {"name": "value", "type": "int256"},
        {"name": "quoteAsset", "type": "tuple", "components": ASSET},
        {"name": "timestamp", "type": "uint64"},
        {"name": "stalePriceAssets", "type": "tuple[]", "components": ASSET},
        {"name": "sequencerDown", "type": "bool"},
        {"name": "quoteAssetStale", "type": "bool"},
        {"name": "irregularPriceAssets", "type": "tuple[]", "components": ASSET},
        {"name": "quoteAssetIrregular", "type": "bool"},
        {"name": "monitorsUnhealthyPriceAssets", "type": "tuple[]", "components": ASSET},
    ]}],
}]
shares_abi = [{"name": "totalSupply", "type": "function", "stateMutability": "view",
               "inputs": [], "outputs": [{"type": "uint256"}]}]

w3 = Web3(Web3.HTTPProvider("https://eth.llamarpc.com"))
calc = w3.eth.contract(address=NAV_CALCULATOR, abi=nav_abi)
shares = w3.eth.contract(address=SHARES, abi=shares_abi)

nav = calc.functions.getAccountNav(PORTFOLIO_SAFE, "0x0000000000000000000000000000000000000000").call()
supply = shares.functions.totalSupply().call()
share_price = nav[0] * 10**18 // supply
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}

## Only use a complete reading

A NAV reading must not be used for subscriptions/redemptions if it is incomplete: check that `stalePriceAssets` is empty and that `sequencerDown` and `quoteAssetStale` are both `false` on **every** chain. For multichain funds, sum each chain's `value` before dividing by the global `totalSupply`. See the NAV Calculator reference for the full reliability model.

The two soft signals do not block a reading, but read them **together**: `irregularPriceAssets` flags a primary that disagreed with its monitors, while `monitorsUnhealthyPriceAssets` flags assets where no monitor answered, so the disagreement check never ran. An asset in the second list is unverified, not verified-clean.
{% endhint %}

{% content-ref url="/pages/Uwrpt7y1t7nhi7zJBgVd" %}
[NAV Calculator](/funds/infrastructure/architecture/onchain-accounting/contracts/nav-calculator.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.kpk.io/funds/kpk-fund-integration/calculate-share-price.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
