pub enum OrderLifetime {
ShortTerm,
LongTerm,
Conditional,
}Expand description
Order lifetime type determined by time_in_force and expire_time.
dYdX v4 has different execution paths for orders based on their expected lifetime:
- ShortTerm: Lower latency/fees, expire by block height (max 20 blocks ~30s)
- LongTerm: Stored on-chain, expire by timestamp, explicit cancel events
- Conditional: Triggered by price conditions, always stored on-chain
Variants§
ShortTerm
Short-term orders expire by block height (max 20 blocks). Lower latency and fees, but expire silently without cancel events. Used for IOC, FOK, or orders expiring within 60 seconds.
LongTerm
Long-term orders expire by timestamp. Stored on-chain with explicit cancel events when they expire or are cancelled. Used for GTC, GTD orders with expiry > 60 seconds.
Conditional
Conditional orders triggered by price conditions. Always stored on-chain (stateful), used for stop-loss and take-profit orders.
Implementations§
Source§impl OrderLifetime
impl OrderLifetime
Sourcepub fn from_time_in_force(
time_in_force: TimeInForce,
expire_time: Option<i64>,
is_conditional: bool,
max_short_term_secs: f64,
) -> Self
pub fn from_time_in_force( time_in_force: TimeInForce, expire_time: Option<i64>, is_conditional: bool, max_short_term_secs: f64, ) -> Self
Determines order lifetime based on time_in_force, expire_time, and max short-term duration.
The max_short_term_secs is computed dynamically from BlockTimeMonitor:
max_short_term_secs = SHORT_TERM_ORDER_MAXIMUM_LIFETIME (20 blocks) × seconds_per_block
Returns ShortTerm when:
- TimeInForce is IOC or FOK (immediate execution orders)
- expire_time is set and within
max_short_term_secsfrom now
Returns LongTerm for GTC/GTD orders with expiry beyond short-term window.
Returns Conditional for stop/take-profit orders (when is_conditional is true).
Sourcepub const fn order_flags(&self) -> u32
pub const fn order_flags(&self) -> u32
Returns the dYdX order_flags value for this lifetime.
These flags are used in both MsgPlaceOrder and MsgCancelOrder to identify
the order type on-chain.
Sourcepub const fn is_short_term(&self) -> bool
pub const fn is_short_term(&self) -> bool
Returns true if this is a short-term order.
Sourcepub const fn is_conditional(&self) -> bool
pub const fn is_conditional(&self) -> bool
Returns true if this is a conditional order (stop/take-profit).
Trait Implementations§
Source§impl Clone for OrderLifetime
impl Clone for OrderLifetime
Source§fn clone(&self) -> OrderLifetime
fn clone(&self) -> OrderLifetime
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OrderLifetime
impl Debug for OrderLifetime
Source§impl PartialEq for OrderLifetime
impl PartialEq for OrderLifetime
impl Copy for OrderLifetime
impl Eq for OrderLifetime
impl StructuralPartialEq for OrderLifetime
Auto Trait Implementations§
impl Freeze for OrderLifetime
impl RefUnwindSafe for OrderLifetime
impl Send for OrderLifetime
impl Sync for OrderLifetime
impl Unpin for OrderLifetime
impl UnsafeUnpin for OrderLifetime
impl UnwindSafe for OrderLifetime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].