Orders: limit, TP/SL
Limit orders open a position at a target price; take-profit and stop-loss close the whole position when the signed index price reaches a trigger.
Order types#
Limit order. A limit order is an open instruction with a price condition. It fills once the signed index price is at the limit or better: for a long, price ≤ limit; for a short, price ≥ limit. The fill price is the signed price of the settling block, not the limit itself.
Take-profit and stop-loss. A take-profit (TP) or stop-loss (SL) is a close instruction with a trigger price. It can be attached to a new order or set on an open position. When the signed price reaches the trigger (equality counts), the entire position closes at that signed price. Positions cannot be partially closed.
Rules#
- The trigger is the signed index price of the settling block. Movements between signed updates and candle wicks do not trigger orders.
- No margin is reserved for resting orders. If the balance is insufficient when a limit order triggers, the order fails and is not retried.
- Good-till-cancelled, up to 30 days, or until the signing session key expires, whichever comes first.
- Placement checks. For a long, TP must be above the reference price, and SL must lie between the liquidation price and the reference price. For a short, the conditions are mirrored.
- Limits. At most 50 active orders per wallet, and at most one active TP and one active SL per position.
- Liquidation takes precedence. If a stop-loss and a liquidation trigger in the same block, the position is liquidated.
- Gaps. If the price moves past a stop between signed updates, the order triggers at the next signed price, which may be worse than the stop.
- Copy trading does not copy orders.
- Moving an order line on the chart cancels the existing order and places a new one in a single step.
Orders rest with the relayer, not on-chain. The contract re-checks every condition at settlement.
Example: limit order with stop-loss#
Alice places a BTC limit long with 100 USDT margin at 100× leverage (10,000 USDT notional), a limit of 79,500 and a stop-loss at 79,000.
| Signed price | Rule | Result |
|---|---|---|
| 79,620 | Long fills only at price ≤ 79,500 | No fill; order keeps resting |
| 79,480 | 79,480 ≤ 79,500 | Fills at 79,480; liquidation price ≈ 78,722.66 |
| 79,000 | Signed price reaches the SL trigger (equal counts) | Whole position closes at 79,000 |
liquidation base = 79,480 − 79,480 / 100 = 78,685.20
liquidation = 78,685.20 × (1 + 0.000476041…) ≈ 78,722.66
loss = 10,000 × (79,480 − 79,000) / 79,480 ≈ 60.39 USDT
LP-side fee = 60.39 × 2% ≈ 1.21 USDT (payout queue empty)
SPAPER minted = (60.39 − 1.21) × 100 ≈ 5,918 SPAPER (LP net below 2,000,000 USDT)
← Scroll sideways for long formulas
The stop-loss limits the loss to about 60 USDT instead of the full 100 USDT margin, and the realised loss still mints SPAPER.
Example: take-profit#
The same position instead carries a take-profit at 80,275.
| Step | Rule | Result |
|---|---|---|
| Signed price reaches 80,275 | Long TP triggers at price ≥ 80,275 | Whole position closes at 80,275 |
| Deadband | Exit treated 79,480 / 50,000 ≈ 1.59 less favourable | Gain ≈ 99.83 USDT |
| Impact scale | scale at a ≈0.998% move ≈ 0.8832 | ≈ 88.17 USDT |
| Win fee | 2% of the scaled gain | ≈ 1.76 USDT; Alice receives ≈ 86.41 USDT profit plus 100 USDT margin |
gain after deadband = 10,000 × (80,275 − 79,480 − 1.5896) / 79,480 ≈ 99.83
scaled gain = 99.83 × 0.8832 ≈ 88.17
win fee = 88.17 × 2% ≈ 1.76
net profit = 88.17 − 1.76 ≈ 86.41 USDT
← Scroll sideways for long formulas
A take-profit settles exactly like a manual close at the same signed price; see Asymmetric impact.