> For the complete documentation index, see [llms.txt](https://docs.lagoon.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lagoon.finance/developer-hub/integration/compute-vault-share-valuation.md).

# Compute vault share valuation

There are two independent ways to get the value of a vault share. Pick one:

* **On-chain** — call the vault contract directly over RPC and convert to dollars with your own asset price.
* **Lagoon API (GraphQL)** — one query returns the price per share in assets and in USD.

{% tabs %}
{% tab title="On-chain" %}
*The method described below is identical to that used for an ERC4626 vault.*

To calculate the value of a single share, first determine the price per share of the vault in terms of assets. To achieve this, call the function `convertToAssets(uint256 sharers) returns (uint256 assets);` with the argument set to `10 ** vault.decimals().`

The price per share is given with a scaling factor of `10 ** underlyingAsset.decimals`. To obtain a standard value, you have to divide the price by this scaling factor.

To calculate the value of a share in dollars, multiply the price per share by the price of the underlying asset in dollars:\
`pricePerShare / 10 ** underlyingAsset.decimals * underlyingAssetPriceInDollar = shareValueInDollar`.
{% endtab %}

{% tab title="Lagoon API (GraphQL)" %}
Send this query to `https://api.lagoon.finance/query`:

```graphql
query GetSharePrice {
  vaultByAddress(
    address: "0x936facdf10c8c36294e7b9d28345255539d81bc7"
    chainId: 1
  ) {
    asset { decimals }
    state {
      pricePerShare
      pricePerShareUsd
    }
  }
}
```

[**Try in Apollo Sandbox →**](https://api.lagoon.finance/query?document=query%20GetSharePrice%20%7B%0A%20%20vaultByAddress%28%0A%20%20%20%20address%3A%20%220x936facdf10c8c36294e7b9d28345255539d81bc7%22%0A%20%20%20%20chainId%3A%201%0A%20%20%29%20%7B%0A%20%20%20%20asset%20%7B%20decimals%20%7D%0A%20%20%20%20state%20%7B%0A%20%20%20%20%20%20pricePerShare%0A%20%20%20%20%20%20pricePerShareUsd%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D)

```bash
curl -sS -X POST https://api.lagoon.finance/query \
  -H "Content-Type: application/json" \
  -d '{"query":"query GetSharePrice { vaultByAddress(address: \"0x936facdf10c8c36294e7b9d28345255539d81bc7\", chainId: 1) { asset { decimals } state { pricePerShare pricePerShareUsd } } }"}'
```

| Field              | Meaning                                                                  | On-chain equivalent                                         |
| ------------------ | ------------------------------------------------------------------------ | ----------------------------------------------------------- |
| `pricePerShare`    | Price of one share in asset base units, scaled by `10 ** asset.decimals` | `convertToAssets(10 ** vault.decimals())`                   |
| `pricePerShareUsd` | Price of one share in USD, already converted                             | `pricePerShare / 10 ** asset.decimals * assetPriceInDollar` |

For the price per share at a past date, use `stateAt(timestamp)` or `stateHistory` — see [Historical data](/developer-hub/lagoon-api/conventions.md#historical-data).
{% endtab %}
{% endtabs %}
