For the complete documentation index, see llms.txt. This page is also available as Markdown.

Time-Weighted Average Price

A TWAP (Time-Weighted Average Price) order splits a large order into smaller chunks executed over a duration. Each chunk is a market order β€” individual chunks and timing are not exposed on-chain (CEX-style shielded execution).

Use executionType: "TWAP". Also works for closing positions via the close API with executionType: "TWAP".

{
  "executionType": "TWAP",
  "leverage": 5,
  "usdValue": 5000,
  "slippage": 0.01,
  "twapDuration": 30,
  "twapIntervalSeconds": 60,
  "randomizeExecution": true,
  "longAssets": [{ "asset": "BTC", "weight": 0.5 }],
  "shortAssets": [{ "asset": "ETH", "weight": 0.5 }]
}

How it works:

  • twapDuration: total duration in minutes (required)

  • twapIntervalSeconds: seconds between chunks (default: 30)

  • Number of chunks = duration / interval, capped by minimum $11 per asset per chunk

  • USD value split equally across chunks

  • randomizeExecution: adds Β±10% jitter to chunk timing to reduce predictability

  • Chunks queued via BullMQ and executed as individual market orders

  • TP/SL intents are cached and applied after the first chunk creates a position; subsequent chunks merge into it

Example: $5,000 over 30 minutes at 60s intervals β†’ 30 chunks of ~$166 each, one every ~60s (Β±6s with randomization).

Last updated