Summary
Limit and stop-loss orders currently live in storage indefinitely until executed or manually cancelled. Users have no way to set an automatic expiry, which means stale orders accumulate and clutter keeper queues.
Proposed Design
Add an optional expiry_ledger: Option<u64> field to CreateOrderParams.
- If
Some(n), the order is only executable while env.ledger().sequence() <= n
- After expiry, the keeper calls
execute_order and it auto-cancels (refunding the user) instead of reverting
- Alternatively, anyone can call
cleanup_expired_order(nonce) to cancel and get a small incentive fee
Storage Impact
One extra u64 field per order — negligible.
Acceptance Criteria
Affected Contracts
exchange_router, order_handler, data_store
Summary
Limit and stop-loss orders currently live in storage indefinitely until executed or manually cancelled. Users have no way to set an automatic expiry, which means stale orders accumulate and clutter keeper queues.
Proposed Design
Add an optional
expiry_ledger: Option<u64>field toCreateOrderParams.Some(n), the order is only executable whileenv.ledger().sequence() <= nexecute_orderand it auto-cancels (refunding the user) instead of revertingcleanup_expired_order(nonce)to cancel and get a small incentive feeStorage Impact
One extra
u64field per order — negligible.Acceptance Criteria
CreateOrderParamsincludesexpiry_ledger: Option<u64>cleanup_expired_ordercallable by anyone; caller receives a configurable incentiveexpiry_ledger = Nonebehaves exactly as today (no regression)Affected Contracts
exchange_router,order_handler,data_store