Skip to main content
Place a TWAP (time-weighted average price) parent order that executes over a fixed duration, or cancel a running one, through PerpsClient.placeTwapOrder / PerpsClient.cancelTwapOrder. The registered provider plugin authorizes both flows with its SDK-managed credential; the user’s wallet is not prompted.
The examples on this page use Hyperliquid (provider: 'hyperliquid'). Replace the provider value with any supported DEX from getProviders(). Each provider documents its own extras and duration bounds on its own trading page — see Hyperliquid, Lighter, and Ondo.

placeTwapOrder

Returns: ExecuteActionResponse with results[] array. A successful result carries twapId — the provider-native identifier for the placed TWAP parent.
market, side, size, durationSeconds, and reduceOnly are the provider-independent core. The remaining fields are extras: a provider only honours the ones it advertises on its placeTwapOrder action’s params descriptors (GET /providers), and ignores extras it does not declare. See each provider’s trading page for which extras it supports and its own duration bounds.

cancelTwapOrder

Returns: ExecuteActionResponse with results[] array.
On Lighter, a placement result’s twapId carries the submit-time transaction hash — Lighter assigns the parent’s real order index asynchronously. Read the account’s running TWAPs once assigned to get the id cancelTwapOrder actually expects.
API Reference: POST /createAction · /executeAction