TWAP orders
Split a large order into N Dutch-auction slices that open at fixed chain-time intervals, funded in a single transaction.
A TWAP order sells totalAmountIn in numSlices equal slices, one every intervalSec. Each slice is an ordinary DutchAuctionSwapV2 intent whose startTime is pushed into the future, so the covenant itself refuses to fill a slice before its turn. Each slice stays fillable for sliceWindowSec, by default the larger of the interval and 1 hour (minimum 30 minutes). If it isn't filled in that window, it is refunded.

Submit
curl -X POST "$MESH_URL/api/v1/twap/submit" \
-H "Content-Type: application/json" \
-d '{
"creatorAddress": "bchtest:qr…",
"tokenIn": "0x",
"tokenOut": "<pUSD category>",
"totalAmountIn": "400000",
"numSlices": 4,
"intervalSec": 600,
"minAmountOutPerSlice": "48",
"startAmountOutPerSlice": "52"
}'
The response lists one funding entry per slice. Fund them all in one transaction: one output per slice address.
Progress
GET /api/v1/twap/:orderId derives progress from the slices:
| Status | Meaning |
|---|---|
AWAITING_FUNDING |
Slices created; funding not seen |
RUNNING |
At least one slice still open |
COMPLETED |
Every slice filled |
PARTIALLY_FILLED |
Some filled, the rest refunded |
REFUNDED |
No slice filled |
Note: Timing precision Slice starts and windows are chain time, which advances one block at a time (often 10–20 minutes on chipnet). A slice opens within about one block of its scheduled time. That's why windows are at least 30 minutes: a shorter window can be skipped entirely between two blocks, and the slice would refund without a chance to fill. For the same reason, intervals shorter than a block don't spread slices out; the app offers 10 minutes to 4 hours.
There is no early cancel. POST /twap/:id/cancel returns the automatic refund schedule for the unfilled slices.