Market orders
Market actions execute immediately in one transaction through the router’s*WithPriceUpdate entry points — opening, closing, adding collateral, reducing leverage, and liquidating, for both ordinary positions and margin accounts.
On Pyth-backed markets these calls refresh the oracle in the same transaction:
- The router reads the Pyth update fee, requires you to send at least that much ETH, updates the feed, then runs your action.
- Any leftover ETH is refunded to you in the same transaction.
- On push-based feeds (such as Chainlink) no update is needed; sending ETH there is rejected.
closePositionAndClaimWithPriceUpdate is a convenience entry point that closes and then claims your settlement in one transaction.
Limit and conditional orders
A limit or conditional order is an EIP-712 message you sign off-chain. It is not held on-chain; a keeper submits it later, together with a fresh price update, and the router verifies your signature before acting. The position belongs to you (the order’s maker), not to the keeper who submits it. There are signed orders for each action — open, close, close-and-claim, add collateral, and reduce leverage — with parallel variants for margin accounts. Each order carries:- What to do — the pool, direction and size (collateral × leverage) for opens, or the position and close amount (in basis points) for closes/reduces.
- A trigger — a
triggerPriceplus atriggerAboveflag. The order can be executed only when the oracle price reaches the trigger:triggerAbove = truefires at or above the price,falsefires at or below it. One signed order expresses a take-profit or a stop-loss depending on which side you choose. - Slippage bounds — optional
minPrice/maxPrice(andminPayouton closes) checked against the execution-time oracle price, independent of the trigger. A bound of zero disables that side. - A keeper fee — a token and amount you agree to pay whoever executes the order.
- A deadline and a nonce — for expiry and cancellation (below).
Keepers and fees
Execution is permissionless — anyone can submit a valid signed order, and the executor is recorded on the resulting event. The keeper fee you specified is paid to whoever executes it:- For opens and collateral changes, the fee is pulled from the maker. When a fee is set it must be the market’s collateral token.
- For closes, the fee is taken out of the proceeds: the router claims your settlement, pays the keeper, and forwards the remainder to you (or to the order’s
receiverfor a close-and-claim).
Cancelling an order
Because a signed order lives off-chain, you cancel it in one of two ways:- Let it expire — an order past its
deadlinecan no longer be executed; no transaction is needed. - Burn its nonce — call
cancelNonce(orcancelNonces) to invalidate that order’s nonce before a keeper can use it. Each nonce is single-use, and a successful execution also consumes the nonce, so an order can never be replayed.
