Skip to main content
Raydium Perps is a white-labeled deployment on Orderly Network. The order book, matching engine, and account state all live on Orderly. The Raydium SDK v2 (@raydium-io/raydium-sdk-v2) does not cover perps — for programmatic access, use Orderly’s REST + WebSocket API directly. The snippets below show the most common flows; the canonical reference is at orderly.network/docs.
Version banner.
  • Backend: Orderly Network REST + WebSocket API
  • Snippet schema verified against Orderly’s API as of 2026-04
  • Solana cluster for on-chain deposits: mainnet-beta
  • Signing: Solana ed25519 over the Orderly EIP-712-style payload (Orderly uses an EIP-712 schema even for non-EVM chains; see Orderly docs for the latest field list)
Orderly’s API surface evolves; check orderly.network/docs before copying these snippets into production.

What’s on this page

The flows below cover the integrator-relevant lifecycle:
  1. Account setup — deposit USDC and register the account with Orderly.
  2. Authenticated REST calls — request signing for order placement, cancellation, and account queries.
  3. Trading — placing market / limit orders, cancelling, fetching positions and fills.
  4. Market data — subscribing to the orderbook and trade WebSocket.
  5. Withdrawal — initiating a withdrawal back to the wallet.
These snippets target Node.js + TypeScript with @solana/web3.js and tweetnacl for Ed25519 signing. They are starting points — Orderly’s API surface is broad and changes faster than this page; always check Orderly’s live docs before shipping production code.

Setup

The Orderly trading key is not your wallet keypair. It’s a request-signing key that you register against your wallet on first use; you can rotate it without touching funds. Treat it as a session credential.

Account registration

Before placing any orders, register the wallet with Orderly:
Account IDs are deterministic per (broker_id, wallet_address) pair — the registration is idempotent. If a wallet has already registered with Raydium’s broker, the call returns the same account ID without creating a new one.

Deposit USDC

Deposits move USDC from the wallet ATA to Orderly’s settlement vault. They are on-chain Solana transactions:
After ~30 seconds, Orderly’s relayer indexes the deposit and the balance shows up under the account’s free margin. Query /v1/client/holding to confirm:
(orderlyAuthGet is defined below — every authenticated call goes through it.)

Request signing helper

Every authenticated REST call to Orderly carries an Ed25519 signature over (timestamp + method + path + body):
Replay protection: requests with a timestamp more than 5 seconds off the server clock are rejected. Sync your clock (NTP) and avoid signing requests in advance.

Place a market order

Market orders execute immediately. The response returns the resulting order_id plus a status. Fills come over the WebSocket (see below); the REST response itself does not block until fully filled.

Place a limit order with Post-Only

For IOC / FOK, set time_in_force: "IOC" or "FOK". See products/perps/order-types for the semantics of each flag.

Cancel an order

A cancel is acknowledged synchronously but the actual cancellation may race with a fill. Always reconcile by polling /v1/orders or watching the WebSocket — assuming a cancel succeeded without confirmation can lead to duplicate or unintended positions.

Fetch open positions

A negative position_qty is a short, positive is a long. position_qty == 0 means the position is closed but the row may still show until the next cleanup.

Fetch fill history

Time arguments are millisecond Unix timestamps. The default page size is 25 rows; use page and size query params to paginate.

WebSocket: market data

For the private stream (your fills, position updates, balance changes), the WebSocket has to be authenticated. Send a subscribe payload signed the same way as REST requests, scoped to your account ID. Orderly’s docs have the exact payload shape; it changes occasionally, so don’t hard-code a particular schema here.

Withdraw USDC

Orderly relays the withdrawal on-chain to the receiver address. There is a flat 1 USDC withdrawal fee (see products/perps/fees). The on-chain transfer happens within 1–2 minutes under normal conditions; expect longer during congestion.

Pitfalls

  • Don’t reuse the trading key across environments. A single Orderly trading key registered against your wallet is associated with one Solana mainnet account. If you also need devnet or staging, generate a separate key for each.
  • Time sync. Orderly’s clock-skew tolerance is tight (±5s). On long-running services, NTP drift will eventually break signing. Re-sync periodically.
  • WebSocket reconnects. The public WS occasionally drops connections during Orderly upgrades. Implement exponential backoff and resubscribe on reopen.
  • Rate limits. REST calls are tier-rate-limited per account. Bulk-cancel via cancel_all rather than looping cancel-by-id when you have >5 orders to cancel.
  • Position direction is implicit. A BUY order on PERP_SOL_USDC opens or extends a long; a SELL opens or extends a short — but if you’re already long, a SELL reduces (and may flip) the position because Raydium Perps is one-way mode. Always check current position before placing an order if the direction matters.
  • Funding and liquidations are separate from order flow. Funding payments and liquidations show up as separate event streams; they are not “orders”. Subscribe to the relevant private WS topics if you need to observe them.

Where to go next

Sources: