Kwenta

Kwenta limit orders used price triggers before delayed execution

Last updated ·

Kwenta limit orders in legacy Smart Margin used price triggers to submit delayed Synthetix Perps V2 orders. A buy limit qualified at or below its target; a sell limit qualified at or above it. A later execution still had to satisfy the separate desired fill price. These were legacy account rules, distinct from Synthetix’s subsequent Ethereum Mainnet order-book architecture.

An old order record could show that its conditional handler had run while the underlying trade still awaited execution. Understanding that record required the order direction, its price parameters, and the position that existed when the handler ran.

Key takeaway: Legacy Smart Margin checked reduce-only instructions against the position at trigger processing, before the submitted delayed order reached execution.

Limit and Stop Triggers

The choice between a limit and a stop depended on which side of the target should activate the signed size change. In the legacy account, a positive sizeDelta represented a buy instruction. A negative value represented a sell instruction. A buy limit qualified when the evaluated price reached or fell below its target. A sell limit qualified when that price reached or rose above its target. Equality satisfied either limit predicate. The code tested the current comparison without requiring a new price crossing.

Stop orders reversed those comparisons: a buy stop qualified at or above its target, and a sell stop qualified at or below it. A sell limit could therefore express a take-profit reduction of an existing long. A sell stop expressed the opposite price condition. The order’s direction alone didn’t determine whether it opened exposure, reduced exposure, or crossed through an existing position; the position and reduce-only setting also mattered.


Trigger Price and Desired Fill Price

The legacy fields targetPrice and desiredFillPrice governed different decisions within a conditional order. The target governed whether the conditional handler could proceed. The desired fill price constrained the Synthetix delayed order that the handler submitted afterward. Reaching the target didn’t settle that later instruction at the target price. When conditional processing succeeded, the account submitted a delayed order for a keeper to execute later. The later market price still had to satisfy the desired fill price. That separation explained how an order could pass its trigger test without completing the intended position change.

When Did a Trigger Become a Trade?

An executor’s call started conditional processing; the position-size change required later execution of the submitted Synthetix delayed order. On the normal path, the handler removed the stored conditional order and cancelled its Gelato task. It then paid the executor, applied the reduce-only check where relevant, adjusted margin, and submitted the delayed instruction. A cancellation or revert could interrupt that path before submission.

In legacy Smart Margin, the ConditionalOrderFilled event recorded submission of an off-chain delayed Synthetix Perps V2 order. Its name could suggest a completed trade, although the underlying order still required execution. The event’s price snapshot belonged to conditional processing. The resulting Synthetix position and delayed-order state established whether the requested exposure change had actually happened.

Diagram: When Did a Trigger Become a Trade? (Kwenta limit orders)

Open full-size image


Oracle Selection in the Legacy Account

The legacy Account implementation labeled 2.1.5 evaluated conditional triggers using a Pyth price returned through the Perps V2 exchange-rate component. If that returned price was older than 120 seconds, the account requested the market’s Chainlink-based price. An invalid fallback price caused a revert. This timestamp test described the account’s trigger-price selection, including the snapshot that it emitted during conditional processing. It didn’t make a chart observation the executable trigger price, or establish the final price of the later delayed trade. The account needed its own valid oracle result.

How Did Reduce-Only Orders Limit Position Changes?

A reduce-only conditional order compared its signed size change with the position that existed when its handler ran. The handler cancelled the conditional order if no position remained, or if the proposed change had the same sign as the position. An existing long needed a negative size change to qualify as a reduction. An existing short needed a positive change. This check prevented an instruction that increased the same directional exposure from continuing through that path.

If the requested reduction exceeded the remaining position’s absolute size, the handler capped the submitted change at that remaining size. The account applied this comparison before submitting the Synthetix delayed order. Its downstream call carried the resulting size delta and desired fill price. The check concerned the position at conditional processing; later account activity could change that position before the delayed order’s execution.

Reserved Margin and Executor Funding

A positive marginDelta reserved that amount of sUSD when the account placed the conditional order. Zero and negative values didn’t create that positive reservation. The account calculated free margin from its sUSD balance after subtracting committed margin. Reserved collateral therefore affected how much remained available for other account actions, even before a trigger qualified. The eventual conditional handler also had to complete the requested market-margin adjustment before submitting the delayed order. Its ETH executor payment remained separate from any trading or configured order-flow charges.

Executor payment used a separate ETH funding path. In the 2.1.5 implementation, the handler paid that fee before its reduce-only check. An execution that reached the ordinary reduce-only cancellation return could therefore incur an executor fee without submitting a new delayed trade. If that order had reserved positive margin, the early return also left that amount committed, reducing free margin after the order’s deletion. That return differed from a transaction revert, which rolled back the transaction’s state changes.


Conditions for a Limit Reduction

A legacy take-profit limit with reduce-only enabled required a position that its signed size change could reduce. If the position had already closed before the conditional handler ran, the reduce-only check cancelled the order.

  • The selected limit direction matched the target condition: a buy at or below the target, or a sell at or above it.
  • The reduce-only size change opposed the existing position, with any oversized reduction capped against its remaining size.
  • The account covered its positive margin commitment, if any, and the applicable ETH executor payment.
  • The outcome record distinguished delayed-order submission from a reduce-only cancellation with no remaining position.
  • The later Synthetix execution satisfied the desired fill price and produced the intended position change.

getDelayedOrder and getPosition exposed different records: the outstanding market instruction and the resulting position. A pending delayed order couldn’t establish that the intended reduction had completed.


Cancelling Conditional and Delayed Orders

Smart Margin exposed separate cancellation commands for a queued conditional order and a pending Synthetix delayed order. The user-requested conditional cancellation routine released a positive margin commitment, cancelled the associated Gelato task, and deleted the stored order. It then emitted ConditionalOrderCancelled . That routine addressed the account’s conditional instruction and its associated automation task.

After conditional processing submitted a delayed order, the outstanding instruction belonged to a different state. Separate Synthetix cancellation calls addressed that pending delayed order. Removing a conditional record and cancelling a market-level delayed order therefore weren’t interchangeable operations, even when both related to the same intended position change.

Position exits used separate close commands. Cancelling an outstanding instruction didn’t itself close an existing position.

What Could Block an Order After Its Price Matched?

A disabled account-execution setting or an inactive futures market could block an order even when its price condition matched. The account checked its execution setting at the execution entry point. Its conditional checker also required an active futures market; a paused market returned an ineligible result. A missing conditional order, represented by an empty market key, likewise couldn’t qualify. The checker assessed conditional eligibility, while execution applied additional requirements. A successful check didn’t ensure that funding, market status, and account execution settings would still permit the later transaction.

Legacy Rules and the Synthetix Transition

Synthetix acquired Kwenta in November 2024, and the frontend subsequently transitioned to Synthetix Exchange branding. Synthetix’s March 13, 2026 roadmap reported that it had deprecated its L2 automated market makers and shifted to an Ethereum Mainnet order-book venue. The Smart Margin predicates described here belonged to the legacy Synthetix Perps V2 account implementation. They explained historical conditional-order behavior without establishing the order types, trigger logic, or fill handling of the later exchange.

Kwenta limit orders FAQ

Did a Legacy Smart Margin Limit Order Buy the Underlying Token?

A legacy Smart Margin limit order requested a change to a perpetual futures position, so it didn’t deliver the underlying market asset to the wallet. The order’s size described the derivative exposure that the account requested. Its margin described collateral supporting that exposure. A buy limit on a perpetual market therefore had a different outcome from a spot-token purchase, even when both expressed a bullish price view.

Could a Single Batch Create Multiple Conditional Orders?

The legacy Account.execute function could process multiple conditional-order placement commands in their supplied order. Each placement created its own conditional order ID and associated Gelato task. Every command required matching encoded inputs, and the account’s execution checks still applied. Sharing a transaction didn’t combine those orders into one trigger or make their later execution simultaneous.

Was Gelato the Only Executor for Legacy Conditional Orders?

Starting with v2.1.0, legacy Smart Margin allowed public actors to execute eligible conditional orders. The account still applied its stored order conditions, so public execution didn’t authorize callers to rewrite the trigger or size. In the 2.1.5 implementation, non-Gelato executors received the fee configured in account settings.

Which Account Permissions Covered conditional-order Placement?

The legacy command interface allowed the account owner and authorized delegates to place and cancel conditional orders. Those permissions differed from owner-only account withdrawals and token-swap commands. A delegate’s trading authority therefore didn’t establish permission to withdraw the account’s sUSD to a wallet. The account checked authorization for the command that the caller actually requested.

Did a take-profit Limit Automatically Remove a Separate Stop Order?

The legacy conditional-order routine didn’t automatically cancel a separate stop when it processed a take-profit limit. It handled the selected conditional order ID and that order’s Gelato task. Another order could remain stored after the position changed. Its own trigger and reduce-only checks determined what happened when an executor later tried to process it.