Skip to main content
Function:
{package}::dex_accounts_entry::place_order_to_subaccount
ABI Object:
const functionAbi: MoveFunction = {
  name: "place_order_to_subaccount",
  visibility: "private",
  is_entry: true,
  is_view: false,
  generic_type_params: [],
  params: [
    "&signer",
    "0x1::object::Object<{package}::dex_accounts::Subaccount>",
    "0x1::object::Object<{package}::perp_market::PerpMarket>",
    "u64",
    "u64",
    "bool",
    "u8",
    "bool",
    "0x1::option::Option<0x1::string::String>",
    "0x1::option::Option<u64>",
    "0x1::option::Option<u64>",
    "0x1::option::Option<u64>",
    "0x1::option::Option<u64>",
    "0x1::option::Option<u64>",
    "0x1::option::Option<address>",
    "0x1::option::Option<u64>",
  ],
  return: [],
};
Parameters:
  • signer - The account signer
  • subaccount - The Trading Account object
  • market - The PerpMarket object
  • price - Order price `<u64>`
  • size - Order size `<u64>`
  • is_buy - True for buy order, false for sell order
  • time_in_force - Time in force `<u8>`: 0 = GoodTillCanceled, 1 = PostOnly, 2 = ImmediateOrCancel
  • is_reduce_only - Whether order can only reduce position size
  • client_order_id - Optional client-assigned order ID `<Option<String>>`
  • stop_price - Optional stop price `<Option<u64>>`
  • tp_trigger_price - Optional take-profit trigger price `<Option<u64>>`
  • tp_limit_price - Optional take-profit limit price `<Option<u64>>`
  • sl_trigger_price - Optional stop-loss trigger price `<Option<u64>>`
  • sl_limit_price - Optional stop-loss limit price `<Option<u64>>`
  • builder_address - Optional builder/referrer address `<Option<address>>`
  • builder_fees - Optional builder fee in basis points `<Option<u64>>`

Time in Force Options

When placing orders, you can specify different execution types using the time_in_force parameter:
  • 0 (GoodTillCanceled) - Order stays active until it is filled or manually canceled
  • 1 (PostOnly) - Order only adds liquidity to the order book (becomes a maker order). If the order would execute immediately, it is canceled
  • 2 (ImmediateOrCancel) - Order executes immediately at the best available price. Any unfilled portion is canceled
Example:
const transaction = await aptos.transaction.build.simple({
  sender: account.accountAddress,
  data: {
    function: `${PACKAGE}::dex_accounts_entry::place_order_to_subaccount`,
    typeArguments: [],
    functionArguments: [
      "0x123...abc", // subaccountAddr
      "0x456...def", // marketAddr (PerpMarket object address)
      5670000000, // price (5.67 with 9 decimals)
      1000000000, // size (1.0 with 9 decimals)
      true, // isBuy (true for buy, false for sell)
      0, // timeInForce (0 = GoodTillCanceled, 1 = PostOnly, 2 = ImmediateOrCancel)
      false, // isReduceOnly
      "my-order-123", // clientOrderId (optional)
      null, // stopPrice (optional)
      null, // tpTriggerPrice (optional)
      null, // tpLimitPrice (optional)
      null, // slTriggerPrice (optional)
      null, // slLimitPrice (optional)
      null, // builderAddress (optional)
      null, // builderFees (optional)
    ],
  },
});