pub struct Order { /* private fields */ }Expand description
Active order in the perpetual contract order book.
Exchange order book has a limited capacity of 2^16-1 orders, which requires an extensive reuse of order IDs, up to the point that within the order of execution of a single order request, the same order ID can be used for more than one order. For example, if a taker order partially matches and then gets placed, the matched maker order with order ID = 1 gets removed from the book (and thus vacates the ID), then taker order gets placed under the same order ID = 1.
So the state of order book and particular mapping between orders and their IDs is tied to a particular point in time and should be used with care.
Exchange does not support concept of client order IDs and does not store any
externally-provided state with orders on-chain, but each order request emits
provided Order::request_id() with it, which gets indexed and stored with
the order, with the original request ID preserved as
Order::client_order_id() but with the limitation that this data is
available only from events, not from the original snapshot.
See crate::abi::dex::Exchange::OrderDesc for more details on particular
order parameters and exchange behavior.
This wrapper provides automatic conversion from exchnage fixed numeric types
to decimal numbers.
Implementations§
Source§impl Order
impl Order
Sourcepub fn instant(&self) -> StateInstant
pub fn instant(&self) -> StateInstant
Instant the order state is consistent with or was last updated at.
Sourcepub fn request_id(&self) -> Option<RequestId>
pub fn request_id(&self) -> Option<RequestId>
ID of the request this order was posted or updated by. Available only from real-time events, not from the initial snapshot.
Sourcepub fn client_order_id(&self) -> Option<RequestId>
pub fn client_order_id(&self) -> Option<RequestId>
Client order ID = ID of the request this order was placed by. Available only from real-time events, not from the initial snapshot.
Sourcepub fn account_id(&self) -> AccountId
pub fn account_id(&self) -> AccountId
ID of the account issued the order.
Sourcepub fn placed_size(&self) -> Option<UD64>
pub fn placed_size(&self) -> Option<UD64>
Size of the order that was placed. Available only from real-time events, not from the initial snapshot.
Sourcepub fn filled_size(&self) -> Option<UD64>
pub fn filled_size(&self) -> Option<UD64>
Filled size of the order. Available only from real-time events, not from the initial snapshot.
Sourcepub fn expiry_block(&self) -> u64
pub fn expiry_block(&self) -> u64
Expiry block of the order, zero if was not specified.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the order is expired. NOTE: Valid only after the end of expiry block processing.
Sourcepub fn post_only(&self) -> Option<bool>
pub fn post_only(&self) -> Option<bool>
Post-only flag. Available only from real-time events, not from the initial snapshot.
Sourcepub fn fill_or_kill(&self) -> Option<bool>
pub fn fill_or_kill(&self) -> Option<bool>
Fill-or-fill flag. Available only from real-time events, not from the initial snapshot.
Sourcepub fn immediate_or_cancel(&self) -> Option<bool>
pub fn immediate_or_cancel(&self) -> Option<bool>
Immediate-or-cancel flag. Available only from real-time events, not from the initial snapshot.
Sourcepub fn builder(&self) -> Option<BuilderAttribution>
pub fn builder(&self) -> Option<BuilderAttribution>
Builder the order is attributed to, along with the additive fee rate
that builder charges on the size the order adds. None means no
builder.
Unlike the flags above, attribution is persisted with the resting order
on-chain, so it is available both from the initial snapshot (contract
v1.1.7.4+, via getOrderV2) and from the OrderRequestV2 event stream.
What a builder actually earned per fill is reported by the builder_fee
of super::OrderEventType::Filled.
Sourcepub fn prev_order_id(&self) -> Option<OrderId>
pub fn prev_order_id(&self) -> Option<OrderId>
Previous order ID in the FIFO queue at this price level. Available from snapshot, None for newly placed orders or if this is the first order.
Sourcepub fn next_order_id(&self) -> Option<OrderId>
pub fn next_order_id(&self) -> Option<OrderId>
Next order ID in the FIFO queue at this price level. Available from snapshot, None for newly placed orders or if this is the last order.
Trait Implementations§
impl Copy for Order
Auto Trait Implementations§
impl Freeze for Order
impl RefUnwindSafe for Order
impl Send for Order
impl Sync for Order
impl Unpin for Order
impl UnsafeUnpin for Order
impl UnwindSafe for Order
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.