> ## Documentation Index
> Fetch the complete documentation index at: https://docs.exponent.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Capacity and LP Prices

> Query tranche LP prices and current capacity

Use these helpers to determine how much Senior or Junior capacity remains and how LP shares are priced.

## Usage

<CodeGroup>
  ```typescript TypeScript theme={null}
  console.log("Senior LP price:", market.getSrLpPriceNetAsset());
  console.log("Junior LP price:", market.getJrLpPriceNetAsset());
  console.log("Senior LP capacity:", market.getSrLpCapacity());
  console.log("Junior LP capacity:", market.getJrLpCapacity());
  console.log("Senior remaining LP capacity:", market.getSrRemainingLpCapacity());
  console.log("Junior remaining LP capacity:", market.getJrRemainingLpCapacity());
  console.log("Senior remaining NAV capacity:", market.getSrRemainingCapacityNetAssetValue());
  console.log("Junior remaining NAV capacity:", market.getJrRemainingCapacityNetAssetValue());
  ```

  ```rust Rust theme={null}
  use exponent_tranching::ExponentTranchingMarket;
  use precise_number::Number;

  fn calculate_lp_price_net_asset(
      total_lp_supply: u64,
      effective_nav: Number,
  ) -> Option<Number> {
      let virtual_total_supply = (total_lp_supply as u128).checked_add(1)?;
      let virtual_total_assets = effective_nav.checked_add(&Number::ONE)?;

      virtual_total_assets.checked_div(&Number::from(virtual_total_supply))
  }

  fn read_capacity_inputs(market: &ExponentTranchingMarket) {
      let senior_lp_price = calculate_lp_price_net_asset(
          market.tranche_supply_state.total_senior_lp_supply,
          market.financials.sr_effective_net_asset,
      );
      let junior_lp_price = calculate_lp_price_net_asset(
          market.tranche_supply_state.total_junior_lp_supply,
          market.financials.jr_effective_net_asset,
      );

      let max_senior_lp_supply = market.tranche_supply_state.max_senior_lp_supply;
      let max_junior_lp_supply = market.tranche_supply_state.max_junior_lp_supply;
      let total_senior_lp_supply = market.tranche_supply_state.total_senior_lp_supply;
      let total_junior_lp_supply = market.tranche_supply_state.total_junior_lp_supply;

      let senior_remaining_by_configured_cap =
          max_senior_lp_supply.saturating_sub(total_senior_lp_supply);
      let junior_remaining_lp_capacity = if max_junior_lp_supply == 0 {
          None
      } else {
          Some(max_junior_lp_supply.saturating_sub(total_junior_lp_supply))
      };

      let min_coverage = market.risk_config.min_coverage;
      let beta = market.risk_config.beta;
      let utilization = market.financials.utilization;

      println!("Senior LP price: {:?}", senior_lp_price);
      println!("Junior LP price: {:?}", junior_lp_price);
      println!(
          "Senior remaining LP by configured cap: {}",
          senior_remaining_by_configured_cap
      );
      println!("Junior remaining LP capacity: {:?}", junior_remaining_lp_capacity);
      println!("Minimum coverage: {}", min_coverage);
      println!("Beta: {}", beta);
      println!("Utilization: {}", utilization);
  }
  ```
</CodeGroup>

In Rust, `max_senior_lp_supply` is only the configured Senior cap. Exact Senior capacity also depends on available Junior coverage. Use `min_coverage`, `beta`, raw NAV, effective NAV, and LP supply to mirror the capacity helper formulas below.

## LP price helpers

| Function                 | Returns  | Description                                                   |
| ------------------------ | -------- | ------------------------------------------------------------- |
| `getSrLpPriceNetAsset()` | `bigint` | Senior LP price as raw fixed-point NAV per raw Senior LP unit |
| `getJrLpPriceNetAsset()` | `bigint` | Junior LP price as raw fixed-point NAV per raw Junior LP unit |

LP price uses the virtual-share formula:

$$
\text{lpPrice} = \left\lfloor \frac{\text{effectiveNAV} + 1_{\text{NAV}}}{\text{totalLpSupply} + 1} \right\rfloor
$$

In SDK raw `bigint` values, `1_NAV` is `1_000_000_000_000`. This converts the fixed-point scale only. Apply token mint decimals separately when showing NAV or LP balances in a UI.

## Capacity helpers

| Function                                | Returns          | Description                                                                    |
| --------------------------------------- | ---------------- | ------------------------------------------------------------------------------ |
| `getSrLpCapacity()`                     | `bigint`         | Senior LP capacity constrained by configured max supply and Junior coverage    |
| `getJrLpCapacity()`                     | `bigint`         | Configured Junior max LP supply. `0n` means uncapped                           |
| `getSrRemainingLpCapacity()`            | `bigint`         | Remaining Senior LP capacity                                                   |
| `getJrRemainingLpCapacity()`            | `bigint \| null` | Remaining Junior LP capacity, or `null` when uncapped                          |
| `getSrMaxCapacityNetAssetValue()`       | `bigint`         | Max Senior capacity as raw fixed-point NAV                                     |
| `getJrMaxCapacityNetAssetValue()`       | `bigint \| null` | Max Junior capacity as raw fixed-point NAV, or `null` when uncapped            |
| `getSrRemainingCapacityNetAssetValue()` | `bigint`         | Remaining Senior deposit room as raw fixed-point NAV                           |
| `getJrRemainingCapacityNetAssetValue()` | `bigint \| null` | Remaining Junior deposit room as raw fixed-point NAV, or `null` when uncapped  |
| `getSrCoverageRemainingNetAssetValue()` | `bigint`         | Senior deposit room allowed by current Junior coverage, as raw fixed-point NAV |

<Tip>
  Senior capacity can be lower than `maxSeniorLpSupply` because Senior deposits also depend on available Junior coverage.
</Tip>
