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

# Limit Orders

> Set a target price for leveraged positions. Partial fills supported, unfilled capital refunded.

Limit orders let you set a target price for opening a leveraged position on Polymarket. Instead of executing immediately at the current market price, your capital is locked and the order rests on the Polymarket CLOB until the price is hit.

## How It Works

<Steps>
  <Step title="Set Your Order">
    Choose a market, set your margin, leverage (up to 10x), direction (Long/Short), and a **target price**.
  </Step>

  <Step title="Capital Is Locked">
    Your margin + vault loan + 1.5% open fee are locked immediately.
  </Step>

  <Step title="Order Placed on CLOB">
    The order is placed on the Polymarket CLOB as a resting limit order.
  </Step>

  <Step title="Fills Arrive">
    As the market hits your target price, fills arrive incrementally from the CLOB. Your position builds up with each fill.
  </Step>
</Steps>

**Example:** You place a limit order with \$1,000 margin at 5x leverage, targeting a price of \$0.45.

| Component            | Amount                |
| :------------------- | :-------------------- |
| Your margin          | \$1,000               |
| Borrowed from vault  | \$4,000               |
| Total position size  | \$5,000               |
| Opening fee          | \$15 (1.5% of margin) |
| Total capital locked | \$5,015               |

## Partial Fills

Limit orders support partial fills. Your position doesn't need to fill all at once.

* Each fill proportionally allocates margin and borrowed capital to the position
* Entry price is the **weighted average** across all fills
* The position is tradeable (can close, can be liquidated) after the **first fill**
* Multiple fills accumulate into a single position

**Example:** Your \$5,000 limit order fills in two chunks:

| Fill                     | Amount        | Price         |
| :----------------------- | :------------ | :------------ |
| First fill               | \$3,000 (60%) | \$0.45        |
| Second fill              | \$2,000 (40%) | \$0.43        |
| **Weighted entry price** |               | **\~\$0.442** |

After the first fill, you have a \$3,000 open position. After the second fill, it grows to \$5,000. The margin and borrowed capital are allocated proportionally with each fill.

<Info>
  Your position is fully tradeable after the first fill. You can close it, and it can be liquidated, just like any market order position.
</Info>

## Cancellation & Expiry

Orders can be cancelled at any time. Orders can also have an expiry timestamp (GTD, Good Till Date).

When a limit order is cancelled or expires:

<CardGroup cols={2}>
  <Card title="Filled Portion" icon="check">
    Remains as a normal open position. You can close it, let it run, or it will auto-close at the market close date.
  </Card>

  <Card title="Unfilled Portion" icon="rotate-left">
    Capital is refunded proportionally. Vault gets back its borrowed share, trader gets back margin + proportional fee refund.
  </Card>
</CardGroup>

**Example:** You place a \$5,000 limit order. 60% fills, then you cancel.

| Component | Filled (60%)                  | Refunded (40%)            |
| :-------- | :---------------------------- | :------------------------ |
| Margin    | \$600 allocated to position   | \$400 returned to trader  |
| Borrowed  | \$2,400 allocated to position | \$1,600 returned to vault |
| Open fee  | \$9 consumed                  | \$6 refunded to trader    |

## Limit Close Orders

Open positions can also be closed via limit orders on the CLOB, not just market orders.

* You set a target sell price, and the order rests on the CLOB
* Each sell fill is a self-contained mini-settlement: shares, margin, and borrowed capital are proportionally reduced, and USDC is distributed immediately
* Partial close fills reduce the position incrementally
* The position fully closes when all shares are sold

<Info>
  Limit close orders give you price control when exiting. Instead of selling at whatever the current market offers, you set the price you want and wait for it.
</Info>

## Market Orders vs Limit Orders

|                  | Market Order                 | Limit Order                                   |
| :--------------- | :--------------------------- | :-------------------------------------------- |
| **Execution**    | Immediate at current price   | Rests on CLOB until target price is hit       |
| **Open fee**     | 0.5% of margin               | 1.5% of margin                                |
| **Fills**        | Single fill                  | Partial fills supported                       |
| **Cancellation** | Can cancel before execution  | Can cancel anytime; unfilled portion refunded |
| **Entry price**  | Single fill price            | Weighted average across fills                 |
| **Capital**      | Locked only during execution | Locked until filled, cancelled, or expired    |
