Enhancing Conditional Orders

TLDR:

  • How Stop/Limit & market orders function on Kwenta and the execution process

  • Current Constraints of the Advanced Order System

  • Upgraded Smart Margin to use Pyth or Chainlink oracle prices to trigger conditional orders

  • Identifying latency & working with Integrators to minimize execution times

In the realm of DeFi, Kwenta is gaining popularity as a go-to platform for trading. One notable feature offered by Kwenta is the ability to utilize conditional orders, such as stop and limit orders. However, users may have encountered warnings about the experimental nature of these order types. To shed light on the intricacies of Kwenta's conditional orders, associated risks, and anticipated improvements, this blog post aims to provide a comprehensive analysis.

How Stop/Limit Orders Function on Kwenta

In Synthetix Perps v2, the underlying liquidity layer, native support for stop and limit orders, is absent. Consequently, Kwenta developed a system that transmits orders on behalf of users. Presently, all orders must utilize the same delayed order system supported by Synthetix. This leads to a multi-step process for executing conditional orders on Kwenta.

Life Cycle of an Order on Kwenta:

  1. Placing the Order: Users initiate the order by specifying the desired conditions for triggering the trade.

  2. Transmitting the Trigger Price: The oracle, a vital component in the system, transmits the trigger price on-chain. (Currently, we use prices from push-based Chainlink oracles)

  3. Executing the Delayed Market Order: Kwenta employs the services of Gelato, an autonomous network of keepers, to place a delayed market order on the user's behalf when trigger conditions are ‘valid.’

  4. Keeper Execution: Subsequently, the delayed market order placed on the users’ behalf is executed by a community-maintained keeper, ensuring the trade is executed according to the specified conditions.

On Kwenta, all transactions are processed as delayed orders. This allows an executor (either a trader or a keeper) to complete the transaction after a specified number of blocks have elapsed (Currently two blocks).

Conditional Orders Constraints

While conditional orders offer significant advantages, constraints need to be considered when utilizing them on Kwenta. These include:

  1. Delay-Induced Price Execution Variability: Due to the multi-step process involved in executing conditional orders, the delay may currently result in unpredictable price execution. Market conditions can change during the delay, potentially impacting the final executed price.

  2. Oracle Trigger Price Discrepancies: The market price at the time of execution may differ from the oracle trigger price. This discrepancy could lead to trades being executed at a premium or discount compared to the expected trigger price.

  3. Price Impacts: During the execution of your order, other orders executed before can negatively or positively affect your execution price.

  4. Liquidation Risk: In certain scenarios, the time required for the execution of a conditional order may expose positions to the risk of liquidation before the order can be fulfilled.

Once a conditional order is triggered, there is no guarantee that it will execute successfully. Factors such as liquidity constraints or network congestion can affect the completion of the order.

Mitigating Risk and Maximizing Reliability

While edge cases exist, it is important to note that the majority of conditional orders on Kwenta are executed successfully near the trigger price. To enhance the reliability of trigger orders, users can take the following measures:

  1. Reduce Leverage: Highly leveraged positions inherently carry more risk and are more susceptible to issues with conditional orders. By reducing leverage, traders can lower the potential impact of delayed execution or price discrepancies.

  2. Set Appropriate Stop Levels: To minimize the likelihood of liquidation before an order can be executed, it is advisable to set stop levels that are not too close to the liquidation price. This ensures a reasonable buffer for the conditional order to be processed in a timely manner.

  3. Trade highly liquid assets: Since more frequent price updates result in more accurate and reliable pricing and execution, assets traded more frequently are less likely to experience issues. Additionally, premiums and discounts on highly liquid assets will be less significant, reducing the chance of an unexpected fill price.

What else can be done?

Improved Infrastructure

The first major improvement was enabled by Optimism with their Bedrock upgrade, shortening the Optimism block time to just 2 seconds. This upgrade allowed the reduction of the delay on market orders by over 10 seconds. While we hope this and today's release leads to a significant improvement in pricing and reliability, the work does not end here.

Improved Automation

We were finding that sometimes Gelato tasks can take longer than expected to execute, resulting in users experiencing less than optimal execution times. In the current design, orders should be checked every ~10 seconds for execution eligibility. This is not configurable at the moment, but we are working with Gelato, to introduce this upgrade as quickly as possible towards Q4 this year.

This will help ensure that orders trigger as quickly as possible after conditions are met.

Perps v3

Perps v3 includes several important upgrades to the foundation of Synthetix Perps, our primary source of liquidity for Kwenta. These contract upgrades will enable several new features, and offer major improvements to existing features like conditional orders, greatly improving the predictability of fill prices. More details will be shared as we begin testing the Perps v3 system.

Upgrading Contract Logic

One of the primary factors affecting orders on Kwenta has been the latency issues associated with the current push-based price feeds. As these price updates occur less frequently, they can hinder the efficiency of trading activities. To address this concern, Kwenta has recognized the need to replace the existing mechanism used by Smart Margin (SM) accounts.

We’ve upgraded Smart Margin (SM) conditional order logic; now making use of the faster pull based price feeds provided by Pyth's Oracle Network.

As part of this upgrade, Kwenta has implemented a new logic for SM conditional orders by leveraging the faster pull-based price feeds offered by Pyth's Oracle Network. This enhancement allows conditional orders to validate trigger prices by checking both the Chainlink and/or the Pyth oracle prices. By utilizing the more frequent Pyth oracles, which are updated every time a trade is executed on Kwenta, the spread created by the previous use of slower push-based prices is reduced by up to 20 basis points (bps).

In cases where no market order has been executed for a configurable period (currently set at two minutes), the system automatically reverts to using Chainlink prices until an updated Pyth price is pushed on-chain. This ensures that the trading process remains uninterrupted and accurate, even in situations where the Pyth oracle data may be temporarily unavailable.

What does this mean for Traders

By utilizing faster and more frequent price feeds, Kwenta aims to provide users with a seamless trading experience, minimizing latency issues and reducing the potential for discrepancies between trigger prices and market execution.

Conditional orders, such as stop and limit orders, offer traders on Kwenta a powerful tool for managing risk and automating trade execution & while the current implementation of these order types comes with limitations, including execution delays and potential price discrepancies. Kwenta is actively working to improve these aspects.

By acknowledging these risks and adopting appropriate risk mitigation strategies, traders can navigate the conditional order system on Kwenta more effectively. As Kwenta continues to refine and optimize its conditional order functionality, users can expect a more reliable and efficient trading experience. It is crucial for traders to stay informed about the latest updates and improvements on Kwenta to make the most of its conditional order features while mitigating associated risks.

Join the Kwenta Community

If you haven't already, join the Kwenta community on Discord.

To be the first to learn about new updates to Kwenta, follow us on Twitter.

To trade synthetic assets and futures, visit Kwenta.

Subscribe to Kwenta
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.