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

# Wrapper Deposit

> Low-level instruction to mint SY from base assets and deposit into a tranche

# createWrapperDepositInstruction

Builds a raw instruction that mints SY from base assets, deposits the SY into the selected tranche, and mints tranche LP shares.

## Usage

```typescript theme={null}
import {
  TrancheSide,
  createWrapperDepositInstruction,
} from "@exponent-labs/exponent-sdk/client/tranching";

const ix = createWrapperDepositInstruction(
  {
    user: wallet.publicKey,
    market: marketAddress,
    returnModelStorage,
    addressLookupTable,
    syProgram,
    syMint,
    tokenSrc: userSyTokenAccount,
    tokenSyEscrow,
    tokenLpDst: userLpTokenAccount,
    mintLp: mintLpSenior,
    tokenProgram,
    eventAuthority,
    program: tranchingProgram,
  },
  {
    trancheSide: TrancheSide.Senior,
    amountBase: 1_000_000_000n, // raw base-token units
    minLpOut: 0n,               // raw Senior LP units
    mintSyAccountsUntil: 0,
  }
);
```

## Accounts

| Name                 | Type        | Signer | Writable | Description                               |
| -------------------- | ----------- | ------ | -------- | ----------------------------------------- |
| `user`               | `PublicKey` | Yes    | Yes      | Depositor                                 |
| `market`             | `PublicKey` | No     | Yes      | Tranching market account                  |
| `returnModelStorage` | `PublicKey` | No     | Yes      | Return model storage account              |
| `addressLookupTable` | `PublicKey` | No     | No       | Market address lookup table               |
| `syProgram`          | `PublicKey` | No     | No       | Linked SY program                         |
| `syMint`             | `PublicKey` | No     | Yes      | SY mint                                   |
| `tokenSrc`           | `PublicKey` | No     | Yes      | User SY token account used by the wrapper |
| `tokenSyEscrow`      | `PublicKey` | No     | Yes      | Market SY escrow                          |
| `tokenLpDst`         | `PublicKey` | No     | Yes      | Destination LP token account              |
| `mintLp`             | `PublicKey` | No     | Yes      | Senior or Junior LP mint                  |
| `tokenProgram`       | `PublicKey` | No     | No       | SPL Token program                         |
| `eventAuthority`     | `PublicKey` | No     | No       | Event authority PDA                       |
| `program`            | `PublicKey` | No     | No       | Exponent Tranching program                |

## Args

| Name                  | Type          | Description                                                  |
| --------------------- | ------------- | ------------------------------------------------------------ |
| `trancheSide`         | `TrancheSide` | `Senior` or `Junior`                                         |
| `amountBase`          | `u64`         | Base asset amount to wrap into SY, in raw base-token units   |
| `minLpOut`            | `u64`         | Minimum selected-tranche LP shares to mint, in raw LP units  |
| `mintSyAccountsUntil` | `u8`          | Number of remaining accounts used by the SY mint CPI segment |

## Remaining accounts

Append remaining accounts in this order:

1. SY mint CPI accounts, with length `mintSyAccountsUntil`
2. Tranching `getSyState` and `depositSy` CPI accounts

Use `TranchingMarket.ixWrapperDeposit` to build this ordering automatically.

## Returns

`TransactionInstruction` - a transaction instruction ready to be added to a transaction.
