Placing an order
Step-by-step guide to placing limit and market orders on Phasis, including order types and side encoding.
Order types
Phasis supports four order types, all of which are executed on the underlying DeepBook v3 order book.
| Order type | Behaviour |
|---|---|
NO_RESTRICTION (limit GTC) | Rests in the book until filled or cancelled |
POST_ONLY | Rests only; aborts if it would cross an existing order |
FILL_OR_KILL (FOK) | Fills in full immediately or aborts entirely |
IMMEDIATE_OR_CANCEL (IOC) | Fills what matches immediately; any unfilled remainder is cancelled |
A market order is modelled as a limit order at an extreme price submitted with IMMEDIATE_OR_CANCEL. This ensures the order sweeps available liquidity and any unmatched remainder is discarded rather than resting.
Buy vs. sell
- Buy (BID side): Opens a long position or closes an existing short.
- Sell (ASK side): Opens a short position or closes an existing long.
Opening a long by buying requires only that you have enough free USDC to pay the premium. Opening a short by selling requires that you have enough free USDC to satisfy the margin requirement.
Choosing your parameters
When placing an order you specify the series (underlying, expiry, strike, call/put), the side, the quantity, and a limit price.
Common scenarios
Buy 2 BTC calls, limit $0.05:
- Side: BID
- Quantity: 2 contracts
- Limit price: $0.05
- Order type:
NO_RESTRICTION— the order rests until fully filled or you cancel
Sell 1 ETH put at market:
- Side: ASK
- Quantity: 1 contract
- Order type:
IMMEDIATE_OR_CANCELwith a high limit price (to sweep all available bids)
Close half of a 2-contract short:
- Side: BID (buying closes a short)
- Quantity: 1 contract
- The protocol automatically clamps the fill to your actual position size
Pre-trade margin check
Before any order reaches the order book, the protocol runs a full margin check on your portfolio. If placing the order would cause your free balance to drop below your margin requirement, the transaction aborts.
Free balance = balance_quote − locked_margin − quote_locked
This means you may need to close an existing short or deposit additional USDC before opening new short positions. See The cross-margin account for details.
Behind the scenes: price and quantity encoding
The on-chain protocol stores prices and quantities as fixed-point integers:
- Price is encoded as
price_in_USDC × 1e9(UD30×9 format). A $0.05 option premium becomes50_000_000on-chain. - Quantity is encoded as
contracts × 1e6. One contract becomes1_000_000on-chain.
The Phasis SDK handles this conversion for you automatically. If you are constructing transactions manually, apply these scaling factors before calling the entry function.
Order lifecycle
- Transaction submitted to Sui.
- Protocol validates market state (
Listed), series state (Active), and registry not paused. - Margin pre-check runs against your current portfolio.
- Matching engine attempts to fill against resting orders in the book.
- Any fill is applied atomically: position delta, open interest, fee accrual, and margin lock are all updated in the same transaction.
- Any unfilled remainder is handled according to the order type (rests, cancels, or aborts).
Continue to The cross-margin account to understand how margin is calculated.