Skip to main content
Use this page when a trader account already exists and you want to build Solana instructions for trading. Your app still signs and sends the transaction with the correct authority, position authority, delegated wallet, or fee payer. For account indexes, cross vs isolated accounts, and trader-state subscriptions across all subaccounts, see Accounts. For mark-price joins, account health, and liquidation estimates, see Margin.

Instruction Builders

All order builders produce Phoenix instructions. They do not submit transactions by themselves.
ActionTypeScript builderRust builderPhoenix instruction
Place limit orderclient.ixs.buildPlaceLimitOrder(...)PhoenixTxBuilder::place_limit_order(...)PlaceLimitOrder
Cancel by order idclient.ixs.buildCancelOrdersById(...)PhoenixTxBuilder::build_cancel_orders(...)CancelOrdersById
Cancel all in a marketclient.ixs.buildCancelAll(...)PhoenixTxBuilder::build_cancel_all_orders(...)CancelAll
Place market orderclient.ixs.buildPlaceMarketOrder(...)PhoenixTxBuilder::place_market_order(...)PlaceMarketOrder
Place position stop lossclient.ixs.buildPlaceStopLoss(...)PhoenixTxBuilder::build_stop_loss_orders(...)PlaceStopLoss
Place conditional orderclient.ixs.buildPlacePositionConditionalOrder(...)PhoenixTxBuilder::place_position_bracket_order(...) or raw ix buildersPlacePositionConditionalOrder

Limit Order

import { Side } from "@ellipsis-labs/rise";

await client.exchange.ready();

const orderPacket = await client.orderPackets.buildLimitOrderPacket({
  symbol: "SOL",
  side: Side.Bid,
  priceUsd: "150.50",
  baseUnits: "0.25",
});

const ix = await client.ixs.buildPlaceLimitOrder({
  authority: "AUTHORITY_PUBKEY",
  symbol: "SOL",
  orderPacket,
  traderPdaIndex: 0,
  traderSubaccountIndex: 0,
});
References:

Cancel Limit Order

const ix = await client.ixs.buildCancelOrdersById({
  authority: "AUTHORITY_PUBKEY",
  symbol: "SOL",
  orders: [
    {
      price: 50_000n,
      orderSequenceNumber: "12345",
    },
  ],
  traderPdaIndex: 0,
  traderSubaccountIndex: 0,
});
Reference: Rust cancel-order example.

Cancel All

const ix = await client.ixs.buildCancelAll({
  authority: "AUTHORITY_PUBKEY",
  symbol: "SOL",
  traderPdaIndex: 0,
  traderSubaccountIndex: 0,
});

Market Order

import { Side } from "@ellipsis-labs/rise";

const orderPacket = await client.orderPackets.buildMarketOrderPacket({
  symbol: "SOL",
  side: Side.Bid,
  baseUnits: "0.25",
});

const ix = await client.ixs.buildPlaceMarketOrder({
  authority: "AUTHORITY_PUBKEY",
  symbol: "SOL",
  orderPacket,
  traderPdaIndex: 0,
  traderSubaccountIndex: 0,
});
Reference: Rust market-order example.

Stop Losses

Position stop losses use a per-trader, per-asset stop-loss account. If the account does not already exist, creating it can add an account-init instruction and incur rent.
import { Direction, Side, StopLossOrderKind } from "@ellipsis-labs/rise";

const ix = await client.ixs.buildPlaceStopLoss({
  authority: "AUTHORITY_PUBKEY",
  symbol: "SOL",
  triggerPrice: 140_000n,
  slippageBps: 100,
  tradeSide: Side.Ask,
  executionDirection: Direction.LessThan,
  orderKind: StopLossOrderKind.IOC,
  traderPdaIndex: 0,
  traderSubaccountIndex: 0,
});
To cancel a position stop loss:
import { Direction } from "@ellipsis-labs/rise";

const ix = await client.ixs.buildCancelStopLoss({
  authority: "AUTHORITY_PUBKEY",
  symbol: "SOL",
  executionDirection: Direction.LessThan,
  traderPdaIndex: 0,
  traderSubaccountIndex: 0,
});
Reference: Rust cancel stop-loss example.

Conditional Orders

Conditional orders use a trader conditional-orders account. If the account does not already exist, your flow may need to create it first and pay rent. The newer bracket helpers can check and create the account when configured with an RPC client; raw builders require you to include CreateConditionalOrdersAccount yourself when needed.
import {
  Direction,
  Side,
  StopLossOrderKind,
  ticks,
} from "@ellipsis-labs/rise";

declare const conditionalOrdersAccountExists: boolean;

const ixs = [];

if (!conditionalOrdersAccountExists) {
  ixs.push(
    await client.ixs.buildCreateConditionalOrdersAccount({
      authority: "AUTHORITY_PUBKEY",
      traderPdaIndex: 0,
      traderSubaccountIndex: 0,
    })
  );
}

ixs.push(
  await client.ixs.buildPlacePositionConditionalOrder({
    authority: "AUTHORITY_PUBKEY",
    symbol: "SOL",
    lessTriggerOrder: {
      triggerDirection: Direction.LessThan,
      tradeSide: Side.Ask,
      orderKind: StopLossOrderKind.IOC,
      triggerPrice: ticks(140_000n),
      slippageBps: 100,
    },
    sizePercent: 100,
    traderPdaIndex: 0,
    traderSubaccountIndex: 0,
  })
);
For bulk cancellation, read the conditional-orders account, enumerate active trigger legs, and build one cancel instruction per active leg. The public examples show the full account-read and batching flow: