Stop-loss and take-profit#
Protect a position with stop-loss and take-profit orders, or work size with iceberg and pegged orders.
The Seesaw program has no trigger order. It matches only orders that are on the book or that arrive in a transaction. A condition such as "sell if the price falls to 40%" is therefore enforced in one of three places:
- Program. The program checks the condition when the transaction lands. Nobody can bypass it.
- Signed bounds. The owner signs one exact transaction in advance. A worker decides when to send it, but it cannot change what the transaction does. The program enforces the bounds inside the transaction: worst price, minimum fill, deadline, quote bounds and fee epoch.
- Per-order bounds. A worker builds a new order when a condition holds, and the owner's signer signs it then. The program enforces that order's own bounds, but not the condition.
- Off-chain trigger. A worker watches the market and places a new order when the condition holds. You trust that worker to watch, to decide correctly, and to stay online.
Where each condition is enforced#
| Feature | Where the condition is enforced | What a worker can do wrong | Where you use it |
|---|---|---|---|
| Take profit (a resting post-only SELL) | Program: the order rests at your price and post-only refuses a cross | Nothing: no worker is involved | Web, mobile, TypeScript SDK (takeProfitOrderParams); any client that places a post-only SELL |
| Stop-loss keeper | Off-chain trigger, then signed bounds: the keeper sends a SELL that you signed in advance | Not send, or send late. It cannot sell below your floor, sell more, or sell after the deadline | Web and mobile, when the operator runs a stop-loss keeper |
| STOP and REVERSE_STOP | Off-chain trigger in the River gateway | Place the child late or not at all. The child is an ordinary order with its own bounds | River gateway REST (POST /v1/complex-orders) |
| Take profit and stop loss linked to a parent order | Off-chain, in the River gateway: the parent must be fully filled; siblings are reserved and then cancelled | As above, plus sibling cancellation | River gateway REST |
| Iceberg and smart-taker | Off-chain worker in the River gateway. The worker builds each child order from the parent's terms, and your signer module signs it when the worker places it. The program enforces each child's bounds: deadline, worst price, minimum fill | Choose when to place each child. It cannot place a child outside the parent's terms without your signer signing it | River gateway REST |
| Pegged | Off-chain worker in the River gateway | Choose when to reprice | River gateway REST |
| Durable execution recovery | Off-chain journal plus chain evidence | Mark an attempt late. A lost response never allows a second order | TypeScript SDK (TransactionAttemptJournal), web, mobile, River gateway |
Take profit#
A take profit is a post-only limit SELL of shares that you hold. Use
takeProfitOrderParams in TypeScript or take_profit_order_params in the Rust
and Python SDKs to set the outcome price and the reject-on-cross flag. The CLI
uses order place --intent sell --order-type post-only --reject-post-only-would-cross 1
with the same outcome, price and quantity.
Post-only means that the order only rests. If your price would
cross the book when the order arrives, the program refuses the order and does not fill it at a
worse price. After the order rests, it fills only at your price or better. The condition is the
order itself, so no keeper is involved.
Stop-loss keeper#
The stop-loss keeper (services/stop-loss-keeper) holds no key and pays nothing. You sign one
transaction in advance. It uses a durable nonce that you own, and it holds one immediate-or-cancel
SELL whose worst price is your floor, whose minimum fill is at least one share atom, and whose
deadline is the end of the market (packages/core/src/stopLoss/transaction.ts). The keeper
watches the on-chain book. When the best bid is at or below your trigger and at or above your
floor, the keeper checks that the nonce has not moved, simulates the transaction, and only then
sends it (packages/core/src/stopLoss/trigger.ts). If the best bid falls through the floor in one
move, the keeper waits: a SELL that cannot fill above your floor would only burn the nonce. If it
landed anyway, the program would refuse to sell below the floor, and you would keep your shares.
Web and mobile verify that the wallet signed the full reviewed message byte for byte before registering the stop. The sell uses the same public order book that the keeper watches. The keeper uses Solana's Clock for deadlines and saves the signed transaction's signature before sending, so it can recover an interrupted submission.
- The program enforces: the floor, the quantity, the deadline and the market.
- You trust the keeper for: the decision to send, and the time it sends.
- To cancel: close the nonce account. The signed transaction then can never land.
River gateway workers#
The River gateway (services/river-gateway) is a gateway that you run yourself. It is not a
hosted service. Its workers implement STOP, REVERSE_STOP, take profit and stop loss linked to a
parent (src/conditional.ts), iceberg and smart-taker (src/algorithms.ts), and pegged orders
(src/peg.ts).
- Triggers. A worker places a child order only after it sees a fresh committed observation. The exception is a linked take-profit LIMIT, which needs only a fully filled parent.
- Signing. Your own signer module (
RIVER_CUSTOMER_SIGNER_MODULE) signs each child. The gateway receives only public keys. - Wire check. Before the gateway sends an order, it checks that the signed wire intent equals
the intent it persisted (
src/execution-adapter.ts). For an advanced child, it also checks the parent id, the deadline and that the child is immediate-or-cancel. - Recovery. The gateway journals every signed attempt in SQLite. It reconciles each attempt against the chain and the indexer before it allows a resubmission.
Web and Android can manage River parents when their deployments configure a gateway.
Durable execution recovery#
The TypeScript SDK records every signed transaction before it sends it
(packages/core/src/transactionAttempt.ts). After a lost response, the client reconciles the
attempt against the chain. Until it knows whether the attempt landed, it blocks a replacement.
This is a client control. It prevents a duplicate order from the same client. It does not stop a
transaction that another client built.
Limits#
- No worker has authority that you did not sign. A worker that sends nothing can still fail you: a stop that is never sent does not protect the position.
@seesaw/corerefuses stop and take-profit order kinds inbuildAdvancedOrderIntent(UnsupportedHostedConditionalOrderError). These kinds need a worker. Use the take-profit order, the stop-loss keeper, or the River gateway.- Program-enforced strategy limits apply when a registered delegate uses the strategy order routes. See Strategy limits.
River gateway SDK clients#
createRiverComplexOrderClient from @seesaw/core submits and manages conditional, iceberg,
pegged and smart-taker parent orders on a configured River gateway. Provide the gateway origin,
your registered key ID and subaccount, and a callback that returns the raw or base64 Ed25519 signature
for the request bytes. The callback keeps the signing key in your own signer.
Use createOrder with the River market ID and one parameter block. Use the returned parent ID
with getOrder or cancelOrder, or use listOrders to recover orders in the same subaccount.
The gateway runs triggers and schedules child orders. The program enforces each child's signed
transaction bounds. A successful order submission confirms the gateway accepted the parent.
The Python SDK exposes the same operations through RiverComplexOrderClient. Its signer
callback returns the raw 64-byte Ed25519 signature. Call create_order, get_order,
list_orders and cancel_order to manage orders in the registered subaccount.
The Rust SDK exposes seesaw_sdk::river::RiverComplexOrderClient through its http feature.
Pass a callback returning the raw signature to each request. RiverOrderParams selects the
parent order kind and accepts exact decimal strings for sizes and prices.
The CLI provides these operations in the river command group. See the CLI guide (unavailable reference).
On web, open Settings → Manage River orders and enter your registered key ID and subaccount. The wallet signs each gateway request. Review the parent parameters or cancellation ID before signing. A gateway acceptance reports the parent request status. On-chain child orders have their own execution status.
On Android, open Settings → River orders. The app build enables the screen with
EXPO_PUBLIC_RIVER_GATEWAY_URL. The connected wallet must match the registered River request key.