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

# Trading Operations

> Check, recover, and safely stop automated trading.

> [!NOTE]
>
> Mainnet currently supports Spot DEX only. Perpetuals, Oracle, Margin Trading, Lending, and Vaults are **Testnet-Only**. Use Testnet endpoints and assets for those products.

Keep a durable journal of the network, product, trading account, client order ID, exact signed
transaction hash, returned order IDs, and final result. A network response, acceptance by a node, a committed transaction, order state, and a fill are five separate things to check.

## Before quoting

1. Load the [native constraints](https://docs.aultblockchain.com/dex-api/trading/place-or-modify-order.md#protocol-constraints),
   account balances or risk, and [usable prices](https://docs.aultblockchain.com/ault-dex/oracle.md#how-ault-dex-handles-closed-stale-or-transitioning-prices).
   Resolve market IDs separately from display symbols and oracle feed IDs.
2. Check the [agent's permissions and replay namespace](https://docs.aultblockchain.com/dex-api/trading/api-key.md#signing-and-replay-protection).
   Coordinate processes sharing a message account or wallet sequence.
3. Reconcile ordinary, conditional (Testnet-Only), and TWAP parent orders for every account the strategy controls.
   A fresh process or replacement key does not start with an empty account.
4. Allocate headroom for cancellation, risk changes, and reconnect work before sending new quotes.

## Unknown submission result

| Observation | Meaning | Next action |
| - | - | - |
| Clear rejection by the node | That submission did not pass the node's checks | Correct the cause; reconcile any earlier attempts separately |
| Accepted by the node, no committed result yet | Execution is unconfirmed | Track the hash; do not create a second logical order because the response was slow |
| Committed transaction with nonzero code | Transaction execution failed | Read the log and refresh funds, risk, sequence, and orders before a corrected submission |
| Committed success | The message executed | Inspect order/fill events and per-item results; an IOC can fill without resting |
| Timeout or connection loss during broadcast/confirmation | Outcome is unknown | Query the transaction hash, then reconcile IDs, fills, and account state |

A timeout is not proof of rejection. Search indexed history and the native order/client-ID query
for the exact account, allowing for indexer delay. Absence from open orders does not prove an
order never executed: it may have filled, expired, or been replaced. A client ID is not permanent
deduplication storage. Keep the signed bytes and hash and resolve their result before signing a
fresh attempt with a new sequence or agent timestamp.

For a timed-out cancel or modify, query the old ID, replacement ID, client ID, and intervening fills.
Interpret [batch results](https://docs.aultblockchain.com/dex-api/trading/cancel-order.md#batch-results) separately from transaction
success. Stop the affected quoting loop while its exposure is uncertain.

## Disconnect and restart

Pause quoting when required market or account data is stale. Reconnect, resubscribe, and refresh
paginated orders, fills, balances, and product risk before resuming. Deduplicate fill records by
their identifiers rather than summing repeated deliveries.

Each Spot `l2Book` frame is a complete snapshot of its published depth: replace both sides.
There is no common REST/WS sequence bridge or guaranteed replay of missed intermediate books.
Follow the [reconnect rules](https://docs.aultblockchain.com/dex-api/websocket/overview.md#reconnecting). Use
[product REST reads](https://docs.aultblockchain.com/dex-api/getting-started/introduction.md#choose-the-product-interface) for risk
reconciliation. Spot frames do not represent every product account.

## Stop quoting and remove orders

1. Stop every writer that can recreate quotes. A socket disconnect or agent expiry leaves
   existing on-chain orders and schedules in place.
2. Enumerate every page of ordinary and pending conditional orders across the owner and derived
   accounts. Include TWAP parents; a Spot open-order list is not this full inventory.
3. Cancel explicit IDs through `MsgCancelOrders`. Inspect the committed code and succeeded/failed
   items. Orders created in the current block cannot be canceled or modified through this action
   until a later block.
4. Confirm terminal states and requery. [Canceling the TWAP parent](https://docs.aultblockchain.com/dex-api/trading/cancel-order.md#cancelling-a-twap-schedule)
   stops later slices after commit; already-created slices and fills need separate reconciliation.
   Cancellation does not reverse executions, close positions, or repay debt.
5. Revoke a compromised or retired agent separately. Keep another authorized signer available;
   revocation is not a cancel-all instruction.

This workflow uses explicit on-chain cancellations. Do not treat the read-only WebSocket heartbeat
as a quote-cancellation timer or infer server-side protection from connection health.

## Limits and backoff

| Budget | Scope and action |
| - | - |
| REST reads | HTTP 429 is read-service throttling. Back off with jitter, cache reference data, and replace frequent polling with supported subscriptions. |
| WebSocket | Connection command/subscription caps are in [WebSocket Errors](https://docs.aultblockchain.com/dex-api/websocket/errors.md). Reconnecting does not increase chain transaction capacity. |
| Signed transactions | Native limits use message type and the message's signer account, with per-block limits. Agent keys do not each create an account budget. CLOB trading-tier benefits can multiply a base limit. |
| Batch and gas | One message can contain several actions, but gas grows with the batch. A rate-limit slot is not unlimited batch capacity. |
| Orders and deadlines | CLOB capacity and maximum lifespan differ from throughput. Cancellation uses its own transaction path; maintain headroom rather than assuming spare capacity. |

Read [rate-limit configuration](https://docs.aultblockchain.com/dex-api/advanced/chain-queries.md#order-validation-and-throughput)
and current account benefits instead of copying a fixed requests-per-second value. A chain
rejection is distinct from REST 429. Retries must respect the unknown-result procedure above.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.