Trade through a River gateway#
This how-to connects a bot to a locally operated River-shaped Seesaw gateway
(services/river-gateway). The gateway accepts signed River requests, maps each
order to a native Seesaw placement, and has the transaction signed by your own
customer signer module. It never holds your keys. For parent orders (stops,
take-profit, iceberg, peg and smart taker), see
River conditional and algorithmic orders.
The gateway is a locally tested adapter, not a hosted River service: hosted River routing, batch deadlines and custodial execution are not supported.
Before you start#
You need:
- the gateway origin, for example
http://127.0.0.1:8787(the service binds to127.0.0.1, port 8787 unless configured); - a registered River request key ID and its Ed25519 signing key;
- a registered subaccount ID. The operator configures one distinct customer wallet per subaccount; shared wallets are refused.
Every listing is one outcome (YES or NO) of one Seesaw market. Every price the
gateway accepts or returns is in that outcome's own price space; the gateway never
converts a NO price into a YES price.
Sign requests#
Every REST request, reads included, carries three headers:
| Header | Value |
|---|---|
X-River-Key-Id | Your registered key ID |
X-River-Timestamp | The current time in milliseconds |
X-River-Signature | Base64 Ed25519 signature of the canonical request described below |
The canonical request joins, with newlines: the method, the path, the query sorted by code point, the timestamp, and the SHA-256 hash of the body. The TypeScript SDK builds it for you:
// docs-check: semantic
import { createRiverGatewayClient } from '@seesaw/core';
import { signBytes } from '@solana/keys';
declare const requestKey: CryptoKey; // the private key of your registered River request key
const river = createRiverGatewayClient({
origin: 'http://127.0.0.1:8787',
keyId: process.env.RIVER_KEY_ID!,
subaccountId: process.env.RIVER_SUBACCOUNT_ID!,
sign: (canonical) => signBytes(requestKey, canonical),
});
The Python SDK (seesaw.river) and the Rust SDK (seesaw_sdk::river) expose the
same client. From the command line, every seesaw river command takes
--url, --key-id and --subaccount-id and signs with the configured keypair;
see seesaw river.
Place and manage simple orders#
A simple order is a limit, market, post-only, IOC, FOK, GTC or GTD order on one listing. Put the order in a JSON file and create it:
seesaw river order create --order-file order.json --client-request-id <uuid> \
--url <origin> --key-id <id> --subaccount-id <id>
Pass the same client_request_id when you retry: the gateway journals the signed
request durably and answers the retry with the original order instead of placing
a second one. qty (6 decimals) and price (4 decimals) may be JSON numbers or
decimal strings; a value that does not parse exactly is refused, never rounded.
GTD expiry is sent both as the execution deadline and as the resting expiry.
Read and cancel orders with order get, order list and order cancel.
Cancellation is asynchronous: DELETE /v1/orders/{id} answers 202, and the
order appears in cancelled_river_order_ids only once its status is
CANCELLED. A failed or expired cancellation is never retried automatically;
re-arm it once with order cancel-retry.
Read market data#
The gateway serves market data from the trusted indexer projection and fails closed on stale or inconsistent evidence:
Command (seesaw river ...) | Reads |
|---|---|
markets search, markets lookup | Configured listings, by search or exact lookup |
orderbook <river-id> | The listing's own lane: its bids and asks |
prices <river-id> | Price candlesticks or history |
tradeprints | Recent fills for the listing, newest first |
fills, positions | Native fills and positions of your subaccount |
YES and NO are independent lanes: a listing's book shows only its own outcome's resting orders, and every fill pairs a bid and an ask of the same lane. The order-book WebSocket requires a River key and a signed challenge.
Check balances and fees#
seesaw river balanceandseesaw river portfolioreport the verified native balance of the subaccount's wallet and its Seesaw portfolio.seesaw river fees quotequotes the native Seesaw taker fee of a fill (--river-id,--quantity-d6,--price-bps).seesaw river fees schedulesanswers River fee-schedule lookups; this gateway reports every River schedule ID as missing, because Seesaw fees are native. Usefees native-schedulesfor Seesaw's own schedules.
Recover an order that did not land#
Every signed placement and cancellation attempt is kept with its generation, signature, signed bytes and last valid block height.
seesaw river order attempts <id>lists the attempts of an order.- An attempt counts as expired only when the finalized block height has passed its last valid block height and a history search still finds no status.
- A placement becomes
expired_unlandedonly when the indexer has processed through the expiry slot with no receipt, order or fill for the signature. Only then doesseesaw river order resubmit <id>sign one new generation, with the same price bound, deadline, side and quantity. If the deadline has passed, the order is rejected instead of repriced. seesaw river healthreports projection age, retrying and quarantined rows, missing cancellation mappings and expired or failed attempts.