Place limit orders

Submit one or more limit orders to the orderbook. Can be used for both options and perpetual futures.

Authentication Options:

  • Signature: Include signature and signature_deadline fields in each order (both required)
  • One-click session: Include x-one-click header with session hash (signature fields not required)

Important Constraints:

  • All orders in a batch must be from the same maker (single maker per request)
  • All orders in a batch must be for the same market (BTC, ETH, or ARB - determined by trading pair)
  • When NOT using one-click sessions, both signature and signature_deadline are required fields
  • For options orders, use contracts field; for perpetual orders, use amount field
  • The taker field is optional and defaults to zero address (any taker) if not specified
  • EIP-712 signature field order must match exactly as shown in the examples

EIP-712 Signature Example (TypeScript)

import { parseUnits, zeroAddress } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';

// Domain parameters for EIP-712 signature
const EIP712Domain = {
  chainId: 421614, // Arbitrum Sepolia (use 42161 for Arbitrum One mainnet)
  name: 'Premia',
  verifyingContract: '0x...' // ClearingHouseProxy address from deployment
  version: '1'
};

// Type definition for limit orders
const UserLimitOrder = [
  { name: 'deadline', type: 'uint256' },
  { name: 'instrumentName', type: 'string' },
  { name: 'size', type: 'uint256' },
  { name: 'price', type: 'uint256' },
  { name: 'taker', type: 'address' },
  { name: 'maker', type: 'address' },
  { name: 'direction', type: 'uint8' },
  { name: 'isLiquidation', type: 'bool' },
  { name: 'isPostOnly', type: 'bool' },
  { name: 'mmp', type: 'bool' }
];

// Example order data (Options)
const optionsOrder = {
  instrument_name: 'BTC_USDC-31OCT25-130000-C',
  type: 'good_til_cancelled',
  contracts: 1.5,
  direction: 'buy',
  price: 1000.5,
  post_only: true,
  mmp: false,
  liquidation: false,
  maker: '0xYourAddress', // Your Ethereum address
  taker: null // Set to a specific address or null for any taker
};

// Example order data (Perpetuals)
const perpsOrder = {
  instrument_name: 'BTC_USDC-PERPETUAL',
  type: 'good_til_cancelled',
  amount: 10000,
  direction: 'buy',
  price: 45000,
  post_only: false,
  mmp: false,
  liquidation: false,
  maker: '0xYourAddress', // Your Ethereum address
  taker: null // Set to a specific address or null for any taker
};

// Calculate deadline (30 seconds from now)
const deadline = Math.floor(Date.now() / 1000) + 30;

// Setup wallet
const account = privateKeyToAccount('0xYourPrivateKey');

// Choose which order to use (options or perps)
const order = optionsOrder; // or perpsOrder for perpetuals

// Sign the typed data
const signature = await account.signTypedData({
  domain: EIP712Domain,
  types: { UserLimitOrder },
  primaryType: 'UserLimitOrder',
  message: {
    deadline,
    instrumentName: order.instrument_name,
    size: parseUnits((order.contracts ?? order.amount).toString(), 6), // Use contracts for options, amount for perps
    price: parseUnits(order.price.toString(), 6),
    taker: order.taker ?? zeroAddress,
    maker: order.maker,
    direction: order.direction === 'buy' ? 0 : 1,
    isLiquidation: order.liquidation,
    isPostOnly: order.post_only,
    mmp: order.mmp
  }
});

// Final request payload
const requestPayload = {
  ...order,
  signature,
  signature_deadline: deadline
};
Language
Credentials
Header
URL
Click Try It! to start a request and see the response here!