> 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/integration/calculate-share-price.md).

# Calculate share price

When subscribing or redeeming you must supply a slippage minimum (`minSharesOut` / `minAssetsOut`). This page shows the easiest way to derive those, plus how to read the current share price directly.

{% 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 %}

## Easiest path: preview functions

The shares contract can compute the result of a request for you at the fund's **last settled price** — no need to source NAV yourself. Pass `sharesPrice = 0` to use the last settled price:

```solidity
function previewSubscription(uint256 assets, uint256 sharesPrice, address subscriptionAsset)
    external view returns (uint256 shares);   // shares before fees

function previewRedemption(uint256 shares, uint256 sharesPrice, address redemptionAsset)
    external view returns (uint256 assets);    // assets AFTER the redemption fee
```

Take the returned value and apply your slippage tolerance — see [Subscription request](/funds/integration/subscription-request.md) and [Redemption request](/funds/integration/redemption-request.md) for full examples. If the fund has never settled a price for that asset, the call reverts with `NoStoredPrice`.

The raw last settled price (8-decimal USD) is also readable directly:

```solidity
function getLastSettledPrice(address asset) external view returns (uint256);
```

## Current share price

For display — or to price against a fresher value than the last settlement — fetch the NAV and total supply. There are two routes.

### JSON API (recommended)

The Data Indexer aggregates multi-chain NAV into a single, up-to-date value, so you don't have to query every chain and sum yourself.

```
GET /funds/<fund>
```

```json
{
  "nav": { "usd": "string" },
  "supply": { "totalSupply": "string" }
}
```

Share price = `nav.usd / supply.totalSupply`, adjusting for decimals.

<figure><picture><source srcset="/files/XFiXIMrRNdGJBP7z5Fdv" media="(prefers-color-scheme: dark)"><img src="/files/n5gRzsUcVsYZT5aVO5iD" alt=""></picture><figcaption></figcaption></figure>

### Onchain

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/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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
