amount into smaller market orders, called sub-orders, and sends them over duration_in_seconds. Each sub-order uses slippage_percent as its maximum slippage.
This endpoint creates a TWAP order that the matching engine runs. It has no price limit and no randomized slices. For those settings, create a TWAP order strategy instead.
How a TWAP order runs
- Pacifica plans one sub-order for every 30 seconds of
duration_in_seconds, plus one. It plans fewer ifamountholds fewer lots than that, so each sub-order is at least one lot. - Pacifica sends one sub-order about every 30 seconds.
- Each sub-order is the remaining amount divided by the remaining sub-order count, rounded down to the lot size. It is at most 3 times the planned sub-order amount.
- The order ends as
completedwhen the full amount fills. - The order ends as
expiredif part of the amount is still unfilled after the last planned sub-order, or when its time runs out. Itsexpirationis 30 seconds after the end ofduration_in_seconds. - If the engine rejects a sub-order, the order stops and ends as
rejected_due_to_sub_order. - You can have up to 4 open TWAP orders per account in each market.
Operation Type (for Signing)
Request Body
| Field | Type | Need | Description | Example |
|---|---|---|---|---|
”account” | string | required | User’s wallet address | 42trU9A5… |
“signature” | string | required | Cryptographic signature | 5j1Vy9Uq… |
“timestamp” | integer | required | Current timestamp in milliseconds | 1716200000000 |
”symbol” | string | required | Trading pair symbol | BTC |
”amount” | string | required | Total amount to execute, in token units | 0.121 |
”side” | string | required | Order side (bid/ask) | bid |
”reduce_only” | boolean | required | Whether each sub-order is reduce-only | false |
”slippage_percent” | string | required | Maximum slippage for each sub-order, in percent. For example, “0.5” means 0.5%. At most 2 decimal places | 0.5 |
”duration_in_seconds” | integer | required | Time to spread the sub-orders over, in seconds. Minimum 30 | 3600 |
”client_order_id” | Full UUID string | optional | Client-defined order ID. Must not match another open TWAP order of yours in the same market | f47ac10b-58cc-4372-a567-0e02b2c3d479 |
”agent_wallet” | string | optional | Agent wallet address | 69trU9A5… |
“expiry_window” | integer | optional | Signature expiry in milliseconds | 30000 |
”builder_code” | string | optional | Builder program code (3-16 alphanumeric characters). Not supported on spot markets | MYCODE |
Response
- Status 200: TWAP order created successfully
order_id is the TWAP order ID. Use it to cancel the order or to get its history.
- Status 400: Invalid request body, for example an unknown
sideor aslippage_percentwith more than 2 decimal places - Status 422: The engine rejected the order
- Status 500: Internal server error