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

# Market Order

> Execute a market order on the orderbook

The `ixWrapperMarketOffer` instruction executes a market order on the Exponent orderbook.

## Usage

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

const { ix, setupIxs } = await orderbook.ixWrapperMarketOffer({
  trader: wallet.publicKey,
  maxPriceApy: 5.5,
  amount: 1_000_000_000n,
  offerType: OfferType.BuyYt,
  minAmountOut: 990_000_000n,
  virtualOffer: false,
  mintSy: syMintAddress,
});
```

## Required Parameters

| Parameter | Type | Description |
| - | - | - |
| `trader` | `PublicKey` | The trader's wallet public key |
| `maxPriceApy` | `number` | Maximum price in APY terms |
| `amount` | `bigint` | The amount to trade |
| `offerType` | `OfferType` | The type of offer (`OfferType.BuyYt` / `OfferType.SellYt`) |
| `minAmountOut` | `bigint` | Minimum amount to receive (slippage protection) |
| `virtualOffer` | `boolean` | Whether this is a virtual offer |
| `mintSy` | `PublicKey` | The SY token mint address |

## Optional Parameters

| Parameter | Type | Description |
| - | - | - |
| `ptSrc` | `PublicKey` | PT token source account |
| `ytSrc` | `PublicKey` | YT token source account |
| `sySrc` | `PublicKey` | SY token source account |
| `tokenBaseTrader` | `PublicKey` | Base token account for the trader |

## Returns

Returns an object with:

* `ix` - The `TransactionInstruction` that executes the market order
* `setupIxs` - An array of setup instructions to run before `ix`:
  * `setupIxs[0]` - Creates the PT associated token account for the trader (if it doesn't exist)
  * `setupIxs[1]` - Creates the YT associated token account for the trader (if it doesn't exist)
  * `setupIxs[2]` - Creates the SY associated token account for the trader (if it doesn't exist)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.