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

# Placing Orders

> Order creation and execution flow

Orders are created through the API and processed asynchronously through multiple stages. The system handles the complete lifecycle from order creation to on-chain token execution.

<Info>
  Order creation requires both JWT authentication and an API key. Make sure to include both the `Authorization: Bearer <token>` header and the `x-api-key` header in your requests.
</Info>

## Order Types

**Buy Orders:**

* Purchase market positions (e.g., buying "yes" on a market)
* Requires USDC balance in your smart wallet
* When filled, ERC-1155 tokens are minted to your wallet

**Sell Orders:**

* Sell existing market positions
* Requires ERC-1155 token balance in your smart wallet
* When filled, tokens are burned from your wallet

## Order Flow

Orders progress through these stages automatically:

1. **Create Order** - Submit order details via API
   * Market ID, side, quantity, price
   * For buy orders: quote amount (USDC to lock)
   * Order is created with status "pending"

2. **Balance Validation** - System validates and locks required funds
   * Buy orders: Locks USDC in your smart wallet
   * Sell orders: Validates you hold the required ERC-1155 tokens
   * Status changes to "validated"

3. **Prediction Market Execution** - Order is placed on the prediction market exchange
   * Order submitted to the prediction market with your credentials
   * Prediction market order ID is stored
   * Status changes to "placed"

4. **Fill Detection** - System monitors for order fills
   * Polls the prediction market API for fill status
   * When filled, captures fill details (price, quantity, cost)
   * Status changes to "filled"

5. **On-chain Execution** - Tokens are minted or burned
   * Buy orders: ERC-1155 tokens minted to your wallet
   * Sell orders: ERC-1155 tokens burned from your wallet
   * Transaction hash is stored
   * Status changes to "txn\_filled" then "completed"

## Order Parameters

* **Market ID** - The prediction market identifier
* **Side** - The outcome side ("yes", "no", etc.)
* **Order Type** - "buy" or "sell"
* **Quantity** - Number of contracts/shares
* **Price** - Price in cents (1-99), limit price with slippage tolerance
* **Quote Amount** - USDC amount to lock (required for buy orders only)

<Tip>
  Orders are processed asynchronously. Use the order status endpoint to track progress through each stage.
</Tip>
