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

# The two order kinds

> A ratio locked at creation, or no stored price at all — and what each one costs its maker.

The only real choice a maker makes is **whether their price is allowed to move**.

<CardGroup cols={2}>
  <Card title="Fixed" icon="lock">
    Stores a ratio. Band-checked once, at creation, then never consults the oracle again.
    Predictable, and it keeps trading through a feed outage.
  </Card>

  <Card title="Pegged" icon="wave-square">
    Stores no price. Every fill is priced off Orakl's five-minute reference and discounted so the taker's realised
    edge lands exactly on the premium. Tracks the market instead of going stale.
  </Card>
</CardGroup>

## Fixed — `createOrder`

```solidity theme={"system"}
createOrder(address sellToken, uint256 sellAmount, address buyToken, uint256 buyAmount, uint64 expiry)
```

<Steps>
  <Step title="Pair and size">
    `buyToken` must be the counter-token. `sellAmount ≥ minOrderAmount[sellToken]`.
  </Step>

  <Step title="Expiry">
    `expiry > block.timestamp` and `expiry ≤ now + maxOrderDuration`.
  </Step>

  <Step title="Oracle read — strict">
    Reverts on a missing, non-positive or stale five-minute average. During a feed outage **no new orders can be
    posted**, of either kind.
  </Step>

  <Step title="Price band">
    ```
    x    = usdtAmount × priceScale
    base = answer × jpycAmount
    require  base·(BPS − band) ≤ x ≤ base·(BPS + band)
    ```

    Checked **once**. The band never applies again, so an order filled much later can sit far from
    the market — that is deliberate, not an oversight.
  </Step>

  <Step title="Escrow and record">
    `safeTransferFrom(maker → this, sellAmount)`, the fee rate is snapshotted, an id is assigned and
    the order is added to both index sets.
  </Step>
</Steps>

`buyAmount` is the total the maker receives on a complete fill. Every partial fill uses that same
ratio.

## Pegged — `createPeggedOrder`

```solidity theme={"system"}
createPeggedOrder(address sellToken, uint256 sellAmount, uint16 premiumBps, uint256 minRate, uint64 expiry)
```

<Steps>
  <Step title="Premium">
    `premiumBps ≤ maxPremiumBps ≤ MAX_PREMIUM_BPS` (1000). A later configuration change does not
    alter orders already on the book.
  </Step>

  <Step title="A floor is mandatory">
    `minRate == 0` is refused outright, so "no protection" can never be the quiet default that
    happens when a field is left alone.
  </Step>

  <Step title="The floor must be fillable at creation">
    `minRate ≤ peggedRateNow(...)`, else `FloorAboveMarket` — otherwise a maker could post an order
    that passes creation and can never fill.
  </Step>

  <Step title="Escrow and record">
    As Fixed. `buyAmount` is stored as **0**, because there is no price to store.
  </Step>
</Steps>

### What the floor bounds, and why it matters

```
amountIn ≥ mulDiv(minRate, sellAmountOut, RATE_SCALE)     // RATE_SCALE = 1e18
```

It bounds **the money that changes hands**, not the oracle answer. That is deliberate: if a newly
selected feed uses different decimals, `priceScale` changes with it. Checking the settled amount
keeps the maker's floor expressed against the actual transfer value.

<Note>
  Below its floor a pegged order **pauses itself** and resumes on its own when the price recovers.
  Escrow is untouched, and protocol pause/oracle state never disables cancellation. A refund can
  still fail if the sell-token contract itself rejects the transfer; see the
  [security model](/protocol/security#base-tokens-and-usdt).
</Note>

## The `Order` struct

| Field                          | Type             | Meaning                                                                       |
| ------------------------------ | ---------------- | ----------------------------------------------------------------------------- |
| `maker` · `expiry`             | address · uint64 | Paid directly on every fill; the only address that can cancel · hard deadline |
| `feeBps`                       | uint16           | **Snapshot** at creation — a later fee raise cannot reach this order          |
| `status` · `kind`              | enum             | Open/Filled/Cancelled/Expired · Fixed/Pegged                                  |
| `sellToken` · `buyToken`       | address          | Escrowed here · pulled from the taker and forwarded on                        |
| `sellAmount` · `sellRemaining` | uint256          | Original escrow · what is still fillable                                      |
| `buyAmount`                    | uint256          | **Fixed only.** Total on a complete fill. `0` when Pegged                     |
| `premiumBps` · `minRate`       | uint16 · uint256 | **Pegged only.** Guaranteed taker edge · the maker's floor. `0` when Fixed    |

The first five fields share a single 32-byte slot. `minRate` lives inside the struct, which lives
inside a mapping, so adding it consumed no contract storage slot.
