Edit limit orders

Edit one or more existing limit orders on the orderbook. Can modify the size and/or price of options or perpetual futures orders.

Authentication:

  • Signature: Include signature and signature_deadline fields in each edit request (both required)
  • One-click sessions are NOT supported for editing orders

Important Constraints:

  • All orders being edited must belong to the same maker
  • All orders being edited must be for the same market (BTC, ETH, or ARB)
  • MMP (Market Maker Protection) must NOT be active for the maker/market pair
  • Orders currently being filled (inflight) cannot be edited
  • Post-only orders cannot be edited to a price that would cross the market
  • Minimum size requirements still apply after editing
  • Each order_id must be unique in the batch (no duplicate order ids)

EIP-712 Signature Example (TypeScript)

import { parseUnits } 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 editing limit orders
const UserEditOrder = [
  { name: 'deadline', type: 'uint256' },
  { name: 'size', type: 'uint256' },
  { name: 'price', type: 'uint256' },
  { name: 'orderId', type: 'string' }
];

// Example edit request (Options)
const optionsEdit = {
  order_id: 'abc123def456789012345678901234567',
  contracts: 2.5,  // New size
  price: 1100.0    // New price
};

// Example edit request (Perpetuals)
const perpsEdit = {
  order_id: 'abc123def456789012345678901234567',
  amount: 15000,   // New size in USD
  price: 46000     // New price
};

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

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

// Choose which edit to use
const edit = optionsEdit; // or perpsEdit for perpetuals

// Sign the typed data
const signature = await account.signTypedData({
  domain: EIP712Domain,
  types: { UserEditOrder },
  primaryType: 'UserEditOrder',
  message: {
    deadline,
    size: parseUnits((edit.contracts ?? edit.amount).toString(), 6),
    price: parseUnits(edit.price.toString(), 6),
    orderId: edit.order_id
  }
});

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