synthetix icon indicating copy to clipboard operation
synthetix copied to clipboard

Feature/time based order

Open davidvuong opened this issue 2 years ago • 0 comments

This PR adjusts the existing next-price order component in FuturesV2 such that the execution of orders are based on time rather than a semi-arbitrary price update from CL feeds. A trader can specify a desiredTimeDelta in submitDelayedOrder, allowing their order to be filled after block.timestamp + desiredTimeDelta.

At the same time, order can also be filled if in the situation where a CL price update occurs before block.timestamp + desiredTimeDelta (denoted as executableAtTime in the DelayedOrder struct).

For validation and additional configurability, each market has two additional parameters, minDelayTimeDelta and maxDelayTimeDelta. When submitting an order, the desiredTimeDelta must be between the lower and upper bound respectively.

All references to nextPrice has been renamed to delayedOrder, including documentation (at least I hope). Note that nextPriceConfirmWindow has not changed. As of writing this, we are still discussing we should introduce delayedOrderConfirmWindow such that,

if hasPassedNextPriceConfirmWindow or hasPassedDelayedOrderWindow:
  keeperCanCancelOrder()

davidvuong avatar Sep 13 '22 06:09 davidvuong