> ## 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 Sell YT

> Low-level instruction to sell YT tokens for base assets atomically

# createWrapperSellYtInstruction

Sells YT tokens for base assets in a single atomic operation. This instruction buys PT on the market, merges the PT and YT back into SY, and then redeems the SY for the underlying base asset. The entire flow is executed atomically so the caller receives base tokens directly from their YT position.

## Usage

```typescript theme={null}
import { createWrapperSellYtInstruction } from "@exponent-labs/exponent-sdk/client/clmm";
import { PublicKey } from "@solana/web3.js";

const ix = createWrapperSellYtInstruction({
  seller: sellerKeypair.publicKey,
  market: new PublicKey("market..."),
  tokenSyTrader: new PublicKey("tokenSyTrader..."),
  tokenYtTrader: new PublicKey("tokenYtTrader..."),
  tokenPtTrader: new PublicKey("tokenPtTrader..."),
  tokenSyEscrow: new PublicKey("tokenSyEscrow..."),
  tokenYtEscrow: new PublicKey("tokenYtEscrow..."),
  tokenPtEscrow: new PublicKey("tokenPtEscrow..."),
  marketAddressLookupTable: new PublicKey("lookupTable..."),
  tokenProgram: new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),
  syProgram: new PublicKey("syProgram..."),
  tokenFeeTreasurySy: new PublicKey("tokenFeeTreasurySy..."),
  tokenFeeTreasuryPt: new PublicKey("tokenFeeTreasuryPt..."),
  ticks: new PublicKey("ticks..."),
  exponentCoreProgram: new PublicKey("exponentCoreProgram..."),
  eventAuthority: new PublicKey("eventAuthority..."),
  program: new PublicKey("program..."),
  ytAmount: 1_000_000n,
  minBaseAmount: 950_000n,
  redeemSyAccountsUntil: 3,
});
```

## Accounts

| Name                       | Type        | Signer | Writable | Description                                 |
| -------------------------- | ----------- | ------ | -------- | ------------------------------------------- |
| `seller`                   | `PublicKey` | Yes    | Yes      | Wallet executing the trade                  |
| `market`                   | `PublicKey` | No     | Yes      | The CLMM market account                     |
| `ticks`                    | `PublicKey` | No     | Yes      | The market tick array account               |
| `tokenSyTrader`            | `PublicKey` | No     | Yes      | Trader's SY token account                   |
| `tokenYtTrader`            | `PublicKey` | No     | Yes      | Trader's YT token account                   |
| `tokenPtTrader`            | `PublicKey` | No     | Yes      | Trader's PT token account                   |
| `tokenSyEscrow`            | `PublicKey` | No     | Yes      | Market SY escrow account                    |
| `tokenYtEscrow`            | `PublicKey` | No     | Yes      | Market YT escrow account                    |
| `tokenPtEscrow`            | `PublicKey` | No     | Yes      | Market PT escrow account                    |
| `marketAddressLookupTable` | `PublicKey` | No     | No       | Market address lookup table                 |
| `tokenProgram`             | `PublicKey` | No     | No       | SPL Token program                           |
| `syProgram`                | `PublicKey` | No     | No       | SY program                                  |
| `tokenFeeTreasurySy`       | `PublicKey` | No     | Yes      | SY fee treasury account                     |
| `tokenFeeTreasuryPt`       | `PublicKey` | No     | Yes      | PT fee treasury account                     |
| `exponentCoreProgram`      | `PublicKey` | No     | No       | Exponent core program (for strip/merge CPI) |
| `eventAuthority`           | `PublicKey` | No     | No       | Event authority PDA                         |
| `program`                  | `PublicKey` | No     | No       | CLMM program ID                             |

## Args

| Name                  | Type  | Description                                                 |
| --------------------- | ----- | ----------------------------------------------------------- |
| ytAmount              | `u64` | The amount of YT tokens to sell                             |
| minBaseAmount         | `u64` | The minimum amount of base asset to receive                 |
| redeemSyAccountsUntil | `u8`  | The number of CPI remaining accounts used for SY redemption |

## Returns

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