sdk.delta module as market Delta orders, using submitTWAPDeltaOrder (or the buildTWAPDeltaOrder split flow). The defining inputs are the total amount, the number of slices, and the interval between them.
For the conceptual model (slices, intervals, sell vs. buy, how TWAP differs from a one-shot swap or a limit order), see Product stack → TWAP.
When to use this
- A one-shot swap is too sensitive to execute at a single market moment (large size, thin pair).
- You want to spread execution across time to reduce price impact and timing risk.
- You want the whole schedule to settle gaslessly from a single signature.
Sell vs. buy
- Sell TWAP (
onChainOrderType: "TWAPOrder") fixes the total source amount and splits it across slices. UsetotalSrcAmount. - Buy TWAP (
onChainOrderType: "TWAPBuyOrder"): fixes the total destination amount to receive and splits that target across slices, while capping the total source spent. UsetotalDestAmountandmaxSrcAmount.
The flow
The build → sign → post → poll flow mirrors a market Delta order, with one wrinkle: you quote a single slice, not the whole order.Quote one slice
Call
sdk.delta.getDeltaPrice for a single slice: the per-slice amount, i.e. floor(total / numSlices). The route’s amount must match that per-slice amount; the server multiplies it across the schedule.Approve the source token (or sign a Permit)
Approve the total source amount (
totalSrcAmount for sell, maxSrcAmount for buy) with sdk.delta.approveTokenForDelta, or sign a Permit / Permit2 message. Native tokens skip this step.Build, sign, and post the schedule
Call
sdk.delta.submitTWAPDeltaOrder with the schedule, or run buildTWAPDeltaOrder → signDeltaOrder → postTWAPDeltaOrder yourself when you need control over signing.One-call submit (sell TWAP)
Buy TWAP
A buy TWAP fixes how much you want to receive and caps what you’ll spend. Quote a single slice by the per-slice destination amount, then submit withtotalDestAmount and maxSrcAmount:
Split flow
Use the three-step flow when you need to customize signing (a hardware wallet, an async multisig, or batched signing).signDeltaOrder is the same generic signer used for market and limit orders; there’s no TWAP-specific signing call.
Poll, list, and cancel
sdk.delta.getDeltaOrders and narrow on onChainOrderType ("TWAPOrder" / "TWAPBuyOrder") to surface their TWAPs. Cancel the remaining (unsettled) slices with sdk.delta.cancelDeltaOrders({ orderIds: [auction.id] }).
Partner fee
Passpartner (and optionally partnerAddress, partnerFeeBps, partnerTakesSurplus) to getDeltaPrice, submitTWAPDeltaOrder, buildTWAPDeltaOrder, and postTWAPDeltaOrder, exactly as with market Delta orders. See Monetize for the full field reference.
Related pages
- Swaps → Delta covers the market Delta order flow this builds on.
- Limit orders: the other Delta-based order type.
- Product stack → TWAP — the conceptual model.