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

# Deposit Previews

> Calculate gross LP output, deposit fees, and net LP output

Deposits can start from the base asset through [`ixWrapperDeposit`](/developer-tranching/typescript/instructions/ix-wrapper-deposit), or from existing SY through [`ixDeposit`](/developer-tranching/typescript/instructions/ix-deposit).

For raw/display units and fee-rate scale, see [Units and Fees](/developer-tranching/defi-integrations/pricing-units-and-fees).

## Deposit Preview Math

The tranching market mints LP shares from the SY value allocated to the selected tranche.

$$
\text{valueAllocated} = \text{amountInSY} \times \text{syExchangeRate}
$$

In raw execution, `amountInSY` is the `amount_in` `u64` in SY token units and `syExchangeRate` is a `Number`. The result is a raw fixed-point NAV value. No token-decimal normalization happens onchain.

$$
\text{grossLpOut} =
\left\lfloor
\frac{\text{valueAllocated} \times (\text{currentLpSupply} + 1)}
{\text{trancheEffectiveNAV} + 1_{\text{NAV}}}
\right\rfloor
$$

Deposit fees are charged in LP shares:

$$
\text{depositFeeLpShares} = \left\lceil \text{grossLpOut} \times \text{depositFeeRate} \right\rceil
$$

The user receives:

$$
\text{netLpOut} = \text{grossLpOut} - \text{depositFeeLpShares}
$$

The market accounting supply increases by `grossLpOut`, not `netLpOut`:

$$
\text{totalLpSupply}_{\text{next}} = \text{currentLpSupply} + \text{grossLpOut}
$$

The user receives `netLpOut`. The fee shares remain pending until `mintProtocolFeeShares` mints them to the protocol fee recipient.

## Deposit Example

Assume a Senior deposit with normalized values. For raw execution, scale SY and LP amounts by the mint decimals and scale fee rates by `1_000_000_000_000`.

| Input                      | Value              |
| -------------------------- | ------------------ |
| `amountInSY`               | `1,000` SY         |
| `syExchangeRate`           | `1.05` NAV per SY  |
| `valueAllocated`           | `1,050` NAV        |
| `currentLpSupply`          | `10,000` Senior LP |
| `trancheEffectiveNAV`      | `10,000` NAV       |
| `seniorDepositProtocolFee` | `0.20%`            |

Then:

$$
\text{grossLpOut} =
\left\lfloor
\frac{1{,}050 \times (10{,}000 + 1)}{10{,}000 + 1}
\right\rfloor
= 1{,}050
$$

$$
\text{depositFeeLpShares} = \left\lceil 1{,}050 \times 0.002 \right\rceil = 3
$$

$$
\text{netLpOut} = 1{,}050 - 3 = 1{,}047
$$

The user receives `1,047` Senior LP. Market accounting total Senior LP supply increases by `1,050`, and `3` Senior LP shares are added to pending deposit protocol fees.

<Tip>
  Set `minLpOut` on [`ixWrapperDeposit`](/developer-tranching/typescript/instructions/ix-wrapper-deposit#parameters) or [`ixDeposit`](/developer-tranching/typescript/instructions/ix-deposit#parameters) so the transaction fails if the output is worse than your integration preview.
</Tip>
