Order types
There are two things a trader can send: a batch order, which goes into the next auction now, and a trigger, which waits for a price and then becomes a batch order. Two more are built from those: a TWAP, which sends one order into the batches in slices on a clock, and a scale ladder of triggers.
Key figures
| Orders per batch | 64 |
| Resting orders per wallet per batch | 4 |
| Open needed to take a slot in a full batch | 2 × the smallest resting open |
| Life of a batch order | 1 batch |
| Minimum open, site listing | $10 |
| Minimum reduce-only order | the market's minimum position, unless it closes all that is left |
| Market order limit (site) | 1% through the mark |
| Fired close limit | 1% through the oracle |
| Fired limit close limit | its trigger price |
| Trailing stop distance | 0.1% to 50% |
| Trigger check (devnet keeper) | every 3 seconds |
| TWAP window | 5 minutes to 24 hours |
| TWAP slices | at least 10 seconds apart, at most 1,000 |
| TWAPs per wallet per market | 1 |
| Scale ladder (site) | 2 to 10 triggers |
Batch orders
Every batch order is a limit. It fills at its flow's clearing price, never worse than its limit, or not at all. See The auction.
| Order | Maker or taker | Limit |
|---|---|---|
| Market (site) | taker | mark ± 1% |
| Limit, post only | maker | the price given |
| Close (site) | taker | mark ± 1% |
| Fired trigger | taker | see below |
Opens escrow their collateral at submission. Unfilled collateral comes back at settlement.
Closes are reduce-only. They escrow nothing and reserve size on the position, so the same size cannot be promised to two closing orders. A close fills like any other taker: in full when the batch can match it, pro rata with its flow when it cannot. What a crowded batch does not fill is not carried over. The rest of the position stays open, and the trade screen shows how much closed. Before a close is sent, the trade screen asks to confirm it: how much to close (25, 50, 75 or 100%, or an exact amount no smaller than the minimum unless it is the whole position), the expected fill price, PnL and close fee, the share of profit paid when the market's payout is under 100%, and how long until the batch clears. It also says when the close is larger than the market fills in one batch.
Makers rest as liquidity at their own price. A maker trades only with
takers, never with the pool and never with another maker. Set is_maker on
submit_order, or maker: true on the devnet API's order endpoint. A maker
order must carry a price.
Post only
The limit tab's Post only box sends the order as a maker at the limit price.
- It never trades with the pool and never takes.
- It fills only when a taker in the same batch crosses it, at that flow's clearing price.
- It lasts one batch. Unfilled, it lapses and its collateral comes back at settlement. To quote again, place it again.
- It posts the same margin and pays the same fees as any open.
- It cannot be reduce-only and has no time in force.
Limits that keep one wallet from filling a batch
- A wallet may hold at most 4 resting orders in a market's batch.
- A reduce-only order must be at least the market's minimum position size, unless it closes everything left. Reduce-only orders post no collateral, so without a floor they would cost nothing, and enough of them priced never to cross could block every exit.
- A wallet cannot hold opening orders on both sides of one batch. A flip's open half is an opening order on its side.
All three apply to orders a trigger fires as well as to orders sent by hand.
A full batch
Many wallets can still fill a batch between them. A full batch therefore does not simply refuse. It gives up a slot by these rules:
- Only a taker open is ever displaced, a flip's open half included. A close is never displaced, a flip's close half included, and neither is a maker's post-only quote: it is the liquidity the batch clears against, and letting a large taker remove it would let that taker move the price it fills at.
- The open displaced is the smallest taker open by notional in the batch, the lowest slot among equals. Nobody chooses it.
- A close displaces it whatever the close's size. An exit outranks any open.
- An open displaces it only if it is at least 2 × its size. Below
that, the new order is refused with
BatchFull. - The displaced order's collateral is refunded in full, at once. No fee is kept. It is the same as a cancellation by the program, and the owner can place the order again in the next batch.
- The per-wallet limits above still apply to the new order.
The new order takes the displaced one's slot. No other order's index moves, and the batch never holds more than 64 orders, so clearing costs what it did.
The caller passes the displaced owner's USDC token account as the first
remaining account of submit_order, or of execute_order for a fired
trigger. Any token account of the pool's USDC mint owned by that wallet will
do, and anyone can create one. Without it the instruction fails and nothing
is displaced. A BatchOrderEvicted event records the slot, the owner and the
refund.
What it costs to fill a batch now. Spam at the minimum size is pushed out
by any open of twice the minimum, and by any close. To keep an open of size
S out, every taker open resting in the batch must be over S / 2: more than 32 ×
S of notional, at margin, at prices that may fill, posted again every
batch. A batch is shut to everyone only when it holds no taker open: 64
closes and quotes. Quotes cost collateral at prices that may fill, and closes
need real positions, four to a wallet.
Why not the alternatives. A higher minimum order would price out small traders and still let 64 orders at that minimum shut the batch to anything the same size. A fee on unfilled orders would charge honest makers whose quotes nobody took, and cannot touch closes, which escrow nothing. Liquidation does not go through the batch, so none of this can block it.
Flipping a position
A wallet holds one position per market, long or short.
- An open on the side the position holds adds to it: the size grows, the entry is blended by size, and leverage is checked on the combined position.
- An open on the other side is refused at submission. So is a limit placed on the other side.
- An open is also refused while the wallet's own opening order on the other side is still in the batch.
- To change sides in one order, flip:
submit_flip, orflip: trueon the devnet API's order endpoint. Or close first, and open the other side once the close has filled.
What a flip is
A flip from long to short is one taker's sell: the whole long, and the short after it. A flip from short to long is one buy. It goes into the batch as two orders on the same side at the same limit, linked:
| Half | Size | Escrow | Is, for every rule |
|---|---|---|---|
| Close | the whole position | none; the size is reserved | a close |
| Open | the new side's size | its collateral, at submission | an open |
They clear together, in one flow, at one price. The fill goes to the close first. Only once the whole position is covered does any of it go to the open. The total is the clearing's, so nobody else's fill changes.
| Batch fills | Closes | Opens | Open's margin back |
|---|---|---|---|
| all of it | the whole long | the whole short | none |
| more than the long | the whole long | the rest | the unfilled share, exactly |
| the long or less | that much of the long | nothing | all of it |
Settlement closes before it opens. Settling the open half settles the close half first, in the same instruction, if it has not settled yet. The open books only into an empty position, so a partial fill never leaves the trader long and short, and never larger on the old side. Either half may be settled first, by anyone, and the outcome is the same.
If the position was liquidated or deleveraged before the batch settled, the close half closes what is left, possibly nothing. The open half opens only the share of the fill past the close half's size, never more than it was placed for.
What a flip must pass
At submission:
- A position on the other side, none of it already promised to a resting close. A flip closes all of it, so cancel a partial close first. The position's size is reserved, so no other close can promise it again while the flip rests.
- The open half passes every check an open does, as a new position on its side: the minimum size, the maximum leverage on collateral net of the open fee, and the open interest cap with the side's resting opens counted.
- The crowded-side leverage cap is asked with the closing position already off the other side, since the open lands only after it has gone. It is never higher than the cap for the same open on its own.
- The per-wallet limits count both halves: two of the wallet's four slots, and no opening order of the wallet's on the old side may be resting. While the flip rests, no open on the old side is admitted.
- Market only on the site. A flip is always a taker, never post-only.
A flip opens, so it is refused on a paused market. A plain close is not.
A flip in a full batch
Each half is placed by its own rule. The close half takes a slot the way any close does. The open half must find its own: a free slot, or the smallest taker open, and only at 2 × that order's size, counted on the open half's size alone. A large position closing gives a small open no right to anyone's slot. If the open half cannot get a slot, the whole flip is refused and nothing moves.
Resting, the open half can be displaced like any open, and is refunded in full. The close half stays and fills as a plain close. The close half is never displaced.
A flip that displaces orders passes one refund account per order displaced,
the close half's first, as the first remaining accounts of submit_flip.
Cancelling
Cancelling the close half cancels the open half with it and returns its escrow. Cancelling the open half leaves the close half as a plain close.
On the site
When the ticket holds the other side of a position, it disables the open and says what is held ("You already hold a SHORT on SOL. Flip it, or close it first."). Beside Reduce and Close it offers Flip to long (or short). Chosen, the button becomes "Flip to long" and the ticket shows what will happen, in order: the close of the whole position, then the open of the size entered, and that a partial fill only closes. The margin for the new side comes from the free balance: the old side's collateral comes back only when its close settles.
A flip sent from the site cancels the old position's take profit and stop in the same transaction, as a full close does. Left standing, they would fire against the position on the new side.
The trade ticket checks all of this before anything is signed, from fresh reads of the position and the batch, and the server asks the same question from the chain before it builds the transaction.
Opens are checked at submission
An open entering a batch must fit, as things stand then:
- the position's side,
- the market's maximum leverage, on collateral net of the open fee and of funding the position already owes, lowered when the open's side holds more than 60% of open interest with this open and the side's resting opens in (see Margining),
- the open interest cap, counting every open already resting on that side of the batch.
Settlement books whatever the auction filled without checking again.
Triggers
A trigger is one object for limit, take profit and stop loss: a price, a direction to cross it from, and what to do on the other side. It is either:
- an open, which escrows its collateral when placed, or
- a close, which escrows nothing. A close of size zero closes the whole position.
A trigger fires against the oracle mark, not the fill price. What it becomes is a taker order in the market's batch. The auction sets the price, the same as for an order sent by hand.
| Trigger | Limit of the order it becomes |
|---|---|
| Open (limit) | the trigger price |
| Close (take profit, stop) | oracle - 1% for a long, oracle + 1% for a short |
| Limit close | the trigger price |
The 1% is wide enough to cross the pool's quote in an ordinary market and narrow enough that a stop in a dislocation is not filled at any price.
Limit close
A close placed with limit_close carries its own limit, the trigger price.
It fires when the oracle reaches that price and enters the batch at it, so it
fills there or better and never worse. A take profit can fill up to 1% under
its trigger; a limit close cannot. Only a close can be a limit close.
Trailing stop
A close placed with trail_bps is a trailing stop: its trigger stays that
far behind the best price since it was placed. A long's stop is below the
price and only rises; a short's is above and only falls.
trail_order moves it. Anyone can call it. It reads the same oracle mark a
trigger fires on, and moves the stop only toward the price, so a caller can
only put the stop where the price already says it belongs. It is refused when
the stop would not move (TrailNotMoved) and on an expired order. A moved
trigger is requoted in the market's current price factor, so a later split
rebases it from there. It fires as any stop does, at the oracle less 1%.
The site's keeper calls trail_order once the price has run a tenth of the
trail past the stop, and never for less than 0.05%. A 5% trail moves every
half percent.
Checked twice
When placed:
- Nothing on a paused pool. Only closes on a paused market.
- An open must fit the side, leverage and open interest cap as they stand.
- An expiry, if set, must be in the future.
When fired:
- Refused on a paused pool or a paused market.
- An open must pass the same checks as a submitted open, including the opens resting in the batch, because the position and the market may have moved.
- A close needs size still closable on the position, and keeps the reduce-only minimum: no smaller than the market's minimum, unless it is all that is left.
A trigger that fails when fired never reaches the batch, so it never moves a clearing price. It stays in place until it fires, expires or is canceled. A trigger that fires is spent: its account closes. If the batch it lands in cannot fill it, it lapses with that batch, and a fired open's collateral comes back at settlement.
An expired trigger is closed by the next attempt to fire it, and its escrow is refunded. A canceled trigger's escrow is paid back from the vault of the pool its market belongs to, and from no other.
On the site
- There is one take profit, one stop, one limit and one limit close per market. The stop can be a fixed price or a trail. Setting one where one already stands replaces it in the same transaction.
- Closing a whole position from the site cancels its take profit, stop and limit close in the same transaction.
- A limit close is set from the Close dialog's Limit tab, only on the position's winning side of the price. Past it, a close fills now.
- A trigger whose position is already gone, for example after a liquidation, shows as "No position" under Open Orders. Cancel it: left standing, it would act on the next position opened on that market.
- A paused market shows "Exits only" in its header.
TWAP
A TWAP is one order, posted once, that goes into the market's batches in slices over a window. It is for size a single batch cannot take without moving the price, mostly on thin markets.
- The trader sets the size, the running time (5 minutes to 24 hours), the frequency (at least 10 seconds, at most 1,000 sub-orders) and, if they want one, a limit: the most a buy pays, the least a sell takes.
- An open escrows all its collateral when placed. Each slice takes its share, at the leverage of the whole order. A close escrows nothing; a close of size zero works through the whole position.
- Anyone can send a slice once it is due. It enters the batch as a taker order, priced 1% through the mark (and never past the TWAP's limit), and the auction sets its price, the same as any order.
What each slice is
Each slice is what is left divided by the slices left in the window, and never under the market's minimum position. Settlement books what the slice filled against the TWAP, and the collateral it did not use goes back to the TWAP, not the wallet. So a batch that fills only part of a slice makes the next slices larger, and the last slice in the window sends all that is left.
While the mark is past the limit, slices wait. They resume when it comes back, spread over what remains of the window.
Checked when each slice is sent
- Not before it is due, and not after the window has closed.
- One slice at a time: the next waits until the last one settles.
- An open must pass the same checks as a submitted open. A close needs size still closable on the position.
- A slice that would displace an order in a full batch follows the same rule as any other order. A displaced slice's collateral goes back to the wallet, and the TWAP finishes smaller rather than at higher leverage.
Ending
A TWAP is done when nothing is left or its window has closed. The owner can cancel it at any time no slice is in a batch. Anyone can close one that is done, or a closing TWAP whose position is gone; either way its unused collateral goes back to the owner.
Scale
A scale order is a ladder of triggers spread evenly across a price range, placed in one signature. On the site:
- Scaling in places limit opens across a price range. The size and margin are split Flat (the same at every price), Increasing (larger toward the high end) or Decreasing (larger toward the low end).
- Scaling out places take profits on the position, split the same way.
Each rung is an ordinary trigger, with everything said above about triggers. Ladders use their own slots, so they never replace the market's take profit, stop or limit. Each rung must be at least the market's minimum.
Execution
Clearing, settlement, triggers and liquidation are permissionless. None of them takes a price or a choice from the caller. On devnet the venue's server checks every trigger against the mark every 3 seconds; one that is reached but will not fire is tried again after 60 seconds. It looks for due TWAP slices every 2 seconds and closes TWAPs that are done.