Skip to main content
A TWAP (time-weighted average price) splits a larger trade into slices executed over time. On Velora it’s one Delta order, not a loop of swaps: the user signs a single scheduled order, and Delta settles each eligible slice gaslessly through the Portikus Network until the order completes or expires. This page walks the whole integration with direct calls to https://api.velora.xyz. It’s the Delta swap flow with one wrinkle that trips people up: you quote a single slice, not the whole order, and the server multiplies it across the schedule. For the conceptual model, see Product stack → TWAP. For a typed wrapper, see SDK → TWAP.

Sell vs buy

A TWAP is either a sell or a buy, and the field that fixes the total differs:
  • Sell TWAP (orderType: "TWAPOrder") fixes the total source amount and splits it across slices. Set totalSrcAmount.
  • Buy TWAP (orderType: "TWAPBuyOrder") fixes the total destination amount to receive and caps the total source spent. Set totalDestAmount and maxSrcAmount.

The flow

1

Quote one slice

GET /v2/quote?mode=DELTA for the per-slice amount, floor(total / numSlices). The route’s amount must match that slice; the server applies it across the schedule.
2

Approve the total

Approve the total source on-chain (totalSrcAmount for sell, maxSrcAmount for buy), not one slice. A TWAP uses approval, not a permit; see Approvals and permit. Native source skips this.
3

Build the schedule

POST /v2/delta/orders/build with the orderType, interval, numSlices, a deadline, and the totals. See POST /v2/delta/orders/build.
4

Sign and submit

The user signs toSign; POST /v2/delta/orders. See POST /v2/delta/orders.
5

Poll over the order's lifetime

Each slice settles as it becomes eligible; the order completes when the final slice settles, or expires if its constraints can no longer be met.

1. Quote one slice

Quote the per-slice amount, not the total. For a 4-slice sell of 10,000 USDC, quote 10000000000 / 4 = 2500000000:
curl -G 'https://api.velora.xyz/v2/quote' \
  --data-urlencode 'srcToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' \
  --data-urlencode 'destToken=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' \
  --data-urlencode 'amount=2500000000' \
  --data-urlencode 'srcDecimals=6' \
  --data-urlencode 'destDecimals=18' \
  --data-urlencode 'side=SELL' \
  --data-urlencode 'chainId=1' \
  --data-urlencode 'mode=DELTA' \
  --data-urlencode 'userAddress=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' \
  --data-urlencode 'partner=my-app-name'
For a sell TWAP, route.origin.input.amount must equal floor(totalSrcAmount / numSlices). For a buy TWAP, route.origin.output.amount must equal floor(totalDestAmount / numSlices). Then approve the total source amount, not the slice. Approve on-chain rather than with a permit, which can’t cover a multi-slice order (see Approvals and permit).

2. Build the schedule (sell TWAP)

curl -X POST 'https://api.velora.xyz/v2/delta/orders/build' \
  -H 'Content-Type: application/json' \
  -d '{
    "orderType": "TWAPOrder",
    "route": { "...": "the single-slice delta.route, unchanged" },
    "owner": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
    "totalSrcAmount": "10000000000",
    "numSlices": 4,
    "interval": 300,
    "slippage": 50,
    "deadline": 1893456000,
    "partner": "my-app-name"
  }'
numSlices is at least 2 and interval (seconds between slices) at least 60. The response is the same { toSign, orderHash } as any Delta order.

Buy TWAP

A buy TWAP fixes how much to receive and caps what’s spent. Quote a single slice by the per-slice destination amount, then build with totalDestAmount and maxSrcAmount:
curl -X POST 'https://api.velora.xyz/v2/delta/orders/build' \
  -H 'Content-Type: application/json' \
  -d '{
    "orderType": "TWAPBuyOrder",
    "route": { "...": "single-slice route; output.amount = floor(totalDestAmount / numSlices)" },
    "owner": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
    "totalDestAmount": "3000000000000000000",
    "maxSrcAmount": "10100000000",
    "numSlices": 4,
    "interval": 300,
    "slippage": 50,
    "deadline": 1893456000,
    "partner": "my-app-name"
  }'

3. Sign and submit

The user signs toSign (ERC-2098 compact signature), then you submit the order. There’s no TWAP-specific submit; it’s the same call as a market Delta order:
curl -X POST 'https://api.velora.xyz/v2/delta/orders' \
  -H 'Content-Type: application/json' \
  -d '{
    "chainId": 1,
    "order": { "...": "toSign.value, sent verbatim" },
    "signature": "0x...",
    "partner": "my-app-name"
  }'

4. Poll, list, and cancel

Poll GET /v2/delta/orders/{orderId} over the order’s lifetime; the input/output amounts carry expected and executed totals, so you can show fill progress without computing it yourself. For a human-readable view of slice-by-slice progress, open the order in the Velora explorer at https://explorer.velora.xyz/order/{orderId}. List a user’s TWAPs by filtering on onChainOrderType:
curl -G 'https://api.velora.xyz/v2/delta/orders' \
  --data-urlencode 'userAddress=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' \
  --data-urlencode 'chainId=1' \
  --data-urlencode 'onChainOrderType=TWAPOrder'
Cancel the remaining (unsettled) slices with a gasless signed cancellation, the same call as any Delta order:
curl -X POST 'https://api.velora.xyz/v2/delta/orders/cancel' \
  -H 'Content-Type: application/json' \
  -d '{ "orderIds": ["..."], "signature": "0x..." }'
See GET /v2/delta/orders and POST /v2/delta/orders/cancel.

Partner fee

Pass partner on the quote, build, and submit calls (plus optional partnerAddress, partnerFeeBps, partnerTakesSurplus), exactly as for a Delta swap. See Monetize.
Last modified on June 11, 2026