> ## Documentation Index
> Fetch the complete documentation index at: https://docs.decibel.trade/llms.txt
> Use this file to discover all available pages before exploring further.

# Place Spot Order

> Place a limit order on a spot market

**Function:**

```
{package}::dex_accounts_spot_entry::place_spot_order_to_subaccount
```

**ABI Object:**

```typescript theme={null}
const functionAbi: MoveFunction = {
  name: "place_spot_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}::spot_market::SpotMarket>",
    "u64",
    "u64",
    "bool",
    "u8",
    "0x1::option::Option<address>",
    "0x1::option::Option<u64>",
  ],
  return: [],
};
```

**Parameters:**

* `auth` - The account signer
* `subaccount` - The Trading Account object
* `market` - The SpotMarket object
* `price` - Order price in raw quote units, aligned to `tick_size` `` `<u64>` ``
* `orig_size` - Order size in raw base units, aligned to `lot_size` `` `<u64>` ``
* `is_bid` - True for a bid (buy), false for an ask (sell)
* `time_in_force` - Time in force `` `<u8>` ``: 0 = GoodTillCanceled, 1 = PostOnly, 2 = ImmediateOrCancel
* `builder_address` - Optional builder/referrer address `` `<Option<address>>` ``
* `builder_fees` - Optional builder fee cap `` `<Option<u64>>` ``

For converting human-readable prices and sizes to raw units, see [Formatting Prices and Sizes](/developer-hub/on-chain/overview/formatting-prices-sizes).

<Info>
  A spot market address is not interchangeable with a perp market address. A spot BTC market and a perp BTC market are separate markets with separate addresses — pass the spot market you want. Spot has no reduce-only flag, client order ID, or TP/SL parameters.
</Info>

## Time in Force Options

* **`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

## Collateral and Funding

Spot orders are fully collateralized before they reach the book: a bid escrows the quote asset, an ask escrows the base asset.

Funds are sourced from the subaccount's primary fungible store (PFS) first, then the remainder from collateral-backed storage (CBS) when the asset is CBS-supported. If the CBS withdrawal is rate-limited, the order is queued in `spot_pending_cbs_queue` and placed once `process_pending_withdrawals` drains the request — so a successful transaction does not always mean the order is immediately resting on the book.

<Warning>
  Placement aborts with `EUNDELIVERABLE_PROCEEDS` if the projected maximum fill proceeds could not be delivered to your account (neither CBS nor PFS deposits would succeed). This is a pre-trade gate: check `get_max_proceeds_balance` and `can_make_spot_deposit` if you need to predict it.
</Warning>

To trade directly from a wallet instead of a Trading Account, use `place_spot_order`, which takes the same arguments without the `subaccount` parameter.

**Example:**

<CodeGroup>
  ```typescript Typescript theme={null}
  const transaction = await aptos.transaction.build.simple({
    sender: account.accountAddress,
    data: {
      function: `${PACKAGE}::dex_accounts_spot_entry::place_spot_order_to_subaccount`,
      typeArguments: [],
      functionArguments: [
        "0x123...abc", // subaccountAddr
        "0x456...def", // marketAddr (SpotMarket object address)
        45000000, // price (raw quote units, aligned to tickSize)
        100000, // origSize (raw base units, aligned to lotSize)
        true, // isBid (true for buy, false for sell)
        0, // timeInForce (0 = GoodTillCanceled, 1 = PostOnly, 2 = ImmediateOrCancel)
        null, // builderAddress (optional)
        null, // builderFees (optional)
      ],
    },
  });
  ```

  ```python Python theme={null}
  transaction = rest_client.build_transaction(
      sender=account.address(),
      payload={
          "function": f"{PACKAGE}::dex_accounts_spot_entry::place_spot_order_to_subaccount",
          "type_arguments": [],
          "function_arguments": [
              "0x123...abc",  # subaccountAddr
              "0x456...def",  # marketAddr (SpotMarket object address)
              45000000,  # price (raw quote units, aligned to tickSize)
              100000,  # origSize (raw base units, aligned to lotSize)
              True,  # isBid (true for buy, false for sell)
              0,  # timeInForce (0 = GoodTillCanceled, 1 = PostOnly, 2 = ImmediateOrCancel)
              None,  # builderAddress (optional)
              None,  # builderFees (optional)
          ],
      },
  )
  ```
</CodeGroup>
