Guides
Orders

Orders

Order operations go over the WebSocket as submit ops. createOrder signs the payload with your identity (CIP-8) and encrypts it (ChaCha20). The server cannot read an order before it matches.

Human units, or exact wire values

price and size take human decimals by default. The SDK converts them with BigInt math, so there is no float loss. Wrap a value in exact(...) to pass a raw wire amount instead.

Create an order
import { exact } from "@sugar-rush/sdk";
const ack = await client.createOrder({
symbol: "DARK-VAN", side: "buy", type: "limit",
price: "2.15", // human decimal
size: exact(1_000_000_000n), // or raw base units, verbatim
timeInForce: "GTC",
});
console.log("submitted:", ack.requestId);

Time in force

  • GTC (default) — rests on the book until cancelled.
  • IOC — fills whatever crosses immediately and cancels the rest.
  • FOK — fills completely or rejects.
  • PostOnly — rejects if the order would cross.

type: "market" orders are always IOC.

Cancel

Cancel
await client.cancelOrder(orderId);
await client.cancelAllOrders(); // account-wide
console.log("open orders:", client.openOrders().length);