Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

submitPerpsOrder

Submit a market or limit perps order, optionally with take-profit and stop-loss children.

Orders are decomposed into closing and opening portions against the user's existing position before matching, and each fill settles funding, PnL, and the volume-tiered fee in-place on USD margin. See protocol book: perps/2-order-matching.

Signature

function submitPerpsOrder(
  client: Client<Signer>,
  parameters: {
    sender: Address
    pairId: string
    size: string
    kind: PerpsOrderKind
    reduceOnly: boolean
    tp?: ChildOrder
    sl?: ChildOrder
  },
): Promise<{ hash: Uint8Array } & TxData>

Example

import { createSignerClient, createTransport, testnet, PrivateKeySigner } from "@left-curve/sdk"
import type { Address } from "@left-curve/sdk"
 
const client = createSignerClient({
  chain: testnet,
  transport: createTransport(),
  signer: PrivateKeySigner.fromMnemonic(process.env.DANGO_MNEMONIC!),
})
const sender: Address = "0x1234567890abcdef1234567890abcdef12345678"
 
// Market order
await client.submitPerpsOrder({
  sender,
  pairId: "BTC-PERP",
  size: "0.1",
  kind: { market: { maxSlippage: "0.005" } },
  reduceOnly: false,
})
 
// Limit order
await client.submitPerpsOrder({
  sender,
  pairId: "BTC-PERP",
  size: "-0.05",
  kind: {
    limit: { limitPrice: "65000", timeInForce: "GTC" },
  },
  reduceOnly: false,
})

Parameters

senderAddress. The trader.

pairIdstring. Perps pair identifier.

sizestring. Signed quantity. Positive = buy (opens long / closes short), negative = sell. Zero is rejected.

kindPerpsOrderKind. Discriminated union: { market: { maxSlippage } } or { limit: { limitPrice, timeInForce, clientOrderId? } }. timeInForce is "GTC" (rest on book), "IOC" (immediate-or-cancel — discard unfilled), or "POST" (post-only — reject if it would cross). maxSlippage is bounded by the per-pair max_market_slippage cap. clientOrderId is not allowed with "IOC".

reduceOnlyboolean. When true, the order can only reduce an existing position.

tpChildOrder, optional. Take-profit { triggerPrice, maxSlippage, size? }.

slChildOrder, optional. Stop-loss { triggerPrice, maxSlippage, size? }.

Returns

{ hash: Uint8Array } & TxData — see broadcastTxSync.

Notes

  • clientOrderId is normalized: null/undefined is stripped from both the message and the typed-data structure.
  • The chain rejects orders that fail pre-match checks: per-pair tick-size alignment, OI cap, slippage cap, limit-price band relative to oracle, and pre-match margin (worst-case 100 % fill IM + projected fee + reserved margin must be covered by equity). See perps/2-order-matching §3a, §3b, §5, §11.
  • Market and IOC limit orders revert with "no liquidity at acceptable price" if nothing fills; GTC remainders rest on the book and reserve |openingSize| × limitPrice × imr until cancelled or filled.
  • Reduce-only orders skip the pre-match margin and OI checks; they reserve zero margin.

See also