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

twapOrder

Places a time-weighted average price (TWAP) order on a perp. The node splits the total size s into market slices sent every interval seconds until the m-minute duration ends. The action is signed by an approved agent.

POST/exchangetype twapOrder

Execute a large perp order in slices at a fixed interval over 5 minutes to 24 hours.Agent-signed

Action fields
twapTwapBodyrequired

The TWAP parameters.

ainteger · uint32required

Perp instrument's external id — the `index` value from `perpMeta`.

bbooleanrequired

`true` to buy, `false` to sell.

intervalintegerrequired

Seconds between slices.

510153060
minteger · uint32required

Total duration in **minutes**, from `5` to `1440`.

rbooleanrequired

Reduce-only. Every slice inherits it.

sstringrequired

Total size to execute across all slices, in base units.

tbooleanrequired

Randomize slice timing. Always `false`.

false
marginModestringoptional

Margin mode for the slices. When omitted, the account's current margin mode for this instrument applies.

"cross""isolated"
typestringrequired

Must be `twapOrder`.

"twapOrder"
Request example
curl -X POST https://rpc.txflow-testnet.xyz/exchange \
  -H "Content-Type: application/json" \
  -H "x-api-version: 2026-08-16" \
  -d '{
  "action": {
    "type": "twapOrder",
    "twap": {
      "a": 1,
      "b": true,
      "s": "0.1",
      "r": false,
      "m": 30,
      "t": false,
      "interval": 30,
      "marginMode": "cross"
    }
  },
  "signature": {
    "r": "0x<r>",
    "s": "0x<s>",
    "v": 27
  },
  "nonce": 1757992743994,
  "vaultAddress": null,
  "signatureChainId": null
}'
Try it
Response · twapOrder 200
codeinteger

`0` on success.

dataobject
dataobject
typestring

The action's internal name, which does not always match the request `type`.

"twapOrder"
statusstring

A rejected request returns `err` with a non-zero `code` and the reason in `message` (or `response`).

"ok"
Response example
{
  "status": "ok",
  "code": 0,
  "data": {
    "type": "twapOrder",
    "data": {
      "status": {
        "running": {
          "twapId": "8642097531"
        }
      }
    }
  }
}

TWAP body

ainteger · uint32required

Perp instrument's external id — the `index` value from `perpMeta`.

bbooleanrequired

`true` to buy, `false` to sell.

intervalintegerrequired

Seconds between slices.

510153060
minteger · uint32required

Total duration in **minutes**, from `5` to `1440`.

rbooleanrequired

Reduce-only. Every slice inherits it.

sstringrequired

Total size to execute across all slices, in base units.

tbooleanrequired

Randomize slice timing. Always `false`.

false
marginModestringoptional

Margin mode for the slices. When omitted, the account's current margin mode for this instrument applies.

"cross""isolated"

Inside twap, m is the duration in minutes and t is the randomize flag.

Signing

Hash the body as { "twap": { … } } with the keys in the order shown in the request example: a, b, s, r, m, t, interval, then marginMode if you send it. Send the envelope vaultAddress as null. See Signing.

Next steps

The response returns the new TWAP's id in data.data.status.running.twapId. Pass it to twapCancel to stop the TWAP early.